simulate_phenotype: Simulate phenotype

View source: R/simulation.R

simulate_phenotypeR Documentation

Simulate phenotype

Description

Simulates a phenotype from a GWAS experiment and a specified set of causal SNPs. If the data is qualitative, only controls are used.

Usage

simulate_phenotype(
  gwas,
  snps,
  h2,
  model = "additive",
  effectSize = rnorm(length(snps)),
  qualitative = FALSE,
  ncases,
  ncontrols,
  prevalence
)

Arguments

gwas

A SnpMatrix object with the GWAS information.

snps

Character vector with the SNP ids of the causal SNPs. Must match SNPs in gwas[["map"]][["snp.name"]].

h2

Heritability of the phenotype (between 0 and 1).

model

String specifying the genetic model under the phenotype. Accepted values: "additive".

effectSize

Numeric vector with the same lenght as the number of causal SNPs. It indicates the effect size of each of the SNPs; if absent, they are sampled fron a normal distribution.

qualitative

Bool indicating if the phenotype is qualitative or not (quantitative).

ncases

Integer specifying the number of cases to simulate in a qualitative phenotype. Required if qualitative = TRUE.

ncontrols

Integer specifying the number of controls to simulate in a qualitative phenotype. Required if qualitative = TRUE.

prevalence

Value between 0 and 1 specifying the population prevalence of the disease. Note that ncases cannot be greater than prevalence * number of samples. Required if qualitative = TRUE.

Value

A copy of the GWAS experiment with the new phenotypes in gwas[["fam"]][["affected"]].

References

Inspired from GCTA simulation tool: http://cnsgenomics.com/software/gcta/Simu.html.

Examples

gi <- get_GI_network(minigwas, snpMapping = minisnpMapping, ppi = minippi)
causal <- simulate_causal_snps(gi, ngenes = 2)
simulate_phenotype(minigwas, causal, h2 = 1)

hclimente/martini documentation built on Feb. 26, 2024, 6:23 p.m.