simBs: R6 Class Representing a Breeding Scheme

simBsR Documentation

R6 Class Representing a Breeding Scheme

Description

simBs object store specific information of simulation results of breeding scheme.

Public fields

simBsName

[character] Name of this simulation of breeding schemes

bsInfoInit

[bsInfo] breeding scheme info (see:bsInfo)

breederInfoInit

[breederInfo] breeder info (see:breederInfo)

lociEffMethod

[character] How to compute loci effects (use true QTL effects ("true") or estimated marker effects ("estimated"))

trainingPopType

[character] Training population consists of all populations created in the breeding scheme for 'trainingPopType = "all"', or consists of the latest population in breeding scheme for 'trainingPopType = "latest"'.

trainingPopInit

[character / numeric] Training population names or No.s (not generations!!) for initial population

trainingIndNamesInit

[character] Names of training individuals for initia; population

methodMLRInit

[character] Methods for estimating marker effects for initial population. The following methods are offered:

"Ridge", "LASSO", "ElasticNet", "RR-BLUP", "GBLUP", "BayesA" (uni-trait), "BayesB" (uni-trait), "BayesC" (uni-trait), "BRR", "BL" (uni-trait), "SpikeSlab" (multi-trait)

multiTraitInit

[logical] Use multiple-trait model for estimation of marker effects or not for initial population

nIterSimulation

[numeric] Number of iterations for this simulation setting

nGenerationProceed

[numeric] Number of generations to be proceeded

nRefreshMemoryEvery

[numeric] Every 'nRefreshMemoryEvery' iterations, we refresh memory used for simulations by 'gc(reset = TRUE)'.

updateBreederInfo

[logical] Update breederInfo or not for each generation

phenotypingInds

[logical] Phenotyping individuals or not for each generation

nRepForPhenoInit

[numeric] Number of replications to be phenotyped for initial population

nRepForPheno

[numeric] Number of replications to be phenotyped for each generation

updateModels

[logical] Whether or not updating the model for each generation (If 'phenotypingInds = FALSE' for generation of your interest, 'updateModels' will be automatically 'FALSE' for that generation.)

methodMLR

[character] Methods for estimating marker effects. The following methods are offered:

"Ridge", "LASSO", "ElasticNet", "RR-BLUP", "GBLUP", "BayesA" (uni-trait), "BayesB" (uni-trait), "BayesC" (uni-trait), "BRR", "BL" (uni-trait), "SpikeSlab" (multi-trait)

multiTrait

[logical] Use multiple-trait model for estimation of marker effects or not

nSelectionWaysVec

[numeric] Number of selection ways for each generation

selectionMethodList

[list] (list of) Selection method for each generation

traitNoSelList

[list] (list of list of) Number of trait No of your interest for selection for each generation

blockSplitMethod

[character] How to determine the markers belonging to each block when computing OHV. You can define the number of markers in each block ('nMrkInBlock') or the minimum length of each segment ('minimumSegmentLength').

nMrkInBlock

[numeric] Number of markers in each block. This will be used for the computation of OHV.

minimumSegmentLength

[numeric] Minimum length of each segment [cM]. This will be used for the computation of OHV.

nSelInitOPVList

[list] (list of) Number of selected candiates for first screening before selecting parent candidates by OPV for each generation

nIterOPV

[numeric] Number of iterations for computation of OPV

nProgeniesEMBVVec

[numeric] Number of progenies of double haploids produced when computing EMBV for each generation

nIterEMBV

[numeric] Number of iterations to estimate EMBV

nCoresEMBV

[numeric] Number of cores used for EMBV estimation

clusteringForSelList

[list] (list of) Apply clustering results of marker genotype to selection or not for each generation

nClusterList

[list] (list of) Number of clusters for each generation

nTopClusterList

[list] (list of) Number of top clusters used for selection for each generation

nTopEachList

[list] (list of) Number of selected individuals in each cluster for each generation

nSelList

[list] (list of) Number of selection candidates for each generation

multiTraitsEvalMethodList

[list] (list of) When evaluating multiple traits, you can choose how to evaluate these traits simultaneously. One method is to take a weighted sum of these traits, and the other is to compute a product of these traits (adjusted to be positive values in advance.)

