Pedigree BLUP in AlphaSimR
Chris Gaynor
2026-12-01
Source:vignettes/articles/PedigreeBLUP.Rmd
PedigreeBLUP.RmdIntroduction
Before genomic selection, breeding values were predicted from phenotypes and pedigrees. Pedigree BLUP, also called the animal model (Henderson 1975), combines an individual’s own records with those of its relatives, weighting each relative by how closely related it is. It remains the standard method in many breeding programs, and in a simulation it is the natural baseline against which genomic selection is compared.
AlphaSimR provides it through pedBLUP,
which works like the genomic prediction functions described in
vignette("GenomicSelection"): fit a model to a training
population, then apply it to any population with setEBV.
This article covers recording the pedigree, the relationships it
implies, fitting the model, and what pedigree prediction can and cannot
do.
Recording the pedigree
AlphaSimR keeps a record of every individual’s parents
only when asked to. Pedigree tracking is turned on with
setTrackPed, and it has to be turned on before the first
population is created, because a pedigree that starts part way through a
simulation is missing the relationships among its first individuals.
set.seed(1975)
founderPop = quickHaplo(nInd = 4, nChr = 1, segSites = 10)
SP = SimParam$new(founderPop)
SP$setTrackPed(TRUE)
founders = newPop(founderPop, simParam = SP)Relationships from a pedigree
The relationships a pedigree implies are summarized by the numerator
relationship matrix
,
whose off-diagonal elements are twice the kinship between two
individuals and whose diagonal is one plus the individual’s inbreeding
coefficient for a diploid. pedigreeA calculates it for a
population, and pedigreeInbreeding the inbreeding
coefficients alone.
The small pedigree below has two full sibs, a half sib of them, a selfed individual and a doubled haploid, all descended from the four founders.
fullSibs = makeCross(founders, crossPlan = matrix(c(1, 2), nrow = 2,
ncol = 2, byrow = TRUE),
simParam = SP)
halfSib = makeCross(founders, crossPlan = matrix(c(1, 3), nrow = 1),
simParam = SP)
selfed = self(founders[1], simParam = SP)
dh = makeDH(founders[1], simParam = SP)
everyone = c(founders, fullSibs, halfSib, selfed, dh)
getPed(everyone)
#> id mother father
#> 1 1 0 0
#> 2 2 0 0
#> 3 3 0 0
#> 4 4 0 0
#> 5 5 1 2
#> 6 6 1 2
#> 7 7 1 3
#> 8 8 0 0
#> 9 9 0 0The selfed individual (8) and the doubled haploid (9) appear to have
unknown parents. That is because self and
makeDH default to keepParents = TRUE, which
labels the new individual’s mother and father
slots with its parent’s parents, here the unknown parents of a founder.
The pedigree recorded in the SimParam always holds the real
parent, with a column marking doubled haploids, and it is what the
pedigree functions use:
SP$pedigree
#> mother father isDH
#> 1 0 0 0
#> 2 0 0 0
#> 3 0 0 0
#> 4 0 0 0
#> 5 1 2 0
#> 6 1 2 0
#> 7 1 3 0
#> 8 1 1 0
#> 9 1 1 1
round(pedigreeA(everyone, simParam = SP), 3)
#> 1 2 3 4 5 6 7 8 9
#> 1 1.0 0.0 0.0 0 0.50 0.50 0.50 1.0 1.0
#> 2 0.0 1.0 0.0 0 0.50 0.50 0.00 0.0 0.0
#> 3 0.0 0.0 1.0 0 0.00 0.00 0.50 0.0 0.0
#> 4 0.0 0.0 0.0 1 0.00 0.00 0.00 0.0 0.0
#> 5 0.5 0.5 0.0 0 1.00 0.50 0.25 0.5 0.5
#> 6 0.5 0.5 0.0 0 0.50 1.00 0.25 0.5 0.5
#> 7 0.5 0.0 0.5 0 0.25 0.25 1.00 0.5 0.5
#> 8 1.0 0.0 0.0 0 0.50 0.50 0.50 1.5 1.0
#> 9 1.0 0.0 0.0 0 0.50 0.50 0.50 1.0 2.0
pedigreeInbreeding(everyone, simParam = SP)
#> 1 2 3 4 5 6 7 8 9
#> 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 1.0The matrix shows the familiar values. The founders are unrelated and not inbred. Full sibs have a relationship of 0.5 and each has 0.5 with each parent. The half sib has 0.25 with each full sib. Selfing an outbred founder gives an inbreeding coefficient of 0.5. A doubled haploid is fully inbred, so its diagonal is 2, and because its genome is two copies of one gamete from its parent, it is related to everyone else exactly as that parent is.
Founders made by runMacs or quickHaplo with
inbred = TRUE are taken to be fully inbred rather than
outbred. For polyploids, inheritance is taken to be autopolyploid
without double reduction, and the diagonal is
for ploidy
(Kerr et al. 2012). The details are on the
help page of pedigreeA.
The calculation uses the method of Colleau
(2002), which never forms the relationship matrix of the whole
pedigree, so it stays fast in long simulations. pedigreeA
still returns a dense matrix, so its memory grows with the square of the
number of individuals asked for.
Fitting the model
The model is
,
where
holds the fixed effects,
the breeding values with covariance
,
and
the errors. pedBLUP builds the mixed model equations from
the inverse of
,
which is sparse (Henderson 1976), and
solves them with a sparse Cholesky factorization. Unless they are held
fixed with estVarComp = FALSE, the variance components are
estimated by restricted maximum likelihood (REML), using the
derivative-free approach of Graser et al.
(1987) and Meyer (1989).
The example simulates four generations of random mating in 40
full-sib families of five, and uses every phenotyped individual to train
the model. A fifth generation, made from the fourth, is the set of
selection candidates. runMacs founders are used so that the
same population can later be used for genomic prediction.
set.seed(2001)
founderPop = runMacs(nInd = 200, nChr = 10, segSites = 200)
SP = SimParam$new(founderPop)
SP$setTrackPed(TRUE)
SP$restrSegSites(minQtlPerChr = 50, minSnpPerChr = 100)
SP$addTraitA(nQtlPerChr = 50)
SP$addSnpChip(nSnpPerChr = 100)
SP$setVarE(h2 = 0.3)
generations = vector("list", 5)
generations[[1]] = newPop(founderPop, simParam = SP)
for(i in 2:5){
generations[[i]] = randCross(generations[[i - 1]], nCrosses = 40,
nProgeny = 5, simParam = SP)
}
trainPop = do.call(c, generations[1:4])
candidates = generations[[5]]
nInd(trainPop)
#> [1] 800
pedModel = pedBLUP(trainPop, simParam = SP)
pedModel@Vu
#> [,1]
#> [1,] 1.091412
pedModel@Ve
#> [,1]
#> [1,] 2.315888The estimates can be compared with the variances the simulation was set up with, an additive genetic variance of 1 and an error variance of 2.333 in the founders:
SP$varA
#> [1] 1
SP$varE
#> [1] 2.333333Predicting with setEBV
As with the genomic models, setEBV applies the fit to a
population. value = "bv" gives estimated breeding values
centered on the training population, or on targetPop when
one is supplied, and value = "gv" gives the estimated
breeding value plus the estimate for the first level of the fixed
effects, which puts the estimate on the scale of the phenotypes. The two
differ only by a constant, so they rank individuals identically.
"female" and "male" are not available.
candidates = setEBV(candidates, pedModel, value = "bv", simParam = SP)
# Accuracy of the candidates' estimated breeding values
cor(ebv(candidates)[, 1], bv(candidates, simParam = SP)[, 1])
#> [1] 0.525778The candidates were not in the training population, so they have no
records of their own and no records from descendants. Their best linear
unbiased prediction is then the average of their parents’ estimates, and
that is what setEBV uses for any individual outside the
fit. The same holds for individuals created long after the model was
fitted.
What a pedigree cannot see
A consequence is that full sibs without records get identical estimates, because they have identical pedigrees:
family = paste(candidates@mother, candidates@father)
estimatesPerFamily = tapply(ebv(candidates)[, 1], family,
function(x) length(unique(round(x, 10))))
table(estimatesPerFamily)
#> estimatesPerFamily
#> 1
#> 40Every family has a single estimate. The pedigree predicts the average
of a family well, but it carries no information about which sib
inherited the better half of each parent’s genome, the Mendelian
sampling term that makes up half of the additive variance in an outbred
population. Markers do carry that information, which is a large part of
the advantage of genomic selection (Daetwyler et
al. 2007). Fitting RRBLUP to the same training
population shows the difference:
gsModel = RRBLUP(trainPop, simParam = SP)
gsCandidates = setEBV(candidates, gsModel, value = "bv", simParam = SP)
accuracy = function(x){
cor(ebv(x)[, 1], bv(x, simParam = SP)[, 1])
}
withinFamily = function(x){
# The correlation within each family, averaged over families
df = data.frame(ebv = ebv(x)[, 1], bv = bv(x, simParam = SP)[, 1],
family = paste(x@mother, x@father))
mean(sapply(split(df, df$family), function(f){
if(sd(f$ebv) == 0) return(0)
cor(f$ebv, f$bv)
}))
}
round(rbind(
pedigree = c(overall = accuracy(candidates),
withinFamily = withinFamily(candidates)),
markers = c(overall = accuracy(gsCandidates),
withinFamily = withinFamily(gsCandidates))
), 3)
#> overall withinFamily
#> pedigree 0.526 0.000
#> markers 0.627 0.355Overall, markers predict the candidates better than the pedigree does. The difference comes from within families: the pedigree’s within-family accuracy is zero by construction, while markers rank sibs with an accuracy well above zero. A larger training population generally widens the gap, because it improves the estimates of the marker effects, while records on the candidates themselves would let the pedigree separate sibs too.
More than one record per individual
An individual that appears in the training population more than once has its records treated as repeated records of a single breeding value. That is how several years of records on a long-lived parent are combined:
repeated = c(trainPop, setPheno(generations[[4]], simParam = SP))
nInd(repeated)
#> [1] 1000
length(unique(repeated@id))
#> [1] 800
repeatModel = pedBLUP(repeated, simParam = SP)No permanent environmental effect is fitted, so any non-additive genetic variance shared by an individual’s repeated records is absorbed into the estimate of the additive genetic variance.
The fixEff slot is fitted as a set of fixed effects,
exactly as in the genomic models. Records from different environments or
years should be labeled with their own fixEff, as described
in vignette("GenomicSelection"):
Fitting more cheaply
Estimating the variance components is most of the cost of a fit.
Within one simulation they change slowly, so a common pattern is to
estimate them once and pass that fit as varComp, with
estVarComp = FALSE, in later fits, which then only solve
the mixed model equations. Vu and Ve can also
be given directly. With estVarComp left at its default,
TRUE, the variance components are estimated again instead,
with the REML search centered on the earlier fit’s ratio, which keeps
the search near the estimate as the population drifts from the founders
but takes as long as a fit from scratch.
Things to know
The REML search is local. The variance ratio is
searched over two orders of magnitude either side of the ratio of
supplied variance components, or else of the ratio set for the trait in
the SimParam, or of 1 when that is not available, first on
a grid and then near its best point. The result is the best ratio found,
not a guaranteed global maximum, and a warning is given if it falls at
the edge of the range. Breeding values change little with the ratio near
its best value.
No reliabilities are reported. The output holds estimates, not their prediction error variances, as with the genomic models.
A fit belongs to its pedigree. resetPed
discards individuals from the recorded pedigree, and new individuals can
then take their internal IDs. setEBV therefore refuses a
fit once a reset has discarded any of the individuals it was fitted
to.
Ploidy changes are not recorded. A doubled haploid
made by reduceGenome followed by doubleGenome
is recorded as two generations of selfing, and individuals made by
reduceGenome, doubleGenome or
mergeGenome have the wrong relationships. Use
makeDH for doubled haploids.
Only one trait. pedBLUP fits a single
trait. A function of several traits, such as an index, can be passed as
traits to fit the index as one trait.