individual: R6 class representing an individual

individualR Documentation

R6 class representing an individual

Description

individual object store specific information about one individual

Public fields

name

[string] Name of the individual

specie

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

traitInfo

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

parent1

[string] Name of the individual's parent

parent2

[string] Name of the individual's parent

haplo

[haplotype class] Haplotype of the individual (see: haplotype)

Active bindings

trueAGVs

[numeric] true additive genotypic values

trueAGVETs

[numeric] true additive genotypic values specific to each trait

trueAGVCTs

[numeric] true additive genotypic values common across traits

trueDGVs

[numeric] true dominant genotypic values

trueDGVETs

[numeric] true dominance genotypic values specific to each trait

trueDGVCTs

[numeric] true dominant genotypic values common across traits

trueEGVs

[numeric] true epistatic genotypic values

trueEGVETs

[numeric] true epistatic genotypic values between effects specific to each trait

trueEGVCTs

[numeric] true epistatic genotypic values between effects common across each trait

trueGVs

[numeric] true genotypic values

trueGVETs

[numeric] true genotypic values specific to each trait

trueGVCTs

[numeric] true genotypic values common across trait

Methods

Public methods


Method new()

Create a new individual object.

Usage
individual$new(
  name = "Unnamed",
  specie = specie$new(),
  traitInfo = NULL,
  parent1 = NA,
  parent2 = NA,
  haplo = NULL,
  verbose = TRUE
)
Arguments
name

[string] name of the individual

specie

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

traitInfo

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

parent1

[string] Name of the individual's parent

parent2

[string] Name of the individual's parent

haplo

[haplotype class] Haplotype of the individual (see: haplotype)

verbose

[boolean] display information

Returns

A new 'individual' 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 = c(3, 4, 5),
                     effPopSize = 3,
                     simInfo = mySimInfo,
                     verbose = TRUE)

### create lociInfo object
myLoci <- lociInfo$new(genoMap = NULL, specie = mySpec)


### create traitInfo object
myTrait <- traitInfo$new(lociInfo = myLoci,
                         nMarkers = c(2, 4, 3),
                         nTraits = 2,
                         nQTLs = matrix(c(1, 0, 2,
                                          1, 0, 1),
                                        nrow = 2,
                                        byrow = TRUE),
                         actionTypeEpiSimple = TRUE,
                         qtlOverlap = TRUE,
                         nOverlap = c(1, 0, 1),
                         effCor = 0.6,
                         propDomi = 0.2,
                         interactionMean = c(1, 0))
plot(myTrait, alphaMarker = 0.4)
### simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
                   nrow = 2)
colnames(rawHaplo) <- paste0("Locus_", 1:(3 + 4 + 5))

haplo <- myBreedSimulatR::haplotype$new(lociInfo = myLoci,
                                        haplo = rawHaplo)

### create individuals:
myInd <- individual$new(name = "Ind 1",
                        specie = myTrait$lociInfo$specie,
                        traitInfo = myTrait,
                        parent1 = "OkaaSan", parent2 = "OtouSan",
                        haplo = myHaplo, verbose = TRUE)

Method generateGametes()

Generate Gametes

Usage
individual$generateGametes(n = 1)
Arguments
n

[float] number of gametes to create (default: 1)

Returns

list of gametes. A gamete is a named vectors with value 0 or 1.

Examples
myInd$generateGametes()
myInd$generateGametes(2)

Method clone()

The objects of this class are cloneable with this method.

Usage
individual$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `individual$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 = c(3, 4, 5),
                     effPopSize = 3,
                     simInfo = mySimInfo,
                     verbose = TRUE)

### create lociInfo object
myLoci <- lociInfo$new(genoMap = NULL, specie = mySpec)


### create traitInfo object
myTrait <- traitInfo$new(lociInfo = myLoci,
                         nMarkers = c(2, 4, 3),
                         nTraits = 2,
                         nQTLs = matrix(c(1, 0, 2,
                                          1, 0, 1),
                                        nrow = 2,
                                        byrow = TRUE),
                         actionTypeEpiSimple = TRUE,
                         qtlOverlap = TRUE,
                         nOverlap = c(1, 0, 1),
                         effCor = 0.6,
                         propDomi = 0.2,
                         interactionMean = c(1, 0))
plot(myTrait, alphaMarker = 0.4)
### simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
                   nrow = 2)
colnames(rawHaplo) <- paste0("Locus_", 1:(3 + 4 + 5))

haplo <- myBreedSimulatR::haplotype$new(lociInfo = myLoci,
                                        haplo = rawHaplo)

### create individuals:
myInd <- individual$new(name = "Ind 1",
                        specie = myTrait$lociInfo$specie,
                        traitInfo = myTrait,
                        parent1 = "OkaaSan", parent2 = "OtouSan",
                        haplo = myHaplo, verbose = TRUE)

## ------------------------------------------------
## Method `individual$generateGametes`
## ------------------------------------------------

myInd$generateGametes()
myInd$generateGametes(2)

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