hSelList

[list] (list of) Hyperparameter which determines which trait is weighted when selecting parent candidates for multiple traits for each generation

matingMethodVec

[character] Mating method for each generation

allocateMethodVec

[character] Allocation method for each generation

weightedAllocationMethodList

[list] (list of) Which selection index will be used for weighted resource allocation for each generation

traitNoRAList

[list] (list of) Trait No of your interest for resource allocation for each generation

hList

[list] (list of) Hyperparameter which determines how parent pair with high BV is emphasized when producing progenies for each generation

includeGVPVec

[logical] Whether or not to consider genetic variance of progenies of each pair when determining the number of progenies per each pair for each generation

nNextPopVec

[numeric] Number of progenies for the next generation for each generation

nameMethod

[character] Method for naming individuals

nCores

[numeric] Number of cores used for simulations of breedinhh scheme

overWriteRes

[logical] Overwrite simulation results when the targeted results already exists

showProgress

[logical] Show progress bar or not

returnMethod

[character] Which type of results will be returned (saved) in the object

saveAllResAt

[character] If NULL, we won't save the simulation results. Else, we will save bsInfo and breederInfo for each iteration in the directory defined by 'saveAllResAt' path.

evaluateGVMethod

[character] Which type of GV (true GV or estimated GV) will be used for evaluation of the simulation results

nTopEval

[numeric] Number of individuals to be evaluated when evaluating population max or population min

traitNoEval

[numeric] Trait No of your interest for evaluation of the method

hEval

[numeric] Hyperparameter which determines which BV is emphasized when evaluating simulation results of each method

summaryAllResAt

[character] If NULL, we will summary the simulation results in 'self$trueGVMatList' and 'self$estimatedGVMatList'. Else, we will summary the simulation results in 'summaryAllResAt' path.

verbose

[logical] Display info (optional)

lociEffectsInit

[matrix] Marker and QTL effects used for crossInfo object for initial population

simBsRes

[list] Simulation results of each method

trueGVMatInit

[matrix] A true GV matrix for initial population

trueGVMatList

[list] A list of true GV matrix of simulation results

trueGVSummaryArray

[array] An array of summary statistics of true GVs for each population & each iteration

estimatedGVMatInit

[matrix] An estimated GV matrix for initial population

estimatedGVMatList

[list] A list of estimated GV matrix of simulation results

estimatedGVSummaryArray

[array] An array of summary statistics of estimated GVs for each population & each iteration

Methods

Public methods


Method new()

Create a new simBs object.

Usage
simBs$new(
  simBsName = "Undefined",
  bsInfoInit,
  breederInfoInit = NULL,
  lociEffMethod = NULL,
  trainingPopType = NULL,
  trainingPopInit = NULL,
  trainingIndNamesInit = NULL,
  methodMLRInit = NULL,
  multiTraitInit = FALSE,
  nIterSimulation = NULL,
  nGenerationProceed = NULL,
  nRefreshMemoryEvery = NULL,
  updateBreederInfo = TRUE,
  phenotypingInds = FALSE,
  nRepForPhenoInit = NULL,
  nRepForPheno = NULL,
  updateModels = FALSE,
  methodMLR = NULL,
  multiTrait = FALSE,
  nSelectionWaysVec = NULL,
  selectionMethodList = NULL,
  traitNoSelList = NULL,
  blockSplitMethod = NULL,
  nMrkInBlock = NULL,
  minimumSegmentLength = NULL,
  nSelInitOPVList = NULL,
  nIterOPV = NULL,
  nProgeniesEMBVVec = NULL,
  nIterEMBV = NULL,
  nCoresEMBV = NULL,
  clusteringForSelList = FALSE,
  nClusterList = NULL,
  nTopClusterList = NULL,
  nTopEachList = NULL,
  nSelList = NULL,
  multiTraitsEvalMethodList = NULL,
  hSelList = NULL,
  matingMethodVec = NULL,
  allocateMethodVec = NULL,
  weightedAllocationMethodList = NULL,
  traitNoRAList = NULL,
  hList = NULL,
  includeGVPVec = FALSE,
  nNextPopVec = NULL,
  nameMethod = "pairBase",
  nCores = NULL,
  overWriteRes = FALSE,
  showProgress = TRUE,
  returnMethod = "all",
  saveAllResAt = NULL,
  evaluateGVMethod = "true",
  nTopEval = NULL,
  traitNoEval = NULL,
  hEval = NULL,
  summaryAllResAt = NULL,
  verbose = TRUE
)
Arguments
simBsName

