simEval: R6 Class Representing a Breeding Scheme

simEvalR Documentation

R6 Class Representing a Breeding Scheme

Description

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

Public fields

simEvalName

[character] Name of this simulation of breeding schemes

simBsList

[list] list of simulation results of breeding scheme (see:simBs; simBsOpt)

verbose

[logical] Display info (optional)

Methods

Public methods


Method new()

Create a new simEval object.

Usage
simEval$new(simEvalName = "Undefined", simBsList, verbose = TRUE)
Arguments
simEvalName

[character] Name of this evaluation of simulation results

simBsList

[list] list of simulation results of breeding scheme (see:simBs; simBsOpt)

verbose

[logical] Display info (optional)

Returns

A new 'simEval' 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 prepareSimRes()

start simulation & summary results of breeding scheme

Usage
simEval$prepareSimRes()

Method print()

Display information about the object

Usage
simEval$print()

Method plot()

Draw figures for visualization of simulation results for summary statistics to compare strategies

Usage
simEval$plot(
  targetTrait = 1,
  targetPopulation = NULL,
  plotType = "box",
  plotTarget = "max",
  returnGain = TRUE,
  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.

plotTarget

[character] You should select which summary statistics will be plotted. It should be a vector with length 1.

returnGain

[logical] Return genetic gain (difference against initial population) or not

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
simEval$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `simEval$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.