Last data update: 2014.03.03
R: Assign sequence IDs to sequence names
rankSeqlevels R Documentation
Assign sequence IDs to sequence names
Description
rankSeqlevels
assigns a unique ID to each unique sequence name
in the input vector. The returned IDs span 1:N where N is the number of
unique sequence names in the input vector.
orderSeqlevels
is similar to rankSeqlevels
except that
the returned vector contains the order instead of the rank.
Usage
rankSeqlevels(seqnames, X.is.sexchrom=NA)
orderSeqlevels(seqnames, X.is.sexchrom=NA)
Arguments
seqnames
A character vector or factor containing sequence names.
X.is.sexchrom
A logical indicating whether X refers to the sexual chromosome
or to chromosome with Roman Numeral X. If NA
, rankSeqlevels
does its best to "guess".
Value
An integer vector of the same length as seqnames
that tries to
reflect the “natural” order of seqnames, e.g.,chr1
,
chr2
, chr3
, ...
The values in the returned vector span 1:N where N is the number
of unique sequence names in the input vector.
Author(s)
H. Pages for rankSeqlevels
, orderSeqlevels
added by
Sonali Arora
See Also
Examples
library(BSgenome.Scerevisiae.UCSC.sacCer2)
rankSeqlevels(seqnames(Scerevisiae))
rankSeqlevels(seqnames(Scerevisiae)[c(1:5,5:1)])
newchr <- paste0("chr",c(1:3,6:15,4:5,16:22))
newchr
orderSeqlevels(newchr)
rankSeqlevels(newchr)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GenomeInfoDb)
Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: S4Vectors
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/GenomeInfoDb/rankSeqlevels.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rankSeqlevels
> ### Title: Assign sequence IDs to sequence names
> ### Aliases: rankSeqlevels orderSeqlevels
> ### Keywords: manip
>
> ### ** Examples
>
> library(BSgenome.Scerevisiae.UCSC.sacCer2)
Loading required package: BSgenome
Loading required package: GenomicRanges
Loading required package: Biostrings
Loading required package: XVector
Loading required package: rtracklayer
> rankSeqlevels(seqnames(Scerevisiae))
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
> rankSeqlevels(seqnames(Scerevisiae)[c(1:5,5:1)])
[1] 1 2 3 4 5 5 4 3 2 1
>
> newchr <- paste0("chr",c(1:3,6:15,4:5,16:22))
> newchr
[1] "chr1" "chr2" "chr3" "chr6" "chr7" "chr8" "chr9" "chr10" "chr11"
[10] "chr12" "chr13" "chr14" "chr15" "chr4" "chr5" "chr16" "chr17" "chr18"
[19] "chr19" "chr20" "chr21" "chr22"
> orderSeqlevels(newchr)
[1] 1 2 3 14 15 4 5 6 7 8 9 10 11 12 13 16 17 18 19 20 21 22
> rankSeqlevels(newchr)
[1] 1 2 3 6 7 8 9 10 11 12 13 14 15 4 5 16 17 18 19 20 21 22
>
>
>
>
>
> dev.off()
null device
1
>