[character] Name of this simulation of breeding schemes

bsInfoInit

[bsInfo] breeding scheme info (see:bsInfo)

breederInfoInit

[breederInfo] breeder info (see:breederInfo)

lociEffMethod

[character] How to compute loci effects (use true QTL effects ("true") or estimated marker effects ("estimated"))

trainingPopType

[character] Training population consists of all populations created in the breeding scheme for 'trainingPopType = "all"', or consists of the latest population in breeding scheme for 'trainingPopType = "latest"'.

trainingPopInit

[character / numeric] Training population names or No.s (not generations!!) for initial population

trainingIndNamesInit

[character] Names of training individuals for initia; population

methodMLRInit

[character] Methods for estimating marker effects for initial population. The following methods are offered:

"Ridge", "LASSO", "ElasticNet", "RR-BLUP", "GBLUP", "BayesA" (uni-trait), "BayesB" (uni-trait), "BayesC" (uni-trait), "BRR", "BL" (uni-trait), "SpikeSlab" (multi-trait)

multiTraitInit

[logical] Use multiple-trait model for estimation of marker effects or not for initial population

nIterSimulation

[numeric] Number of iterations for this simulation setting

nGenerationProceed

[numeric] Number of generations to be proceeded

nRefreshMemoryEvery

[numeric] Every 'nRefreshMemoryEvery' iterations, we refresh memory used for simulations by 'gc(reset = TRUE)'.

updateBreederInfo

[logical] Update breederInfo or not for each generation

phenotypingInds

[logical] Phenotyping individuals or not for each generation

nRepForPhenoInit

[numeric] Number of replications to be phenotyped for initial population

nRepForPheno

[numeric] Number of replications to be phenotyped for each generation

updateModels

[logical] Whether or not updating the model for each generation (If 'phenotypingInds = FALSE' for generation of your interest, 'updateModels' will be automatically 'FALSE' for that generation.)

methodMLR

[character] Methods for estimating marker effects. The following methods are offered:

"Ridge", "LASSO", "ElasticNet", "RR-BLUP", "GBLUP", "BayesA" (uni-trait), "BayesB" (uni-trait), "BayesC" (uni-trait), "BRR", "BL" (uni-trait), "SpikeSlab" (multi-trait)

multiTrait

[logical] Use multiple-trait model for estimation of marker effects or not

nSelectionWaysVec

[numeric] Number of selection ways for each generation

selectionMethodList

[list] (list of) Selection method for each generation

traitNoSelList

[list] (list of list of) Number of trait No of your interest for selection for each generation

blockSplitMethod

[character] How to determine the markers belonging to each block when computing OHV. You can define the number of markers in each block ('nMrkInBlock') or the minimum length of each segment ('minimumSegmentLength').

nMrkInBlock

[numeric] Number of markers in each block. This will be used for the computation of OHV.

minimumSegmentLength

[numeric] Minimum length of each segment [cM]. This will be used for the computation of OHV.

nSelInitOPVList

[list] (list of) Number of selected candiates for first screening before selecting parent candidates by OPV for each generation

nIterOPV

[numeric] Number of iterations for computation of OPV

nProgeniesEMBVVec

[numeric] Number of progenies of double haploids produced when computing EMBV for each generation

nIterEMBV

[numeric] Number of iterations to estimate EMBV

nCoresEMBV

[numeric] Number of cores used for EMBV estimation

clusteringForSelList

[list] (list of) Apply clustering results of marker genotype to selection or not for each generation

nClusterList

[list] (list of) Number of clusters for each generation

nTopClusterList

[list] (list of) Number of top clusters used for selection for each generation

nTopEachList

[list] (list of) Number of selected individuals in each cluster for each generation

nSelList

[list] (list of) Number of selection candidates for each generation

multiTraitsEvalMethodList

[list] (list of) When evaluating multiple traits, you can choose how to evaluate these traits simultaneously. One method is to take a weighted sum of these traits, and the other is to compute a product of these traits (adjusted to be positive values in advance.)

