## ---------------------------------------------------------------------
## seqlevelsStyle() getter and setter
## ---------------------------------------------------------------------
## find the seqname Style for a given character vector
seqlevelsStyle(paste0("chr", 1:30))
## Rename the seqlevels of a GRanges object with the seqlevelsStyle()
## setter:
library(GenomicRanges)
gr <- GRanges(rep(c("chr2", "chr3", "chrM"), 2), IRanges(1:6, 10))
seqlevelsStyle(gr)
seqlevelsStyle(gr) <- "NCBI"
gr
seqlevelsStyle(gr)
seqlevelsStyle(gr) <- "dbSNP"
gr
seqlevelsStyle(gr)
seqlevelsStyle(gr) <- "UCSC"
gr
## ---------------------------------------------------------------------
## Related low-level utilities
## ---------------------------------------------------------------------
names(genomeStyles())
genomeStyles("Homo_sapiens")
"UCSC" %in% names(genomeStyles("Homo_sapiens"))
## List the supported seqname style for the given species and the given
## style
extractSeqlevels(species="Drosophila_melanogaster" , style="Ensembl")
## List all sex chromosomes for Homo sapiens using style UCSC
## 3 groups are supported: 'auto' for autosomes, 'sex' for allosomes
## and 'circular' for circular chromosomes
extractSeqlevelsByGroup(species="Homo_sapiens", style="UCSC", group="sex")
## find whether the seqnames belong to a given group
newchr <- paste0("chr",c(1:22,"X","Y","M","1_gl000192_random","4_ctg9"))
seqlevelsInGroup(newchr, group="sex")
newchr <- as.character(c(1:22,"X","Y","MT"))
seqlevelsInGroup(newchr, group="all","Homo_sapiens","NCBI")
## if we have a vector conatining seqnames and we want to verify the
## species and style for them , we can use:
seqnames <- c("chr1","chr9", "chr2", "chr3", "chr10")
all(seqnames %in% extractSeqlevels("Homo_sapiens", "UCSC"))
## find mapped seqlevelsStyles for exsiting seqnames
mapSeqlevels(c("chrII", "chrIII", "chrM"), "NCBI")
mapSeqlevels(c("chrII", "chrIII", "chrM"), "Ensembl")
Run the code above in your browser using DataLab