4.2 Multivariate genetic effects
We can simulate genetic effects affecting multiple phenotypes and the covariance between them, by specifying the number of response variables, and a covariance matrix, instead of only a variance.
<- simulate_population(
squid_data data_structure = ped,
pedigree = list(animal = ped),
n_response=2,
parameters = list(
animal = list(
vcov = diag(2)
),residual = list(
vcov = diag(2)
)
)
)
<- get_population_data(squid_data)
data head(data)
## y1 y2 animal_effect1 animal_effect2 residual1 residual2
## 1 0.6642658 0.83471076 0.46407220 0.22094082 0.2001936 0.6137699
## 2 -0.7466087 0.14747280 0.54421651 0.52761540 -1.2908253 -0.3801426
## 3 1.6963890 -0.40456141 0.39385325 -0.30347849 1.3025357 -0.1010829
## 4 1.9764612 0.85993234 0.08271504 0.26908060 1.8937461 0.5908517
## 5 -0.8080648 -0.09793586 -1.85489445 0.07503407 1.0468296 -0.1729699
## 6 3.0311582 0.96837367 2.32009932 0.25440902 0.7110589 0.7139646
## animal dam sire squid_pop
## 1 204 <NA> <NA> 1
## 2 205 <NA> <NA> 1
## 3 206 <NA> <NA> 1
## 4 207 <NA> <NA> 1
## 5 208 <NA> <NA> 1
## 6 209 <NA> <NA> 1
library(MCMCglmm)
<-inverseA(ped)$Ainv
Ainv<- MCMCglmm(cbind(y1,y2)~1,
mod random=~us(trait):animal,
rcov=~us(trait):units,
data=data,
ginverse=list(animal=Ainv),
family=rep("gaussian",2),
verbose=FALSE)
summary(mod)
##
## Iterations = 3001:12991
## Thinning interval = 10
## Sample size = 1000
##
## DIC: 32469.06
##
## G-structure: ~us(trait):animal
##
## post.mean l-95% CI u-95% CI eff.samp
## traity1:traity1.animal 0.99346 0.82773 1.1631 162.4
## traity2:traity1.animal 0.01649 -0.09408 0.1259 211.7
## traity1:traity2.animal 0.01649 -0.09408 0.1259 211.7
## traity2:traity2.animal 1.06973 0.87654 1.2265 202.6
##
## R-structure: ~us(trait):units
##
## post.mean l-95% CI u-95% CI eff.samp
## traity1:traity1.units 1.06566 0.9433 1.21635 206.0
## traity2:traity1.units -0.05158 -0.1421 0.04004 209.5
## traity1:traity2.units -0.05158 -0.1421 0.04004 209.5
## traity2:traity2.units 0.97807 0.8336 1.10499 211.3
##
## Location effects: cbind(y1, y2) ~ 1
##
## post.mean l-95% CI u-95% CI eff.samp pMCMC
## (Intercept) -0.02171 -0.05669 0.01237 893.3 0.242