Skip to contents

Selects individuals by an approximation to optimal contribution selection, maximizing merit while restricting the expected increase in fixation. No crosses are made, so the selected individuals can be crossed with a custom crossing plan, for example with makeCross. selectCross with restrInbr=TRUE makes the same selection and crosses at random.

Usage

selectOC(
  pop,
  nInd = NULL,
  nFemale = NULL,
  nMale = NULL,
  trait = 1,
  use = "pheno",
  selectTop = TRUE,
  inbrTarget = 0.01,
  inbrType = "relative",
  snpChip = 1,
  useQtl = FALSE,
  returnPop = TRUE,
  simParam = NULL,
  nThreads = NULL,
  onShortfall = "warning",
  usePed = FALSE,
  ...
)

Arguments

pop

an object of Pop-class

nInd

the number of individuals to select. These individuals are selected without regard to sex and it supersedes values for nFemale and nMale. Thus if the simulation uses sexes, it is likely better to leave this value as NULL and use nFemale and nMale instead.

nFemale

the number of females to select. This value is ignored if nInd is set.

nMale

the number of males to select. This value is ignored if nInd is set.

trait

the trait for selection. Either a number indicating a single trait or a function returning a vector of length nInd.

use

the selection criterion. Either a character (genetic values "gv", estimated breeding values "ebv", breeding values "bv", phenotypes "pheno", or randomly "rand") or a function returning a vector of length nInd.

selectTop

selects highest values if true. Selects lowest values if false.

inbrTarget

the target for expected fixation. Its meaning depends on inbrType. The default of 0.01 with inbrType="relative" allows a loss of 1% of the current heterozygosity per generation, which corresponds to an effective population size of 50 for a diploid.

inbrType

either "relative", where inbrTarget is the allowed increase in expected fixation as a proportion of the remaining heterozygosity in pop, or "absolute", where inbrTarget is the maximum allowed expected fixation.

snpChip

an integer indicating which SNP chip genotypes are used to measure expected fixation

useQtl

should QTL genotypes be used instead of a SNP chip to measure expected fixation. If TRUE, snpChip specifies which trait's QTL to use.

returnPop

should results be returned as a Pop-class. If FALSE, only the index of selected individuals is returned.

simParam

an object of class SimParam. If NULL, the function uses the object named SP from the global environment.

nThreads

number of threads to use if OpenMP is available. If NULL, the number is obtained from simParam$nThreads.

onShortfall

what to do when fewer suitable candidates are available than requested. "warning" (the default) warns and selects from all of them, "error" stops, and "none" does so silently. When no candidates of a required sex are available, selection is not possible and an error is raised whatever the value.

usePed

should the pedigree relationship matrix of pedigreeA be used instead of genotypes to measure expected fixation. The pedigree must have been tracked from the start of the simulation, see setTrackPed. If TRUE, snpChip is ignored and useQtl must be FALSE.

...

additional arguments if using a function for trait or use

Value

Returns an object of Pop-class, or the indices of the selected individuals if returnPop=FALSE. With nFemale and nMale, the selected females come before the selected males.

Details

Individuals are chosen by an approximation to optimal contribution selection in which every selected individual contributes equally to the next generation.

