Title: | Breeding Program Simulations |
---|---|
Description: | The successor to the 'AlphaSim' software for breeding program simulation [Faux et al. (2016) <doi:10.3835/plantgenome2016.02.0013>]. Used for stochastic simulations of breeding programs to the level of DNA sequence for every individual. Contained is a wide range of functions for modeling common tasks in a breeding program, such as selection and crossing. These functions allow for constructing simulations of highly complex plant and animal breeding programs via scripting in the R software environment. Such simulations can be used to evaluate overall breeding program performance and conduct research into breeding program design, such as implementation of genomic selection. Included is the 'Markovian Coalescent Simulator' ('MaCS') for fast simulation of biallelic sequences according to a population demographic history [Chen et al. (2009) <doi:10.1101/gr.083634.108>]. |
Authors: | Chris Gaynor [aut, cre] , Gregor Gorjanc [ctb] , John Hickey [ctb] , Daniel Money [ctb] , David Wilson [ctb], Thiago Oliveira [ctb] , Audrey Martin [ctb] , Philip Greenspoon [ctb] |
Maintainer: | Chris Gaynor <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.6.1 |
Built: | 2024-11-03 01:04:17 UTC |
Source: | CRAN |
Creates a new Pop-class
from an object of
of the Pop superclass.
.newPop( rawPop, id = NULL, mother = NULL, father = NULL, iMother = NULL, iFather = NULL, isDH = NULL, femaleParentPop = NULL, maleParentPop = NULL, hist = NULL, simParam = NULL, ... )
.newPop( rawPop, id = NULL, mother = NULL, father = NULL, iMother = NULL, iFather = NULL, isDH = NULL, femaleParentPop = NULL, maleParentPop = NULL, hist = NULL, simParam = NULL, ... )
rawPop |
an object of the pop superclass |
id |
optional id for new individuals |
mother |
optional id for mothers |
father |
optional id for fathers |
iMother |
optional internal id for mothers |
iFather |
optional internal id for fathers |
isDH |
optional indicator for DH/inbred individuals |
femaleParentPop |
optional population of female parents |
maleParentPop |
optional population of male parents |
hist |
optional recombination history |
simParam |
an object of |
... |
additional arguments passed to the finalizePop function in simParam |
Returns an object of Pop-class
Returns additive-by-additive epistatic deviations for all traits
aa(pop, simParam = NULL)
aa(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) aa(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) aa(pop, simParam=SP)
This function allows for adding a new segregating site with user supplied genotypes to a MapPop. The position of the site is set using a genetic map position.
addSegSite(mapPop, siteName, chr, mapPos, haplo)
addSegSite(mapPop, siteName, chr, mapPos, haplo)
mapPop |
an object of |
siteName |
name to give the segregating site |
chr |
which chromosome to add the site |
mapPos |
genetic map position of site in Morgans |
haplo |
haplotypes for the site |
an object of MapPop-class
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 2 segregating sites founderPop = quickHaplo(nInd=10,nChr=1,segSites=2) # Add a locus a the 0.5 Morgan map position haplo = matrix(sample(x=0:1, size=20, replace=TRUE), ncol=1) founderPop2 = addSegSite(founderPop, siteName="x", chr=1, mapPos=0.5, haplo=haplo) pullSegSiteHaplo(founderPop2)
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 2 segregating sites founderPop = quickHaplo(nInd=10,nChr=1,segSites=2) # Add a locus a the 0.5 Morgan map position haplo = matrix(sample(x=0:1, size=20, replace=TRUE), ncol=1) founderPop2 = addSegSite(founderPop, siteName="x", chr=1, mapPos=0.5, haplo=haplo) pullSegSiteHaplo(founderPop2)
Samples individuals at random to remove from the population. The user supplies a probability for the individuals to be removed from the population.
attrition(pop, p)
attrition(pop, p)
pop |
an object of |
p |
the expected proportion of individuals that will be lost to attrition. |
an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=100, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Lose an expected 5% of individuals pop = attrition(pop, p=0.05)
#Create founder haplotypes founderPop = quickHaplo(nInd=100, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Lose an expected 5% of individuals pop = attrition(pop, p=0.05)
Returns breeding values for all traits
bv(pop, simParam = NULL)
bv(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) bv(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) bv(pop, simParam=SP)
Calculate general combining ability of test crosses. Intended for output from hybridCross using the "testcross" option, but will work for any population.
calcGCA(pop, use = "pheno")
calcGCA(pop, use = "pheno")
pop |
an object of |
use |
tabulate either genetic values "gv", estimated breeding values "ebv", or phenotypes "pheno" |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Make crosses for full diallele pop2 = hybridCross(pop, pop, simParam=SP) GCA = calcGCA(pop2, use="gv")
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Make crosses for full diallele pop2 = hybridCross(pop, pop, simParam=SP) GCA = calcGCA(pop2, use="gv")
Merges the chromosomes of multiple MapPop-class
or
NamedMapPop-class
objects.
Each MapPop must have the same number of chromosomes
cChr(...)
cChr(...)
... |
|
Returns an object of MapPop-class
pop1 = quickHaplo(nInd=10, nChr=1, segSites=10) pop2 = quickHaplo(nInd=10, nChr=1, segSites=10) combinedPop = cChr(pop1, pop2)
pop1 = quickHaplo(nInd=10, nChr=1, segSites=10) pop2 = quickHaplo(nInd=10, nChr=1, segSites=10) combinedPop = cChr(pop1, pop2)
Returns dominance deviations for all traits
dd(pop, simParam = NULL)
dd(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) dd(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) dd(pop, simParam=SP)
Creates new individuals with twice the ploidy. This function was created to model the formation of tetraploid potatoes from diploid potatoes. This function will work on any population.
doubleGenome(pop, keepParents = TRUE, simParam = NULL)
doubleGenome(pop, keepParents = TRUE, simParam = NULL)
pop |
an object of 'Pop' superclass |
keepParents |
should previous parents be used for mother and father. |
simParam |
an object of 'SimParam' class |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create individuals with doubled ploidy pop2 = doubleGenome(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create individuals with doubled ploidy pop2 = doubleGenome(pop, simParam=SP)
A wrapper for accessing the ebv slot
ebv(pop)
ebv(pop)
pop |
a |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = matrix(rnorm(pop@nInd), nrow=pop@nInd, ncol=1) ebv(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = matrix(rnorm(pop@nInd), nrow=pop@nInd, ncol=1) ebv(pop)
Edits selected loci of selected individuals to a homozygous state for either the 1 or 0 allele. The gv slot is recalculated to reflect the any changes due to editing, but other slots remain the same.
editGenome(pop, ind, chr, segSites, allele, simParam = NULL)
editGenome(pop, ind, chr, segSites, allele, simParam = NULL)
pop |
an object of |
ind |
a vector of individuals to edit |
chr |
a vector of chromosomes to edit. Length must match length of segSites. |
segSites |
a vector of segregating sites to edit. Length must match length of chr. |
allele |
either 0 or 1 for desired allele |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Change individual 1 to homozygous for the 1 allele #at locus 1, chromosome 1 pop2 = editGenome(pop, ind=1, chr=1, segSites=1, allele=1, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Change individual 1 to homozygous for the 1 allele #at locus 1, chromosome 1 pop2 = editGenome(pop, ind=1, chr=1, segSites=1, allele=1, simParam=SP)
Edits the top QTL (with the largest additive effect) to a homozygous state for the allele increasing. Only nonfixed QTL are edited The gv slot is recalculated to reflect the any changes due to editing, but other slots remain the same.
editGenomeTopQtl(pop, ind, nQtl, trait = 1, increase = TRUE, simParam = NULL)
editGenomeTopQtl(pop, ind, nQtl, trait = 1, increase = TRUE, simParam = NULL)
pop |
an object of |
ind |
a vector of individuals to edit |
nQtl |
number of QTL to edit |
trait |
which trait effects should guide selection of the top QTL |
increase |
should the trait value be increased or decreased |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Change up to 10 loci for individual 1 pop2 = editGenomeTopQtl(pop, ind=1, nQtl=10, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Change up to 10 loci for individual 1 pop2 = editGenomeTopQtl(pop, ind=1, nQtl=10, simParam=SP)
Solves an RR-BLUP model for genomic predictions given known variance
components. This implementation is meant as a fast and low memory
alternative to RRBLUP
or RRBLUP2
. Unlike
the those functions, the fastRRBLUP does not fit fixed effects (other
than the intercept) or account for unequal replication.
fastRRBLUP( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 1000, Vu = NULL, Ve = NULL, simParam = NULL, ... )
fastRRBLUP( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 1000, Vu = NULL, Ve = NULL, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. Only univariate models are supported. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations. |
Vu |
marker effect variance. If value is NULL, a reasonable value is chosen automatically. |
Ve |
error variance. If value is NULL, a reasonable value is chosen automatically. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#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) #Run GS model and set EBV ans = fastRRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = fastRRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Returns additive genic variance for all traits
genicVarA(pop, simParam = NULL)
genicVarA(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarA(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarA(pop, simParam=SP)
Returns additive-by-additive epistatic genic variance for all traits
genicVarAA(pop, simParam = NULL)
genicVarAA(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarAA(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarAA(pop, simParam=SP)
Returns dominance genic variance for all traits
genicVarD(pop, simParam = NULL)
genicVarD(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarD(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarD(pop, simParam=SP)
Returns total genic variance for all traits
genicVarG(pop, simParam = NULL)
genicVarG(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarG(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) genicVarG(pop, simParam=SP)
Calculates genetic and genic additive and dominance variances
for an object of Pop-class
genParam(pop, simParam = NULL)
genParam(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
an nTrait by nTrait matrix of additive genetic variances
an nTrait by nTrait matrix of dominance genetic variances
an nTrait by nTrait matrix of additive-by-additive genetic variances
an nTrait by nTrait matrix of total genetic variances
an nTrait vector of additive genic variances
an nTrait vector of dominance genic variances
an nTrait vector of additive-by-additive genic variances
an nTrait vector of total genic variances
an nTrait vector of additive covariances due to non-random mating
an nTrait vector of dominance covariances due to non-random mating
an nTrait vector of additive-by-additive covariances due to non-random mating
an nTrait vector of total genic covariances due to non-random mating
an nTrait vector of additive covariances due to linkage disequilibrium
an nTrait vector of dominance covariances due to linkage disequilibrium
an nTrait vector of additive-by-additive covariances due to linkage disequilibrium
an nTrait vector of additive by dominance covariances due to linkage disequilibrium
an nTrait vector of additive by additive-by-additive covariances due to linkage disequilibrium
an nTrait vector of dominance by additive-by-additive covariances due to linkage disequilibrium
an nTrait vector of total genic covariances due to linkage disequilibrium
an nTrait vector of trait means
an nTrait vector of expected trait means under random mating
a matrix of genetic values with dimensions nInd by nTraits
a matrix of breeding values with dimensions nInd by nTraits
a matrix of dominance deviations with dimensions nInd by nTraits
a matrix of additive-by-additive epistatic deviations with dimensions nInd by nTraits
an nTrait vector of intercepts with dimensions nInd by nTraits
a matrix of additive genetic values with dimensions nInd by nTraits
a matrix of dominance genetic values with dimensions nInd by nTraits
a matrix of additive-by-additive genetic values with dimensions nInd by nTraits
a list of average allele subsitution effects with length nTraits
a list of average allele subsitution effects at Hardy-Weinberg equilibrium with length nTraits
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) ans = genParam(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) ans = genParam(pop, simParam=SP)
Retrieves the genetic map for all loci.
getGenMap(object = NULL, sex = "A")
getGenMap(object = NULL, sex = "A")
object |
where to retrieve the genetic map.
Can be an object of |
sex |
determines which sex specific map is returned. Options are "A" for average map, "F" for female map, and "M" for male map. All options are equivalent if not using sex specific maps or using pulling from a MapPop. |
Returns a data.frame with:
Unique identifier for locus
Chromosome containing the locus
Genetic map position
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters getGenMap(founderPop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters getGenMap(founderPop)
Gets the number of available threads by calling the OpenMP function
omp_get_max_threads()
getNumThreads()
getNumThreads()
integer
getNumThreads()
getNumThreads()
Returns the population's pedigree as stored in the id, mother and father slots. NULL is returned if the input population lacks the required.
getPed(pop)
getPed(pop)
pop |
a population |
# Create a founder population founderPop = quickHaplo(2,1,2) # Set simulation parameters SP = SimParam$new(founderPop) # Create a population pop = newPop(founderPop, simParam=SP) # Get the pedigree getPed(pop) # Returns NULL when a population lacks a pedigree getPed(founderPop)
# Create a founder population founderPop = quickHaplo(2,1,2) # Set simulation parameters SP = SimParam$new(founderPop) # Create a population pop = newPop(founderPop, simParam=SP) # Get the pedigree getPed(pop) # Returns NULL when a population lacks a pedigree getPed(founderPop)
Retrieves the genetic map for the QTL of a given trait.
getQtlMap(trait = 1, sex = "A", simParam = NULL)
getQtlMap(trait = 1, sex = "A", simParam = NULL)
trait |
an integer for the |
sex |
determines which sex specific map is returned. Options are "A" for average map, "F" for female map, and "M" for male map. All options are equivalent if not using sex specific maps. |
simParam |
an object of |
Returns a data.frame with:
Unique identifier for the QTL
Chromosome containing the QTL
Segregating site on the chromosome
Genetic map position
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(5) #Pull SNP map getQtlMap(trait=1, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(5) #Pull SNP map getQtlMap(trait=1, simParam=SP)
Retrieves the genetic map for a given SNP chip.
getSnpMap(snpChip = 1, sex = "A", simParam = NULL)
getSnpMap(snpChip = 1, sex = "A", simParam = NULL)
snpChip |
an integer. Indicates which SNP chip's map to retrieve. |
sex |
determines which sex specific map is returned. Options are "A" for average map, "F" for female map, and "M" for male map. All options are equivalent if not using sex specific maps. |
simParam |
an object of |
Returns a data.frame with:
Unique identifier for the SNP
Chromosome containing the SNP
Segregating site on the chromosome
Genetic map position
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChip(5) #Pull SNP map getSnpMap(snpChip=1, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChip(5) #Pull SNP map getSnpMap(snpChip=1, simParam=SP)
A wrapper for accessing the gv slot
gv(pop)
gv(pop)
pop |
a |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) gv(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) gv(pop)
A convenient function for hybrid plant breeding simulations. Allows for
easy specification of a test cross scheme and/or creation of an object
of HybridPop-class
. Note that the HybridPop-class
should only be used if the parents were created using the makeDH
function or newPop
using inbred founders. The id for
new individuals is [mother_id]_[father_id]
hybridCross( females, males, crossPlan = "testcross", returnHybridPop = FALSE, simParam = NULL )
hybridCross( females, males, crossPlan = "testcross", returnHybridPop = FALSE, simParam = NULL )
females |
female population, an object of |
males |
male population, an object of |
crossPlan |
either "testcross" for all possible combinations or a matrix with two columns for designed crosses |
returnHybridPop |
should results be returned as
|
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make crosses for full diallele pop2 = hybridCross(pop, pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make crosses for full diallele pop2 = hybridCross(pop, pop, simParam=SP)
A lightweight version of Pop-class
for hybrid lines.
Memory is saved by not storing genotypic data.
## S4 method for signature 'HybridPop' x[i] ## S4 method for signature 'HybridPop' c(x, ...) isHybridPop(x)
## S4 method for signature 'HybridPop' x[i] ## S4 method for signature 'HybridPop' c(x, ...) isHybridPop(x)
x |
a 'HybridPop' |
i |
index of individuals |
... |
additional 'HybridPop' objects |
[
: Extract HybridPop using index or id
c(HybridPop)
: Combine multiple HybridPops
isHybridPop()
: Test if object is of a HybridPop class
nInd
number of individuals
id
an individual's identifier
mother
the identifier of the individual's mother
father
the identifier of the individual's father
nTraits
number of traits
gv
matrix of genetic values. When using GxE traits, gv reflects gv when p=0.5. Dimensions are nInd by nTraits.
pheno
matrix of phenotypic values. Dimensions are nInd by nTraits.
gxe
list containing GxE slopes for GxE traits
Formats a genetic map stored in a data.frame to AlphaSimR's internal format. Map positions must be in Morgans.
importGenMap(genMap)
importGenMap(genMap)
genMap |
genetic map as a data.frame. The first three columns must be: marker name, chromosome, and map position (Morgans). Marker name and chromosome are coerced using as.character. |
a list of named vectors
genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) asrMap = importGenMap(genMap=genMap) str(asrMap)
genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) asrMap = importGenMap(genMap=genMap) str(asrMap)
Formats haplotype in a matrix format to an
AlphaSimR population that can be used to
initialize a simulation. This function serves
as wrapper for newMapPop
that
utilizes a more user friendly input format.
importHaplo(haplo, genMap, ploidy = 2L, ped = NULL)
importHaplo(haplo, genMap, ploidy = 2L, ped = NULL)
haplo |
a matrix of haplotypes |
genMap |
genetic map as a data.frame. The first
three columns must be: marker name, chromosome, and
map position (Morgans). Marker name and chromosome are
coerced using as.character. See |
ploidy |
ploidy level of the organism |
ped |
an optional pedigree for the supplied genotypes. See details. |
The optional pedigree can be a data.frame, matrix or a vector. If the object is a data.frame or matrix, the first three columns must include information in the following order: id, mother, and father. All values are coerced using as.character. If the object is a vector, it is assumed to only include the id. In this case, the mother and father will be set to "0" for all individuals.
a MapPop-class
if ped is NULL,
otherwise a NamedMapPop-class
haplo = rbind(c(1,1,0,1,0), c(1,1,0,1,0), c(0,1,1,0,0), c(0,1,1,0,0)) colnames(haplo) = letters[1:5] genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) ped = data.frame(id=c("a","b"), mother=c(0,0), father=c(0,0)) founderPop = importHaplo(haplo=haplo, genMap=genMap, ploidy=2L, ped=ped)
haplo = rbind(c(1,1,0,1,0), c(1,1,0,1,0), c(0,1,1,0,0), c(0,1,1,0,0)) colnames(haplo) = letters[1:5] genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) ped = data.frame(id=c("a","b"), mother=c(0,0), father=c(0,0)) founderPop = importHaplo(haplo=haplo, genMap=genMap, ploidy=2L, ped=ped)
Formats the genotypes from inbred, diploid lines to an AlphaSimR population that can be used to initialize a simulation. An attempt is made to automatically detect 0,1,2 or -1,0,1 genotype coding. Heterozygotes or probabilistic genotypes are allowed, but will be coerced to the nearest homozygote. Pedigree information is optional and when provided will be passed to the population for easier identification in the simulation.
importInbredGeno(geno, genMap, ped = NULL)
importInbredGeno(geno, genMap, ped = NULL)
geno |
a matrix of genotypes |
genMap |
genetic map as a data.frame. The first three columns must be: marker name, chromosome, and map position (Morgans). Marker name and chromosome are coerced using as.character. See importGenMap |
ped |
an optional pedigree for the supplied genotypes. See details. |
The optional pedigree can be a data.frame, matrix or a vector. If the object is a data.frame or matrix, the first three columns must include information in the following order: id, mother, and father. All values are coerced using as.character. If the object is a vector, it is assumed to only include the id. In this case, the mother and father will be set to "0" for all individuals.
a MapPop-class
if ped is NULL,
otherwise a NamedMapPop-class
geno = rbind(c(2,2,0,2,0), c(0,2,2,0,0)) colnames(geno) = letters[1:5] genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) ped = data.frame(id=c("a","b"), mother=c(0,0), father=c(0,0)) founderPop = importInbredGeno(geno=geno, genMap=genMap, ped=ped)
geno = rbind(c(2,2,0,2,0), c(0,2,2,0,0)) colnames(geno) = letters[1:5] genMap = data.frame(markerName=letters[1:5], chromosome=c(1,1,1,2,2), position=c(0,0.5,1,0.15,0.4)) ped = data.frame(id=c("a","b"), mother=c(0,0), father=c(0,0)) founderPop = importInbredGeno(geno=geno, genMap=genMap, ped=ped)
Test if individuals of a population are female or male
isFemale(x) isMale(x)
isFemale(x) isMale(x)
x |
logical
isMale()
: Test if individuals of a population are female or male
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParam$new(founderGenomes) SP$setSexes(sexes = "yes_sys") pop <- newPop(founderGenomes) isFemale(pop) isMale(pop) pop[isFemale(pop)] pop[isFemale(pop)]@sex
founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100) SP <- SimParam$new(founderGenomes) SP$setSexes(sexes = "yes_sys") pop <- newPop(founderGenomes) isFemale(pop) isMale(pop) pop[isFemale(pop)] pop[isFemale(pop)]@sex
Utilify function to test if object is of a Population class
isPop(x)
isPop(x)
x |
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) isPop(pop) isPop(SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) isPop(pop) isPop(SP)
used for both SNPs and QTLs
nLoci
total number of loci
lociPerChr
number of loci per chromosome
lociLoc
physical position of loci
name
optional name for LociMap object
Makes crosses within a population using a user supplied crossing plan.
makeCross(pop, crossPlan, nProgeny = 1, simParam = NULL)
makeCross(pop, crossPlan, nProgeny = 1, simParam = NULL)
pop |
an object of |
crossPlan |
a matrix with two column representing female and male parents. Either integers for the position in population or character strings for the IDs. |
nProgeny |
number of progeny per cross |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = makeCross(pop, crossPlan, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = makeCross(pop, crossPlan, simParam=SP)
Makes crosses between two populations using a user supplied crossing plan.
makeCross2(females, males, crossPlan, nProgeny = 1, simParam = NULL)
makeCross2(females, males, crossPlan, nProgeny = 1, simParam = NULL)
females |
an object of |
males |
an object of |
crossPlan |
a matrix with two column representing female and male parents. Either integers for the position in population or character strings for the IDs. |
nProgeny |
number of progeny per cross |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = makeCross2(pop, pop, crossPlan, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = makeCross2(pop, pop, crossPlan, simParam=SP)
Creates DH lines from each individual in a population.
Only works with diploid individuals. For polyploids, use
reduceGenome
and doubleGenome
.
makeDH(pop, nDH = 1, useFemale = TRUE, keepParents = TRUE, simParam = NULL)
makeDH(pop, nDH = 1, useFemale = TRUE, keepParents = TRUE, simParam = NULL)
pop |
an object of 'Pop' superclass |
nDH |
total number of DH lines per individual |
useFemale |
should female recombination rates be used. |
keepParents |
should previous parents be used for mother and father. |
simParam |
an object of 'SimParam' class |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create 1 DH for each individual pop2 = makeDH(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create 1 DH for each individual pop2 = makeDH(pop, simParam=SP)
Extends RawPop-class
to add a genetic map.
This is the first object created in a simulation. It is used
for creating initial populations and setting traits in the
SimParam
.
## S4 method for signature 'MapPop' x[i] ## S4 method for signature 'MapPop' c(x, ...) isMapPop(x)
## S4 method for signature 'MapPop' x[i] ## S4 method for signature 'MapPop' c(x, ...) isMapPop(x)
x |
a 'MapPop' object |
i |
index of individuals |
... |
additional 'MapPop' objects |
[
: Extract MapPop by index
c(MapPop)
: Combine multiple MapPops
isMapPop()
: Test if object is of a MapPop class
genMap
list of chromosome genetic maps
centromere
vector of centromere positions
inbred
indicates whether the individuals are fully inbred
Returns the mean estimated breeding values for all traits
meanEBV(pop)
meanEBV(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) trtH2 = 0.5 SP$setVarE(h2=trtH2) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = trtH2 * (pop@pheno - meanP(pop)) #ind performance based EBV meanEBV(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) trtH2 = 0.5 SP$setVarE(h2=trtH2) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = trtH2 * (pop@pheno - meanP(pop)) #ind performance based EBV meanEBV(pop)
Returns the mean genetic values for all traits
meanG(pop)
meanG(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) meanG(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) meanG(pop)
Returns the mean phenotypic values for all traits
meanP(pop)
meanP(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) meanP(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) meanP(pop)
This function is designed to model the pairing of gametes. The male and female individuals are treated as gametes, so the ploidy of newly created individuals will be the sum of it parents.
mergeGenome(females, males, crossPlan, simParam = NULL)
mergeGenome(females, males, crossPlan, simParam = NULL)
females |
an object of |
males |
an object of |
crossPlan |
a matrix with two column representing female and male parents. Either integers for the position in population or character strings for the IDs. |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = mergeGenome(pop, pop, crossPlan, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Cross individual 1 with individual 10 crossPlan = matrix(c(1,10), nrow=1, ncol=2) pop2 = mergeGenome(pop, pop, crossPlan, simParam=SP)
Rapidly merges a list of populations into a single population
mergePops(popList)
mergePops(popList)
popList |
a list containing |
Returns a Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create a list of populations and merge list pop = newPop(founderPop, simParam=SP) pop@misc$tmp = rnorm(n=10) pop@misc$tmp2 = rnorm(n=10) popList = list(pop, pop) pop2 = mergePops(popList)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create a list of populations and merge list pop = newPop(founderPop, simParam=SP) pop@misc$tmp = rnorm(n=10) pop@misc$tmp2 = rnorm(n=10) popList = list(pop, pop) pop2 = mergePops(popList)
The mega-population represents a population of populations. It is designed to behave like a list of populations.
## S4 method for signature 'MultiPop' x[i] ## S4 method for signature 'MultiPop' x[[i]] ## S4 method for signature 'MultiPop' c(x, ...) ## S4 method for signature 'MultiPop' length(x) isMultiPop(x)
## S4 method for signature 'MultiPop' x[i] ## S4 method for signature 'MultiPop' x[[i]] ## S4 method for signature 'MultiPop' c(x, ...) ## S4 method for signature 'MultiPop' length(x) isMultiPop(x)
x |
a 'MultiPop' object |
i |
index of populations or mega-populations |
... |
additional 'MultiPop' or 'Pop' objects |
[
: Extract MultiPop by index
[[
: Extract Pop by index
c(MultiPop)
: Combine multiple MultiPops
length(MultiPop)
: Number of pops in MultiPop
isMultiPop()
: Test if object is of a MultiPop class
pops
list of Pop-class
and/or
MultiPop-class
Adds random mutations to individuals in a
population. Note that any existing phenotypes
or EBVs are kept. Thus, the user will need to run
setPheno
and/or setEBV
to generate new phenotypes or EBVs that reflect
changes introduced by the new mutations.
mutate(pop, mutRate = 2.5e-08, returnPos = FALSE, simParam = NULL)
mutate(pop, mutRate = 2.5e-08, returnPos = FALSE, simParam = NULL)
pop |
an object of |
mutRate |
rate of new mutations |
returnPos |
should the positions of mutations be returned |
simParam |
an object of |
an object of Pop-class
if
returnPos=FALSE or a list containing a
Pop-class
and a data.frame containing the
postions of mutations if returnPos=TRUE
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Introduce mutations pop = mutate(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Introduce mutations pop = mutate(pop, simParam=SP)
Extends MapPop-class
to add id, mother and father.
## S4 method for signature 'NamedMapPop' x[i] ## S4 method for signature 'NamedMapPop' c(x, ...) isNamedMapPop(x)
## S4 method for signature 'NamedMapPop' x[i] ## S4 method for signature 'NamedMapPop' c(x, ...) isNamedMapPop(x)
x |
a 'NamedMapPop' object |
i |
index of individuals |
... |
additional 'NamedMapPop' objects |
[
: Extract NamedMapPop by index
c(NamedMapPop)
: Combine multiple NamedMapPops
isNamedMapPop()
: Test if object is a NamedMapPop class
id
an individual's identifier
mother
the identifier of the individual's mother
father
the identifier of the individual's father
Creates an empty Pop-class
object with user
defined ploidy and other parameters taken from simParam.
newEmptyPop(ploidy = 2L, simParam = NULL)
newEmptyPop(ploidy = 2L, simParam = NULL)
ploidy |
the ploidy of the population |
simParam |
an object of |
Returns an object of Pop-class
with
zero individuals
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create empty population pop = newEmptyPop(simParam=SP) isPop(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create empty population pop = newEmptyPop(simParam=SP) isPop(pop)
Creates a new MapPop-class
from user supplied
genetic maps and haplotypes.
newMapPop(genMap, haplotypes, inbred = FALSE, ploidy = 2L)
newMapPop(genMap, haplotypes, inbred = FALSE, ploidy = 2L)
genMap |
a list of genetic maps |
haplotypes |
a list of matrices or data.frames that can be coerced to matrices. See details. |
inbred |
are individuals fully inbred |
ploidy |
ploidy level of the organism |
Each item of genMap must be a vector of ordered genetic lengths in Morgans. The first value must be zero. The length of the vector determines the number of segregating sites on the chromosome.
Each item of haplotypes must be coercible to a matrix. The columns of this matrix correspond to segregating sites. The number of rows must match the number of individuals times the ploidy if using inbred=FALSE. If using inbred=TRUE, the number of rows must equal the number of individuals. The haplotypes can be stored as numeric, integer or raw. The underlying C++ function will use raw.
an object of MapPop-class
# Create genetic map for two chromosomes, each 1 Morgan long # Each chromosome contains 11 equally spaced segregating sites genMap = list(seq(0,1,length.out=11), seq(0,1,length.out=11)) # Create haplotypes for 10 outbred individuals chr1 = sample(x=0:1,size=20*11,replace=TRUE) chr1 = matrix(chr1,nrow=20,ncol=11) chr2 = sample(x=0:1,size=20*11,replace=TRUE) chr2 = matrix(chr2,nrow=20,ncol=11) haplotypes = list(chr1,chr2) founderPop = newMapPop(genMap=genMap, haplotypes=haplotypes)
# Create genetic map for two chromosomes, each 1 Morgan long # Each chromosome contains 11 equally spaced segregating sites genMap = list(seq(0,1,length.out=11), seq(0,1,length.out=11)) # Create haplotypes for 10 outbred individuals chr1 = sample(x=0:1,size=20*11,replace=TRUE) chr1 = matrix(chr1,nrow=20,ncol=11) chr2 = sample(x=0:1,size=20*11,replace=TRUE) chr2 = matrix(chr2,nrow=20,ncol=11) haplotypes = list(chr1,chr2) founderPop = newMapPop(genMap=genMap, haplotypes=haplotypes)
Creates a new MultiPop-class
from one or more
Pop-class
and/or MultiPop-class
objects.
newMultiPop(...)
newMultiPop(...)
... |
one or more |
Returns an object of MultiPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) megaPop = newMultiPop(pop=pop) isMultiPop(megaPop)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) megaPop = newMultiPop(pop=pop) isMultiPop(megaPop)
Creates an initial Pop-class
from an object of
MapPop-class
or NamedMapPop-class
.
The function is intended for use with output from functions such
as runMacs
, newMapPop
, or
quickHaplo
.
newPop(rawPop, simParam = NULL, ...)
newPop(rawPop, simParam = NULL, ...)
rawPop |
an object of |
simParam |
an object of |
... |
additional arguments used internally |
Note that newPop
takes genomes from the
rawPop
and uses them without recombination! Hence, if you
call newPop(rawPop = founderGenomes)
twice, you will get
two sets of individuals with different id but the same genomes.
To get genetically different sets of individuals you can subset the
rawPop
input, say first half for one set and the second half
for the other set.
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) isPop(pop) #Misc pop@misc$tmp1 = rnorm(n=2) pop@misc$tmp2 = rnorm(n=2) #MiscPop pop@miscPop$tmp1 = sum(pop@misc$tmp1) pop@miscPop$tmp2 = sum(pop@misc$tmp2)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) isPop(pop) #Misc pop@misc$tmp1 = rnorm(n=2) pop@misc$tmp2 = rnorm(n=2) #MiscPop pop@miscPop$tmp1 = sum(pop@misc$tmp1) pop@miscPop$tmp2 = sum(pop@misc$tmp2)
A wrapper for accessing the nInd slot
nInd(pop)
nInd(pop)
pop |
a |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) nInd(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) nInd(pop)
Creates a Pop-class
from a generic
pedigree and a set of founder individuals.
The way in which the user supplied pedigree is used depends on the value of matchID. If matchID is TRUE, the IDs in the user supplied pedigree are matched against founderNames. If matchID is FALSE, founder individuals in the user supplied pedigree are randomly sampled from founderPop.
pedigreeCross( founderPop, id, mother, father, matchID = FALSE, maxCycle = 100, DH = NULL, nSelf = NULL, useFemale = TRUE, simParam = NULL )
pedigreeCross( founderPop, id, mother, father, matchID = FALSE, maxCycle = 100, DH = NULL, nSelf = NULL, useFemale = TRUE, simParam = NULL )
founderPop |
|
id |
a vector of unique identifiers for individuals in the pedigree. The values of these IDs are seperate from the IDs in the founderPop if matchID=FALSE. |
mother |
a vector of identifiers for the mothers of individuals in the pedigree. Must match one of the elements in the id vector or they will be treated as unknown. |
father |
a vector of identifiers for the fathers of individuals in the pedigree. Must match one of the elements in the id vector or they will be treated as unknown. |
matchID |
indicates if the IDs in founderPop should be matched to the id argument. See details. |
maxCycle |
the maximum number of loops to make over the pedigree to sort it. |
DH |
an optional vector indicating if an individual should be made a doubled haploid. |
nSelf |
an optional vector indicating how many generations an individual should be selfed. |
useFemale |
If creating DH lines, should female recombination rates be used. This parameter has no effect if, recombRatio=1. |
simParam |
an object of 'SimParam' class |
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Pedigree for a biparental cross with 7 generations of selfing id = 1:10 mother = c(0,0,1,3:9) father = c(0,0,2,3:9) pop2 = pedigreeCross(pop, id, mother, father, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Pedigree for a biparental cross with 7 generations of selfing id = 1:10 mother = c(0,0,1,3:9) father = c(0,0,2,3:9) pop2 = pedigreeCross(pop, id, mother, father, simParam=SP)
A wrapper for accessing the pheno slot
pheno(pop)
pheno(pop)
pop |
a |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) pheno(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) pheno(pop)
Extends RawPop-class
to add sex, genetic values,
phenotypes, and pedigrees.
## S4 method for signature 'Pop' x[i] ## S4 method for signature 'Pop' c(x, ...) ## S4 method for signature 'Pop' show(object) ## S4 method for signature 'Pop' length(x)
## S4 method for signature 'Pop' x[i] ## S4 method for signature 'Pop' c(x, ...) ## S4 method for signature 'Pop' show(object) ## S4 method for signature 'Pop' length(x)
x |
a 'Pop' object |
i |
index of individuals |
... |
additional 'Pop' objects |
object |
a 'Pop' object |
[
: Extract Pop by index or id
c(Pop)
: Combine multiple Pops
show(Pop)
: Show population summary
length(Pop)
: Number of individuals in Pop (the same as nInd())
id
an individual's identifier
iid
an individual's internal identifier
mother
the identifier of the individual's mother
father
the identifier of the individual's father
sex
sex of individuals: "M" for males, "F" for females, and "H" for hermaphrodites
nTraits
number of traits
gv
matrix of genetic values. When using GxE traits, gv reflects gv when p=0.5. Dimensions are nInd by nTraits.
pheno
matrix of phenotypic values. Dimensions are nInd by nTraits.
ebv
matrix of estimated breeding values. Dimensions are nInd rows and a variable number of columns.
gxe
list containing GxE slopes for GxE traits
fixEff
a fixed effect relating to the phenotype. Used by genomic selection models but otherwise ignored.
misc
a list whose elements correspond to additional miscellaneous
nodes with the items for individuals in the population (see example in
newPop
) - we support vectors and matrices or objects that
have a generic length and subset method.
This list is normally empty and exists solely as an
open slot available for uses to store extra information about
individuals.
miscPop
a list of any length containing optional meta data for the
population (see example in newPop
).
This list is empty unless information is supplied by the user.
Note that the list is emptied every time the population is subsetted or
combined because the meta data for old population might not be valid anymore.
Calculates the population variance matrix as
opposed to the sample variance matrix calculated
by var
. i.e. divides by n instead
of n-1
popVar(X)
popVar(X)
X |
an n by m matrix |
an m by m variance-covariance matrix
Retrieves IBD haplotype data
pullIbdHaplo(pop, chr = NULL, snpChip = NULL, simParam = NULL)
pullIbdHaplo(pop, chr = NULL, snpChip = NULL, simParam = NULL)
pop |
an object of |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosomes are retrieved. |
snpChip |
an integer indicating which SNP array loci are to be retrieved. If NULL, all sites are retrieved. |
simParam |
an object of |
Returns a matrix of IBD haplotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) SP$setTrackRec(TRUE) #Create population pop = newPop(founderPop, simParam=SP) pullIbdHaplo(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) SP$setTrackRec(TRUE) #Create population pop = newPop(founderPop, simParam=SP) pullIbdHaplo(pop, simParam=SP)
Retrieves genotype data for user specified loci
pullMarkerGeno(pop, markers, asRaw = FALSE, simParam = NULL)
pullMarkerGeno(pop, markers, asRaw = FALSE, simParam = NULL)
pop |
an object of |
markers |
a character vector. Indicates the names of the loci to be retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of genotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) #Pull genotype data for first two markers on chromosome one. #Marker name is consistent with default naming in AlphaSimR. pullMarkerGeno(pop, markers=c("1_1","1_2"), simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) #Pull genotype data for first two markers on chromosome one. #Marker name is consistent with default naming in AlphaSimR. pullMarkerGeno(pop, markers=c("1_1","1_2"), simParam=SP)
Retrieves haplotype data for user specified loci
pullMarkerHaplo(pop, markers, haplo = "all", asRaw = FALSE, simParam = NULL)
pullMarkerHaplo(pop, markers, haplo = "all", asRaw = FALSE, simParam = NULL)
pop |
an object of |
markers |
a character vector. Indicates the names of the loci to be retrieved |
haplo |
either "all" for all haplotypes or an integer for a single set of haplotypes. Use a value of 1 for female haplotypes and a value of 2 for male haplotypes in diploids. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of genotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) SP$setTrackRec(TRUE) #Create population pop = newPop(founderPop, simParam=SP) #Pull haplotype data for first two markers on chromosome one. #Marker name is consistent with default naming in AlphaSimR. pullMarkerHaplo(pop, markers=c("1_1","1_2"), simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) SP$setTrackRec(TRUE) #Create population pop = newPop(founderPop, simParam=SP) #Pull haplotype data for first two markers on chromosome one. #Marker name is consistent with default naming in AlphaSimR. pullMarkerHaplo(pop, markers=c("1_1","1_2"), simParam=SP)
Retrieves QTL genotype data
pullQtlGeno(pop, trait = 1, chr = NULL, asRaw = FALSE, simParam = NULL)
pullQtlGeno(pop, trait = 1, chr = NULL, asRaw = FALSE, simParam = NULL)
pop |
an object of |
trait |
an integer. Indicates which trait's QTL genotypes to retrieve. |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of QTL genotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullQtlGeno(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullQtlGeno(pop, simParam=SP)
Retrieves QTL haplotype data
pullQtlHaplo( pop, trait = 1, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pullQtlHaplo( pop, trait = 1, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pop |
an object of |
trait |
an integer. Indicates which trait's QTL haplotypes to retrieve. |
haplo |
either "all" for all haplotypes or an integer for a single set of haplotypes. Use a value of 1 for female haplotypes and a value of 2 for male haplotypes in diploids. |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of QTL haplotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullQtlHaplo(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullQtlHaplo(pop, simParam=SP)
Retrieves genotype data for all segregating sites
pullSegSiteGeno(pop, chr = NULL, asRaw = FALSE, simParam = NULL)
pullSegSiteGeno(pop, chr = NULL, asRaw = FALSE, simParam = NULL)
pop |
an object of |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of genotypes
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSegSiteGeno(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSegSiteGeno(pop, simParam=SP)
Retrieves haplotype data for all segregating sites
pullSegSiteHaplo( pop, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pullSegSiteHaplo( pop, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pop |
an object of |
haplo |
either "all" for all haplotypes or an integer for a single set of haplotypes. Use a value of 1 for female haplotypes and a value of 2 for male haplotypes in diploids. |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of haplotypes
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSegSiteHaplo(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSegSiteHaplo(pop, simParam=SP)
Retrieves SNP genotype data
pullSnpGeno(pop, snpChip = 1, chr = NULL, asRaw = FALSE, simParam = NULL)
pullSnpGeno(pop, snpChip = 1, chr = NULL, asRaw = FALSE, simParam = NULL)
pop |
an object of |
snpChip |
an integer. Indicates which SNP chip's genotypes to retrieve. |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of SNP genotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSnpGeno(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSnpGeno(pop, simParam=SP)
Retrieves SNP haplotype data
pullSnpHaplo( pop, snpChip = 1, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pullSnpHaplo( pop, snpChip = 1, haplo = "all", chr = NULL, asRaw = FALSE, simParam = NULL )
pop |
an object of |
snpChip |
an integer. Indicates which SNP chip's haplotypes to retrieve. |
haplo |
either "all" for all haplotypes or an integer for a single set of haplotypes. Use a value of 1 for female haplotypes and a value of 2 for male haplotypes in diploids. |
chr |
a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved. |
asRaw |
return in raw (byte) format |
simParam |
an object of |
Returns a matrix of SNP haplotypes.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSnpHaplo(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$addSnpChip(5) #Create population pop = newPop(founderPop, simParam=SP) pullSnpHaplo(pop, simParam=SP)
Rapidly simulates founder haplotypes by randomly sampling 0s and 1s. This is equivalent to having all loci with allele frequency 0.5 and being in linkage equilibrium.
quickHaplo(nInd, nChr, segSites, genLen = 1, ploidy = 2L, inbred = FALSE)
quickHaplo(nInd, nChr, segSites, genLen = 1, ploidy = 2L, inbred = FALSE)
nInd |
number of individuals to simulate |
nChr |
number of chromosomes to simulate |
segSites |
number of segregating sites per chromosome |
genLen |
genetic length of chromosomes |
ploidy |
ploidy level of organism |
inbred |
should founder individuals be inbred |
an object of MapPop-class
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites founderPop = quickHaplo(nInd=10,nChr=1,segSites=100)
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites founderPop = quickHaplo(nInd=10,nChr=1,segSites=100)
A wrapper for makeCross
that randomly
selects parental combinations for all possible combinantions.
randCross( pop, nCrosses, nProgeny = 1, balance = TRUE, parents = NULL, ignoreSexes = FALSE, simParam = NULL )
randCross( pop, nCrosses, nProgeny = 1, balance = TRUE, parents = NULL, ignoreSexes = FALSE, simParam = NULL )
pop |
an object of |
nCrosses |
total number of crosses to make |
nProgeny |
number of progeny per cross |
balance |
if using sexes, this option will balance the number of progeny per parent |
parents |
an optional vector of indices for allowable parents |
ignoreSexes |
should sexes be ignored |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make 10 crosses pop2 = randCross(pop, 10, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make 10 crosses pop2 = randCross(pop, 10, simParam=SP)
A wrapper for makeCross2
that randomly
selects parental combinations for all possible combinantions between
two populations.
randCross2( females, males, nCrosses, nProgeny = 1, balance = TRUE, femaleParents = NULL, maleParents = NULL, ignoreSexes = FALSE, simParam = NULL )
randCross2( females, males, nCrosses, nProgeny = 1, balance = TRUE, femaleParents = NULL, maleParents = NULL, ignoreSexes = FALSE, simParam = NULL )
females |
an object of |
males |
an object of |
nCrosses |
total number of crosses to make |
nProgeny |
number of progeny per cross |
balance |
this option will balance the number of progeny per parent |
femaleParents |
an optional vector of indices for allowable female parents |
maleParents |
an optional vector of indices for allowable male parents |
ignoreSexes |
should sex be ignored |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make 10 crosses pop2 = randCross2(pop, pop, 10, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Make 10 crosses pop2 = randCross2(pop, pop, 10, simParam=SP)
The raw population class contains only genotype data.
## S4 method for signature 'RawPop' x[i] ## S4 method for signature 'RawPop' c(x, ...) ## S4 method for signature 'RawPop' show(object) isRawPop(x)
## S4 method for signature 'RawPop' x[i] ## S4 method for signature 'RawPop' c(x, ...) ## S4 method for signature 'RawPop' show(object) isRawPop(x)
x |
a 'RawPop' object |
i |
index of individuals |
... |
additional 'RawPop' objects |
object |
a 'RawPop' object |
[
: Extract RawPop by index
c(RawPop)
: Combine multiple RawPops
show(RawPop)
: Show population summary
isRawPop()
: Test if object is of a RawPop class
nInd
number of individuals
nChr
number of chromosomes
ploidy
level of ploidy
nLoci
number of loci per chromosome
geno
list of nChr length containing chromosome genotypes. Each element is a three dimensional array of raw values. The array dimensions are nLoci by ploidy by nInd.
Creates new individuals from gametes. This function was created to model the creation of diploid potatoes from tetraploid potatoes. It can be used on any population with an even ploidy level. The newly created individuals will have half the ploidy level of the originals. The reduction can occur with or without genetic recombination.
reduceGenome( pop, nProgeny = 1, useFemale = TRUE, keepParents = TRUE, simRecomb = TRUE, simParam = NULL )
reduceGenome( pop, nProgeny = 1, useFemale = TRUE, keepParents = TRUE, simRecomb = TRUE, simParam = NULL )
pop |
an object of 'Pop' superclass |
nProgeny |
total number of progeny per individual |
useFemale |
should female recombination rates be used. |
keepParents |
should previous parents be used for mother and father. |
simRecomb |
should genetic recombination be modeled. |
simParam |
an object of 'SimParam' class |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create individuals with reduced ploidy pop2 = reduceGenome(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Create individuals with reduced ploidy pop2 = reduceGenome(pop, simParam=SP)
Recalculates a population's genetic values and resets phenotypes and EBVs.
resetPop(pop, simParam = NULL)
resetPop(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Rescale to set mean to 1 SP$rescaleTraits(mean=1) pop = resetPop(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Rescale to set mean to 1 SP$rescaleTraits(mean=1) pop = resetPop(pop, simParam=SP)
Fits an RR-BLUP model for genomic predictions.
RRBLUP( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 1000L, simParam = NULL, ... )
RRBLUP( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 1000L, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait or traits to model, a vector of trait names, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations. Only used when number of traits is greater than 1. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#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) #Run GS model and set EBV ans = RRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model for genomic predictions that includes dominance effects.
RRBLUP_D( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
RRBLUP_D( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations. Only used when number of traits is greater than 1. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=20) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) SP$addSnpChip(10) #Create population pop = newPop(founderPop, simParam=SP) #Run GS model and set EBV ans = RRBLUP_D(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=20) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) SP$addSnpChip(10) #Create population pop = newPop(founderPop, simParam=SP) #Run GS model and set EBV ans = RRBLUP_D(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model for genomic predictions that includes
dominance effects. This implementation is meant for situations where
RRBLUP_D
is too slow. Note that RRBLUP_D2
is only faster in certain situations. Most users should use
RRBLUP_D
.
RRBLUP_D2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, Va = NULL, Vd = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
RRBLUP_D2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, Va = NULL, Vd = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations. Only used when number of traits is greater than 1. |
Va |
marker effect variance for additive effects. If value is NULL, a reasonable starting point is chosen automatically. |
Vd |
marker effect variance for dominance effects. If value is NULL, a reasonable starting point is chosen automatically. |
Ve |
error variance. If value is NULL, a reasonable starting point is chosen automatically. |
useEM |
use EM to solve variance components. If false, the initial values are considered true. |
tol |
tolerance for EM algorithm convergence |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=20) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) SP$addSnpChip(10) #Create population pop = newPop(founderPop, simParam=SP) #Run GS model and set EBV ans = RRBLUP_D2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=20) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) SP$addSnpChip(10) #Create population pop = newPop(founderPop, simParam=SP) #Run GS model and set EBV ans = RRBLUP_D2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model that estimates seperate marker effects for females and males. Useful for predicting GCA of parents in single cross hybrids. Can also predict performance of specific single cross hybrids.
RRBLUP_GCA( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
RRBLUP_GCA( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations for convergence. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#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) #Run GS model and set EBV ans = RRBLUP_GCA(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP_GCA(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model that estimates seperate marker effects for
females and males. This implementation is meant for situations where
RRBLUP_GCA
is too slow. Note that RRBLUP_GCA2
is only faster in certain situations. Most users should use
RRBLUP_GCA
.
RRBLUP_GCA2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, VuF = NULL, VuM = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
RRBLUP_GCA2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, VuF = NULL, VuM = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations for convergence. |
VuF |
marker effect variance for females. If value is NULL, a reasonable starting point is chosen automatically. |
VuM |
marker effect variance for males. If value is NULL, a reasonable starting point is chosen automatically. |
Ve |
error variance. If value is NULL, a reasonable starting point is chosen automatically. |
useEM |
use EM to solve variance components. If false, the initial values are considered true. |
tol |
tolerance for EM algorithm convergence |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#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) #Run GS model and set EBV ans = RRBLUP_GCA2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP_GCA2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
An extention of RRBLUP_GCA
that adds dominance effects.
Note that we have not seen any consistent benefit of this model over
RRBLUP_GCA
.
RRBLUP_SCA( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
RRBLUP_SCA( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 40L, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations for convergence. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#Create founder haplotypes founderPop = quickHaplo(nInd=2, 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) #Run GS model and set EBV ans = RRBLUP_SCA(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#Create founder haplotypes founderPop = quickHaplo(nInd=2, 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) #Run GS model and set EBV ans = RRBLUP_SCA(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model that estimates seperate additive effects for
females and males and a dominance effect. This implementation is meant
for situations where RRBLUP_SCA
is too slow. Note that
RRBLUP_SCA2 is only faster in certain situations. Most users should use
RRBLUP_SCA
.
RRBLUP_SCA2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, VuF = NULL, VuM = NULL, VuD = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
RRBLUP_SCA2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, VuF = NULL, VuM = NULL, VuD = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a function of the traits returning a single value. |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations for convergence. |
VuF |
marker effect variance for females. If value is NULL, a reasonable starting point is chosen automatically. |
VuM |
marker effect variance for males. If value is NULL, a reasonable starting point is chosen automatically. |
VuD |
marker effect variance for dominance. If value is NULL, a reasonable starting point is chosen automatically. |
Ve |
error variance. If value is NULL, a reasonable starting point is chosen automatically. |
useEM |
use EM to solve variance components. If false, the initial values are considered true. |
tol |
tolerance for EM algorithm convergence |
simParam |
an object of |
... |
additional arguments if using a function for traits |
#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) #Run GS model and set EBV ans = RRBLUP_SCA2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP_SCA2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Fits an RR-BLUP model for genomic predictions. This implementation is
meant for situations where RRBLUP
is too slow. Note that
RRBLUP2 is only faster in certain situations, see details below. Most
users should use RRBLUP
.
RRBLUP2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, Vu = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
RRBLUP2( pop, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, maxIter = 10, Vu = NULL, Ve = NULL, useEM = TRUE, tol = 1e-06, simParam = NULL, ... )
pop |
a |
traits |
an integer indicating the trait to model, a trait name, or a
function of the traits returning a single value. Unlike |
use |
train model using phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or randomly "rand" |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
maxIter |
maximum number of iterations. |
Vu |
marker effect variance. If value is NULL, a reasonable starting point is chosen automatically. |
Ve |
error variance. If value is NULL, a reasonable starting point is chosen automatically. |
useEM |
use EM to solve variance components. If false, the initial values are considered true. |
tol |
tolerance for EM algorithm convergence |
simParam |
an object of |
... |
additional arguments if using a function for traits |
The RRBLUP2 function works best when the number of markers is not
too large. This is because it solves the RR-BLUP problem by setting
up and solving Henderson's mixed model equations. Solving these equations
involves a square matrix with dimensions equal to the number of fixed
effects plus the number of random effects (markers). Whereas the RRBLUP
function solves the RR-BLUP problem using the EMMA approach. This approach involves
a square matrix with dimensions equal to the number of phenotypic records. This means
that the RRBLUP2 function uses less memory than RRBLUP when the number of markers
is approximately equal to or smaller than the number of phenotypic records.
The RRBLUP2 function is not recommend for cases where the variance components are
unknown. This is uses the EM algorithm to solve for unknown variance components,
which is generally considerably slower than the EMMA approach of RRBLUP
.
The number of iterations for the EM algorithm is set by maxIter. The default value
is typically too small for convergence. When the algorithm fails to converge a
warning is displayed, but results are given for the last iteration. These results may
be "good enough". However we make no claim to this effect, because we can not generalize
to all possible use cases.
The RRBLUP2 function can quickly solve the mixed model equations without estimating variance
components. The variance components are set by defining Vu and Ve. Estimation of components
is suppressed by setting useEM to false. This may be useful if the model is being retrained
multiple times during the simulation. You could run RRBLUP
function the first
time the model is trained, and then use the variance components from this output for all
future runs with the RRBLUP2 functions. Again, we can make no claim to the general robustness
of this approach.
#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) #Run GS model and set EBV ans = RRBLUP2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP2(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Estimates the amount of RAM needed to run the RRBLUP
and its related functions for a given training population size.
Note that this function may underestimate total usage.
RRBLUPMemUse(nInd, nMarker, model = "REG")
RRBLUPMemUse(nInd, nMarker, model = "REG")
nInd |
the number of individuals in the training population |
nMarker |
the number of markers per individual |
model |
either "REG", "GCA", or "SCA" for |
Returns an estimate for the required gigabytes of RAM
RRBLUPMemUse(nInd=1000, nMarker=5000)
RRBLUPMemUse(nInd=1000, nMarker=5000)
Contains output from AlphaSimR's genomic selection functions.
gv
Trait(s) for estimating genetic values
bv
Trait(s) for estimating breeding values
female
Trait(s) for estimating GCA in the female pool
male
Trait(s) for estimating GCA in the male pool
Vu
Estimated marker variance(s)
Ve
Estimated error variance
Uses the MaCS software to produce founder haplotypes (Chen et al. 2009).
runMacs( nInd, nChr = 1, segSites = NULL, inbred = FALSE, species = "GENERIC", split = NULL, ploidy = 2L, manualCommand = NULL, manualGenLen = NULL, nThreads = NULL )
runMacs( nInd, nChr = 1, segSites = NULL, inbred = FALSE, species = "GENERIC", split = NULL, ploidy = 2L, manualCommand = NULL, manualGenLen = NULL, nThreads = NULL )
nInd |
number of individuals to simulate |
nChr |
number of chromosomes to simulate |
segSites |
number of segregating sites to keep per chromosome. A value of NULL results in all sites being retained. |
inbred |
should founder individuals be inbred |
species |
species history to simulate. See details. |
split |
an optional historic population split in terms of generations ago. |
ploidy |
ploidy level of organism |
manualCommand |
user provided MaCS options. For advanced users only. |
manualGenLen |
user provided genetic length. This must be supplied if using manualCommand. If not using manualCommand, this value will replace the predefined genetic length for the species. However, this the genetic length is only used by AlphaSimR and is not passed to MaCS, so MaCS still uses the predefined genetic length. For advanced users only. |
nThreads |
if OpenMP is available, this will allow for simulating chromosomes in parallel. If the value is NULL, the number of threads is automatically detected. |
There are currently three species histories available: GENERIC, CATTLE, WHEAT, and MAIZE.
The GENERIC history is meant to be a reasonable all-purpose choice. It runs quickly and
models a population with an effective populations size that has gone through several historic
bottlenecks. This species history is used as the default arguments in the runMacs2
function, so the user should examine this function for the details of how the species is modeled.
The CATTLE history is based off of real genome sequence data (MacLeod et al. 2013).
The WHEAT (Gaynor et al. 2017) and MAIZE (Hickey et al. 2014) histories have been included due to their use in previous simulations. However, it should be noted that neither faithfully simulates its respective species. This is apparent by the low number of segregating sites simulated by each history relative to their real-world analogs. Adjusting these histories to better represent their real-world analogs would result in a drastic increase to runtime.
an object of MapPop-class
Chen GK, Marjoram P, Wall JD (2009).
“Fast and Flexible Simulation of DNA Sequence Data.”
Genome Research, 19, 136-142.
https://genome.cshlp.org/content/19/1/136.
Gaynor RC, Gorjanc G, Bentley AR, Ober ES, Howell P, Jackson R, Mackay IJ, Hickey JM (2017).
“A Two-Part Strategy for Using Genomic Selection to Develop Inbred Lines.”
Crop Science, 57(5), 2372–2386.
ISSN 0011-183X, doi:10.2135/cropsci2016.09.0742, https://acsess.onlinelibrary.wiley.com/doi/full/10.2135/cropsci2016.09.0742.
Hickey JMDS, Crossa J, Hearne S, Babu R, Prasanna BM, Grondona M, Zambelli A, Windhausen VS, Mathews K, Gorjanc G (2014).
“Evaluation of Genomic Selection Training Population Designs and Genotyping Strategies in Plant Breeding Programs Using Simulation.”
Crop Science, 54(4), 1476-1488.
doi:10.2135/cropsci2013.03.0195.
MacLeod IM, Larkin DM, Lewin HAHBJ, Goddard ME (2013).
“Inferring Demography from Runs of Homozygosity in Whole-Genome Sequence, with Correction for Sequence Errors.”
Molecular Biology and Evolution, 30(9), 2209–2223.
doi:10.1093/molbev/mst125.
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites ## Not run: founderPop = runMacs(nInd=10,nChr=1,segSites=100) ## End(Not run)
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites ## Not run: founderPop = runMacs(nInd=10,nChr=1,segSites=100) ## End(Not run)
A wrapper function for runMacs
. This wrapper is designed
to provide a more intuitive interface for writing custom commands
in MaCS (Chen et al. 2009). It effectively automates the creation
of an appropriate line for the manualCommand argument in runMacs
using user supplied variables, but only allows for a subset of the functionality
offered by this argument. The default arguments of this function were chosen to match
species="GENERIC" in runMacs
.
runMacs2( nInd, nChr = 1, segSites = NULL, Ne = 100, bp = 1e+08, genLen = 1, mutRate = 2.5e-08, histNe = c(500, 1500, 6000, 12000, 1e+05), histGen = c(100, 1000, 10000, 1e+05, 1e+06), inbred = FALSE, split = NULL, ploidy = 2L, returnCommand = FALSE, nThreads = NULL )
runMacs2( nInd, nChr = 1, segSites = NULL, Ne = 100, bp = 1e+08, genLen = 1, mutRate = 2.5e-08, histNe = c(500, 1500, 6000, 12000, 1e+05), histGen = c(100, 1000, 10000, 1e+05, 1e+06), inbred = FALSE, split = NULL, ploidy = 2L, returnCommand = FALSE, nThreads = NULL )
nInd |
number of individuals to simulate |
nChr |
number of chromosomes to simulate |
segSites |
number of segregating sites to keep per chromosome |
Ne |
effective population size |
bp |
base pair length of chromosome |
genLen |
genetic length of chromosome in Morgans |
mutRate |
per base pair mutation rate |
histNe |
effective population size in previous generations |
histGen |
number of generations ago for effective population sizes given in histNe |
inbred |
should founder individuals be inbred |
split |
an optional historic population split in terms of generations ago |
ploidy |
ploidy level of organism |
returnCommand |
should the command passed to manualCommand in
|
nThreads |
if OpenMP is available, this will allow for simulating chromosomes in parallel. If the value is NULL, the number of threads is automatically detected. |
an object of MapPop-class
or if
returnCommand is true a string giving the MaCS command passed to
the manualCommand argument of runMacs
.
Chen GK, Marjoram P, Wall JD (2009). “Fast and Flexible Simulation of DNA Sequence Data.” Genome Research, 19, 136-142. https://genome.cshlp.org/content/19/1/136.
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites # The command is equivalent to using species="GENERIC" in runMacs ## Not run: founderPop = runMacs2(nInd=10,nChr=1,segSites=100) # runMacs() Implementation of the cattle demography following # Macleod et al. (2013) https://doi.org/10.1093/molbev/mst125 cattleChrSum = 2.8e9 # https://www.ncbi.nlm.nih.gov/datasets/genome/GCF_002263795.3/ (cattleChrBp = cattleChrSum / 30) recRate = 9.26e-09 (cattleGenLen = recRate * cattleChrBp) mutRate = 1.20e-08 runMacs2(nInd = 10, nChr = 1, Ne = 90, bp = cattleChrBp, genLen = cattleGenLen, mutRate = 1.20e-08, histNe = c(120, 250, 350, 1000, 1500, 2000, 2500, 3500, 7000, 10000, 17000, 62000), histGen = c( 3, 6, 12, 18, 24, 154, 454, 654, 1754, 2354, 3354, 33154), returnCommand = TRUE) ## End(Not run)
# Creates a populations of 10 outbred individuals # Their genome consists of 1 chromosome and 100 segregating sites # The command is equivalent to using species="GENERIC" in runMacs ## Not run: founderPop = runMacs2(nInd=10,nChr=1,segSites=100) # runMacs() Implementation of the cattle demography following # Macleod et al. (2013) https://doi.org/10.1093/molbev/mst125 cattleChrSum = 2.8e9 # https://www.ncbi.nlm.nih.gov/datasets/genome/GCF_002263795.3/ (cattleChrBp = cattleChrSum / 30) recRate = 9.26e-09 (cattleGenLen = recRate * cattleChrBp) mutRate = 1.20e-08 runMacs2(nInd = 10, nChr = 1, Ne = 90, bp = cattleChrBp, genLen = cattleGenLen, mutRate = 1.20e-08, histNe = c(120, 250, 350, 1000, 1500, 2000, 2500, 3500, 7000, 10000, 17000, 62000), histGen = c( 3, 6, 12, 18, 24, 154, 454, 654, 1754, 2354, 3354, 33154), returnCommand = TRUE) ## End(Not run)
Creates a new MapPop-class
from an existing
MapPop-class
by randomly sampling haplotypes.
sampleHaplo(mapPop, nInd, inbred = FALSE, ploidy = NULL, replace = TRUE)
sampleHaplo(mapPop, nInd, inbred = FALSE, ploidy = NULL, replace = TRUE)
mapPop |
the |
nInd |
the number of individuals to create |
inbred |
should new individuals be fully inbred |
ploidy |
new ploidy level for organism. If NULL, the ploidy level of the mapPop is used. |
replace |
should haplotypes be sampled with replacement |
an object of MapPop-class
founderPop = quickHaplo(nInd=2,nChr=1,segSites=11,inbred=TRUE) founderPop = sampleHaplo(mapPop=founderPop,nInd=20)
founderPop = quickHaplo(nInd=2,nChr=1,segSites=11,inbred=TRUE) founderPop = sampleHaplo(mapPop=founderPop,nInd=20)
This is a wrapper that combines the functionalities of
randCross
and selectInd
. The
purpose of this wrapper is to combine both selection and
crossing in one function call that minimized the amount
of intermediate populations created. This reduces RAM usage
and simplifies code writing. Note that this wrapper does not
provide the full functionality of either function.
selectCross( pop, nInd = NULL, nFemale = NULL, nMale = NULL, nCrosses, nProgeny = 1, trait = 1, use = "pheno", selectTop = TRUE, simParam = NULL, ..., balance = TRUE )
selectCross( pop, nInd = NULL, nFemale = NULL, nMale = NULL, nCrosses, nProgeny = 1, trait = 1, use = "pheno", selectTop = TRUE, simParam = NULL, ..., balance = TRUE )
pop |
an object of |
nInd |
the number of individuals to select. These individuals are selected without regards to sex and it supercedes 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. |
nCrosses |
total number of crosses to make |
nProgeny |
number of progeny per cross |
trait |
the trait for selection. Either a number indicating a single trait or a function returning a vector of length nInd. |
use |
select on genetic values "gv", estimated breeding values "ebv", breeding values "bv", phenotypes "pheno", or randomly "rand" |
selectTop |
selects highest values if true. Selects lowest values if false. |
simParam |
an object of |
... |
additional arguments if using a function for trait |
balance |
if using sexes, this option will balance the number of progeny per parent. This argument occurs after ..., so the argument name must be matched exactly. |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Select 4 individuals and make 8 crosses pop2 = selectCross(pop, nInd=4, nCrosses=8, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Select 4 individuals and make 8 crosses pop2 = selectCross(pop, nInd=4, nCrosses=8, simParam=SP)
Selects a subset of full-sib families from a population.
selectFam( pop, nFam, trait = 1, use = "pheno", sex = "B", famType = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
selectFam( pop, nFam, trait = 1, use = "pheno", sex = "B", famType = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
pop |
and object of |
nFam |
the number of families to select |
trait |
the trait for selection. Either a number indicating
a single trait or a function returning a vector of length nInd.
The function must work on a vector or matrix of |
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.
The function must work on |
sex |
which sex to select. Use "B" for both, "F" for females and "M" for males. If the simulation is not using sexes, the argument is ignored. |
famType |
which type of family to select. Use "B" for full-sib families, "F" for half-sib families on female side and "M" for half-sib families on the male side. |
selectTop |
selects highest values if true. Selects lowest values if false. |
returnPop |
should results be returned as a
|
candidates |
an optional vector of eligible selection candidates. |
simParam |
an object of |
... |
additional arguments if using a function for
|
Returns an object of Pop-class
,
HybridPop-class
or MultiPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create 3 biparental families with 10 progeny pop2 = randCross(pop, nCrosses=3, nProgeny=10, simParam=SP) #Select best 2 families pop3 = selectFam(pop2, 2, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create 3 biparental families with 10 progeny pop2 = randCross(pop, nCrosses=3, nProgeny=10, simParam=SP) #Select best 2 families pop3 = selectFam(pop2, 2, simParam=SP)
Selects a subset of nInd individuals from a population.
selectInd( pop, nInd, trait = 1, use = "pheno", sex = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
selectInd( pop, nInd, trait = 1, use = "pheno", sex = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
pop |
and object of |
nInd |
the number of individuals to select |
trait |
the trait for selection. Either a number indicating
a single trait or a function returning a vector of length nInd.
The function must work on a vector or matrix of |
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.
The function must work on |
sex |
which sex to select. Use "B" for both, "F" for females and "M" for males. If the simulation is not using sexes, the argument is ignored. |
selectTop |
selects highest values if true. Selects lowest values if false. |
returnPop |
should results be returned as a
|
candidates |
an optional vector of eligible selection candidates. |
simParam |
an object of |
... |
additional arguments if using a function for
|
Returns an object of Pop-class
,
HybridPop-class
or MultiPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Select top 5 (directional selection) pop2 = selectInd(pop, 5, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop2@pheno, col="red", lwd=2) #Select 5 most deviating from an optima (disruptive selection) squaredDeviation = function(x, optima=0) (x - optima)^2 pop3 = selectInd(pop, 5, trait=squaredDeviation, selectTop=TRUE, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop3@pheno, col="red", lwd=2) #Select 5 least deviating from an optima (stabilising selection) pop4 = selectInd(pop, 5, trait=squaredDeviation, selectTop=FALSE, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop4@pheno, col="red", lwd=2) #Select 5 individuals based on miscelaneous information with use function pop@misc = list(smth=rnorm(10), smth2=rnorm(10)) useFunc = function(pop, trait=NULL) pop@misc$smth + pop@misc$smth2 pop5 = selectInd(pop, 5, use=useFunc, simParam=SP) pop5@id #... equivalent result with the use & trait function useFunc2 = function(pop, trait=NULL) cbind(pop@misc$smth, pop@misc$smth2) trtFunc = function(x) rowSums(x) pop6 = selectInd(pop, 5, trait=trtFunc, use=useFunc2, simParam=SP) pop6@id
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Select top 5 (directional selection) pop2 = selectInd(pop, 5, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop2@pheno, col="red", lwd=2) #Select 5 most deviating from an optima (disruptive selection) squaredDeviation = function(x, optima=0) (x - optima)^2 pop3 = selectInd(pop, 5, trait=squaredDeviation, selectTop=TRUE, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop3@pheno, col="red", lwd=2) #Select 5 least deviating from an optima (stabilising selection) pop4 = selectInd(pop, 5, trait=squaredDeviation, selectTop=FALSE, simParam=SP) hist(pop@pheno); abline(v=pop@pheno, lwd=2) abline(v=pop4@pheno, col="red", lwd=2) #Select 5 individuals based on miscelaneous information with use function pop@misc = list(smth=rnorm(10), smth2=rnorm(10)) useFunc = function(pop, trait=NULL) pop@misc$smth + pop@misc$smth2 pop5 = selectInd(pop, 5, use=useFunc, simParam=SP) pop5@id #... equivalent result with the use & trait function useFunc2 = function(pop, trait=NULL) cbind(pop@misc$smth, pop@misc$smth2) trtFunc = function(x) rowSums(x) pop6 = selectInd(pop, 5, trait=trtFunc, use=useFunc2, simParam=SP) pop6@id
This function models selection in an open pollinating plant population. It allows for varying the percentage of selfing. The function also provides an option for modeling selection as occuring before or after pollination.
selectOP( pop, nInd, nSeeds, probSelf = 0, pollenControl = FALSE, trait = 1, use = "pheno", selectTop = TRUE, candidates = NULL, simParam = NULL, ... )
selectOP( pop, nInd, nSeeds, probSelf = 0, pollenControl = FALSE, trait = 1, use = "pheno", selectTop = TRUE, candidates = NULL, simParam = NULL, ... )
pop |
and object of |
nInd |
the number of plants to select |
nSeeds |
number of seeds per plant |
probSelf |
percentage of seeds expected from selfing. Value ranges from 0 to 1. |
pollenControl |
are plants selected before pollination |
trait |
the trait for selection. Either a number indicating
a single trait or a function returning a vector of length nInd.
The function must work on a vector or matrix of |
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.
The function must work on |
selectTop |
selects highest values if true. Selects lowest values if false. |
candidates |
an optional vector of eligible selection candidates. |
simParam |
an object of |
... |
additional arguments if using a function for
|
Returns an object of Pop-class
or MultiPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create new population by selecting the best 3 plant #Assuming 50% selfing in plants and 10 seeds per plant pop2 = selectOP(pop, nInd=3, nSeeds=10, probSelf=0.5, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create new population by selecting the best 3 plant #Assuming 50% selfing in plants and 10 seeds per plant pop2 = selectOP(pop, nInd=3, nSeeds=10, probSelf=0.5, simParam=SP)
Selects a subset of nInd individuals from each full-sib family within a population. Will return all individuals from a full-sib family if it has less than or equal to nInd individuals.
selectWithinFam( pop, nInd, trait = 1, use = "pheno", sex = "B", famType = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
selectWithinFam( pop, nInd, trait = 1, use = "pheno", sex = "B", famType = "B", selectTop = TRUE, returnPop = TRUE, candidates = NULL, simParam = NULL, ... )
pop |
and object of |
nInd |
the number of individuals to select within a family |
trait |
the trait for selection. Either a number indicating
a single trait or a function returning a vector of length nInd.
The function must work on a vector or matrix of |
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.
The function must work on |
sex |
which sex to select. Use "B" for both, "F" for females and "M" for males. If the simulation is not using sexes, the argument is ignored. |
famType |
which type of family to select. Use "B" for full-sib families, "F" for half-sib families on female side and "M" for half-sib families on the male side. |
selectTop |
selects highest values if true. Selects lowest values if false. |
returnPop |
should results be returned as a
|
candidates |
an optional vector of eligible selection candidates. |
simParam |
an object of |
... |
additional arguments if using a function for
|
Returns an object of Pop-class
,
HybridPop-class
or MultiPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create 3 biparental families with 10 progeny pop2 = randCross(pop, nCrosses=3, nProgeny=10, simParam=SP) #Select best individual per family pop3 = selectWithinFam(pop2, 1, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) #Create 3 biparental families with 10 progeny pop2 = randCross(pop, nCrosses=3, nProgeny=10, simParam=SP) #Select best individual per family pop3 = selectWithinFam(pop2, 1, simParam=SP)
Creates selfed progeny from each individual in a population. Only works when sexes is "no".
self(pop, nProgeny = 1, parents = NULL, keepParents = TRUE, simParam = NULL)
self(pop, nProgeny = 1, parents = NULL, keepParents = TRUE, simParam = NULL)
pop |
an object of |
nProgeny |
total number of selfed progeny per individual |
parents |
an optional vector of indices for allowable parents |
keepParents |
should previous parents be used for mother and father. |
simParam |
an object of |
Returns an object of Pop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Self pollinate each individual pop2 = self(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) #Self pollinate each individual pop2 = self(pop, simParam=SP)
Calculates values of a selection index given trait values and
weights. This function is intended to be used in combination with
selection functions working on populations such as
selectInd
.
selIndex(Y, b, scale = FALSE)
selIndex(Y, b, scale = FALSE)
Y |
a matrix of trait values |
b |
a vector of weights |
scale |
should Y be scaled and centered |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Model two genetically correlated traits G = 1.5*diag(2)-0.5 #Genetic correlation matrix SP$addTraitA(10, mean=c(0,0), var=c(1,1), corA=G) SP$setVarE(h2=c(0.5,0.5)) #Create population pop = newPop(founderPop, simParam=SP) #Calculate Smith-Hazel weights econWt = c(1, 1) b = smithHazel(econWt, varG(pop), varP(pop)) #Selection 2 best individuals using Smith-Hazel index #selIndex is used as a trait pop2 = selectInd(pop, nInd=2, trait=selIndex, simParam=SP, b=b)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Model two genetically correlated traits G = 1.5*diag(2)-0.5 #Genetic correlation matrix SP$addTraitA(10, mean=c(0,0), var=c(1,1), corA=G) SP$setVarE(h2=c(0.5,0.5)) #Create population pop = newPop(founderPop, simParam=SP) #Calculate Smith-Hazel weights econWt = c(1, 1) b = smithHazel(econWt, varG(pop), varP(pop)) #Selection 2 best individuals using Smith-Hazel index #selIndex is used as a trait pop2 = selectInd(pop, nInd=2, trait=selIndex, simParam=SP, b=b)
Calculates the standardized selection intensity
selInt(p)
selInt(p)
p |
the proportion of individuals selected |
selInt(0.1)
selInt(0.1)
Adds genomic estimated values to a populations's EBV slot using output from a genomic selection functions. The genomic estimated values can be either estimated breeding values, estimated genetic values, or estimated general combining values.
setEBV( pop, solution, value = "gv", targetPop = NULL, append = FALSE, simParam = NULL )
setEBV( pop, solution, value = "gv", targetPop = NULL, append = FALSE, simParam = NULL )
pop |
an object of |
solution |
an object of |
value |
the genomic value to be estimated. Can be either "gv", "bv", "female", or "male". |
targetPop |
an optional target population that can be used when value is "bv", "female", or "male". When supplied, the allele frequency in the targetPop is used to set these values. |
append |
should estimated values be appended to existing data in the EBV slot. If TRUE, a new column is added. If FALSE, existing data is replaced with the new estimates. |
simParam |
an object of |
Returns an object of Pop-class
#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) #Run GS model and set EBV ans = RRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
#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) #Run GS model and set EBV ans = RRBLUP(pop, simParam=SP) pop = setEBV(pop, ans, simParam=SP) #Evaluate accuracy cor(gv(pop), ebv(pop))
Manually sets the haplotypes in a population for all individuals at one or more loci.
setMarkerHaplo(pop, haplo, simParam = NULL)
setMarkerHaplo(pop, haplo, simParam = NULL)
pop |
an object of |
haplo |
a matrix of haplotypes, see details |
simParam |
an object of |
The format of the haplotype matrix should match
the format of the output from pullMarkerHaplo
with the option haplo="all". Thus, it is recommended that this
function is first used to extract the haplotypes and that any
desired changes be made to the output of pullMarkerHaplo before
passing the matrix to setMarkerHaplo. Any changes made to QTL
may potentially result in changes to an individuals genetic
value. These changes will be reflected in the gv and/or gxe slot.
All other slots will remain unchanged, so the ebv and pheno slots
will not reflect the new genotypes.
an object of the same class as the "pop" input
# Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) # Extract haplotypes for marker "1_1" H = pullMarkerHaplo(founderPop, markers="1_1") # Set the first haplotype to 1 H[1,1] = 1L # Set marker haplotypes founderPop = setMarkerHaplo(founderPop, haplo=H)
# Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) # Extract haplotypes for marker "1_1" H = pullMarkerHaplo(founderPop, markers="1_1") # Set the first haplotype to 1 H[1,1] = 1L # Set marker haplotypes founderPop = setMarkerHaplo(founderPop, haplo=H)
Sets phenotypes for all traits by adding random error from a multivariate normal distribution.
setPheno( pop, h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, onlyPheno = FALSE, traits = NULL, simParam = NULL )
setPheno( pop, h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, onlyPheno = FALSE, traits = NULL, simParam = NULL )
pop |
an object of |
h2 |
a vector of desired narrow-sense heritabilities for each trait. See details. |
H2 |
a vector of desired broad-sense heritabilities for each trait. See details. |
varE |
error (co)variances for traits. See details. |
corE |
an optional matrix for correlations between errors. See details. |
reps |
number of replications for phenotype. See details. |
fixEff |
fixed effect to assign to the population. Used by genomic selection models only. |
p |
the p-value for the environmental covariate used by GxE traits. If NULL, a value is sampled at random. |
onlyPheno |
should only the phenotype be returned, see return |
traits |
an integer vector indicate which traits to set. If NULL, all traits will be set. |
simParam |
an object of |
There are three arguments for setting the error variance of a phenotype: h2, H2, and varE. The user should only use one of these arguments. If the user supplies values for more than one, only one will be used according to order in which they are listed above.
The h2 argument allows the user to specify the error variance according to narrow-sense heritability. This calculation uses the additive genetic variance and total genetic variance in the founder population. Thus, the heritability relates to the founder population and not the current population.
The H2 argument allows the user to specify the error variance according to broad-sense heritability. This calculation uses the total genetic variance in the founder population. Thus, the heritability relates to the founder population and not the current population.
The varE argument allows the user to specify the error variance directly. The user may supply a vector describing the error variance for each trait or supply a matrix that specify the covariance of the errors.
The corE argument allows the user to specify correlations for the error covariance matrix. These correlations are be supplied in addition to the h2, H2, or varE arguments. These correlations will be used to construct a covariance matrix from a vector of variances. If the user supplied a covariance matrix to varE, these correlations will supercede values provided in that matrix.
The reps parameter is for convenient representation of replicated data. It is intended to represent replicated yield trials in plant breeding programs. In this case, varE is set to the plot error and reps is set to the number of plots per entry. The resulting phenotype represents the entry-means.
Returns an object of Pop-class
or
HybridPop-class
if onlyPheno=FALSE, if
onlyPheno=TRUE a matrix is returned
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Add phenotype with error variance of 1 pop = setPheno(pop, varE=1)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Add phenotype with error variance of 1 pop = setPheno(pop, varE=1)
Calculates general combining ability from a set of testers and returns these values as phenotypes for a population.
setPhenoGCA( pop, testers, use = "pheno", h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, inbred = FALSE, onlyPheno = FALSE, simParam = NULL )
setPhenoGCA( pop, testers, use = "pheno", h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, inbred = FALSE, onlyPheno = FALSE, simParam = NULL )
pop |
an object of |
testers |
an object of |
use |
true genetic value ( |
h2 |
a vector of desired narrow-sense heritabilities for
each trait. See details in |
H2 |
a vector of desired broad-sense heritabilities for
each trait. See details in |
varE |
error (co)variances for traits.
See details in |
corE |
an optional matrix for correlations between errors.
See details in |
reps |
number of replications for phenotype.
See details in |
fixEff |
fixed effect to assign to the population. Used by genomic selection models only. |
p |
the p-value for the environmental covariate used by GxE traits. If NULL, a value is sampled at random. |
inbred |
are both pop and testers fully inbred. They are only
fully inbred if created by |
onlyPheno |
should only the phenotype be returned, see return |
simParam |
an object of |
Returns an object of Pop-class
or
a matrix if onlyPheno=TRUE
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Set phenotype to average per pop2 = setPhenoGCA(pop, pop, use="gv", inbred=TRUE, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Set phenotype to average per pop2 = setPhenoGCA(pop, pop, use="gv", inbred=TRUE, simParam=SP)
Models a progeny test of individuals in 'pop'. Returns 'pop' with a phenotype representing the average performance of their progeny. The phenotype is generated by mating individuals in 'pop' to randomly chosen individuals in testPop a number of times equal to 'nMatePerInd'.
setPhenoProgTest( pop, testPop, nMatePerInd = 1L, use = "pheno", h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, onlyPheno = FALSE, simParam = NULL )
setPhenoProgTest( pop, testPop, nMatePerInd = 1L, use = "pheno", h2 = NULL, H2 = NULL, varE = NULL, corE = NULL, reps = 1, fixEff = 1L, p = NULL, onlyPheno = FALSE, simParam = NULL )
pop |
an object of |
testPop |
an object of |
nMatePerInd |
number of times an individual in 'pop' is mated to an individual in testPop |
use |
true genetic value ( |
h2 |
a vector of desired narrow-sense heritabilities for
each trait. See details in |
H2 |
a vector of desired broad-sense heritabilities for
each trait. See details in |
varE |
error (co)variances for traits.
See details in |
corE |
an optional matrix for correlations between errors.
See details in |
reps |
number of replications for phenotype.
See details in |
fixEff |
fixed effect to assign to the population. Used by genomic selection models only. |
p |
the p-value for the environmental covariate used by GxE traits. If NULL, a value is sampled at random. |
onlyPheno |
should only the phenotype be returned, see return |
simParam |
an object of |
The reps parameter is for convenient representation of replicated data. It was intended for representation of replicated yield trials in plant breeding programs. In this case, varE is set to the plot error and reps is set to the number plots per entry. The resulting phenotype would reflect the mean of all replications.
Returns an object of Pop-class
or
a matrix if onlyPheno=TRUE
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create two populations of 5 individuals pop1 = newPop(founderPop[1:5], simParam=SP) pop2 = newPop(founderPop[6:10], simParam=SP) #Set phenotype according to a progeny test pop3 = setPhenoProgTest(pop1, pop2, use="gv", simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10, inbred=TRUE) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create two populations of 5 individuals pop1 = newPop(founderPop[1:5], simParam=SP) pop2 = newPop(founderPop[6:10], simParam=SP) #Set phenotype according to a progeny test pop3 = setPhenoProgTest(pop1, pop2, use="gv", simParam=SP)
Container for global simulation parameters. Saving this object as SP will allow it to be accessed by function defaults.
nThreads
number of threads used on platforms with OpenMP support
snpChips
list of SNP chips
invalidQtl
list of segregating sites that aren't valid QTL
invalidSnp
list of segregating sites that aren't valid SNP
founderPop
founder population used for variance scaling
finalizePop
function applied to newly created populations. Currently does nothing and should only be changed by expert users.
allowEmptyPop
if true, population arguments with nInd=0 will return an empty population with a warning instead of an error.
v
the crossover interference parameter for a gamma model of recombination. A value of 1 indicates no crossover interference (e.g. Haldane mapping function). A value of 2.6 approximates the degree of crossover interference implied by the Kosambi mapping function. (default is 2.6)
p
the proportion of crossovers coming from a non-interfering pathway. (default is 0)
quadProb
the probability of quadrivalent pairing in an autopolyploid. (default is 0)
traitNames
vector of trait names
snpChipNames
vector of chip names
traits
list of traits
nChr
number of chromosomes
nTraits
number of traits
nSnpChips
number of SNP chips
segSites
segregating sites per chromosome
sexes
sexes used for mating
sepMap
are there seperate genetic maps for males and females
genMap
"matrix" of chromosome genetic maps
femaleMap
"matrix" of chromosome genetic maps for females
maleMap
"matrix" of chromosome genetic maps for males
centromere
position of centromeres genetic map
femaleCentromere
position of centromeres on female genetic map
maleCentromere
position of centromeres on male genetic map
lastId
last ID number assigned
isTrackPed
is pedigree being tracked
pedigree
pedigree matrix for all individuals
isTrackRec
is recombination being tracked
recHist
list of historic recombination events
haplotypes
list of computed IBD haplotypes
varA
additive genetic variance in founderPop
varG
total genetic variance in founderPop
varE
default error variance
version
the version of AlphaSimR used to generate this object
new()
Starts the process of building a new simulation by creating a new SimParam object and assigning a founder population to the class. It is recommended that you save the object with the name "SP", because subsequent functions will check your global environment for an object of this name if their simParam arguments are NULL. This allows you to call these functions without explicitly supplying a simParam argument with every call.
SimParam$new(founderPop)
founderPop
an object of MapPop-class
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop)
setTrackPed()
Sets pedigree tracking for the simulation.
By default pedigree tracking is turned off. When turned on,
the pedigree of all individuals created will be tracked,
except those created by hybridCross
. Turning
off pedigree tracking will turn off recombination tracking
if it is turned on.
SimParam$setTrackPed(isTrackPed, force = FALSE)
isTrackPed
should pedigree tracking be on.
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setTrackPed(TRUE)
setTrackRec()
Sets recombination tracking for the simulation.
By default recombination tracking is turned off. When turned
on recombination tracking will also turn on pedigree tracking.
Recombination tracking keeps records of all individuals created,
except those created by hybridCross
, because their
pedigree is not tracked.
SimParam$setTrackRec(isTrackRec, force = FALSE)
isTrackRec
should recombination tracking be on.
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setTrackRec(TRUE)
resetPed()
Resets the internal lastId, the pedigree and recombination tracking (if in use) to the supplied lastId. Be careful using this function because it may introduce a bug if you use individuals from the deleted portion of the pedigree.
SimParam$resetPed(lastId = 0L)
lastId
last ID to include in pedigree
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} #Create population pop = newPop(founderPop, simParam=SP) pop@id # 1:10 #Create another population after reseting pedigree SP$resetPed() pop2 = newPop(founderPop, simParam=SP) pop2@id # 1:10
restrSegSites()
Sets restrictions on which segregating sites can serve as a SNP and/or QTL.
SimParam$restrSegSites( minQtlPerChr = NULL, minSnpPerChr = NULL, excludeQtl = NULL, excludeSnp = NULL, overlap = FALSE, minSnpFreq = NULL )
minQtlPerChr
the minimum number of segregating sites for QTLs. Can be a single value or a vector values for each chromosome.
minSnpPerChr
the minimum number of segregating sites for SNPs. Can be a single value or a vector values for each chromosome.
excludeQtl
an optional vector of segregating site names to exclude from consideration as a viable QTL.
excludeSnp
an optional vector of segregating site names to exclude from consideration as a viable SNP.
overlap
should SNP and QTL sites be allowed to overlap.
minSnpFreq
minimum allowable frequency for SNP loci. No minimum SNP frequency is used if value is NULL.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$restrSegSites(minQtlPerChr=5, minSnpPerChr=5)
setSexes()
Changes how sexes are determined in the simulation. The default sexes is "no", indicating all individuals are hermaphrodites. To add sexes to the simulation, run this function with "yes_sys" or "yes_rand". The value "yes_sys" will systematically assign sexes to newly created individuals as first male and then female. Populations with an odd number of individuals will have one more male than female. The value "yes_rand" will randomly assign a sex to each individual.
SimParam$setSexes(sexes, force = FALSE)
sexes
acceptable value are "no", "yes_sys", or "yes_rand"
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setSexes("yes_sys")
setFounderHap()
Allows for the manual setting of founder haplotypes. This functionality is not fully documented, because it is still experimental.
SimParam$setFounderHap(hapMap)
hapMap
a list of founder haplotypes
addSnpChip()
Randomly assigns eligible SNPs to a SNP chip
SimParam$addSnpChip(nSnpPerChr, minSnpFreq = NULL, refPop = NULL, name = NULL)
nSnpPerChr
number of SNPs per chromosome. Can be a single value or nChr values.
minSnpFreq
minimum allowable frequency for SNP loci. If NULL, no minimum frequency is used.
refPop
reference population for calculating SNP frequency. If NULL, the founder population is used.
name
optional name for chip
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addSnpChip(10)
addSnpChipByName()
Assigns SNPs to a SNP chip by supplying marker names. This function does check against excluded SNPs and will not add the SNPs to the list of excluded QTL for the purpose of avoiding overlap between SNPs and QTL. Excluding these SNPs from being used as QTL can be accomplished using the excludeQtl argument in SimParam's restrSegSites function.
SimParam$addSnpChipByName(markers, name = NULL)
markers
a vector of names for the markers
name
optional name for chip
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChipByName(c("1_1","1_3"))
addStructuredSnpChip()
Randomly selects the number of snps in structure and then assigns them to chips based on structure
SimParam$addStructuredSnpChip(nSnpPerChr, structure, force = FALSE)
nSnpPerChr
number of SNPs per chromosome. Can be a single value or nChr values.
structure
a matrix. Rows are snp chips, columns are chips. If value is true then that snp is on that chip.
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
addTraitA()
Randomly assigns eligible QTLs for one or more additive traits. If simulating more than one trait, all traits will be pleiotropic with correlated additive effects.
SimParam$addTraitA( nQtlPerChr, mean = 0, var = 1, corA = NULL, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
corA
a matrix of correlations between additive effects
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitA(10)
addTraitAD()
Randomly assigns eligible QTLs for one or more traits with dominance. If simulating more than one trait, all traits will be pleiotropic with correlated effects.
SimParam$addTraitAD( nQtlPerChr, mean = 0, var = 1, meanDD = 0, varDD = 0, corA = NULL, corDD = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
meanDD
mean dominance degree
varDD
variance of dominance degree
corA
a matrix of correlations between additive effects
corDD
a matrix of correlations between dominance degrees
useVarA
tune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitAD(10, meanDD=0.5)
altAddTraitAD()
An alternative method for adding a trait with additive and dominance effects to an AlphaSimR simulation. The function attempts to create a trait matching user defined values for number of QTL, inbreeding depression, additive genetic variance and dominance genetic variance.
SimParam$altAddTraitAD( nQtlPerChr, mean = 0, varA = 1, varD = 0, inbrDepr = 0, limMeanDD = c(0, 1.5), limVarDD = c(0, 0.5), silent = FALSE, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
desired mean of the trait
varA
desired additive variance
varD
desired dominance variance
inbrDepr
desired inbreeding depression, see details
limMeanDD
limits for meanDD, see details
limVarDD
limits for varDD, see details
silent
should summary details be printed to the console
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait
This function will always add a trait to 'SimParam', unless an error occurs with picking QTLs. The resulting trait will always have the desired mean and additive genetic variance. However, it may not have the desired values for inbreeding depression and dominance variance. Thus, it is strongly recommended to check the output printed to the console to determine how close the trait's parameters came to these desired values.
The mean and additive genetic variance will always be achieved exactly. The function attempts to achieve the desired dominance variance and inbreeding depression while staying within the user supplied constraints for the acceptable range of dominance degree mean and variance. If the desired values are not being achieved, the acceptable range need to be increased and/or the number of QTL may need to be increased. There are not limits to setting the range for dominance degree mean and variance, but care should be taken to with regards to the biological feasibility of the limits that are supplied. The default limits were somewhat arbitrarily set, so I make not claim to how reasonable these limits are for routine use.
Inbreeding depression in this function is defined as the difference in mean genetic value between a population with the same allele frequency as the reference population (population used to initialize SimParam) in Hardy-Weinberg equilibrium compared to a population with the same allele frequency that is fully inbred. This is equivalent to the amount the mean of a population increases when going from an inbreeding coefficient of 1 (fully inbred) to a population with an inbreeding coefficient of 0 (Hardy-Weinberg equilibrium). Note that the sign of the value should (usually) be positive. This corresponds to a detrimental effect of inbreeding when higher values of the trait are considered biologically beneficial.
Summary information on this trait is printed to the console when silent=FALSE. The summary information reports the inbreeding depression and dominance variance for the population as well as the dominance degree mean and variance applied to the trait.
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$altAddTraitAD(nQtlPerChr=10, mean=0, varA=1, varD=0.05, inbrDepr=0.2)
addTraitAG()
Randomly assigns eligible QTLs for one or more additive GxE traits. If simulating more than one trait, all traits will be pleiotropic with correlated effects.
SimParam$addTraitAG( nQtlPerChr, mean = 0, var = 1, varGxE = 1e-06, varEnv = 0, corA = NULL, corGxE = NULL, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
varGxE
a vector of total genotype-by-environment variances for the traits
varEnv
a vector of environmental variances for one or more traits
corA
a matrix of correlations between additive effects
corGxE
a matrix of correlations between GxE effects
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitAG(10, varGxE=2)
addTraitADG()
Randomly assigns eligible QTLs for a trait with dominance and GxE.
SimParam$addTraitADG( nQtlPerChr, mean = 0, var = 1, varEnv = 0, varGxE = 1e-06, meanDD = 0, varDD = 0, corA = NULL, corDD = NULL, corGxE = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
varEnv
a vector of environmental variances for one or more traits
varGxE
a vector of total genotype-by-environment variances for the traits
meanDD
mean dominance degree
varDD
variance of dominance degree
corA
a matrix of correlations between additive effects
corDD
a matrix of correlations between dominance degrees
corGxE
a matrix of correlations between GxE effects
useVarA
tune according to additive genetic variance if true
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitADG(10, meanDD=0.5, varGxE=2)
addTraitAE()
Randomly assigns eligible QTLs for one or more additive and epistasis traits. If simulating more than one trait, all traits will be pleiotropic with correlated additive effects.
SimParam$addTraitAE( nQtlPerChr, mean = 0, var = 1, relAA = 0, corA = NULL, corAA = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
relAA
the relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corA
a matrix of correlations between additive effects
corAA
a matrix of correlations between additive-by-additive effects
useVarA
tune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitAE(10, relAA=0.1)
addTraitADE()
Randomly assigns eligible QTLs for one or more traits with dominance and epistasis. If simulating more than one trait, all traits will be pleiotropic with correlated effects.
SimParam$addTraitADE( nQtlPerChr, mean = 0, var = 1, meanDD = 0, varDD = 0, relAA = 0, corA = NULL, corDD = NULL, corAA = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
meanDD
mean dominance degree
varDD
variance of dominance degree
relAA
the relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corA
a matrix of correlations between additive effects
corDD
a matrix of correlations between dominance degrees
corAA
a matrix of correlations between additive-by-additive effects
useVarA
tune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitADE(10)
addTraitAEG()
Randomly assigns eligible QTLs for one or more additive and epistasis GxE traits. If simulating more than one trait, all traits will be pleiotropic with correlated effects.
SimParam$addTraitAEG( nQtlPerChr, mean = 0, var = 1, relAA = 0, varGxE = 1e-06, varEnv = 0, corA = NULL, corAA = NULL, corGxE = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
relAA
the relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
varGxE
a vector of total genotype-by-environment variances for the traits
varEnv
a vector of environmental variances for one or more traits
corA
a matrix of correlations between additive effects
corAA
a matrix of correlations between additive-by-additive effects
corGxE
a matrix of correlations between GxE effects
useVarA
tune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitAEG(10, varGxE=2)
addTraitADEG()
Randomly assigns eligible QTLs for a trait with dominance, epistasis and GxE.
SimParam$addTraitADEG( nQtlPerChr, mean = 0, var = 1, varEnv = 0, varGxE = 1e-06, meanDD = 0, varDD = 0, relAA = 0, corA = NULL, corDD = NULL, corAA = NULL, corGxE = NULL, useVarA = TRUE, gamma = FALSE, shape = 1, force = FALSE, name = NULL )
nQtlPerChr
number of QTLs per chromosome. Can be a single value or nChr values.
mean
a vector of desired mean genetic values for one or more traits
var
a vector of desired genetic variances for one or more traits
varEnv
a vector of environmental variances for one or more traits
varGxE
a vector of total genotype-by-environment variances for the traits
meanDD
mean dominance degree
varDD
variance of dominance degree
relAA
the relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corA
a matrix of correlations between additive effects
corDD
a matrix of correlations between dominance degrees
corAA
a matrix of correlations between additive-by-additive effects
corGxE
a matrix of correlations between GxE effects
useVarA
tune according to additive genetic variance if true
gamma
should a gamma distribution be used instead of normal
shape
the shape parameter for the gamma distribution (the rate/scale parameter of the gamma distribution is accounted for via the desired level of genetic variance, the var argument)
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
name
optional name for trait(s)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitADEG(10, meanDD=0.5, varGxE=2)
manAddTrait()
Manually add a new trait to the simulation. Trait must
be formatted as a LociMap-class
. If the
trait is not already formatted, consider using importTrait.
SimParam$manAddTrait(lociMap, varE = NA_real_, force = FALSE)
lociMap
a new object descended from
LociMap-class
varE
default error variance for phenotype, optional
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
importTrait()
Manually add a new trait(s) to the simulation. Unlike the
manAddTrait function, this function does not require
formatting the trait as a LociMap-class
.
The formatting is performed automatically for the user,
with more user friendly data.frames or matrices taken as
inputs. This function only works for A and AD trait types.
SimParam$importTrait( markerNames, addEff, domEff = NULL, intercept = NULL, name = NULL, varE = NULL, force = FALSE )
markerNames
a vector of names for the QTL
addEff
a matrix of additive effects (nLoci x nTraits). Alternatively, a vector of length nLoci can be supplied for a single trait.
domEff
optional dominance effects for each locus
intercept
optional intercepts for each trait
name
optional name(s) for the trait(s)
varE
default error variance for phenotype, optional
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
switchTrait()
Switch a trait in the simulation.
SimParam$switchTrait(traitPos, lociMap, varE = NA_real_, force = FALSE)
traitPos
an integer indicate which trait to switch
lociMap
a new object descended from
LociMap-class
varE
default error variance for phenotype, optional
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
removeTrait()
Remove a trait from the simulation
SimParam$removeTrait(traits, force = FALSE)
traits
an integer vector indicating which traits to remove
force
should the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
setVarE()
Defines a default values for error
variances used in setPheno
. These defaults
will be used to automatically generate phenotypes when new
populations are created. See the details section of setPheno
for more information about each arguments and how they
should be used.
SimParam$setVarE(h2 = NULL, H2 = NULL, varE = NULL, corE = NULL)
h2
a vector of desired narrow-sense heritabilities
H2
a vector of desired broad-sense heritabilities
varE
a vector or matrix of error variances
corE
an optional matrix of error correlations
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitA(10) SP$setVarE(h2=0.5)
setCorE()
Defines a correlation structure for default
error variances. You must call setVarE
first to define
the default error variances.
SimParam$setCorE(corE)
corE
a correlation matrix for the error variances
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$addTraitA(10, mean=c(0,0), var=c(1,1), corA=diag(2)) SP$setVarE(varE=c(1,1)) E = 0.5*diag(2)+0.5 #Positively correlated error SP$setCorE(E)
rescaleTraits()
Linearly scales all traits to achieve desired values of means and variances in the founder population.
SimParam$rescaleTraits( mean = 0, var = 1, varEnv = 0, varGxE = 1e-06, useVarA = TRUE )
mean
a vector of new trait means
var
a vector of new trait variances
varEnv
a vector of new environmental variances
varGxE
a vector of new GxE variances
useVarA
tune according to additive genetic variance if true
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) meanG(pop) #Change mean to 1 SP$rescaleTraits(mean=1) \dontshow{SP$nThreads = 1L} #Run resetPop for change to take effect pop = resetPop(pop, simParam=SP) meanG(pop)
setRecombRatio()
Set the relative recombination rates between males and females. This allows for sex-specific recombination rates, under the assumption of equivalent recombination landscapes.
SimParam$setRecombRatio(femaleRatio)
femaleRatio
relative ratio of recombination in females compared to males. A value of 2 indicate twice as much recombination in females. The value must be greater than 0. (default is 1)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setRecombRatio(2) #Twice as much recombination in females
switchGenMap()
Replaces existing genetic map.
SimParam$switchGenMap(genMap, centromere = NULL)
genMap
a list of length nChr containing numeric vectors for the position of each segregating site on a chromosome.
centromere
a numeric vector of centromere positions. If NULL, the centromere are assumed to be metacentric.
switchFemaleMap()
Replaces existing female genetic map.
SimParam$switchFemaleMap(genMap, centromere = NULL)
genMap
a list of length nChr containing numeric vectors for the position of each segregating site on a chromosome.
centromere
a numeric vector of centromere positions. If NULL, the centromere are assumed to be metacentric.
switchMaleMap()
Replaces existing male genetic map.
SimParam$switchMaleMap(genMap, centromere = NULL)
genMap
a list of length nChr containing numeric vectors for the position of each segregating site on a chromosome.
centromere
a numeric vector of centromere positions. If NULL, the centromere are assumed to be metacentric.
addToRec()
For internal use only.
SimParam$addToRec(lastId, id, mother, father, isDH, hist, ploidy)
lastId
ID of last individual
id
the name of each individual
mother
vector of mother iids
father
vector of father iids
isDH
indicator for DH lines
hist
new recombination history
ploidy
ploidy level
ibdHaplo()
For internal use only.
SimParam$ibdHaplo(iid)
iid
internal ID
updateLastId()
For internal use only.
SimParam$updateLastId(lastId)
lastId
last ID assigned
addToPed()
For internal use only.
SimParam$addToPed(lastId, id, mother, father, isDH)
lastId
ID of last individual
id
the name of each individual
mother
vector of mother iids
father
vector of father iids
isDH
indicator for DH lines
clone()
The objects of this class are cloneable with this method.
SimParam$clone(deep = FALSE)
deep
Whether to make a deep clone.
By default the founder population is the population used to
initalize the SimParam object. This population can be changed by
replacing the population in the founderPop slot. You must run
resetPop
on any existing populations to obtain the
new trait values.
## ------------------------------------------------ ## Method `SimParam$new` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) ## ------------------------------------------------ ## Method `SimParam$setTrackPed` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setTrackPed(TRUE) ## ------------------------------------------------ ## Method `SimParam$setTrackRec` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setTrackRec(TRUE) ## ------------------------------------------------ ## Method `SimParam$resetPed` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) pop@id # 1:10 #Create another population after reseting pedigree SP$resetPed() pop2 = newPop(founderPop, simParam=SP) pop2@id # 1:10 ## ------------------------------------------------ ## Method `SimParam$restrSegSites` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$restrSegSites(minQtlPerChr=5, minSnpPerChr=5) ## ------------------------------------------------ ## Method `SimParam$setSexes` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setSexes("yes_sys") ## ------------------------------------------------ ## Method `SimParam$addSnpChip` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChip(10) ## ------------------------------------------------ ## Method `SimParam$addSnpChipByName` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChipByName(c("1_1","1_3")) ## ------------------------------------------------ ## Method `SimParam$addTraitA` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) ## ------------------------------------------------ ## Method `SimParam$addTraitAD` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) ## ------------------------------------------------ ## Method `SimParam$altAddTraitAD` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$altAddTraitAD(nQtlPerChr=10, mean=0, varA=1, varD=0.05, inbrDepr=0.2) ## ------------------------------------------------ ## Method `SimParam$addTraitAG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAG(10, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitADG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADG(10, meanDD=0.5, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitAE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAE(10, relAA=0.1) ## ------------------------------------------------ ## Method `SimParam$addTraitADE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADE(10) ## ------------------------------------------------ ## Method `SimParam$addTraitAEG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAEG(10, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitADEG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADEG(10, meanDD=0.5, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$setVarE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) ## ------------------------------------------------ ## Method `SimParam$setCorE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10, mean=c(0,0), var=c(1,1), corA=diag(2)) SP$setVarE(varE=c(1,1)) E = 0.5*diag(2)+0.5 #Positively correlated error SP$setCorE(E) ## ------------------------------------------------ ## Method `SimParam$rescaleTraits` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) meanG(pop) #Change mean to 1 SP$rescaleTraits(mean=1) #Run resetPop for change to take effect pop = resetPop(pop, simParam=SP) meanG(pop) ## ------------------------------------------------ ## Method `SimParam$setRecombRatio` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setRecombRatio(2) #Twice as much recombination in females
## ------------------------------------------------ ## Method `SimParam$new` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) ## ------------------------------------------------ ## Method `SimParam$setTrackPed` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setTrackPed(TRUE) ## ------------------------------------------------ ## Method `SimParam$setTrackRec` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setTrackRec(TRUE) ## ------------------------------------------------ ## Method `SimParam$resetPed` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) #Create population pop = newPop(founderPop, simParam=SP) pop@id # 1:10 #Create another population after reseting pedigree SP$resetPed() pop2 = newPop(founderPop, simParam=SP) pop2@id # 1:10 ## ------------------------------------------------ ## Method `SimParam$restrSegSites` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$restrSegSites(minQtlPerChr=5, minSnpPerChr=5) ## ------------------------------------------------ ## Method `SimParam$setSexes` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setSexes("yes_sys") ## ------------------------------------------------ ## Method `SimParam$addSnpChip` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChip(10) ## ------------------------------------------------ ## Method `SimParam$addSnpChipByName` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addSnpChipByName(c("1_1","1_3")) ## ------------------------------------------------ ## Method `SimParam$addTraitA` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) ## ------------------------------------------------ ## Method `SimParam$addTraitAD` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) ## ------------------------------------------------ ## Method `SimParam$altAddTraitAD` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$altAddTraitAD(nQtlPerChr=10, mean=0, varA=1, varD=0.05, inbrDepr=0.2) ## ------------------------------------------------ ## Method `SimParam$addTraitAG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAG(10, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitADG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADG(10, meanDD=0.5, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitAE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAE(10, relAA=0.1) ## ------------------------------------------------ ## Method `SimParam$addTraitADE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADE(10) ## ------------------------------------------------ ## Method `SimParam$addTraitAEG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAEG(10, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$addTraitADEG` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitADEG(10, meanDD=0.5, varGxE=2) ## ------------------------------------------------ ## Method `SimParam$setVarE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) ## ------------------------------------------------ ## Method `SimParam$setCorE` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10, mean=c(0,0), var=c(1,1), corA=diag(2)) SP$setVarE(varE=c(1,1)) E = 0.5*diag(2)+0.5 #Positively correlated error SP$setCorE(E) ## ------------------------------------------------ ## Method `SimParam$rescaleTraits` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) meanG(pop) #Change mean to 1 SP$rescaleTraits(mean=1) #Run resetPop for change to take effect pop = resetPop(pop, simParam=SP) meanG(pop) ## ------------------------------------------------ ## Method `SimParam$setRecombRatio` ## ------------------------------------------------ #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$setRecombRatio(2) #Twice as much recombination in females
Calculates weights for Smith-Hazel index given economice weights and phenotypic and genotypic variance-covariance matrices.
smithHazel(econWt, varG, varP)
smithHazel(econWt, varG, varP)
econWt |
vector of economic weights |
varG |
the genetic variance-covariance matrix |
varP |
the phenotypic variance-covariance matrix |
a vector of weight for calculating index values
G = 1.5*diag(2)-0.5 E = diag(2) P = G+E wt = c(1,1) smithHazel(wt, G, P)
G = 1.5*diag(2)-0.5 E = diag(2) P = G+E wt = c(1,1) smithHazel(wt, G, P)
Solves a univariate mixed model with multiple random effects.
solveMKM(y, X, Zlist, Klist, maxIter = 40L, tol = 1e-04)
solveMKM(y, X, Zlist, Klist, maxIter = 40L, tol = 1e-04)
y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
Zlist |
a list of Z matrices |
Klist |
a list of K matrices |
maxIter |
maximum number of iteration |
tol |
tolerance for convergence |
Solves a multivariate mixed model of form
solveMVM(Y, X, Z, K, tol = 1e-06, maxIter = 1000L)
solveMVM(Y, X, Z, K, tol = 1e-06, maxIter = 1000L)
Y |
a matrix with n rows and q columns |
X |
a matrix with n rows and x columns |
Z |
a matrix with n rows and m columns |
K |
a matrix with m rows and m columns |
tol |
tolerance for convergence |
maxIter |
maximum number of iteration |
Solves a univariate mixed model of form
solveRRBLUP(y, X, M)
solveRRBLUP(y, X, M)
y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
M |
a matrix with n rows and m columns |
Solves a univariate mixed model of form using
the Expectation-Maximization algorithm.
solveRRBLUP_EM(Y, X, M, Vu, Ve, tol, maxIter, useEM)
solveRRBLUP_EM(Y, X, M, Vu, Ve, tol, maxIter, useEM)
Y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
M |
a matrix with n rows and m columns |
Vu |
initial guess for variance of marker effects |
Ve |
initial guess for error variance |
tol |
tolerance for declaring convergence |
maxIter |
maximum iteration for attempting convergence |
useEM |
should EM algorithm be used. If false, no estimation of variance components is performed. The initial values are treated as true. |
Solves a univariate mixed model of form using
the Expectation-Maximization algorithm.
solveRRBLUP_EM2(Y, X, M1, M2, Vu1, Vu2, Ve, tol, maxIter, useEM)
solveRRBLUP_EM2(Y, X, M1, M2, Vu1, Vu2, Ve, tol, maxIter, useEM)
Y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
M1 |
a matrix with n rows and m1 columns |
M2 |
a matrix with n rows and m2 columns |
Vu1 |
initial guess for variance of the first marker effects |
Vu2 |
initial guess for variance of the second marker effects |
Ve |
initial guess for error variance |
tol |
tolerance for declaring convergence |
maxIter |
maximum iteration for attempting convergence |
useEM |
should EM algorithm be used. If false, no estimation of variance components is performed. The initial values are treated as true. |
Solves a univariate mixed model of form using
the Expectation-Maximization algorithm.
solveRRBLUP_EM3(Y, X, M1, M2, M3, Vu1, Vu2, Vu3, Ve, tol, maxIter, useEM)
solveRRBLUP_EM3(Y, X, M1, M2, M3, Vu1, Vu2, Vu3, Ve, tol, maxIter, useEM)
Y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
M1 |
a matrix with n rows and m1 columns |
M2 |
a matrix with n rows and m2 columns |
M3 |
a matrix with n rows and m3 columns |
Vu1 |
initial guess for variance of the first marker effects |
Vu2 |
initial guess for variance of the second marker effects |
Vu3 |
initial guess for variance of the second marker effects |
Ve |
initial guess for error variance |
tol |
tolerance for declaring convergence |
maxIter |
maximum iteration for attempting convergence |
useEM |
should EM algorithm be used. If false, no estimation of variance components is performed. The initial values are treated as true. |
Solves a univariate mixed model with multiple random effects.
solveRRBLUPMK(y, X, Mlist, maxIter = 40L)
solveRRBLUPMK(y, X, Mlist, maxIter = 40L)
y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
Mlist |
a list of M matrices |
maxIter |
maximum number of iteration |
Solves a multivariate mixed model of form
solveRRBLUPMV(Y, X, M, maxIter = 1000L, tol = 1e-06)
solveRRBLUPMV(Y, X, M, maxIter = 1000L, tol = 1e-06)
Y |
a matrix with n rows and q columns |
X |
a matrix with n rows and x columns |
M |
a matrix with n rows and m columns |
maxIter |
maximum number of iteration |
tol |
tolerance for convergence |
Solves a univariate mixed model of form
solveUVM(y, X, Z, K)
solveUVM(y, X, Z, K)
y |
a matrix with n rows and 1 column |
X |
a matrix with n rows and x columns |
Z |
a matrix with n rows and m columns |
K |
a matrix with m rows and m columns |
Extends LociMap-class
to model additive traits
addEff
additive effects
intercept
adjustment factor for gv
Extends TraitA-class
to model seperate additive effects for parent of
origin. Used exclusively for genomic selection.
addEffMale
additive effects
Extends TraitA2-class
to add dominance
domEff
dominance effects
Extends TraitA-class
to add dominance
domEff
dominance effects
Extends TraitAD-class
to add epistasis
epiEff
epistatic effects
Extends TraitADE-class
to add GxE effects
gxeEff
GxE effects
gxeInt
GxE intercept
envVar
Environmental variance
Extends TraitAD-class
to add GxE effects
gxeEff
GxE effects
gxeInt
GxE intercept
envVar
Environmental variance
Extends TraitA-class
to add epistasis
epiEff
epistatic effects
Extends TraitAE-class
to add GxE effects
gxeEff
GxE effects
gxeInt
GxE intercept
envVar
Environmental variance
Extends TraitA-class
to add GxE effects
gxeEff
GxE effects
gxeInt
GxE intercept
envVar
Environmental variance
Creates an m by m linear transformation matrix that can be applied to n by m uncorrelated deviates sampled from a standard normal distribution to produce correlated deviates with an arbitrary correlation of R. If R is not positive semi-definite, the function returns smoothing and returns a warning (see details).
transMat(R)
transMat(R)
R |
a correlation matrix |
An eigendecomposition is applied to the correlation matrix and used to test if it is positive semi-definite. If the matrix is not positive semi-definite, it is not a valid correlation matrix. In this case, smoothing is applied to the matrix (as described in the 'cor.smooth' of the 'psych' library) to obtain a valid correlation matrix. The resulting deviates will thus not exactly match the desired correlation, but will hopefully be close if the input matrix wasn't too far removed from a valid correlation matrix.
# Create an 2x2 correlation matrix R = 0.5*diag(2) + 0.5 # Sample 1000 uncorrelated deviates from a # bivariate standard normal distribution X = matrix(rnorm(2*1000), ncol=2) # Compute the transformation matrix T = transMat(R) # Apply the transformation to the deviates Y = X%*%T # Measure the sample correlation cor(Y)
# Create an 2x2 correlation matrix R = 0.5*diag(2) + 0.5 # Sample 1000 uncorrelated deviates from a # bivariate standard normal distribution X = matrix(rnorm(2*1000), ncol=2) # Compute the transformation matrix T = transMat(R) # Apply the transformation to the deviates Y = X%*%T # Measure the sample correlation cor(Y)
Calculates the usefulness criterion
usefulness( pop, trait = 1, use = "gv", p = 0.1, selectTop = TRUE, simParam = NULL, ... )
usefulness( pop, trait = 1, use = "gv", p = 0.1, selectTop = TRUE, simParam = NULL, ... )
pop |
and object of |
trait |
the trait for selection. Either a number indicating a single trait or a function returning a vector of length nInd. |
use |
select on genetic values ( |
p |
the proportion of individuals selected |
selectTop |
selects highest values if true. Selects lowest values if false. |
simParam |
an object of |
... |
additional arguments if using a function for trait |
Returns a numeric value
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Determine usefulness of population usefulness(pop, simParam=SP) #Should be equivalent to GV of best individual max(gv(pop))
#Create founder haplotypes founderPop = quickHaplo(nInd=2, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) #Create population pop = newPop(founderPop, simParam=SP) #Determine usefulness of population usefulness(pop, simParam=SP) #Should be equivalent to GV of best individual max(gv(pop))
Returns additive variance for all traits
varA(pop, simParam = NULL)
varA(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varA(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varA(pop, simParam=SP)
Returns additive-by-additive epistatic variance for all traits
varAA(pop, simParam = NULL)
varAA(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varAA(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varAA(pop, simParam=SP)
Returns dominance variance for all traits
varD(pop, simParam = NULL)
varD(pop, simParam = NULL)
pop |
an object of |
simParam |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varD(pop, simParam=SP)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitAD(10, meanDD=0.5) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varD(pop, simParam=SP)
Returns variance of estimated breeding values for all traits
varEBV(pop)
varEBV(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) trtH2 = 0.5 SP$setVarE(h2=trtH2) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = trtH2 * (pop@pheno - meanP(pop)) #ind performance based EBV varA(pop) varEBV(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) trtH2 = 0.5 SP$setVarE(h2=trtH2) #Create population pop = newPop(founderPop, simParam=SP) pop@ebv = trtH2 * (pop@pheno - meanP(pop)) #ind performance based EBV varA(pop) varEBV(pop)
Returns total genetic variance for all traits
varG(pop)
varG(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varG(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varG(pop)
Returns phenotypic variance for all traits
varP(pop)
varP(pop)
pop |
an object of |
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varP(pop)
#Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=10) #Set simulation parameters SP = SimParam$new(founderPop) SP$addTraitA(10) SP$setVarE(h2=0.5) #Create population pop = newPop(founderPop, simParam=SP) varP(pop)
Writes a Pop-class to PLINK PED and MAP files. The arguments
for this function were chosen for consistency with
RRBLUP2
. The base pair coordinate will the locus
position as stored in AlphaSimR and not an actual base pair
position. This is because AlphaSimR doesn't track base pair
positions, only relative positions for the loci used in the
simulation.
writePlink( pop, baseName, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, simParam = NULL, ... )
writePlink( pop, baseName, traits = 1, use = "pheno", snpChip = 1, useQtl = FALSE, simParam = NULL, ... )
pop |
an object of |
baseName |
basename for PED and MAP files. |
traits |
an integer indicating the trait to write, a trait name, or a function of the traits returning a single value. |
use |
what to use for PLINK's phenotype field. Either phenotypes "pheno", genetic values "gv", estimated breeding values "ebv", breeding values "bv", or random values "rand". |
snpChip |
an integer indicating which SNP chip genotype to use |
useQtl |
should QTL genotypes be used instead of a SNP chip. If TRUE, snpChip specifies which trait's QTL to use, and thus these QTL may not match the QTL underlying the phenotype supplied in traits. |
simParam |
an object of |
... |
additional arguments if using a function for traits |
## Not run: #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setSexes(sex="yes_rand") SP$addTraitA(nQtlPerChr=10) SP$addSnpChip(nSnpPerChr=5) SP$setVarE(h2=0.5) #Create population pop = newPop(rawPop = founderPop) # Write out PLINK files writePlink(pop, baseName="test") ## End(Not run)
## Not run: #Create founder haplotypes founderPop = quickHaplo(nInd=10, nChr=1, segSites=15) #Set simulation parameters SP = SimParam$new(founderPop) \dontshow{SP$nThreads = 1L} SP$setSexes(sex="yes_rand") SP$addTraitA(nQtlPerChr=10) SP$addSnpChip(nSnpPerChr=5) SP$setVarE(h2=0.5) #Create population pop = newPop(rawPop = founderPop) # Write out PLINK files writePlink(pop, baseName="test") ## End(Not run)
Saves a population's phenotypic and marker data to a directory.
writeRecords( pop, dir, snpChip = 1, useQtl = FALSE, includeHaplo = FALSE, append = TRUE, simParam = NULL )
writeRecords( pop, dir, snpChip = 1, useQtl = FALSE, includeHaplo = FALSE, append = TRUE, simParam = NULL )
pop |
an object of |
dir |
path to a directory for saving output |
snpChip |
which SNP chip genotype to save. If useQtl=TRUE, this value will indicate which trait's QTL genotype to save. A value of 0 will skip writing a snpChip. |
useQtl |
should QTL genotype be written instead of SNP chip genotypes. |
includeHaplo |
should markers be separated by female and male haplotypes. |
append |
if true, new records are added to any existing records. If false, any existing records are deleted before writing new records. Note that this will delete all files in the 'dir' directory. |
simParam |
an object of |