This package enables simulation of complex (polygenic and continuous) traits from a simulated or real genotype matrix.
The focus is on controling the mean and covariance structure of the data to yield the desired heritability under arbitrary population structures (any underlying kinship matrix).
The main function is
sim_trait, which returns the simulated trait and the vector of causal loci (randomly selected) and their effect sizes (randomly drawn and scaled appropriately).
cov_trait computes the expected covariance matrix of the trait given the model parameters (namely the desired heritability and the true kinship matrix).
The recommended inputs are simulated genotypes with known ancestral allele frequencies.
bnpsd package simulates genotypes for admixed individuals, resulting in a complex population structure.
For real data it is necessary to estimate the kinship matrix.
popkin package provides high-accuracy kinship estimates.
Maintainer: Alejandro Ochoa [email protected] (0000-0003-4928-3403)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# construct a dummy genotype matrix X <- matrix( data = c(0,1,2,1,2,1,0,0,1), nrow = 3, byrow = TRUE ) # made up ancestral allele frequency vector for example p_anc <- c(0.5, 0.6, 0.2) # desired heritability herit <- 0.8 # create simulated trait and associated data obj <- sim_trait(X = X, m_causal = 2, herit = herit, p_anc = p_anc) # trait vector obj$trait # randomly-picked causal locus indeces obj$causal_indexes # locus effect size vector obj$causal_coeffs # create a dummy kinship matrix for example kinship <- matrix( data = c(0.6,0.1,0, 0.1,0.6,0.1, 0,0.1,0.6), nrow = 3, byrow = TRUE ) # covariance of simulated traits V <- cov_trait(kinship = kinship, herit = herit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.