View source: R/sim_phenotypes.R
sim_phenoval | R Documentation |
Simulates phenotypic observations given the genotypic value of individuals and the heritability of a quantitative trait.
sim_phenoval(pop, h2, n.env = 1, n.rep = 1, ...)
pop |
An object of class |
h2 |
The heritability of the trait or traits. May be a numeric vector of length 1 (heritability is the same for all traits) or a numeric vector of length n_trait. |
n.env |
The number of environments in which to phenotype. |
n.rep |
The number of replicates of each individual in each environment. |
... |
Other arguments. See |
return.eff |
Should the variance components and effects be returned? |
Other arguments that can be specified are :
V_E
The variance of environmental effects. May be a scalar (V_E is the same for all traits) or a numeric vector of length n_trait.
V_R
The variance of the residual effects. May be a scalar (V_R is the same for all traits) or a numeric vector of length n_trait.
Environmental effects are drawn from a normal distribution such that e ~ N(0, V_E)
,
where V_E
is the environmental variance. If V_E
is not provided, it
is 8 times the genotypic variance. Genotype-environmental interaction effects are drawn
from a normal distribution such that ge ~ N(0, V_GE)
, where V_GE
is the genotype-environment
interaction variance. If V_GE
is not provided, it defaults to 2 times the genotypic variance.
Residual effects are drawn from a normal distribution such that \epsilon ~ N(0, V_R)
, where V_R
is
the residual variance. If V_R
is not provided, it is calculated from h2
, where
V_R = n.rep * n.env * (\frac{Vg}{h2} - Vg)
.
An object of class pop
with all information in the input pop
object,
plus simulated phenotypes.
# Create a genome
n.mar <- c(505, 505, 505)
len <- c(120, 130, 140)
genome <- sim_genome(len, n.mar)
# Simulate a a trait with 15 QTL
qtl.model <- matrix(nrow = 15, ncol = 4)
genome <- sim_gen_model(genome, qtl.model, add.dist = "geometric", max.qtl = 15)
pop <- sim_pop(genome = genome, n.ind = 200)
## Default simulates environment and residual effects, but no GxE
pop1 <- sim_phenoval(pop = pop, h2 = 0.5, n.env = 2, n.rep = 2)
# Simulate GxE
# First simulate a population
pop <- sim_pop(genome = genome, n.ind = 200, ignore.gen.model = TRUE)
# Second, create a gene model with QxE
genome <- sim_gen_model(genome = genome, qtl.model = qtl.model, geno = pop$geno,
add.dist = "geometric", V_GE.scale = 2)
# Re-save the population
pop <- create_pop(genome = genome, geno = do.call("cbind", pop$geno))
# Generate phenotypes
pop1 <- sim_phenoval(pop = pop, h2 = 0.5, n.env = 2, n.rep = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.