hSelList

[list] (list of) Hyperparameter which determines which trait is weighted when selecting parent candidates for multiple traits for each generation

matingMethodVec

[character] Mating method for each generation

allocateMethodVec

[character] Allocation method for each generation

weightedAllocationMethodList

[list] (list of) Which selection index will be used for weighted resource allocation for each generation

traitNoRAList

[list] (list of) Trait No of your interest for resource allocation for each generation

hList

[list] (list of) Hyperparameter which determines how parent pair with high BV is emphasized when producing progenies for each generation

includeGVPVec

[logical] Whether or not to consider genetic variance of progenies of each pair when determining the number of progenies per each pair for each generation

nNextPopVec

[numeric] Number of progenies for the next generation for each generation

nameMethod

[character] Method for naming individuals

nCores

[numeric] Number of cores used for simulations of breeding scheme

overWriteRes

[logical] Overwrite simulation results when the targeted results already exists

showProgress

[logical] Show progress bar or not

returnMethod

[character] Which type of results will be returned (saved) in the object

saveAllResAt

[character] If NULL, we won't save the simulation results. Else, we will save bsInfo and breederInfo for each iteration in the directory defined by 'saveAllResAt' path.

evaluateGVMethod

[character] Which type of GV (true GV or estimated GV) will be used for evaluation of the simulation results

nTopEval

[numeric] Number of individuals to be evaluated when evaluating population max or population min

traitNoEval

[numeric] Trait No of your interest for evaluation of the method

hEval

[numeric] Hyperparameter which determines which BV is emphasized when evaluating simulation results of each method

summaryAllResAt

[character] If NULL, we will summary the simulation results in 'self$trueGVMatList' and 'self$estimatedGVMatList'. Else, we will summary the simulation results in 'summaryAllResAt' path.

verbose

[logical] Display info (optional)

Returns

A new 'simBs' object.

Examples
### create simulation information
mySimInfo <- simInfo$new(simName = "Simulation Example",
                         simGeno = TRUE,
                         simPheno = TRUE,
                         #' nSimGeno = 1,
                         #' nSimPheno = 3,
                         #' nCoreMax = 4,
                         #' nCorePerGeno = 1,
                         #' nCorePerPheno = 3,
                         saveDataFileName = NULL)
### create specie information
mySpec <- specie$new(nChr = 3,
                     lChr = c(100, 150, 200),
                     specName = "Example 1",
                     ploidy = 2,
                     mutRate = 10^-8,
                     recombRate = 10^-6,
                     chrNames = c("C1", "C2", "C3"),
                     nLoci = 100,
                     recombRateOneVal = FALSE,
                     effPopSize = 100,
                     simInfo = mySimInfo,
                     verbose = TRUE)
### create lociInfo object
myLoci <- lociInfo$new(genoMap = NULL, specie = mySpec)
plot(myLoci, alpha = 0.1)
### create traitInfo object
myTrait <- traitInfo$new(lociInfo = myLoci,
                         nMarkers = 80,
                         nTraits = 3,
                         nQTLs = c(4, 8, 3),
                         actionTypeEpiSimple = TRUE,
                         qtlOverlap = TRUE,
                         nOverlap = c(2, 3, 0),
                         effCor = 0.1,
                         propDomi = 0.2,
                         interactionMean = c(4, 1, 2))
myTrait$plot(alphaMarker = 0.1)
### create bsInfo object
myBsInfo <- bsInfo$new(simInfo = mySimInfo,
                       specie = mySpec,
                       lociInfo = myLoci,
                       traitInfo = myTrait,
                       geno = NULL,
                       haplo = NULL,
                       founderIsInitPop = TRUE,
                       popNameBase = "Population",
                       initIndNames = NULL,
                       verbose = TRUE)
### create cross information object
for (i in 1:10) {
  myCrossInfo <- crossInfo$new(parentPopulation = myBsInfo$populations[[myBsInfo$generation]],
                               method = "randomMate",
                               nNextPop = 100)
  myBsInfo$nextGeneration(crossInfo = myCrossInfo)
}
geno <- myBsInfo$overGeneration()$genoMat
myBsInfo$print()
myBsInfo$plot(plotTarget = "trueAGV",
              targetTrait = 1:3,
              targetPopulation = 1:11,
              plotType = "jitter")


