Container for global simulation parameters. Saving this object as SP will allow it to be accessed by function defaults.
Note
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.
Public fields
nThreadsnumber of threads used on platforms with OpenMP support
snpChipslist of SNP chips
invalidQtllist of segregating sites that aren't valid QTL
invalidSnplist of segregating sites that aren't valid SNP
founderPopfounder population used for variance scaling
finalizePopfunction applied to newly created populations. Currently does nothing and should only be changed by expert users.
allowEmptyPopif true, population arguments with nInd=0 will return an empty population with a warning instead of an error.
vthe 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)
pthe proportion of crossovers coming from a non-interfering pathway. (default is 0)
quadProbthe probability of quadrivalent pairing in an autopolyploid. (default is 0)
Active bindings
traitNamesvector of trait names
snpChipNamesvector of chip names
traitslist of traits
nChrnumber of chromosomes
nTraitsnumber of traits
nSnpChipsnumber of SNP chips
segSitessegregating sites per chromosome
sexessexes used for mating
sepMapare there seperate genetic maps for males and females
genMaplist of chromosome genetic maps
femaleMaplist of chromosome genetic maps for females
maleMaplist of chromosome genetic maps for males
centromereposition of centromeres genetic map
femaleCentromereposition of centromeres on female genetic map
maleCentromereposition of centromeres on male genetic map
lastIdlast ID number assigned
isTrackPedis pedigree being tracked
pedigreepedigree matrix for all individuals
isTrackRecis recombination being tracked
recHistlist of historic recombination events
haplotypeslist of computed IBD haplotypes
varAadditive genetic variance in founderPop
varGtotal genetic variance in founderPop
varEdefault error variance
versionthe version of AlphaSimR used to generate this object
activeQtla LociMap representing all active QTL in simulation
qtlIndexa list of vectors giving trait specific QTL indices relative to all active QTL
Methods
Method 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.
Usage
SimParam$new(founderPop)Arguments
founderPopan object of
MapPop-class
Examples
#Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=10)
#Set simulation parameters
SP = SimParam$new(founderPop)Method 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.
Method 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.
Method 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.
Examples
#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
Method restrSegSites()
Sets restrictions on which segregating sites can serve as a SNP and/or QTL. The default behavior of AlphaSimR is to randomly sample QTL or SNP from all eligible sites and then mark the sampled sites ineligible to be sampled as the other type (e.g. if a site is sampled as a QTL it will be marked as ineligible to be sampled as a SNP). This behavior is designed to produce the most challenging scenario for genomic selection when the markers used for prediction are not causal.
Setting overlap=TRUE will prevent the addition of loci to the ineligible list, but it won't remove sites already added to these lists. Thus, timing of when restrSegSites is called matters. It should be called before any addTrait or addSnpChip functions with the overlap=TRUE argument to freely allow loci to overlap.
The minQtlPerChr and minSnpPerChr arguments can be used with overlap=FALSE to preallocate sites as QTL and SNP respectively. This option is useful when simulating multiple traits and/or SNP chips, because it can be used to guarantee that enough eligible sites are available when running addTrait and or addSnpChip functions.
Usage
SimParam$restrSegSites(
minQtlPerChr = NULL,
minSnpPerChr = NULL,
excludeQtl = NULL,
excludeSnp = NULL,
overlap = FALSE,
minSnpFreq = NULL
)Arguments
minQtlPerChrthe minimum number of segregating sites for QTLs. Can be a single value or a vector values for each chromosome.
minSnpPerChrthe minimum number of segregating sites for SNPs. Can be a single value or a vector values for each chromosome.
excludeQtlan optional vector of segregating site names to exclude from consideration as a viable QTL.
excludeSnpan optional vector of segregating site names to exclude from consideration as a viable SNP.
overlapshould SNP and QTL sites be allowed to overlap.
minSnpFreqminimum allowable frequency for SNP loci. No minimum SNP frequency is used if value is NULL.
Method 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.
Method setFounderHap()
Allows for the manual setting of founder haplotypes. This functionality is not fully documented, because it is still experimental.
Method addSnpChip()
Randomly assigns eligible SNPs to a SNP chip
Arguments
nSnpPerChrnumber of SNPs per chromosome. Can be a single value or nChr values.
minSnpFreqminimum allowable frequency for SNP loci. If NULL, no minimum frequency is used.
refPopreference population for calculating SNP frequency. If NULL, the founder population is used.
nameoptional name for chip
Method 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.
Examples
#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 addStructuredSnpChip()
Randomly selects the number of snps in structure and then assigns them to chips based on structure
Arguments
nSnpPerChrnumber of SNPs per chromosome. Can be a single value or nChr values.
structurea matrix. Rows are snp chips, columns are chips. If value is true then that snp is on that chip.
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
Method 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.
Usage
SimParam$addTraitA(
nQtlPerChr,
mean = 0,
var = 1,
corA = NULL,
gamma = FALSE,
shape = 1,
force = FALSE,
name = NULL
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
corAa matrix of correlations between additive effects
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Usage
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
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
meanDDmean dominance degree
varDDvariance of dominance degree
corAa matrix of correlations between additive effects
corDDa matrix of correlations between dominance degrees
useVarAtune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meandesired mean of the trait
varAdesired additive variance
varDdesired dominance variance
inbrDeprdesired inbreeding depression, see details
limMeanDDlimits for meanDD, see details
limVarDDlimits for varDD, see details
silentshould summary details be printed to the console
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait
Details
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.
Method 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.
Usage
SimParam$addTraitAG(
nQtlPerChr,
mean = 0,
var = 1,
varGxE = 1e-06,
varEnv = 0,
corA = NULL,
corGxE = NULL,
gamma = FALSE,
shape = 1,
force = FALSE,
name = NULL
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
varGxEa vector of total genotype-by-environment variances for the traits
varEnva vector of environmental variances for one or more traits
corAa matrix of correlations between additive effects
corGxEa matrix of correlations between GxE effects
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method addTraitADG()
Randomly assigns eligible QTLs for a trait with dominance and GxE.
Usage
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
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
varEnva vector of environmental variances for one or more traits
varGxEa vector of total genotype-by-environment variances for the traits
meanDDmean dominance degree
varDDvariance of dominance degree
corAa matrix of correlations between additive effects
corDDa matrix of correlations between dominance degrees
corGxEa matrix of correlations between GxE effects
useVarAtune according to additive genetic variance if true
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Usage
SimParam$addTraitAE(
nQtlPerChr,
mean = 0,
var = 1,
relAA = 0,
corA = NULL,
corAA = NULL,
useVarA = TRUE,
gamma = FALSE,
shape = 1,
force = FALSE,
name = NULL
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
relAAthe relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corAa matrix of correlations between additive effects
corAAa matrix of correlations between additive-by-additive effects
useVarAtune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Usage
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
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
meanDDmean dominance degree
varDDvariance of dominance degree
relAAthe relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corAa matrix of correlations between additive effects
corDDa matrix of correlations between dominance degrees
corAAa matrix of correlations between additive-by-additive effects
useVarAtune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Usage
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
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
relAAthe relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
varGxEa vector of total genotype-by-environment variances for the traits
varEnva vector of environmental variances for one or more traits
corAa matrix of correlations between additive effects
corAAa matrix of correlations between additive-by-additive effects
corGxEa matrix of correlations between GxE effects
useVarAtune according to additive genetic variance if true. If FALSE, tuning is performed according to total genetic variance.
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method addTraitADEG()
Randomly assigns eligible QTLs for a trait with dominance, epistasis and GxE.
Usage
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
)Arguments
nQtlPerChrnumber of QTLs per chromosome. Can be a single value or nChr values.
meana vector of desired mean genetic values for one or more traits
vara vector of desired genetic variances for one or more traits
varEnva vector of environmental variances for one or more traits
varGxEa vector of total genotype-by-environment variances for the traits
meanDDmean dominance degree
varDDvariance of dominance degree
relAAthe relative value of additive-by-additive variance compared to additive variance in a diploid organism with allele frequency 0.5
corAa matrix of correlations between additive effects
corDDa matrix of correlations between dominance degrees
corAAa matrix of correlations between additive-by-additive effects
corGxEa matrix of correlations between GxE effects
useVarAtune according to additive genetic variance if true
gammashould a gamma distribution be used instead of normal
shapethe 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)
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing.
nameoptional name for trait(s)
Method 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.
Arguments
lociMapa new object descended from
LociMap-classvarEdefault error variance for phenotype, optional
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
Method 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.
Usage
SimParam$importTrait(
markerNames,
addEff,
domEff = NULL,
intercept = NULL,
name = NULL,
varE = NULL,
force = FALSE
)Arguments
markerNamesa vector of names for the QTL
addEffa matrix of additive effects (nLoci x nTraits). Alternatively, a vector of length nLoci can be supplied for a single trait.
domEffoptional dominance effects for each locus
interceptoptional intercepts for each trait
nameoptional name(s) for the trait(s)
varEdefault error variance for phenotype, optional
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
Method switchTrait()
Switch a trait in the simulation.
Arguments
traitPosan integer indicate which trait to switch
lociMapa new object descended from
LociMap-classvarEdefault error variance for phenotype, optional
forceshould the check for a running simulation be ignored. Only set to TRUE if you know what you are doing
Method 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.
Method setCorE()
Defines a correlation structure for default
error variances. You must call setVarE first to define
the default error variances.
Examples
#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)
Method rescaleTraits()
Linearly scales all traits to achieve desired values of means and variances in the founder population.
Arguments
meana vector of new trait means
vara vector of new trait variances
varEnva vector of new environmental variances
varGxEa vector of new GxE variances
useVarAtune according to additive genetic variance if true
Examples
#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)
Method setRecombRatio()
Set the relative recombination rates between males and females. This allows for sex-specific recombination rates, under the assumption of equivalent recombination landscapes.
Examples
## ------------------------------------------------
## 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
#> [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
#Create another population after reseting pedigree
SP$resetPed()
pop2 = newPop(founderPop, simParam=SP)
pop2@id # 1:10
#> [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "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)
#> A new trait called Trait1 was added.
#> varD = 0.05000002
#> inbrDepr = 0.2000004
#> meanDD = 0.04665813
#> varDD = 0.1382312
## ------------------------------------------------
## 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)
#> Warning: This function has been deprecated. Use simParam$setVarE instead.
## ------------------------------------------------
## 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)
#> Trait1
#> -6.661338e-17
#Change mean to 1
SP$rescaleTraits(mean=1)
#Run resetPop for change to take effect
pop = resetPop(pop, simParam=SP)
meanG(pop)
#> Trait1
#> 1
## ------------------------------------------------
## 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