Learn R Programming

rBahadur (version 1.0.0)

am_simulate: Simulate genotype/phenotype data under equilibrium univariate AM.

Description

Simulate genotype/phenotype data under equilibrium univariate AM.

Usage

am_simulate(h2_0, r, m, n, afs = NULL, min_MAF = 0.1, haplotypes = FALSE)

Value

A list including the following objects:

  • y: phenotype vector

  • g: heritable component of the phenotype vector

  • X: matrix of diploid genotypes

  • AF: vector of allele frequencies

  • beta_std: standardized genetic effects

  • beta_raw: unstandardized genetic effects

  • H: matrix of haploid genotypes (returned only if haplotypes=TRUE)

Arguments

h2_0

generation zero (panmictic) heritability

r

cross-mate phenotypic correlation

m

number of biallelic causal variants

n

sample size

afs

(optional). Allele frequencies to use. If not provided, m will be drawn uniformly from the interval [min_MAF, 1-min_MAF]

min_MAF

(optional) minimum minor allele frequency for causal variants. Ignored if if afs is not NULL. Defaults to 0.1

haplotypes

logical. If TRUE, includes (phased) haploid genotypes in output. Defaults to FALSE

Examples

Run this code
set.seed(1)
h2_0 = .5; m = 200; n = 1000; r =.5

## simulate genotype/phenotype data
sim_dat <- am_simulate(h2_0, r, m, n)
str(sim_dat)

## empirical h2 vs expected equilibrium h2
(emp_h2 <- var(sim_dat$g)/var(sim_dat$y))
h2_eq(r, h2_0)

Run the code above in your browser using DataLab