In this independent exercise, you will simulate long-term selection with two positively correlated traits but with opposite selection goals. Think about a breeding programme where the goal is to increase the first trait (for example, milk yield in dairy cattle) and decrease the second, yet positively correlated trait (for example, days to calving in dairy cattle). In this sense, you will simulate 15 generations of selection on the first trait only, and continue with another 15 generations on both traits. This change in breeding objective will be a move from a single-trait selection towards a multiple trait index-selection. You will achieve this by simulating:
Use the runMacs()
function to simulate 100 individuals,
10 chromosomes, and capture 100 loci per chromosome, for a generic
species.
# Clean the working environment
rm(list = ls())
# Set the default plot layout
par(mfrow = c(1, 1))
# Load AlphaSimR and simulate founder genomes
library(AlphaSimR)
## Loading required package: R6
founderGenomes = runMacs(nInd = 100,
nChr = 10,
segSites = 100)
Create the SP
object holding the global simulation
parameters. Define two correlated traits with genetic correlation of 0.5
with additive genetic effects, controlled by 50 loci on each chromosome,
and with the mean of 100 units and genetic variance of 100 unit\(^2\). Also set heritabilities to 0.5 for
both traits and save these into the variable h2s
.
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)
h2s = c(0.5, 0.5)
SP$addTraitA(nQtlPerChr = 50, mean = means, var = vars, corA = cors)
Now create a base population and inspect the relationship between the two traits.
# Base population
basePop = newPop(founderGenomes)
# Phenotype the population
basePop = setPheno(basePop, h2 = h2s)
# Explore genetic relationship between traits by plotting and calculating correlation
plot(x = gv(basePop))
cor(gv(basePop))
## Trait1 Trait2
## Trait1 1.0000000 0.5617053
## Trait2 0.5617053 1.0000000
# Explore phenotype relationship between traits by plotting and calculating correlation
plot(x = pheno(basePop))
cor(pheno(basePop))
## Trait1 Trait2
## Trait1 1.0000000 0.2979005
## Trait2 0.2979005 1.0000000
First, simulate 15 generations of selection of the best 25 individuals based on their phenotype values for the first trait and using them as parents of the next generation.
# Allocate containers
nGenerations = (15 + 15) + 1 # +1 to store starting generation
meanGAll = vector("list", length = nGenerations)
varGAll = vector("list", length = nGenerations)
corGAll = numeric(nGenerations)
# Save the starting values
meanGAll[[1]] = meanG(basePop)
varGAll[[1]] = varG(basePop)
corGAll[1] = cov2cor(varGAll[[1]])[2, 1]
# Initial selection
nSelected = 25
newPopSelected = selectInd(pop = basePop,
nInd = nSelected,
use = "pheno",
trait = 1)
# Selection over 15 generations with selection on trait 1 only
for (generation in 1:15) {
cat("Working on the Generation:", generation, "\n")
# Cross parents, phenotype progeny, and select new parents
newPop = randCross(newPopSelected, nCrosses = nInd(basePop))
newPop = setPheno(newPop, h2 = h2s)
newPopSelected = selectInd(pop = newPop,
nInd = nSelected,
use = "pheno",
trait = 1)
# Save summaries
meanGAll[[1 + generation]] = meanG(newPop)
varGAll[[1 + generation]] = varG(newPop)
corGAll[1 + generation] = cov2cor(varGAll[[1 + generation]])[2, 1]
}
## Working on the Generation: 1
## Working on the Generation: 2
## Working on the Generation: 3
## Working on the Generation: 4
## Working on the Generation: 5
## Working on the Generation: 6
## Working on the Generation: 7
## Working on the Generation: 8
## Working on the Generation: 9
## Working on the Generation: 10
## Working on the Generation: 11
## Working on the Generation: 12
## Working on the Generation: 13
## Working on the Generation: 14
## Working on the Generation: 15
Inspect the result of selecting for the first trait only.
# Plot results
meanGTrait1 = sapply(meanGAll[1:15], function(x) x[1])
meanGTrait2 = sapply(meanGAll[1:15], function(x) x[2])
meanRanges = range(c(meanGTrait1, meanGTrait2))
varGTrait1 = sapply(varGAll[1:15], function(x) x[1, 1])
varGTrait2 = sapply(varGAll[1:15], function(x) x[2, 2])
varRanges = range(c(varGTrait1, varGTrait2))
# Plot mean of genetic values over time
plot(x = 1:15, y = meanGTrait1, type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Mean of genetic values", ylim = meanRanges)
lines(x = 1:15, y = meanGTrait2, type = "l", col = "purple", lty = 2, lwd = 3)
legend(x = "topleft", legend = c("1", "2"), title = "Trait",
lwd = 3, lty = c(1, 2), col = c("black", "purple"))
# Plot variance of genetic values over time
plot(x = 1:15, y = varGTrait1, type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Variance of genetic values", ylim = varRanges)
lines(x = 1:15, y = varGTrait2, type = "l", col = "purple", lty = 2, lwd = 3)
legend(x = "topleft", legend = c("1", "2"), title = "Trait",
lwd = 3, lty = c(1, 2), col = c("black", "purple"))
# Plot correlation between genetic values over time
plot(x = 1:15, y = corGAll[1:15], type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Genetic correlation")
We are expectedly increasing the first trait, but also the second trait, while our ultimate breeding goal is to increase the first trait and decrease the second trait!
Now, simulate additional 15 generations of selecting the best 25
individuals based on an index of phenotypes for the first and the second
trait and using them as parents of the next generation. Ensure you
continue selection from the current generation, don’t restart selection
from the basePop
! For index-selection use the
selIndex()
function and put equal weight on both traits,
but aim to increase the first trait and decrease the
second trait.
# Selection over additional 15 generations with a switch to index-selection
for (generation in 16:30) {
cat("Working on the Generation:", generation, "\n")
# Cross parents, phenotype progeny, and select new parents
newPop = randCross(newPopSelected, nCrosses = nInd(basePop))
newPop = setPheno(newPop, h2 = h2s)
newPopSelected = selectInd(pop = newPop,
nInd = nSelected,
use = "pheno",
trait = selIndex, b = c(0.5, -0.5), scale = TRUE)
# Save summaries
meanGAll[[1 + generation]] = meanG(newPop)
varGAll[[1 + generation]] = varG(newPop)
corGAll[1 + generation] = cov2cor(varGAll[[1 + generation]])[2, 1]
}
## Working on the Generation: 16
## Working on the Generation: 17
## Working on the Generation: 18
## Working on the Generation: 19
## Working on the Generation: 20
## Working on the Generation: 21
## Working on the Generation: 22
## Working on the Generation: 23
## Working on the Generation: 24
## Working on the Generation: 25
## Working on the Generation: 26
## Working on the Generation: 27
## Working on the Generation: 28
## Working on the Generation: 29
## Working on the Generation: 30
# Plot results
meanGTrait1 = sapply(meanGAll, function(x) x[1])
meanGTrait2 = sapply(meanGAll, function(x) x[2])
meanRanges = range(c(meanGTrait1, meanGTrait2))
varGTrait1 = sapply(varGAll, function(x) x[1, 1])
varGTrait2 = sapply(varGAll, function(x) x[2, 2])
varRanges = range(c(varGTrait1, varGTrait2))
# Plot mean of genetic values over time
plot(x = 1:nGenerations, y = meanGTrait1, type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Mean of genetic values", ylim = meanRanges)
lines(x = 1:nGenerations, y = meanGTrait2, type = "l", col = "purple", lty = 2, lwd = 3)
legend(x = "topleft", legend = c("1", "2"), title = "Trait",
lwd = 3, lty = c(1, 2), col = c("black", "purple"))
# Plot variance of genetic values over time
plot(x = 1:nGenerations, y = varGTrait1, type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Variance of genetic values", ylim = varRanges)
lines(x = 1:nGenerations, y = varGTrait2, type = "l", col = "purple", lty = 2, lwd = 3)
legend(x = "topleft", legend = c("1", "2"), title = "Trait",
lwd = 3, lty = c(1, 2), col = c("black", "purple"))
# Plot correlation between genetic values over time
plot(x = 1:nGenerations, y = corGAll, type = "l", col = "black", lwd = 3,
xlab = "Generation", ylab = "Genetic correlation")
What do the results from the two scenarios show you about the trends for the first and second trait? In the first 15 generations, selection on the first trait increased its mean, but due to a positive genetic correlation with the second trait, we also observed a positive trend in the second trait. However, we are interested in actually decreasing the second trait. So, for the next 15 generations we switched to an index-selection, where despite a positive genetic correlation, we were able to turn around the trend for the second trait into a desirable direction (decrease) while preserving the increasing trend for the first trait.
To gain further experience with index selection, repeat this exercise by reducing heritability from 0.5 to 0.1 for the second trait and compare changes in genetic means for both traits between the two heritabilities.