View source: R/sim_trait_env.R
sim_trait_env | R Documentation |
Mostly a wrapper around simtrait::sim_trait()
, but can optionally add a structured environment effect.
However, in that case the heritability is no longer as specified.
sim_trait_env( X, p_anc, m_causal, herit, env = NA, env_var = 1, k_subpops = NA, fes = FALSE, verbose = TRUE )
X |
The genotype matrix. |
p_anc |
The vector of ancestral allele frequencies. |
m_causal |
The number of causal loci for the trait, selected randomly from among the simulated loci. |
herit |
The trait heritability. |
env |
A string describing environment model.
Only |
env_var |
The variance of the environment effect.
Ignored if |
k_subpops |
The number of intermediate subpopulations for admixture model.
Used for |
fes |
If |
verbose |
If |
A list containing the following elements:
trait
: The simulated trait vector.
causal_indexes
: The vector of randomly selected causal loci indexes.
causal_coeffs
: The vector of simulated regression coefficients for causal loci.
# draw population parameters using `sim_pop` first # a small example k_subpops <- 3 data_pop <- sim_pop( n_ind = 50, G = 3, k_subpops = k_subpops ) # then draw genotypes m_loci <- 100 data_geno <- sim_geno( data_pop$admix_proportions_1, data_pop$inbr_subpops, data_pop$fam, data_pop$ids ) # now draw trait! m_causal <- 5 herit <- 0.5 data_trait <- sim_trait_env( data_geno$X, data_geno$p_anc, m_causal, herit, env = 'gcat', k_subpops = k_subpops ) # the simulated trait data_trait$trait # indexes of randomly-selected causal loci data_trait$causal_indexes # coefficients of causal loci data_trait$causal_coeffs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.