Genotypes at the SNP chip, or at a trait's QTL if useQtl=TRUE, are coded as \(z = 2x/k - 1\), where \(x\) is the allele dosage and \(k\) is the ploidy. For a set of selected individuals, \(u_j = 2\bar{p}_j - 1\), where \(\bar{p}_j\) is the allele frequency at locus \(j\) among the gametes they supply. When nInd is used, this is the frequency among the selected individuals. When nFemale and nMale are used, each sex supplies half of the gametes, so \(u_j\) is the average of the female and male values. The expected fixation of the selected individuals is $$F = \frac{1}{m}\sum_j u_j^2 = 1 - H/H_{max},$$ where \(m\) is the number of loci, \(H\) is the mean expected heterozygosity of their gametes and \(H_{max} = 0.5\) is its value at an allele frequency of 0.5. For diploids, \(F\) equals the average coancestry \(c'Gc/2\) of the selected individuals, where \(c\) holds their equal contributions and \(G = ZZ'/(m/2)\) is a genomic relationship matrix scaled with allele frequencies of 0.5.

At any ploidy, \(z_i'z_j/m\) estimates the kinship of individuals \(i\) and \(j\), the probability that an allele drawn from each is identical by descent, relative to a base population with allele frequencies of 0.5. With usePed=TRUE, the kinship is instead taken from the pedigree as \(A/k\), where \(A\) is the relationship matrix of pedigreeA, and \(ZZ'/m\) is replaced by \(A/k\) in what follows. \(F\) is then the average kinship of the selected individuals relative to the founders of the simulation, which the pedigree takes to be unrelated, rather than a measure of fixation at the markers. The individuals are also chosen differently, as described below.

The target \(F^*\) is set by inbrType. With "relative", \(F^* = F_t + \Delta F(1 - F_t)\), where \(F_t\) is the expected fixation of all of pop and \(\Delta F\) is inbrTarget. This allows a loss of a proportion \(\Delta F\) of the current heterozygosity per generation. Because each individual carries \(k\) copies of every locus, \(\Delta F = 1/(kN_e)\) for an effective population size \(N_e\), so the default of 0.01 corresponds to an effective population size of 50 for a diploid and 25 for a tetraploid. With "absolute", \(F^* =\) inbrTarget, independent of pop. This is useful when pop has already been preselected, so its own expected fixation is not a suitable reference.

Selection on merit \(m_i\), given by trait and use, subject to \(F \le F^*\) is relaxed with a Lagrange multiplier. Each candidate \(i\) is then scored as $$s_i = m_i - \kappa\left(z_i'u + \frac{c}{2} z_i'z_i\right),$$ where \(c\) is the contribution of each selected individual: \(1/N\) for \(N\) individuals, or \(1/(2N_f)\) for a female and \(1/(2N_m)\) for a male when using sexes. The first term penalizes candidates carrying alleles that are common among the selected individuals and rewards those carrying alleles that are rare among them, pulling allele frequencies toward 0.5. The second is the candidate's own contribution to fixation, which grows with its homozygosity and matters most when few individuals are selected. For a given \(\kappa\), \(u\) starts from the allele frequencies of pop, the top candidates on \(s_i\) are selected, and \(u\) is updated toward their frequencies with a running average. This repeats until \(u\) converges. With nFemale and nMale, females and males are ranked separately against the shared \(u\). The expected fixation of the final set is computed exactly, and bisection finds the smallest \(\kappa\) that meets the target. If \(\kappa = 0\) meets it, the result is ordinary truncation selection. If no \(\kappa\) tried meets it, a warning is given and the individuals selected with the largest \(\kappa\) tried are returned. A message reports \(\kappa\), the achieved \(F\), the target and \(F_t\).

With usePed=TRUE, the individuals are instead selected one at a time for a given \(\kappa\). Each time, the candidate taken is the one with the highest $$s_i = m_i - \kappa\left(\sum_{j \in S} c\,\theta_{ij} + \frac{c}{2}\theta_{ii}\right),$$ where \(\theta_{ij} = A_{ij}/k\) is the kinship and \(S\) holds the individuals already taken, so the penalty is proportional to the increase in \(F\) from adding the candidate to them. With nFemale and nMale, each pick is from the sex with the smaller share of its individuals taken, ranked within that sex. The search for \(\kappa\) is as above. Full sibs have identical relationships in a pedigree, so the score used with genotypes would penalize every sib in a family equally against the same \(u\) and take each family whole or not at all. Taking individuals one at a time instead penalizes each sib for the ones already taken.

A random set of \(N\) individuals of ploidy \(k\), contributing equally, increases expected fixation by about \((1 - F_t)/(kN)\). When using sexes, \(N\) is replaced by \(4N_fN_m/(N_f + N_m)\) for \(N_f\) females and \(N_m\) males. With genotypes, a selected set can do better than a random one by choosing individuals whose alleles balance each other, so the target can be met with fewer than \(1/(k\Delta F)\) individuals, which is 50 for a diploid with the default. Most of the restriction is then spent on keeping allele frequencies balanced, though, so much less gain in merit is made than with a larger number.

A pedigree records whom each candidate descends from but not which alleles it carries, so it cannot balance allele frequencies. Full sibs, for example, are related alike to everyone else and are chosen between on merit, and every set of \(N\) founders that are neither related nor inbred has \(F = 1/(kN)\), whichever are selected. The restriction instead works by spreading selection across families. Because markers also see the Mendelian sampling within families, they usually allow more gain in merit than the pedigree at the same target.

The target holds only if the selected individuals are used as assumed: each contributes equally to the next generation and, with nFemale and nMale, each sex supplies half of the gametes. A custom crossing plan should therefore give every selected individual the same number of progeny, or the realized fixation will differ from the target. The method controls the allele frequencies of the gametes the selected individuals are expected to supply. Sampling at meiosis, including double reduction in polyploids, adds further drift in the progeny that the method does not account for.

The method is a Lagrangian relaxation solved by repeated linearization rather than an exact solution of optimal contribution selection. Swapping one selected individual for another changes fixation through a second order term with three parts: two for the individuals on their own, which the score includes, and one for the relationship between them, which cannot be split between candidates and so is ignored. The one at a time selection used with usePed=TRUE includes that relationship for the individuals already taken, but is greedy: it never revisits a choice, so it is also not an exact solution.

See also

Examples

#Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=20)

#Set simulation parameters
SP = SimParam$new(founderPop)
SP$addTraitA(10)
SP$setVarE(h2=0.5)
SP$addSnpChip(10)

#Create population
pop = newPop(founderPop, simParam=SP)

#Select 4 individuals while restricting the increase in expected
#fixation measured at the SNP chip
parents = selectOC(pop, nInd=4, inbrTarget=0.5, simParam=SP)
#> selectOC: kappa = 0, F = 0.1438 (target 0.5335, current 0.067)

#Cross them in a circle, so each parent is used equally
crossPlan = cbind(1:4, c(2:4, 1))
pop2 = makeCross(parents, crossPlan, nProgeny=2, simParam=SP)

#Restrict the average pedigree relationship instead, which needs the
#pedigree to have been tracked from the start
SP2 = SimParam$new(founderPop)
SP2$addTraitA(10)
SP2$setVarE(h2=0.5)
SP2$setTrackPed(TRUE)
pop = newPop(founderPop, simParam=SP2)
pop = randCross(pop, nCrosses=4, nProgeny=5, simParam=SP2)
parents = selectOC(pop, nInd=4, inbrTarget=0.1, usePed=TRUE,
                   simParam=SP2)
#> selectOC: kappa = 0, F = 0.2031 (target 0.2097, current 0.1219)