individual object store specific information about one individual
Methods
Method new()
Create a new individual object.
Usage
individual$new(
name = "Unnamed",
specie = specie$new(),
parent1 = NA,
parent2 = NA,
haplo = NA,
verbose = TRUE
)
Examples
# create specie
mySpec <- specie$new(nChr = 3,
lchr = c(100, 150, 200),
lchrCm = 100,
verbose = FALSE)
# simulate SNP
SNPcoord <- data.frame(chr = c(rep("Chr1", 3),
rep("Chr2", 4),
rep("Chr3", 5)),
physPos = c(sample(100, 3),
sample(150, 4),
sample(200, 5)),
linkMapPos = NA,
SNPid = sprintf(fmt = paste0("SNP%0", 2,"i"),
1:(3 + 4 + 5)))
# create SNPinfo object
SNPs <- SNPinfo$new(SNPcoord = SNPcoord, specie = mySpec)
# simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
nrow = 2)
colnames(rawHaplo) <- sprintf(fmt = paste0("SNP%0", 2,"i"),
1:(3 + 4 + 5))
haplo <- haplotype$new(SNPinfo = SNPs,
haplo = rawHaplo)
myInd <- individual$new(name = "Ind 1",
specie = mySpec,
parent1 = "OkaaSan",
parent2 = "OtouSan",
haplo = haplo,
verbose = FALSE)
Examples
## ------------------------------------------------
## Method `individual$new`
## ------------------------------------------------
# create specie
mySpec <- specie$new(nChr = 3,
lchr = c(100, 150, 200),
lchrCm = 100,
verbose = FALSE)
# simulate SNP
SNPcoord <- data.frame(chr = c(rep("Chr1", 3),
rep("Chr2", 4),
rep("Chr3", 5)),
physPos = c(sample(100, 3),
sample(150, 4),
sample(200, 5)),
linkMapPos = NA,
SNPid = sprintf(fmt = paste0("SNP%0", 2,"i"),
1:(3 + 4 + 5)))
# create SNPinfo object
SNPs <- SNPinfo$new(SNPcoord = SNPcoord, specie = mySpec)
# simulate haplotype
rawHaplo <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
nrow = 2)
colnames(rawHaplo) <- sprintf(fmt = paste0("SNP%0", 2,"i"),
1:(3 + 4 + 5))
haplo <- haplotype$new(SNPinfo = SNPs,
haplo = rawHaplo)
myInd <- individual$new(name = "Ind 1",
specie = mySpec,
parent1 = "OkaaSan",
parent2 = "OtouSan",
haplo = haplo,
verbose = FALSE)
## ------------------------------------------------
## Method `individual$generateGametes`
## ------------------------------------------------
myInd$generateGametes()
#> [[1]]
#> SNP03 SNP01 SNP02 SNP05 SNP07 SNP06 SNP04 SNP09 SNP08 SNP11 SNP12 SNP10
#> 0 0 1 1 0 0 1 1 1 0 1 1
#>
myInd$generateGametes(2)
#> [[1]]
#> SNP03 SNP01 SNP02 SNP05 SNP07 SNP06 SNP04 SNP09 SNP08 SNP11 SNP12 SNP10
#> 1 0 0 1 0 0 1 1 1 0 1 1
#>
#> [[2]]
#> SNP03 SNP01 SNP02 SNP05 SNP07 SNP06 SNP04 SNP09 SNP08 SNP11 SNP12 SNP10
#> 0 0 1 1 0 0 1 1 1 0 1 1
#>