Working with structured populations using MultiPop in AlphaSimR
Daniel Ariza-Suarez, Gregor Gorjanc and Chris Gaynor
2026-12-01
Source:vignettes/articles/MultiPop.Rmd
MultiPop.RmdIntroduction
AlphaSimR treats a Pop-class object as the
basic unit of simulation. In many breeding programs, however,
individuals are managed, evaluated, and selected as members of a larger
unit such as a family, sward, tank, cage, or colony. The
MultiPop class represents these structured populations
while preserving relationships among their component populations.
A MultiPop can contain Pop objects, other
MultiPop objects, or a combination of both. This makes it
possible to represent nested breeding structures and to apply existing
AlphaSimR operations recursively within those structures.
This vignette introduces MultiPop through two practical
examples: pedigree selection in wheat and recurrent selection followed
by half-sib family evaluation in forage breeding. It assumes familiarity
with the basic AlphaSimR workflow. For more information, see the
following:
vignette("AlphaSimR")for founder populations, simulation parameters, crossing, and selectionvignette("Genome")for an overview of genomes, genes, alleles, loci, genotypes, and haplotypesvignette("traits")for trait specification
The examples focus on workflows that are especially useful in population breeding: constructing and splitting structured populations, applying operations recursively, summarizing values within and across population levels, selecting population units, and simplifying or merging nested structures. The code is intended to be read and run in order.
Quick start
Creating a MultiPop
A MultiPop can be created in two main ways:
-
newMultiPop()combines existingPoporMultiPopobjects. -
splitPop()partitions onePopaccording to one or more grouping variables or functions.
The structure can later be simplified with
flattenMultiPop() or mergeMultiPops().
Flattening changes the nesting depth while retaining the component
Pop objects. Merging combines component populations; the
level argument controls how much of the hierarchy is
retained.
We begin by creating founder haplotypes, a trait, and a population of individuals.
set.seed(1234)
# Generate initial haplotypes
founderPop = quickHaplo(nInd = 20, nChr = 1, segSites = 10)
# Set simulation parameters
SP = SimParam$new(founderPop)
SP$addTraitA(nQtlPerChr = 10)
SP$setVarE(h2 = 0.5)
# Create a population of individuals
pop = newPop(founderPop, simParam = SP)newMultiPop() combines existing populations. Names can
be supplied when the object is constructed, and MultiPop
objects can be nested.
# Combine existing populations into a MultiPop
mp = newMultiPop(
pop[1:4],
pop[5:8],
pop[9:12],
pop[13:16],
pop[17:20]
)
mp
#> An object of class "MultiPop" with 5 item(s)
#> Level 1:
#> |-- [[1]] An object of class "Pop" with 4 individual(s): 1, 2, ..., 4
#> |-- [[2]] An object of class "Pop" with 4 individual(s): 5, 6, ..., 8
#> |-- [[3]] An object of class "Pop" with 4 individual(s): 9, 10, ..., 12
#> |-- [[4]] An object of class "Pop" with 4 individual(s): 13, 14, ..., 16
#> `-- [[5]] An object of class "Pop" with 4 individual(s): 17, 18, ..., 20
# Assign population names
mp_named = newMultiPop(
pop1 = pop[1:4],
pop2 = pop[5:8],
pop3 = pop[9:12],
pop4 = pop[13:16],
pop5 = pop[17:20]
)
mp_named
#> An object of class "MultiPop" with 5 item(s)
#> Level 1:
#> |-- [[1]] "pop1" - An object of class "Pop" with 4 individual(s): 1, 2, ..., 4
#> |-- [[2]] "pop2" - An object of class "Pop" with 4 individual(s): 5, 6, ..., 8
#> |-- [[3]] "pop3" - An object of class "Pop" with 4 individual(s): 9, 10, ..., 12
#> |-- [[4]] "pop4" - An object of class "Pop" with 4 individual(s): 13, 14, ..., 16
#> `-- [[5]] "pop5" - An object of class "Pop" with 4 individual(s): 17, 18, ..., 20
# MultiPop objects can be nested
mp_nested = newMultiPop(
group1 = pop[1:2],
group2 = newMultiPop(
subgroup1 = pop[3:4],
subgroup2 = newMultiPop(pop1 = pop[5:7], pop2 = pop[8:12])
)
)
mp_nested
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "group1" - An object of class "Pop" with 2 individual(s): 1, 2
#> `-- [[2]] "group2" - An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] "subgroup1" - An object of class "Pop" with 2 individual(s): 3, 4
#> `-- [[2]] "subgroup2" - An object of class "MultiPop" with 2 item(s)
#> | Level 3:
#> |-- [[1]] "pop1" - An object of class "Pop" with 3 individual(s): 5, 6, 7
#> `-- [[2]] "pop2" - An object of class "Pop" with 5 individual(s): 8, 9, ..., 12The list-like interface can inspect or replace components by position
or name. Single brackets ([]) retain a
MultiPop, whereas double brackets ([[]])
extract one child object.
mp_named[1:2]
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "pop1" - An object of class "Pop" with 4 individual(s): 1, 2, ..., 4
#> `-- [[2]] "pop2" - An object of class "Pop" with 4 individual(s): 5, 6, ..., 8
mp_named[[1]]
#> An object of class "Pop"
#> Ploidy: 2
#> Individuals: 4
#> Chromosomes: 1
#> Loci: 10
#> Traits: 1
mp_named[["pop1"]]
#> An object of class "Pop"
#> Ploidy: 2
#> Individuals: 4
#> Chromosomes: 1
#> Loci: 10
#> Traits: 1
mp_named$pop1
#> An object of class "Pop"
#> Ploidy: 2
#> Individuals: 4
#> Chromosomes: 1
#> Loci: 10
#> Traits: 1
# Replace one element in the MultiPop
mp_named[["pop1"]] = pop[17:20]
mp_named
#> An object of class "MultiPop" with 5 item(s)
#> Level 1:
#> |-- [[1]] "pop1" - An object of class "Pop" with 4 individual(s): 17, 18, ..., 20
#> |-- [[2]] "pop2" - An object of class "Pop" with 4 individual(s): 5, 6, ..., 8
#> |-- [[3]] "pop3" - An object of class "Pop" with 4 individual(s): 9, 10, ..., 12
#> |-- [[4]] "pop4" - An object of class "Pop" with 4 individual(s): 13, 14, ..., 16
#> `-- [[5]] "pop5" - An object of class "Pop" with 4 individual(s): 17, 18, ..., 20unnameMultiPop() can remove names recursively or at a
specified level.
unnameMultiPop(mp_nested)
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] An object of class "Pop" with 2 individual(s): 1, 2
#> `-- [[2]] An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] An object of class "Pop" with 2 individual(s): 3, 4
#> `-- [[2]] An object of class "MultiPop" with 2 item(s)
#> | Level 3:
#> |-- [[1]] An object of class "Pop" with 3 individual(s): 5, 6, 7
#> `-- [[2]] An object of class "Pop" with 5 individual(s): 8, 9, ..., 12
unnameMultiPop(mp_nested, level = 2)
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "group1" - An object of class "Pop" with 2 individual(s): 1, 2
#> `-- [[2]] "group2" - An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] An object of class "Pop" with 2 individual(s): 3, 4
#> `-- [[2]] An object of class "MultiPop" with 2 item(s)
#> | Level 3:
#> |-- [[1]] "pop1" - An object of class "Pop" with 3 individual(s): 5, 6, 7
#> `-- [[2]] "pop2" - An object of class "Pop" with 5 individual(s): 8, 9, ..., 12Splitting a population
splitPop() is useful when grouping information is stored
as a vector, data frame, or user-defined function.
# Using a vector to split a population
family = rep(c("A", "B"), length.out = nInd(pop))
mp_split1 = splitPop(pop, by = family)
mp_split1
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "A" - An object of class "Pop" with 10 individual(s): 1, 3, ..., 19
#> `-- [[2]] "B" - An object of class "Pop" with 10 individual(s): 2, 4, ..., 20
# Using a data frame. Each column defines one nesting level
grouping = data.frame(
family = sample(LETTERS[1:3], nInd(pop), replace = TRUE),
replicate = sample(letters[4:5], nInd(pop), replace = TRUE),
row.names = pop@id
)
mp_split2 = splitPop(pop, by = grouping)
mp_split2
#> An object of class "MultiPop" with 3 item(s)
#> Level 1:
#> |-- [[1]] "A" - An object of class "MultiPop" with 2 item(s)
#> | | Level 2:
#> | |-- [[1]] "d" - An object of class "Pop" with 3 individual(s): 4, 5, 6
#> | `-- [[2]] "e" - An object of class "Pop" with 3 individual(s): 1, 7, 17
#> |-- [[2]] "B" - An object of class "MultiPop" with 2 item(s)
#> | | Level 2:
#> | |-- [[1]] "d" - An object of class "Pop" with 4 individual(s): 2, 3, ..., 18
#> | `-- [[2]] "e" - An object of class "Pop" with 5 individual(s): 8, 10, ..., 19
#> `-- [[3]] "C" - An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] "d" - An object of class "Pop" with 3 individual(s): 11, 15, 20
#> `-- [[2]] "e" - An object of class "Pop" with 2 individual(s): 14, 16
# Using a function
grouping_fun = function(x) {
value = drop(pheno(x))
ifelse(value > mean(value), "aboveMean", "belowMean")
}
mp_split3 = splitPop(pop, by = grouping_fun)
mp_split3
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "aboveMean" - An object of class "Pop" with 10 individual(s): 3, 4, ..., 20
#> `-- [[2]] "belowMean" - An object of class "Pop" with 10 individual(s): 1, 2, ..., 19
# Using a list of vectors and functions.
mp_split4 = splitPop(pop, by = list(family, grouping_fun))
mp_split4
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "A" - An object of class "MultiPop" with 2 item(s)
#> | | Level 2:
#> | |-- [[1]] "aboveMean" - An object of class "Pop" with 5 individual(s): 3, 5, ..., 13
#> | `-- [[2]] "belowMean" - An object of class "Pop" with 5 individual(s): 1, 9, ..., 19
#> `-- [[2]] "B" - An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] "aboveMean" - An object of class "Pop" with 5 individual(s): 4, 8, ..., 20
#> `-- [[2]] "belowMean" - An object of class "Pop" with 5 individual(s): 2, 6, ..., 18For a data frame, each column defines one nesting level. Row names can be used to align grouping records with individual IDs. A list applies grouping specifications sequentially.
Flattening and merging
flattenMultiPop() removes intermediate levels while
retaining the component Pop objects.
# Flatten the whole structure
flattenMultiPop(mp_nested)
#> An object of class "MultiPop" with 4 item(s)
#> Level 1:
#> |-- [[1]] "group1" - An object of class "Pop" with 2 individual(s): 1, 2
#> |-- [[2]] "subgroup1" - An object of class "Pop" with 2 individual(s): 3, 4
#> |-- [[3]] "pop1" - An object of class "Pop" with 3 individual(s): 5, 6, 7
#> `-- [[4]] "pop2" - An object of class "Pop" with 5 individual(s): 8, 9, ..., 12
# Or flatten up until level 2
flattenMultiPop(mp_nested, level = 2)
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "group1" - An object of class "Pop" with 2 individual(s): 1, 2
#> `-- [[2]] "group2" - An object of class "MultiPop" with 3 item(s)
#> | Level 2:
#> |-- [[1]] "subgroup1" - An object of class "Pop" with 2 individual(s): 3, 4
#> |-- [[2]] "pop1" - An object of class "Pop" with 3 individual(s): 5, 6, 7
#> `-- [[3]] "pop2" - An object of class "Pop" with 5 individual(s): 8, 9, ..., 12
# Duplicate names are dropped
flattenMultiPop(mp_split2)
#> An object of class "MultiPop" with 6 item(s)
#> Level 1:
#> |-- [[1]] An object of class "Pop" with 3 individual(s): 4, 5, 6
#> |-- [[2]] An object of class "Pop" with 3 individual(s): 1, 7, 17
#> |-- [[3]] An object of class "Pop" with 4 individual(s): 2, 3, ..., 18
#> |-- [[4]] An object of class "Pop" with 5 individual(s): 8, 10, ..., 19
#> |-- [[5]] An object of class "Pop" with 3 individual(s): 11, 15, 20
#> `-- [[6]] An object of class "Pop" with 2 individual(s): 14, 16
# To avoid dropping names, "concatenate" them
flattenMultiPop(mp_split2, preserveNames = "concatenate")
#> An object of class "MultiPop" with 6 item(s)
#> Level 1:
#> |-- [[1]] "A_d" - An object of class "Pop" with 3 individual(s): 4, 5, 6
#> |-- [[2]] "A_e" - An object of class "Pop" with 3 individual(s): 1, 7, 17
#> |-- [[3]] "B_d" - An object of class "Pop" with 4 individual(s): 2, 3, ..., 18
#> |-- [[4]] "B_e" - An object of class "Pop" with 5 individual(s): 8, 10, ..., 19
#> |-- [[5]] "C_d" - An object of class "Pop" with 3 individual(s): 11, 15, 20
#> `-- [[6]] "C_e" - An object of class "Pop" with 2 individual(s): 14, 16mergeMultiPops() combines component populations. With
the default level = 0, all populations are merged into one
Pop. Larger values retain progressively more of the
hierarchy.
# All population are merged into one Pop
mergeMultiPops(mp_split4)
#> An object of class "Pop"
#> Ploidy: 2
#> Individuals: 20
#> Chromosomes: 1
#> Loci: 10
#> Traits: 1
# Use `level` to retain the hierarchy
mergeMultiPops(mp_split4, level = 1)
#> An object of class "MultiPop" with 2 item(s)
#> Level 1:
#> |-- [[1]] "A" - An object of class "Pop" with 10 individual(s): 3, 5, ..., 19
#> `-- [[2]] "B" - An object of class "Pop" with 10 individual(s): 4, 8, ..., 18
# Merge two or more objects. `level` controls how merging retains the structure
mergeMultiPops(mp_nested, mp_split4, level = 3)
#> An object of class "MultiPop" with 4 item(s)
#> Level 1:
#> |-- [[1]] "group1" - An object of class "Pop" with 2 individual(s): 1, 2
#> |-- [[2]] "group2" - An object of class "MultiPop" with 2 item(s)
#> | | Level 2:
#> | |-- [[1]] "subgroup1" - An object of class "Pop" with 2 individual(s): 3, 4
#> | `-- [[2]] "subgroup2" - An object of class "MultiPop" with 2 item(s)
#> | | Level 3:
#> | |-- [[1]] "pop1" - An object of class "Pop" with 3 individual(s): 5, 6, 7
#> | `-- [[2]] "pop2" - An object of class "Pop" with 5 individual(s): 8, 9, ..., 12
#> |-- [[3]] "A" - An object of class "MultiPop" with 2 item(s)
#> | | Level 2:
#> | |-- [[1]] "aboveMean" - An object of class "Pop" with 5 individual(s): 3, 5, ..., 13
#> | `-- [[2]] "belowMean" - An object of class "Pop" with 5 individual(s): 1, 9, ..., 19
#> `-- [[4]] "B" - An object of class "MultiPop" with 2 item(s)
#> | Level 2:
#> |-- [[1]] "aboveMean" - An object of class "Pop" with 5 individual(s): 4, 8, ..., 20
#> `-- [[2]] "belowMean" - An object of class "Pop" with 5 individual(s): 2, 6, ..., 18Note: See more examples of flattening and merging in Simplifying a MultiPop hierarchy.
Why use a MultiPop?
Many breeding programs have a hierarchy between an individual and the
complete breeding population. Selection may act on families in plant
breeding, tanks in aquaculture, or colonies in insect breeding. A
MultiPop preserves this hierarchy, making it possible to
apply operations within groups, compare groups, and retain the origin of
each component.
The examples below show how this representation can replace explicit list manipulation while keeping the biological structure of the breeding program visible.
Revisiting pedigree breeding in wheat
We previously showed how to implement a hypothetical wheat line-breeding program using the pedigree method (Bančič et al. 2025). This method involves specific parental crosses followed by repeated family and within-family selection until lines are sufficiently inbred for multi-environment trials. Parent-progeny information is retained to help preserve variation among lines and produce new crosses.
- Stages 1 and 2
- Stages 3 to 5: selecting rows within families
- Stage 6: selecting inbred lines
- Stages 7 to 9: yield trials
A simplified wheat breeding scheme implementing the pedigree breeding method.
Stages 1 and 2
We create founder haplotypes and a trait representing grain yield. The trait includes additive and genotype-by-environment effects. Founder parents are crossed to produce 40 F1 individuals.
# Stage 1
# Generate initial haplotypes
founderPop = runMacs(
nInd = 20,
nChr = 1,
segSites = 1e3,
inbred = TRUE,
species = "WHEAT"
)
# Set simulation parameters
SP = SimParam$new(founderPop)
# Add one trait representing Grain Yield
SP$addTraitAG(
nQtlPerChr = 1e3,
mean = 1,
var = 1,
varEnv = 1e-6,
varGxE = 2,
name = "Yield"
)
# Set p value for the environmental covariate used by GxE trait
p = runif(1)
# Create founder parents and cross to produce F1
Parents = newPop(founderPop, simParam = SP)
F1 = randCross(Parents, nCrosses = 40)In Stage 2, each F1 individual is self-pollinated to produce a family of 250 F2 individuals. We phenotype each family and select 25 individuals from each family.
Without MultiPop, this requires an explicit list and
loop:
# Stage 2
# Create an empty list to keep crosses separate
F2 = vector("list", 40)
# Loop over crosses
for(i in 1:40){
# Self each F1 to produce 250 F2 individuals
F2_i = self(F1[i], nProgeny = 250)
# Phenotype the family of 250 F2 individuals
F2_i = setPheno(F2_i, varE = 4, reps = 4/19, p = p)
# Select 25/250 F2 for the next stage
F2[[i]] = selectInd(F2_i, nInd = 25)
}With MultiPop, each F1 individual becomes a population
unit and the operations are applied recursively to every terminal
Pop.
# Stage 2
# Split the F1 by individual
F1 = splitPop(F1, by = F1@id)
# Self each F1 to produce 250 F2 individuals
F2 = self(F1, nProgeny = 250)
# Phenotype all families of 250 F2 individuals
F2 = setPheno(F2, varE = 4, reps = 4/19, p = p)
# Select 25/250 F2 individuals per family
F2 = selectInd(F2, nInd = 25)Because self(), setPheno() and
selectInd() each take a MultiPop as their
first argument and return a MultiPop, the same steps can be
chained with R’s pipe operator, |>, starting from the
F1 population before it is split:
Stages 3 to 5: selecting rows within families
In each subsequent stage, every selected individual is self-pollinated to produce 20 progeny. The progeny are planted in rows, and the row is the evaluation unit. We simulate individual phenotypes and use their mean as the row phenotype. We then select the best 10 rows per family and the best 4 individuals within each selected row.
Stage 3 is written as follows:
Without MultiPop
# Stage 3
# Create an empty list to keep families separate
F3 = vector("list",40)
# Loop over families
for(i in 1:40){
# Number of rows per family
n = nInd(F2[[i]])
# Create an empty list to keep rows separate
F3rows = vector("list",n)
# Create an empty vector of row phenotypes
F3pheno = numeric(n)
# Loop over rows
for(j in 1:n){
# Self each F2 to produce 20 F3 individuals
F3rows[[j]] = self(F2[[i]][j], nProgeny=20)
# Phenotype the row of F3 individuals
F3rows[[j]] = setPheno(F3rows[[j]], varE=4,
reps=4/19, p=p)
# Calculate the mean phenotypic value per row
F3pheno[j] = meanP(F3rows[[j]])
}
# Select 10 F3 rows per family
take = order(F3pheno,decreasing=TRUE)[1:10]
F3rows = F3rows[take]
# Select 4 plants per selected F3 row
for(j in 1:10){
F3rows[[j]] = selectInd(F3rows[[j]], nInd=4)
}
# Merge all 4×10 selected plants into a single Pop
F3[[i]] = mergePops(F3rows)
}With MultiPop
# Stage 3
# Split each F2 family by individual
F2 = splitPop(F2, by = function(x) x@id)
# Self each F2 to produce 20 F3 individuals
F3 = self(F2, nProgeny=20)
# Phenotype the row of F3 individuals
F3 = setPheno(F3, varE=4, reps=4/19, p=p)
# Select 10 F3 rows per family using mean pheno values
F3 = selectPop(F3, nPop=10, level=2, use='pheno', FUN=mean)
# Select 4 plants per selected F3 row
F3 = selectInd(F3, nInd = 4)
# Merge all 4×10 selected plants into a single Pop
F3 = mergeMultiPops(F3, level = 1)Here, selectPop(level = 2) selects rows within each
family, while selectInd() selects individuals within each
selected row. The hierarchy therefore corresponds directly to the
breeding program: families contain rows, and rows contain
individuals.
The same pattern can be repeated for stages 4 and 5:
Without MultiPop
# Stage 4
# Create an empty list to keep families separate
F4 = vector("list",40)
# Loop over families
for(i in 1:40){
# Number of rows per family
n = nInd(F3[[i]])
# Create an empty list to keep rows separate
F4rows = vector("list",n)
# Create an empty vector of row phenotypes
F4pheno = numeric(n)
# Loop over rows
for(j in 1:n){
# Self each F3 to produce 20 F4 individuals
F4rows[[j]] = self(F3[[i]][j], nProgeny=20)
# Phenotype the row of F4 individuals
F4rows[[j]] = setPheno(F4rows[[j]], varE=4,
reps=4/19, p=p)
# Calculate the mean phenotypic value per row
F4pheno[j] = meanP(F4rows[[j]])
}
# Select 10 F4 rows per family
take = order(F4pheno,decreasing=TRUE)[1:10]
F4rows = F4rows[take]
# Select 4 plants per selected F4 row
for(j in 1:10){
F4rows[[j]] = selectInd(F4rows[[j]],4)
}
# Merge all 4×10 selected plants into a single Pop
F4[[i]] = mergePops(F4rows)
}With MultiPop
# Stage 4
# Split each F3 family by individual
F3 = splitPop(F3, by = function(x) x@id)
# Self each F3 to produce 20 F4 individuals
F4 = self(F3, nProgeny=20)
# Phenotype the row of F4 individuals
F4 = setPheno(F4, varE=4, reps=4/19, p=p)
# Select 10 F4 rows per family using mean pheno values
F4 = selectPop(F4, nPop=10, level=2, use='pheno', FUN=mean)
# Select 4 plants per selected F4 row
F4 = selectInd(F4, nInd=4)
# Merge all 4×10 selected plants into a single Pop
F4 = mergeMultiPops(F4, level=1)Without MultiPop
# Stage 5
# Create an empty list to keep families separate
F5 = vector("list",40)
# Loop over families
for(i in 1:40){
# Number of rows per family
n = nInd(F4[[i]])
# Create an empty list to keep rows separate
F5rows = vector("list",n)
# Create an empty vector of row phenotypes
F5pheno = numeric(n)
# Loop over rows
for(j in 1:n){
# Self each F4 to produce 20 F5 individuals
F5rows[[j]] = self(F4[[i]][j], nProgeny=20)
# Phenotype the row of 20 F5 individuals
F5rows[[j]] = setPheno(F5rows[[j]], varE=4,
reps=4/19, p=p)
# Calculate the mean phenotypic value per row
F5pheno[j] = meanP(F5rows[[j]])
}
# Select 10 F5 rows per family
take = order(F5pheno,decreasing=TRUE)[1:10]
F5rows = F5rows[take]
# Select 4 plants per selected F5 row
for(j in 1:10){
F5rows[[j]] = selectInd(F5rows[[j]],4)
}
# Merge all 4×10 selected plants into a single Pop
F5[[i]] = mergePops(F5rows)
}With MultiPop
# Stage 5
# Split each F4 family by individual
F4 = splitPop(F4, by = function(x) x@id)
# Self each F4 to produce 20 F5 individuals
F5 = self(F4, nProgeny=20)
# Phenotype the row of F5 individuals
F5 = setPheno(F5, varE=4, reps=4/19, p=p)
# Select 10 F5 rows per family using mean pheno values
F5 = selectPop(F5, nPop=10, level=2, use='pheno', FUN=mean)
# Select 4 plants per selected F5 row
F5 = selectInd(F5, nInd=4)
# Merge all 4×10 selected plants into a single Pop
F5 = mergeMultiPops(F5, level=1)Stage 6: selecting inbred lines
At Stage 6, repeated self-pollination has made the plants within a row approximately homogeneous. We select the best four rows per family and randomly retain one plant from each row as the simulated line.
Without MultiPop
# Stage 6
# Create an empty list to keep families separate
F6 = vector("list",40)
# Loop over families
for(i in 1:40){
# Number of rows per family
n = nInd(F5[[i]])
# Create an empty list to keep rows separate
F6lines = vector("list",n)
# Create an empty vector of row phenotypes
F6pheno = numeric(n)
# Loop over rows
for(j in 1:n){
# Self each F5 to produce 20 F6 individuals
F6lines[[j]] = self(F5[[i]][j], nProgeny=20)
# Phenotype the row of F6 individuals
F6lines[[j]] = setPheno(F6lines[[j]], varE=4,
reps=4/19, p=p)
# Calculate the mean phenotypic value per row
F6pheno[j] = meanP(F6lines[[j]])
}
# Select 4 F6 rows per family
take = order(F6pheno,decreasing=TRUE)[1:4]
F6lines = F6lines[take]
# Randomly select 1 plant per F6 row.
for(j in 1:4){
F6lines[[j]] = selectInd(F6lines[[j]], 1, use='rand')
}
# Merge all 4 selected plants into a single Pop
F6[[i]] = mergePops(F6lines)
}
# Merge all 4×40 selected plants into a single Pop
F6 = mergePops(F6)With MultiPop
# Stage 6
# Split each F5 family by individual
F5 = splitPop(F5, by=function(x) x@id)
# Self each F5 to produce 20 F6 individuals
F6 = self(F5, nProgeny=20)
# Phenotype the row of F6 individuals
F6 = setPheno(F6, varE=4, reps=4/19, p=p)
# Select 4 F6 rows per family
F6 = selectPop(F6, nPop=4, level=2, FUN=mean)
# Randomly select 1 plant per F6 row.
F6 = selectInd(F6, nInd=1, use='rand')
# Merge all 4×40 selected plants into a single Pop
F6 = mergeMultiPops(F6)The MultiPop structure can now be removed because each
selected line is treated as an individual in the yield trials.
A forage-breeding example
This example represents a forage-breeding program in which individual plants are selected during recurrent selection, whereas half-sib families and field replicates become the evaluation units later in the program.
- Founder population and traits
- Recurrent selection on individual plants
- Evaluating half-sib families as populations
- Nested
MultiPopobjects
A simplified forage-breeding scheme used in this example.
Founder population and traits
Vigor is evaluated on individual plants during recurrent
selection, whereas Biomass is evaluated later on
swards (plots containing a population of related
plants). The two traits are genetically correlated and include additive
and dominance effects.
set.seed(1234)
# Generate initial haplotypes
founderPop = runMacs(
nInd = 10,
nChr = 7,
segSites = 1e3,
inbred = FALSE,
ploidy = 2L,
species = "GENERIC"
)
# Set simulation parameters
SP = SimParam$new(founderPop)
# Set trait mean, variance, genetic correlation and heritability
traitMean = c(Vigor = 0, Biomass = 0)
traitVar = c(Vigor = 1, Biomass = 1)
genCor = 0.5
corA = matrix(c(1, genCor, genCor, 1), nrow = 2)
h2 = c(Vigor = 0.4, Biomass = 0.4)
# Simulate Vigor and Biomass
SP$addTraitAD(
nQtlPerChr = 1e3,
mean = traitMean,
var = traitVar,
corA = corA,
meanDD = 0.3,
varDD = 0.1,
name = names(h2)
)Recurrent selection on individual plants
Founder parents are open-pollinated to create the first nursery. Each seed is treated as an individual evaluation unit.
# Create founder individuals
parents = newPop(founderPop, simParam = SP)
# Open-pollinate 10 founder parents
ny1 = selectOP(
parents,
nInd = 10,
use = "rand",
nSeeds = 20,
pollenControl = TRUE
)
# Phenotype the first nursery
ny1 = setPheno(ny1, h2 = h2["Vigor"], traits = "Vigor", reps = 4/19)We select one individual from each maternal half-sib family and open-pollinate those plants to form the next nursery.
# Select one individual from each half-sib family
ny1_candidates = selectWithinFam(
ny1,
nInd = 1,
trait = "Vigor",
use = "pheno",
famType = "F",
returnPop = FALSE
)
# Open-pollinate selected plants
ny2 = selectOP(
ny1,
candidates = ny1_candidates,
nInd = 10,
nSeeds = 20,
pollenControl = TRUE
)
# Phenotype the second nursery
ny2 = setPheno(ny2, h2 = h2["Vigor"], traits = "Vigor", reps = 4/19)
# Select one individual from each half-sib family
ny2_candidates = selectWithinFam(
ny2,
nInd = 1,
trait = "Vigor",
use = "pheno",
famType = "F",
returnPop = FALSE
)
# Open-pollinate selected plants
ny3 = selectOP(
ny2,
candidates = ny2_candidates,
nInd = 10,
nSeeds = 20,
pollenControl = TRUE
)
# Phenotype the third nursery
ny3 = setPheno(ny3, h2 = h2["Vigor"], traits = "Vigor", reps = 4/19)After one final round of individual selection, the selected mothers
are cloned and open-pollinated to produce the first synthetic generation
(Syn-1). This process is also known as a polycross in forage
breeding. Increasing nSeeds approximates cloning the
selected mothers to increase seed production.
# Final round of individual selection
ny3_candidates = selectWithinFam(
ny3,
nInd = 1,
trait = "Vigor",
use = "pheno",
famType = "F",
returnPop = FALSE
)
# Open pollination of cloned mothers
syn1 = selectOP(
ny3,
candidates = ny3_candidates,
nInd = 10,
nSeeds = 80,
pollenControl = TRUE
)Evaluating half-sib families as populations
Seed from each mother is sown in a sward, and each
maternal half-sib family is treated as one evaluation unit.
splitPop() creates one terminal Pop per
maternal family.
# Split `syn1` by maternal half-sib family
syn1_HS = splitPop(syn1, by = syn1@mother)
# Phenotype `Biomass` in swards of half-sib families
syn1_HS = setPheno(syn1_HS, h2 = h2["Biomass"], traits = "Biomass", reps = 4/19)
syn1_HS
#> An object of class "MultiPop" with 10 item(s)
#> Level 1:
#> |-- [[1]] "416" - An object of class "Pop" with 80 individual(s): 611, 612, ..., 690
#> |-- [[2]] "436" - An object of class "Pop" with 80 individual(s): 691, 692, ..., 770
#> |-- [[3]] "465" - An object of class "Pop" with 80 individual(s): 771, 772, ..., 850
#> |-- [[4]] "471" - An object of class "Pop" with 80 individual(s): 1091, 1092, ..., 1170
#> |-- [[5]] "494" - An object of class "Pop" with 80 individual(s): 1011, 1012, ..., 1090
#> |-- [[6]] "522" - An object of class "Pop" with 80 individual(s): 931, 932, ..., 1010
#> |-- [[7]] "538" - An object of class "Pop" with 80 individual(s): 1251, 1252, ..., 1330
#> |-- [[8]] "563" - An object of class "Pop" with 80 individual(s): 1171, 1172, ..., 1250
#> |-- [[9]] "587" - An object of class "Pop" with 80 individual(s): 851, 852, ..., 930
#> `-- [[10]] "594" - An object of class "Pop" with 80 individual(s): 1331, 1332, ..., 1410When a MultiPop is passed to meanP(), the
function calculates mean phenotypic values for each terminal
Pop. With simplify = TRUE, the results are
returned as a matrix with a source attribute identifying
the population from which each row originated.
meanP(syn1_HS, simplify = TRUE)
#> Vigor Biomass
#> [1,] NA 0.46347770
#> [2,] NA 0.44086263
#> [3,] NA -0.06029710
#> [4,] NA -0.04194466
#> [5,] NA 0.76765440
#> [6,] NA 0.40305944
#> [7,] NA 0.41551792
#> [8,] NA 0.65925557
#> [9,] NA 1.32658565
#> [10,] NA 0.05965332
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594The more general calcPopValue() function applies a
user-supplied operation to every terminal Pop.
calcPopValue(
syn1_HS,
FUN = function(x) colMeans(pheno(x)),
simplify = TRUE,
level = 1
)
#> Vigor Biomass
#> [1,] NA 0.46347770
#> [2,] NA 0.44086263
#> [3,] NA -0.06029710
#> [4,] NA -0.04194466
#> [5,] NA 0.76765440
#> [6,] NA 0.40305944
#> [7,] NA 0.41551792
#> [8,] NA 0.65925557
#> [9,] NA 1.32658565
#> [10,] NA 0.05965332
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594Tip: You can collect and/or calculate other population-level values from a MultiPop object passing your own function
FUNtocalcPopValue().
We can select the five best half-sib families using their mean
biomass. selectPop() ranks the terminal populations using
FUN = mean.
syn1_HS_candidates = selectPop(
syn1_HS,
nPop = 5,
trait = "Biomass",
use = "pheno",
FUN = mean
)
syn1_HS_candidates
#> An object of class "MultiPop" with 5 item(s)
#> Level 1:
#> |-- [[1]] "587" - An object of class "Pop" with 80 individual(s): 851, 852, ..., 930
#> |-- [[2]] "494" - An object of class "Pop" with 80 individual(s): 1011, 1012, ..., 1090
#> |-- [[3]] "563" - An object of class "Pop" with 80 individual(s): 1171, 1172, ..., 1250
#> |-- [[4]] "416" - An object of class "Pop" with 80 individual(s): 611, 612, ..., 690
#> `-- [[5]] "436" - An object of class "Pop" with 80 individual(s): 691, 692, ..., 770The selected families are merged and intermated. The example uses 2,000 random crosses and one progeny per cross as a manageable approximation of bulk seed production.
syn1_candidates = mergeMultiPops(syn1_HS_candidates)
syn2 = randCross(
syn1_candidates,
nCrosses = 2000,
nProgeny = 1,
simParam = SP
)In addition, the names of syn1_HS_candidates correspond
to the IDs of the selected mothers. They can therefore be used to start
a new recurrent-selection cycle.
Nested MultiPop objects
Field testing may add another level to the hierarchy. Seed from each half-sib family can be divided among several field replicates. Each replicate is sown in a sward and contains genetically related but distinct individuals.
# Split the population, first by half-sib family,
# then by replicate
syn1_HS_reps = splitPop(
syn1,
by = list(
syn1@mother,
function(x) {
sample(paste0("R", 1:3), size = nInd(x), replace = TRUE)
}
)
)
# Phenotype `Biomass` in swards of replicates
syn1_HS_reps = setPheno(
syn1_HS_reps,
h2 = h2["Biomass"],
traits = "Biomass",
reps = 4/19,
simParam = SP
)
syn1_HS_reps
#> An object of class "MultiPop" with 10 item(s)
#> Level 1:
#> |-- [[1]] "416" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 26 individual(s): 614, 620, ..., 685
#> | |-- [[2]] "R2" - An object of class "Pop" with 28 individual(s): 611, 612, ..., 689
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 615, 616, ..., 690
#> |-- [[2]] "436" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[3]] "465" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 24 individual(s): 771, 772, ..., 846
#> | |-- [[2]] "R2" - An object of class "Pop" with 26 individual(s): 777, 781, ..., 850
#> | `-- [[3]] "R3" - An object of class "Pop" with 30 individual(s): 773, 774, ..., 845
#> |-- [[4]] "471" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> | |-- [[2]] "R2" - An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> | `-- [[3]] "R3" - An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[5]] "494" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1015, 1019, ..., 1089
#> | |-- [[2]] "R2" - An object of class "Pop" with 21 individual(s): 1012, 1014, ..., 1088
#> | `-- [[3]] "R3" - An object of class "Pop" with 27 individual(s): 1011, 1013, ..., 1090
#> |-- [[6]] "522" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> | |-- [[2]] "R2" - An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> | `-- [[3]] "R3" - An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> |-- [[7]] "538" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 24 individual(s): 1251, 1254, ..., 1330
#> | |-- [[2]] "R2" - An object of class "Pop" with 30 individual(s): 1252, 1253, ..., 1329
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 1256, 1260, ..., 1326
#> |-- [[8]] "563" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> |-- [[9]] "587" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> | |-- [[2]] "R2" - An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> | `-- [[3]] "R3" - An object of class "Pop" with 29 individual(s): 851, 854, ..., 927
#> `-- [[10]] "594" - An object of class "MultiPop" with 3 item(s)
#> | Level 2:
#> |-- [[1]] "R1" - An object of class "Pop" with 36 individual(s): 1334, 1335, ..., 1403
#> |-- [[2]] "R2" - An object of class "Pop" with 25 individual(s): 1337, 1339, ..., 1410
#> `-- [[3]] "R3" - An object of class "Pop" with 19 individual(s): 1331, 1332, ..., 1406At level = 1, the direct children are family-level
MultiPop objects, so selectPop() cannot select
them:
selectPop(
syn1_HS_reps,
nPop = 5,
level = 1,
trait = "Biomass",
use = "pheno",
FUN = mean
)
#> Error in `selectPop()`:
#> ! This level contains 10 MultiPop-class objects.
#> Selection can only be performed when all populations at this level are Pop-class objects.
#> You may want to increase the value of 'level'At level = 2, selectPop() reaches replicate
Pop objects. Selection is performed separately within each
family. Because each family contains only three replicates, requesting
five produces a warning and returns three replicates per family.
selectPop(
syn1_HS_reps,
nPop = 5,
level = 2,
trait = "Biomass",
use = "pheno",
FUN = mean
)
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> Warning in selectPop(x = x[[i]], nPop = nPop, level = level, trait = trait, :
#> Suitable candidate populations smaller than nPop, returning 3 populations
#> An object of class "MultiPop" with 10 item(s)
#> Level 1:
#> |-- [[1]] "416" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 26 individual(s): 614, 620, ..., 685
#> | |-- [[2]] "R2" - An object of class "Pop" with 28 individual(s): 611, 612, ..., 689
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 615, 616, ..., 690
#> |-- [[2]] "436" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R2" - An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> | |-- [[2]] "R1" - An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[3]] "465" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 24 individual(s): 771, 772, ..., 846
#> | |-- [[2]] "R3" - An object of class "Pop" with 30 individual(s): 773, 774, ..., 845
#> | `-- [[3]] "R2" - An object of class "Pop" with 26 individual(s): 777, 781, ..., 850
#> |-- [[4]] "471" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> | |-- [[2]] "R2" - An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> | `-- [[3]] "R3" - An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[5]] "494" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1015, 1019, ..., 1089
#> | |-- [[2]] "R3" - An object of class "Pop" with 27 individual(s): 1011, 1013, ..., 1090
#> | `-- [[3]] "R2" - An object of class "Pop" with 21 individual(s): 1012, 1014, ..., 1088
#> |-- [[6]] "522" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R3" - An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> | |-- [[2]] "R2" - An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> | `-- [[3]] "R1" - An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> |-- [[7]] "538" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R2" - An object of class "Pop" with 30 individual(s): 1252, 1253, ..., 1329
#> | |-- [[2]] "R1" - An object of class "Pop" with 24 individual(s): 1251, 1254, ..., 1330
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 1256, 1260, ..., 1326
#> |-- [[8]] "563" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> | |-- [[2]] "R3" - An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> | `-- [[3]] "R2" - An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> |-- [[9]] "587" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R2" - An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> | |-- [[2]] "R3" - An object of class "Pop" with 29 individual(s): 851, 854, ..., 927
#> | `-- [[3]] "R1" - An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> `-- [[10]] "594" - An object of class "MultiPop" with 3 item(s)
#> | Level 2:
#> |-- [[1]] "R2" - An object of class "Pop" with 25 individual(s): 1337, 1339, ..., 1410
#> |-- [[2]] "R1" - An object of class "Pop" with 36 individual(s): 1334, 1335, ..., 1403
#> `-- [[3]] "R3" - An object of class "Pop" with 19 individual(s): 1331, 1332, ..., 1406To select families, first aggregate replicate summaries within each
family. meanPPop() performs an unweighted mean of means,
giving each replicate equal weight regardless of its number of
individuals.
meanPPop(syn1_HS_reps, level = 1)
#> Vigor Biomass
#> [1,] NA 0.40681358
#> [2,] NA 0.86873919
#> [3,] NA 0.43052202
#> [4,] NA 0.78964369
#> [5,] NA 0.01899669
#> [6,] NA 1.00450152
#> [7,] NA 0.47824064
#> [8,] NA 0.50558545
#> [9,] NA 0.66861371
#> [10,] NA -0.04122308
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594calcPopSummary() separates the two operations:
withinPopFUN summarizes individuals within each terminal
Pop, and acrossPopFUN aggregates those
summaries through the hierarchy.
calcPopSummary(
syn1_HS_reps,
withinPopFUN = function(p) {
colMeans(pheno(p)[, "Biomass", drop = FALSE])
},
acrossPopFUN = colMeans,
level = 1
)
#> Biomass
#> [1,] 0.40681358
#> [2,] 0.86873919
#> [3,] 0.43052202
#> [4,] 0.78964369
#> [5,] 0.01899669
#> [6,] 1.00450152
#> [7,] 0.47824064
#> [8,] 0.50558545
#> [9,] 0.66861371
#> [10,] -0.04122308
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594Tip: You can summarize and aggregate other population-level values from a MultiPop object passing your own functions to
calcPopSummary().
selectMultiPop() uses these within- and
across-population functions to select structured units directly.
syn1_HS_reps_candidates = selectMultiPop(
syn1_HS_reps,
nMulti = 5,
level = 1,
trait = "Biomass",
use = "pheno",
withinPopFUN = mean,
acrossPopFUN = mean,
simParam = SP
)
syn1_HS_reps_candidates
#> An object of class "MultiPop" with 5 item(s)
#> Level 1:
#> |-- [[1]] "436" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[2]] "471" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> | |-- [[2]] "R2" - An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> | `-- [[3]] "R3" - An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[3]] "522" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> | |-- [[2]] "R2" - An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> | `-- [[3]] "R3" - An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> |-- [[4]] "563" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> `-- [[5]] "587" - An object of class "MultiPop" with 3 item(s)
#> | Level 2:
#> |-- [[1]] "R1" - An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> |-- [[2]] "R2" - An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> `-- [[3]] "R3" - An object of class "Pop" with 29 individual(s): 851, 854, ..., 927The selected families can be merged and intermated as before. Use the names of the selected top-level units when selecting their mothers.
# Bulk seed production
syn1_candidates = mergeMultiPops(syn1_HS_reps_candidates)
syn2 = randCross(
syn1_candidates,
nCrosses = 2000,
nProgeny = 1,
simParam = SP
)
# Start a new recurrent selection cycle
ny1 = selectOP(
ny3,
candidates = names(syn1_HS_reps_candidates),
nInd = 5,
nSeeds = 20,
pollenControl = TRUE
)Summarizing structured populations
The choice between individual-level and population-level summaries
should reflect the breeding question. meanG() and
meanP() average over individuals in each terminal
Pop. meanGPop() and meanPPop()
first calculate terminal summaries and then aggregate them across child
populations, giving each child population equal weight unless a custom
function is supplied.
meanG(syn1_HS, simplify = TRUE)
#> Vigor Biomass
#> [1,] 0.26250685 0.49754814
#> [2,] 0.38691258 0.60788112
#> [3,] 0.01488557 -0.07904386
#> [4,] 0.43120729 0.16020414
#> [5,] 0.57653965 0.15165735
#> [6,] 0.77028889 0.60931996
#> [7,] 0.94613354 0.40683177
#> [8,] 0.06269220 0.28603879
#> [9,] 0.96029601 0.41892677
#> [10,] 0.85946367 0.08583339
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594
meanP(syn1_HS, simplify = TRUE)
#> Vigor Biomass
#> [1,] NA 0.46347770
#> [2,] NA 0.44086263
#> [3,] NA -0.06029710
#> [4,] NA -0.04194466
#> [5,] NA 0.76765440
#> [6,] NA 0.40305944
#> [7,] NA 0.41551792
#> [8,] NA 0.65925557
#> [9,] NA 1.32658565
#> [10,] NA 0.05965332
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594
meanGPop(syn1_HS_reps, level = 1)
#> Vigor Biomass
#> [1,] 0.25552477 0.49762817
#> [2,] 0.38199118 0.55433856
#> [3,] 0.02782437 -0.06099393
#> [4,] 0.43594271 0.15410310
#> [5,] 0.56680606 0.15454546
#> [6,] 0.77878012 0.59331130
#> [7,] 0.94321948 0.40056575
#> [8,] 0.07738432 0.28522508
#> [9,] 0.92844312 0.39274409
#> [10,] 0.85160252 0.07891101
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594
meanPPop(syn1_HS_reps, level = 1)
#> Vigor Biomass
#> [1,] NA 0.40681358
#> [2,] NA 0.86873919
#> [3,] NA 0.43052202
#> [4,] NA 0.78964369
#> [5,] NA 0.01899669
#> [6,] NA 1.00450152
#> [7,] NA 0.47824064
#> [8,] NA 0.50558545
#> [9,] NA 0.66861371
#> [10,] NA -0.04122308
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594For these population-level functions, level = 0 means
aggregation over the complete MultiPop object (it does not
mean the first visible nested level).
meanGPop(syn1_HS_reps, level = 0)
#> Vigor Biomass
#> 0.5247519 0.3050379
meanPPop(syn1_HS_reps, level = 0)
#> Vigor Biomass
#> NA 0.5130433The corresponding genetic variance summaries are:
varGPop(syn1_HS_reps, level = 2)
#> Vigor Biomass
#> Vigor 0.13388900 0.03592953
#> Biomass 0.03592953 0.06829071
varGPop(syn1_HS_reps, level = 1)
#> Vigor Biomass
#> Vigor 0.1059038 0.01850910
#> Biomass 0.0185091 0.04300958The two calls above describe different levels of variation: the first uses replicate-level means, whereas the second uses half-sib-family means.
Selection accuracy can likewise be calculated at the level relevant to selection.
Simplifying a MultiPop hierarchy
Flattening
flattenMultiPop() is useful when units from different
branches should be compared together. It removes intermediate grouping
while retaining the terminal Pop objects.

Flattening a nested MultiPop structure with different level
arguments in flattenMultiPop()
syn1_reps = flattenMultiPop(syn1_HS_reps)
syn1_reps
#> An object of class "MultiPop" with 30 item(s)
#> Level 1:
#> |-- [[1]] An object of class "Pop" with 26 individual(s): 614, 620, ..., 685
#> |-- [[2]] An object of class "Pop" with 28 individual(s): 611, 612, ..., 689
#> |-- [[3]] An object of class "Pop" with 26 individual(s): 615, 616, ..., 690
#> |-- [[4]] An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> |-- [[5]] An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> |-- [[6]] An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[7]] An object of class "Pop" with 24 individual(s): 771, 772, ..., 846
#> |-- [[8]] An object of class "Pop" with 26 individual(s): 777, 781, ..., 850
#> |-- [[9]] An object of class "Pop" with 30 individual(s): 773, 774, ..., 845
#> |-- [[10]] An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> |-- [[11]] An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> |-- [[12]] An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[13]] An object of class "Pop" with 32 individual(s): 1015, 1019, ..., 1089
#> |-- [[14]] An object of class "Pop" with 21 individual(s): 1012, 1014, ..., 1088
#> |-- [[15]] An object of class "Pop" with 27 individual(s): 1011, 1013, ..., 1090
#> |-- [[16]] An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> |-- [[17]] An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> |-- [[18]] An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> |-- [[19]] An object of class "Pop" with 24 individual(s): 1251, 1254, ..., 1330
#> |-- [[20]] An object of class "Pop" with 30 individual(s): 1252, 1253, ..., 1329
#> |-- [[21]] An object of class "Pop" with 26 individual(s): 1256, 1260, ..., 1326
#> |-- [[22]] An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> |-- [[23]] An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> |-- [[24]] An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> |-- [[25]] An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> |-- [[26]] An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> |-- [[27]] An object of class "Pop" with 29 individual(s): 851, 854, ..., 927
#> |-- [[28]] An object of class "Pop" with 36 individual(s): 1334, 1335, ..., 1403
#> |-- [[29]] An object of class "Pop" with 25 individual(s): 1337, 1339, ..., 1410
#> `-- [[30]] An object of class "Pop" with 19 individual(s): 1331, 1332, ..., 1406By default, duplicate population names are dropped. Use
preserveNames = "concatenate" to combine names from nested
levels, or "force" when unique names are required even
after concatenation.
syn1_HSreps = flattenMultiPop(
syn1_HS_reps,
preserveNames = "concatenate"
)
syn1_HSreps
#> An object of class "MultiPop" with 30 item(s)
#> Level 1:
#> |-- [[1]] "416_R1" - An object of class "Pop" with 26 individual(s): 614, 620, ..., 685
#> |-- [[2]] "416_R2" - An object of class "Pop" with 28 individual(s): 611, 612, ..., 689
#> |-- [[3]] "416_R3" - An object of class "Pop" with 26 individual(s): 615, 616, ..., 690
#> |-- [[4]] "436_R1" - An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> |-- [[5]] "436_R2" - An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> |-- [[6]] "436_R3" - An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[7]] "465_R1" - An object of class "Pop" with 24 individual(s): 771, 772, ..., 846
#> |-- [[8]] "465_R2" - An object of class "Pop" with 26 individual(s): 777, 781, ..., 850
#> |-- [[9]] "465_R3" - An object of class "Pop" with 30 individual(s): 773, 774, ..., 845
#> |-- [[10]] "471_R1" - An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> |-- [[11]] "471_R2" - An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> |-- [[12]] "471_R3" - An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[13]] "494_R1" - An object of class "Pop" with 32 individual(s): 1015, 1019, ..., 1089
#> |-- [[14]] "494_R2" - An object of class "Pop" with 21 individual(s): 1012, 1014, ..., 1088
#> |-- [[15]] "494_R3" - An object of class "Pop" with 27 individual(s): 1011, 1013, ..., 1090
#> |-- [[16]] "522_R1" - An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> |-- [[17]] "522_R2" - An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> |-- [[18]] "522_R3" - An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> |-- [[19]] "538_R1" - An object of class "Pop" with 24 individual(s): 1251, 1254, ..., 1330
#> |-- [[20]] "538_R2" - An object of class "Pop" with 30 individual(s): 1252, 1253, ..., 1329
#> |-- [[21]] "538_R3" - An object of class "Pop" with 26 individual(s): 1256, 1260, ..., 1326
#> |-- [[22]] "563_R1" - An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> |-- [[23]] "563_R2" - An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> |-- [[24]] "563_R3" - An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> |-- [[25]] "587_R1" - An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> |-- [[26]] "587_R2" - An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> |-- [[27]] "587_R3" - An object of class "Pop" with 29 individual(s): 851, 854, ..., 927
#> |-- [[28]] "594_R1" - An object of class "Pop" with 36 individual(s): 1334, 1335, ..., 1403
#> |-- [[29]] "594_R2" - An object of class "Pop" with 25 individual(s): 1337, 1339, ..., 1410
#> `-- [[30]] "594_R3" - An object of class "Pop" with 19 individual(s): 1331, 1332, ..., 1406Merging
mergeMultiPops() is useful when the component
populations should become one population, while optionally retaining
selected levels of the hierarchy.

Merging one MultiPop structure with different level
arguments in mergeMultiPops()
# All populations are merged into one Pop
mergeMultiPops(syn1_HS_reps)
#> An object of class "Pop"
#> Ploidy: 2
#> Individuals: 800
#> Chromosomes: 7
#> Loci: 7000
#> Traits: 2
# Use `level` to retain the hierarchy
mergeMultiPops(syn1_HS_reps, level = 1)
#> An object of class "MultiPop" with 10 item(s)
#> Level 1:
#> |-- [[1]] "416" - An object of class "Pop" with 80 individual(s): 614, 620, ..., 690
#> |-- [[2]] "436" - An object of class "Pop" with 80 individual(s): 692, 696, ..., 768
#> |-- [[3]] "465" - An object of class "Pop" with 80 individual(s): 771, 772, ..., 845
#> |-- [[4]] "471" - An object of class "Pop" with 80 individual(s): 1092, 1097, ..., 1167
#> |-- [[5]] "494" - An object of class "Pop" with 80 individual(s): 1015, 1019, ..., 1090
#> |-- [[6]] "522" - An object of class "Pop" with 80 individual(s): 934, 935, ..., 1005
#> |-- [[7]] "538" - An object of class "Pop" with 80 individual(s): 1251, 1254, ..., 1326
#> |-- [[8]] "563" - An object of class "Pop" with 80 individual(s): 1171, 1174, ..., 1249
#> |-- [[9]] "587" - An object of class "Pop" with 80 individual(s): 852, 857, ..., 927
#> `-- [[10]] "594" - An object of class "Pop" with 80 individual(s): 1334, 1335, ..., 1406
Merging two MultiPop structures with different level
arguments in mergeMultiPops()
# Merge two or more objects. `level` controls how merging retains the structure
mergeMultiPops(syn1_HS, syn1_HS_reps, level = 2)
#> An object of class "MultiPop" with 20 item(s)
#> Level 1:
#> |-- [[1]] "416" - An object of class "Pop" with 80 individual(s): 611, 612, ..., 690
#> |-- [[2]] "436" - An object of class "Pop" with 80 individual(s): 691, 692, ..., 770
#> |-- [[3]] "465" - An object of class "Pop" with 80 individual(s): 771, 772, ..., 850
#> |-- [[4]] "471" - An object of class "Pop" with 80 individual(s): 1091, 1092, ..., 1170
#> |-- [[5]] "494" - An object of class "Pop" with 80 individual(s): 1011, 1012, ..., 1090
#> |-- [[6]] "522" - An object of class "Pop" with 80 individual(s): 931, 932, ..., 1010
#> |-- [[7]] "538" - An object of class "Pop" with 80 individual(s): 1251, 1252, ..., 1330
#> |-- [[8]] "563" - An object of class "Pop" with 80 individual(s): 1171, 1172, ..., 1250
#> |-- [[9]] "587" - An object of class "Pop" with 80 individual(s): 851, 852, ..., 930
#> |-- [[10]] "594" - An object of class "Pop" with 80 individual(s): 1331, 1332, ..., 1410
#> |-- [[11]] "416" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 26 individual(s): 614, 620, ..., 685
#> | |-- [[2]] "R2" - An object of class "Pop" with 28 individual(s): 611, 612, ..., 689
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 615, 616, ..., 690
#> |-- [[12]] "436" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 692, 696, ..., 770
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 693, 697, ..., 765
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 691, 694, ..., 768
#> |-- [[13]] "465" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 24 individual(s): 771, 772, ..., 846
#> | |-- [[2]] "R2" - An object of class "Pop" with 26 individual(s): 777, 781, ..., 850
#> | `-- [[3]] "R3" - An object of class "Pop" with 30 individual(s): 773, 774, ..., 845
#> |-- [[14]] "471" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1092, 1097, ..., 1170
#> | |-- [[2]] "R2" - An object of class "Pop" with 27 individual(s): 1091, 1093, ..., 1164
#> | `-- [[3]] "R3" - An object of class "Pop" with 21 individual(s): 1094, 1100, ..., 1167
#> |-- [[15]] "494" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 32 individual(s): 1015, 1019, ..., 1089
#> | |-- [[2]] "R2" - An object of class "Pop" with 21 individual(s): 1012, 1014, ..., 1088
#> | `-- [[3]] "R3" - An object of class "Pop" with 27 individual(s): 1011, 1013, ..., 1090
#> |-- [[16]] "522" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 34 individual(s): 934, 935, ..., 1010
#> | |-- [[2]] "R2" - An object of class "Pop" with 22 individual(s): 933, 940, ..., 1007
#> | `-- [[3]] "R3" - An object of class "Pop" with 24 individual(s): 931, 932, ..., 1005
#> |-- [[17]] "538" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 24 individual(s): 1251, 1254, ..., 1330
#> | |-- [[2]] "R2" - An object of class "Pop" with 30 individual(s): 1252, 1253, ..., 1329
#> | `-- [[3]] "R3" - An object of class "Pop" with 26 individual(s): 1256, 1260, ..., 1326
#> |-- [[18]] "563" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 33 individual(s): 1171, 1174, ..., 1250
#> | |-- [[2]] "R2" - An object of class "Pop" with 19 individual(s): 1173, 1176, ..., 1245
#> | `-- [[3]] "R3" - An object of class "Pop" with 28 individual(s): 1172, 1180, ..., 1249
#> |-- [[19]] "587" - An object of class "MultiPop" with 3 item(s)
#> | | Level 2:
#> | |-- [[1]] "R1" - An object of class "Pop" with 22 individual(s): 852, 857, ..., 930
#> | |-- [[2]] "R2" - An object of class "Pop" with 29 individual(s): 853, 855, ..., 929
#> | `-- [[3]] "R3" - An object of class "Pop" with 29 individual(s): 851, 854, ..., 927
#> `-- [[20]] "594" - An object of class "MultiPop" with 3 item(s)
#> | Level 2:
#> |-- [[1]] "R1" - An object of class "Pop" with 36 individual(s): 1334, 1335, ..., 1403
#> |-- [[2]] "R2" - An object of class "Pop" with 25 individual(s): 1337, 1339, ..., 1410
#> `-- [[3]] "R3" - An object of class "Pop" with 19 individual(s): 1331, 1332, ..., 1406Collecting genotype, haplotype, and allele-frequency data
The pullGeno and pullHaplo families of
functions can collect marker data from each terminal Pop in
a MultiPop. Their simplify and
level arguments help inspect results at a chosen nesting
level.
head(pullMarkerGeno(
syn1_HS,
markers = c("1_1", "1_2"),
simplify = TRUE
))
#> 1_1 1_2
#> 611 2 0
#> 612 2 0
#> 613 2 0
#> 614 2 0
#> 615 2 0
#> 616 2 0
head(pullMarkerHaplo(
syn1_HS,
markers = c("1_1", "1_2"),
haplo = 1,
simplify = TRUE
))
#> 1_1 1_2
#> 611_1 1 0
#> 612_1 1 0
#> 613_1 1 0
#> 614_1 1 0
#> 615_1 1 0
#> 616_1 1 0In population breeding, it may be impractical to genotype every
individual in a large sward, tank, cage or colony. Instead, individuals
can be sampled and pooled, and their allele frequencies can be estimated
for the genotyped markers. The pullAf family of functions
supports this workflow.
pullMarkerAf(
syn1_HS,
markers = c("1_1", "1_2"),
sample = 10,
simplify = TRUE
)
#> 1_1 1_2
#> [1,] 1.00 0.00
#> [2,] 1.00 0.00
#> [3,] 1.00 0.00
#> [4,] 1.00 0.00
#> [5,] 1.00 0.00
#> [6,] 1.00 0.00
#> [7,] 1.00 0.00
#> [8,] 1.00 0.00
#> [9,] 0.75 0.25
#> [10,] 0.95 0.05
#> attr(,"source")
#> level1
#> 1 416
#> 2 436
#> 3 465
#> 4 471
#> 5 494
#> 6 522
#> 7 538
#> 8 563
#> 9 587
#> 10 594Summary
MultiPop represents breeding populations whose
management and evaluation units are larger than individual plants or
animals. Existing operations such as self(),
setPheno(), and selectInd() can be applied
recursively, while selectPop() and
selectMultiPop() support selection among population units
at specified levels of a hierarchy.
Use meanG() and meanP() when the average
individual is the quantity of interest. Use meanGPop() and
meanPPop() when population units should contribute equally
to an aggregated result. Use calcPopSummary() when the
within-population and across-population operations need to be specified
separately.
Use flattenMultiPop() when units from different branches
should be compared together without merging their individuals. Use
mergeMultiPops() when component populations should be
combined for crossing or subsequent individual-level operations.
Together, these tools allow structured breeding programs to be written
in terms of their biological and management units while retaining
control over the population hierarchy.
Troubleshooting
- If
selectPop()reports that a child is not aPop, checklevel. Increase it when selection must descend into nestedMultiPopobjects. - If selection returns fewer units than requested, the requested number exceeds the number of eligible units at that level. Selection is performed separately within each relevant branch.
- If summaries are unexpectedly weighted by individuals, use
meanGPop(),meanPPop(), orcalcPopSummary()to aggregate population-level summaries explicitly. - If names are missing after flattening, inspect for duplicated names
and use
preserveNames = "concatenate"or"force". - If a phenotype-based operation fails because of missing values, set phenotypes before calling the operation and check the requested trait name.