bsInfo: R6 Class Representing a Breeding Scheme

bsInfoR Documentation

R6 Class Representing a Breeding Scheme

Description

bsInfo object store specific information of one breeding scheme.

Public fields

bsName

[character] name of this breeding scheme

simInfo

[simInfo class] Simulation information (see:simInfo)

specie

[specie class] Specie of the SNPs (see:specie)

lociInfo

[lociInfo object] information about the individuals haplotypes' SNPs (see:lociInfo)

traitInfo

[traitInfo class] Specific information of traits (see:traitInfo)

founderIsInitPop

[logical] Founder haplotype will be regarded as first population or not.

seedSimHaplo

[numeric] Random seed for selecting haplotype from founder haplotype

seedSimRM

[numeric] Random seed for mate pairs

seedSimMC

[numeric] Random seed for make crosses

popNameBase

[character] base of population's name.

populations

[list] A list of population objects

crossInfoList

[list] A list of crossInfo objects

generation

[list] current generation No. in the breeding scheme

herit

[numeric] Heritability for each trait (plot-based/line-based)

envSpecificEffects

[numeric] Effects specific to each environments / treatments. If 'multiTraitsAsEnvs = FALSE', envSpecificEffects will be 0 for all traits.

residCor

[matrix] Residual correlation between traits

Active bindings

lociEffects

[matrix] marker and QTL effects used for crossInfo object

Methods

Public methods


Method new()

Create a new bsInfo object.

Usage
bsInfo$new(
  bsName = "Undefined",
  simInfo,
  specie,
  lociInfo,
  traitInfo,
  geno = NULL,
  haplo = NULL,
  founderIsInitPop = TRUE,
  seedSimHaplo = NA,
  seedSimRM = NA,
  seedSimMC = NA,
  popNameBase = "Population",
  initIndNames = NULL,
  herit = NULL,
  envSpecificEffects = NULL,
  residCor = NULL,
  verbose = TRUE
)
Arguments
bsName

[character] Name of this breeding scheme

simInfo

[simInfo class] Simulation information (see:simInfo)

specie

[specie class] Specie of the SNPs (see:specie)

lociInfo

[lociInfo object] information about the individuals haplotypes' SNPs (see:lociInfo)

traitInfo

[traitInfo class] Specific information of traits (see:traitInfo)

geno

[data.frame / matrix] genotype of the individuals encoded in allele dose. If you use real data, you must specify 'geno' or 'haplo' argument.

haplo

[array] haplotype of the individuals scored with 0 and 1 (3-dimensional array).

founderIsInitPop

[logical] Founder haplotype will be regarded as first population or not.

seedSimHaplo

[numeric] Random seed for selecting haplotype from founder haplotype

seedSimRM

[numeric] Random seed for mate pairs

seedSimMC

[numeric] Random seed for make crosses

popNameBase

[character] base of population's name.

initIndNames

[character] NULL or character string vector specifying the individuals names for initial population. If NULL, rownames(geno) will be used.

herit

[numeric] Heritability for each trait (plot-based/line-based)

envSpecificEffects

[numeric] Effects specific to each environments / treatments. If 'multiTraitsAsEnvs = FALSE', envSpecificEffects will be 0 for all traits.

residCor

[matrix] Residual correlation between traits

verbose

[logical] Display info (optional)

Returns

A new 'bsInfo' 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 nextGeneration()

create next population

Usage
bsInfo$nextGeneration(crossInfo)
Arguments
crossInfo

[crossInfo class] Information of crossing (including selection scheme) (see:crossInfo)


Method removeLatestPop()

remove latest population

Usage
bsInfo$removeLatestPop()

Method removeInitialPop()

remove initial population

Usage
bsInfo$removeInitialPop()

Method overGeneration()

assemble populations over generation

Usage
bsInfo$overGeneration(targetPop = NULL)
Arguments
targetPop

[character / numeric] population names or No.s you want to assemble. If NULL, assemble all the populations


Method parentInd()

search parents of an individual of interest

Usage
bsInfo$parentInd(indName)
Arguments
indName

[character] individual name of interest


Method print()

Display information about the object

Usage
bsInfo$print()

Method plot()

Draw figures for visualization of each data (GVs)

Usage
bsInfo$plot(
  plotTarget = "trueGV",
  targetTrait = 1:self$traitInfo$nTraits,
  targetPopulation = 1:self$generation,
  plotType = "box",
  facet_grid = FALSE,
  unitSd = 1,
  colorVecBase = c("black", "red", "green", "blue", "lightblue", "purple", "yellow",
    "gray", "pink", "orange"),
  widthVecBase = c(1.5, 0.8, 0.8),
  dashVecBase = c("solid", "dash", "dash")
)
Arguments
plotTarget

[character] Target of figure, select either one of "trueAGV", "trueDGV", "trueEGV", "trueGV", "trueAGVET", "trueDGVET", "trueEGVET", "trueGVET", "trueAGVCT", "trueDGVCT", "trueEGVCT", "trueGVCT".

targetTrait

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

targetPopulation

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

plotType

[character] We offer "box", "violin", "jitter", "lines" to draw figures for genotypic values.

facet_grid

[logical] When you choose "jitter" for plotType, you can select whether you display the plot for wach trait with grid.

unitSd

[numeric] When you choose "lines", we will show the mean, mean + unitSd * sd, mean - unitSd * sd.

colorVecBase

[character] vector representing color of the line for traits in "lines" option

widthVecBase

[numeric] vector representing width of the line in "lines" option

dashVecBase

[character]vector representing solid / dash in "lines" option


Method clone()

The objects of this class are cloneable with this method.

Usage
bsInfo$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


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