SNPinfo object store specific information of a set of SNP markers
Details
This class is useful for setting the Haplotype class. (see:
haplotype
)
Public fields
SNPcoord
[data.frame] Coordinate of all SNPs.
4 columns:
chr
: Chromosome holding the SNPphysPos
: SNP physical position on the chromosomelinkMapPos
: SNP linkage map position on the chromosomeSNPid
: SNP's IDs
specie
[specie class] Specie of the SNPs (see:specie)
SNPcoordList
[list] Named list of dataframes with the coordinate of all SNPs. for each chromosomes
ids
[list] Named list of the SNP ids for all chromosomes
Methods
Method new()
Create a new SNPinfo object.
Usage
SNPinfo$new(SNPcoord, specie)
Arguments
SNPcoord
[data.frame] Coordinate of all SNPs.
3 columns:
chr
: Chromosome holding the SNPphysPos
: SNP physical position on the chromosomelinkMapPos
: SNP linkage map position on the chromosomeSNPid
: SNP's IDs
specie
[specie class] Specie of the SNPs (see:specie)
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)
Method nSNP()
Get the number of SNPs per chromosomes
Examples
SNPs$nSNP()
SNPs$nSNP(c("Chr2","Chr3"))
Method getInfo()
Get information about specific SNPs
Examples
SNPs$getInfo("SNP01")
SNPs$getInfo(c("SNP01", "SNP03"))
Method print()
Display summary information about the object: specie, number of SNP, SNP coordinates.
Examples
## ------------------------------------------------
## Method `SNPinfo$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)
## ------------------------------------------------
## Method `SNPinfo$nSNP`
## ------------------------------------------------
SNPs$nSNP()
#> [1] 12
SNPs$nSNP(c("Chr2","Chr3"))
#> Chr2 Chr3
#> 4 5
## ------------------------------------------------
## Method `SNPinfo$getInfo`
## ------------------------------------------------
SNPs$getInfo("SNP01")
#> chr SNPid physPos linkMapPos
#> SNP01 Chr1 SNP01 63 NA
SNPs$getInfo(c("SNP01", "SNP03"))
#> chr SNPid physPos linkMapPos
#> SNP01 Chr1 SNP01 63 NA
#> SNP03 Chr1 SNP03 72 NA
## ------------------------------------------------
## Method `SNPinfo$plot`
## ------------------------------------------------
SNPs$plot(alpha = 1)