haplotype object store specific information of individuals haplotype
Public fields
SNPinfo
[SNPinfo class] information about the haplotype of the SNPs (see:SNPinfo)
values
[list] list haplotype values
Methods
Method new()
Create a new Haplotype object.
Usage
haplotype$new(SNPinfo, haplo)
Arguments
SNPinfo
[SNPinfo class] information about the haplotype's SNPs (see:SNPinfo)
haplo
[matrix] named matrix of the haplotypes for all markers. This matrix should have `SNPinfo$specie$ploidy` line and `SNPinfo$nSNP()` columns.
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)
Examples
## ------------------------------------------------
## Method `haplotype$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)