haplotype: R6 Class representing an haplotype

haplotypeR Documentation

R6 Class representing an haplotype

Description

haplotype object store specific information of individuals haplotype

Public fields

lociInfo

[lociInfo class] information about the haplotype of the SNPs (see:lociInfo)

values

[list] list haplotype values

Active bindings

allelDose

[numeric] vector of haplotypes encoded in allele dose

Methods

Public methods


Method new()

Create a new Haplotype object.

Usage
haplotype$new(lociInfo, haplo)
Arguments
lociInfo

[lociInfo class] information about the haplotype's SNPs (see:lociInfo)

haplo

[matrix] named matrix of the genotype for all markers

Returns

A new 'lociInfo' 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,
                     recombRateOneVal = FALSE,
                     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)

### simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 3, replace = TRUE),
                   nrow = 2)
colnames(rawHaplo) <- paste0("Locus_", 1:(3 + 4 + 5))

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

Method clone()

The objects of this class are cloneable with this method.

Usage
haplotype$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `haplotype$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,
                     recombRateOneVal = FALSE,
                     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)

### simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 3, replace = TRUE),
                   nrow = 2)
colnames(rawHaplo) <- paste0("Locus_", 1:(3 + 4 + 5))

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

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