This function generates simulated genotype and phenotype data for all eight GxT model categories.

make_sim_data(
  num,
  anno,
  fn,
  genotype = NULL,
  lb.maf = 0.05,
  ub.maf = 0.5,
  filter.geno = FALSE,
  sd = rep(NA, 3),
  coef = rep(NA, 3),
  b0 = 0,
  sigma = 1,
  ranef = FALSE,
  sigma.u = NULL,
  kinship = NULL,
  seed = 1,
  output = "data.frame"
)

Arguments

num

A named, ordered integer vector specifying the numbers of simulations in the eight model categories.

anno

A data frame containing sample IDs (character strings or integers), subject IDs (character strings or integers), and treatment conditions (0 or 1). The columns must be named as "sample", "subject", and "condition".

fn

A character string specifying the function. This must be one of "nonlinear" and "linear", corresponding to nonlinear and linear models, respectively.

genotype

A data frame containing the subject IDs (character strings or integers) and the genotype coded as (0, 1, 2) or the imputation-based allelic dosage in the first and second columns, respectively. The columns must be named as "subject" and "g".

lb.maf

A scalar specifying the lower bound of MAF.

ub.maf

A scalar specifying the upper bound of MAF.

filter.geno

A logical scalar as to whether to ensure that homozygotes for both alleles have at least one observation in both control and treated conditions.

sd

A numeric vector of length three specifying the standard deviations of the genotype, treatment, and interaction effects, respectively. For each effect, exactly one of the corresponding elements of sd and coef must be non-NA.

coef

A numeric vector of length three specifying fixed values for the genotype, treatment, and interaction effects, respectively. For each effect, exactly one of the corresponding elements of sd and coef must be non-NA.

b0

A scalar specifying the intercept.

sigma

A scalar specifying the residual error standard deviation.

ranef

A logical scalar as to whether to include random effect.

sigma.u

A scalar specifying the random intercept standard deviation. If ranef is TRUE, this is set to 1 by default.

kinship

A matrix containing pairwise genetic relatedness between subjects. The row and column names must match the set of unique elements of the "subject" column in "anno" in the corresponding order (i.e., unique(anno$subject)). This is set to NULL by default, in which case the identity matrix is used.

seed

An integer specifying a seed for RNG.

output

A character string specifying the output format. This must be one of "list" and "data.frame".

Value

A list of lists containing:

  • y - A vector of phenotypes.

  • g - A vector of genotypes.

  • t - A vector of treatment indicators.

  • sample - A vector of sequencing sample IDs.

  • subject - A vector of subject IDs.

  • index - An integer specifying one of the eight models.

  • maf - A scalar specifying the minor allele frequency used for generating the genotype data.

  • beta - A named numeric vector specifying the true coefficient values used for generating the phenotype data. The "b0" element represents the intercept. The "b1", "b2", and "b3" elements respectively represent the genotype, treatment, and interaction effect sizes.

or a list containing:

  • candidate - A data frame containing feature IDs and SNP IDs. See map_qtl. This also includes the integers specifying models, the minor allele frequency, and the true coefficient values.

  • geno - A data frame containing genotypes. See map_qtl.

  • pheno - A data frame containing phenotypes. See map_qtl.

Examples

anno <- data.frame(
    sample = paste0("s", 1:20),
    subject = rep(paste0("d", 1:10), each = 2),
    condition = rep(c(0, 1), 10)
)
dat <- make_sim_data(
    num = c(0, 0, 0, 0, 0, 0, 0, 1),
    anno = anno,
    fn = "nonlinear",
    coef = c(0.5, 0.3, 0.2)
)