Method computeLociEffInit()

estimate/extract marker/QTL effects information

Usage
simBs$computeLociEffInit()

Method startSimulation()

start simulation of breeding scheme

Usage
simBs$startSimulation()

Method summaryResults()

start simulation of breeding scheme

Usage
simBs$summaryResults()

Method print()

Display information about the object

Usage
simBs$print()

Method plot()

Draw figures for visualization of simulation results for summary statistics

Usage
simBs$plot(
  targetTrait = 1,
  targetPopulation = NULL,
  plotType = "box",
  plotTargetDensity = "max",
  plotGVMethod = "true",
  adjust = 1e-05
)
Arguments
targetTrait

[numeric] Target trait. character is OK, but numeric vector corresponding to target traits is preferred. It should be a vector with length 1.

targetPopulation

[numeric] Target populations. character is OK, but numeric vector corresponding to target traits is preferred.

plotType

[character] We offer "box", "violin", "lines", "density" to draw figures for simulation results.

plotTargetDensity

[character] When you choose "density" for 'plotType', you should select which summary statistics will be plotted. It should be a vector with length 1.

plotGVMethod

[character] Which type of GV (true GV or estimated GV) will be used for plotting the simulation results

adjust

[numeric] the bandwidth used is actually adjust*bw. This makes it easy to specify values like ‘half the default’ bandwidth. (see: 'adjust' in density)


Method clone()

The objects of this class are cloneable with this method.

Usage
simBs$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `simBs$new`
## ------------------------------------------------

### create simulation information
mySimInfo <- simInfo$new(simName = "Simulation Example",
                         simGeno = TRUE,
                         simPheno = TRUE,
                         #' nSimGeno = 1,
                         #' nSimPheno = 3,
                         #' nCoreMax = 4,
                         #' nCorePerGeno = 1,
                         #' nCorePerPheno = 3,
                         saveDataFileName = NULL)
### create specie information
mySpec <- specie$new(nChr = 3,
                     lChr = c(100, 150, 200),
                     specName = "Example 1",
                     ploidy = 2,
                     mutRate = 10^-8,
                     recombRate = 10^-6,
                     chrNames = c("C1", "C2", "C3"),
                     nLoci = 100,
                     recombRateOneVal = FALSE,
                     effPopSize = 100,
                     simInfo = mySimInfo,
                     verbose = TRUE)
### create lociInfo object
myLoci <- lociInfo$new(genoMap = NULL, specie = mySpec)
plot(myLoci, alpha = 0.1)
### create traitInfo object
myTrait <- traitInfo$new(lociInfo = myLoci,
                         nMarkers = 80,
                         nTraits = 3,
                         nQTLs = c(4, 8, 3),
                         actionTypeEpiSimple = TRUE,
                         qtlOverlap = TRUE,
                         nOverlap = c(2, 3, 0),
                         effCor = 0.1,
                         propDomi = 0.2,
                         interactionMean = c(4, 1, 2))
myTrait$plot(alphaMarker = 0.1)
### create bsInfo object
myBsInfo <- bsInfo$new(simInfo = mySimInfo,
                       specie = mySpec,
                       lociInfo = myLoci,
                       traitInfo = myTrait,
                       geno = NULL,
                       haplo = NULL,
                       founderIsInitPop = TRUE,
                       popNameBase = "Population",
                       initIndNames = NULL,
                       verbose = TRUE)
### create cross information object
for (i in 1:10) {
  myCrossInfo <- crossInfo$new(parentPopulation = myBsInfo$populations[[myBsInfo$generation]],
                               method = "randomMate",
                               nNextPop = 100)
  myBsInfo$nextGeneration(crossInfo = myCrossInfo)
}
geno <- myBsInfo$overGeneration()$genoMat
myBsInfo$print()
myBsInfo$plot(plotTarget = "trueAGV",
              targetTrait = 1:3,
              targetPopulation = 1:11,
              plotType = "jitter")


KosukeHamazaki/myBreedSimulatR documentation built on Aug. 31, 2024, 3:55 p.m.