4.4 Indirect Genetic Effects

Indirect genetic effects are a bit more difficult to code. Lets take the example of maternal genetic effects. The maternal genetic effect that affects an individual’s phenotype, is that of its mother, not itself. Here we can use [] to index the levels of the random effects within the formula. We need to be careful here as internally in simulate_population() the indexing of the factors in the data structure is done independently. We therefore need to generate a index for the mothers that links to the individual. We can do this using the index_link argument - in the code below we create a new factor to index with, called dam_link, that is the dam factor in our data structure, that has been indexed to match the animal factor.

Using this indexing trick, we can simulate the direct genetic and maternal genetic effects that an individual has (and the covariance between them), as well as generating an individual’s phenotype from its own direct genetic effects, and its mother’s maternal genetic effect.

squid_data <- simulate_population(
  parameters=list(
    animal = list(
      names=c("direct","maternal"),
      vcov = matrix(c(1,0.3,0.3,0.5),2,2)
    ),
    residual = list(
      names="residual",
      vcov = 0.5
    )
  ),
  data_structure=BTped,
  pedigree=list(animal=BTped),
  index_link=list(dam_link="dam-animal"),
  model = "y = direct + maternal[dam_link] + residual"
)
## Warning in FUN(X[[i]], ...): Not all levels are of dam are present in animal
## meaning that there will be NAs in the new grouping factor
data <- get_population_data(squid_data)

head(data)
##    y     direct    maternal    residual  animal  dam sire squid_pop
## 1 NA -1.1765364 -0.33246522  0.98593948 R187557 <NA> <NA>         1
## 2 NA  1.0032654  0.17594714  0.46289797 R187559 <NA> <NA>         1
## 3 NA -1.3823286 -0.43613248 -0.89167875 R187568 <NA> <NA>         1
## 4 NA  0.3973638 -0.07201462  0.16249743 R187518 <NA> <NA>         1
## 5 NA -1.2407912 -0.56117955 -0.01929683 R187528 <NA> <NA>         1
## 6 NA  0.6117901  0.45613335  1.49005498 R187945 <NA> <NA>         1