gaynorr / AlphaSimR

R package for breeding program simulations
https://gaynorr.github.io/AlphaSimR/
Other
42 stars 18 forks source link

Are correlation/covariance parameters stored in the SP object? #63

Closed poca87 closed 2 years ago

poca87 commented 2 years ago

Imagine this simulation:

library(AlphaSimR)
founderGenomes = runMacs(nInd = 100,
                         nChr = 10,
                         segSites = 100)

SP = SimParam$new(founderGenomes)

# Define the traits
means = c(100, 100)
vars = c(100, 100)
cors = matrix(data = c( 1.0, -0.5,
                       -0.5,  1.0),
                byrow = TRUE, nrow = 2, ncol = 2)
SP$addTraitA(nQtlPerChr = 50, mean = means, var = vars, corA = cors)

How can I see variance parameters used in the simulation? Well we have them in the SP

> SP$varA
[1] 1 2
> SP$varG
[1] 1 2

But, I can't seem to find correlations (or covariances) at all. I know we can get them for each population object, but would be good to store them also in the SP.

gaynorr commented 2 years ago

No, they aren't stored for the QTL effects. They get used to generate the effects and are then forgotten. The varA and varG values stored in SimParams are really just for the h2 and H2 calculations in setPheno. The covariances are stored for varE, because it gets used to generate new residual errors.

gregorgorjanc commented 2 years ago

I think it would make sense to store the correlation matrix - for completeness.