Skip to contents

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 SNP

  • physPos: SNP physical position on the chromosome

  • linkMapPos: SNP linkage map position on the chromosome

  • SNPid: 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 SNP

  • physPos: SNP physical position on the chromosome

  • linkMapPos: SNP linkage map position on the chromosome

  • SNPid: SNP's IDs

specie

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

Returns

A new `SNPinfo` object.

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

Usage

SNPinfo$nSNP(chr = NA)

Arguments

chr

[str or numeric] chromosome id

Examples

SNPs$nSNP()
SNPs$nSNP(c("Chr2","Chr3"))


Method getInfo()

Get information about specific SNPs

Usage

SNPinfo$getInfo(SNPid)

Arguments

SNPid

[str] SNP ids

Examples

SNPs$getInfo("SNP01")
SNPs$getInfo(c("SNP01", "SNP03"))


Method print()

Display summary information about the object: specie, number of SNP, SNP coordinates.

Usage

SNPinfo$print()


Method plot()

plot chromosome map using the plotly package

Usage

SNPinfo$plot(alpha = 0.01)

Arguments

alpha

transparency see plot_ly

Examples

SNPs$plot(alpha = 1)


Method clone()

The objects of this class are cloneable with this method.

Usage

SNPinfo$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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)