View source: R/sim_trait_model.R
sim_trait_model | R Documentation |
This function requires a trait model
, which contains values for all of its variance components and intercept coeficient, as well as pre-determined causal loci indexes along with their coefficients, and simply simulates the traits with genetic effects and random non-genetic effects, for the individuals provided.
This is useful to simulate traits for new individuals from a pre-existing model that was constructed using some previous data, so that the trait is fundamentally the same in all individuals (rather than a new random trait as sim_trait
does for each call).
sim_trait_model(
model,
X,
labs = NULL,
loci_on_cols = FALSE,
X_subset = FALSE,
skip_checks = FALSE
)
model |
A list returned by a previous |
X |
The |
labs |
Optional labels assigning individuals to groups, to simulate environment group effects.
Values can be numeric or strings, simply assigning the same values to individuals in the same group.
If vector (single environment), length must be number of individuals.
If matrix (multiple environments), individuals must be along rows, and environments along columns.
The environments are not required to be nested.
If this is non- |
loci_on_cols |
If |
X_subset |
If |
skip_checks |
If |
The same type of named list returned by sim_trait()
, please see that for more details. This includes the desired trait
values, as well as copies of the input model parameters.
sim_trait()
for simulating traits from scratch, picking random causal variants and their coefficients from various models.
# make two genotype matrices, one to construct the initial trait,
# the second one is a new dataset from which we want to simulate the same trait.
# They should have the same loci (number of rows), but individuals should be different!
X <- matrix(
data = c(
0, 1, 2,
1, 2, 1,
0, 0, 1
),
nrow = 3,
byrow = TRUE
)
X2 <- matrix(
data = c(
2, 1,
2, 0,
1, 1
),
nrow = 3,
byrow = TRUE
)
# here's a minimal `sim_trait` call that simulates a trait of interest from the first dataset
model <- sim_trait( X = X, m_causal = 2, herit = 0.7, kinship = 0.2 )
# use the same model to simulate traits for the new individuals!
obj <- sim_trait_model( model, X2 )
# trait vector for new individuals:
obj$trait
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.