Learn R Programming

genomeIntervals (version 1.28.0)

Genome_intervals-ordering: Ordering methods for Genome intervals

Description

An order is defined on genome intervals and stranded genome intervals to allow sort(), order() and rank().

Usage

"order"(..., na.last=TRUE, decreasing=FALSE) "order"(..., na.last=TRUE, decreasing=FALSE)
"sort"(x, decreasing=FALSE, ...)
"rank"(x, na.last=TRUE, ties.method = c("average", "first", "random", "max", "min") ) "xtfrm"(x)

Arguments

x
Objects of class Genome_intervals or Genome_intervals_stranded.
...
Objects of class Genome_intervals, Genome_intervals_stranded or of any other class for order.
na.last
Ignored for ordering Genome_intervals and Genome_intervals_stranded objects
decreasing
TRUE or FALSE.
ties.method
A character string specifying how ties are treated. Only "first" is supported.

Details

An order on Genome_intervals entries is defined by sorting by 1. seqnames 2. start, where closed start & not inter-base < closed start & inter-base < open start & not inter-base < open start & inter-base 3. stop, where open stop & not inter-base < open stop & inter-base < closed stop & not inter-base < closed stop & inter-base 4. strand (for Genome_intervals_stranded object)

The factors seqnames and strand are sorted according to their levels (default R behavior).

The primitive is implemented in xtfrm which is then called by the other methods. Hence, the order, sort and rank methods are consistent.

order(..., na.last=TRUE, decreasing=TRUE): return a permutation which rearranges its first argument into ascending or descending order, breaking ties by further arguments. See order in the base package for more details. na.last is ignored for Genome_intervals objects.

rank(x, na.last=TRUE, ties.method=c("average", "first", "random", "max", "min")): Return the sample ranks of the (stranded) genome intervals in x. See rank in the base package for more details.

sort(x): Sort x. See sort in the base package for more details.

xtfrm(x): Auxiliary function that produces a numeric vector which will sort in the same order as 'x' x. See xtfrm in the base package for more details. Workhorse for the other methods

See Also

Genome_intervals Genome_intervals_stranded order, sort, rank, xtfrm

Examples

Run this code
## an example with ties
gi = GenomeIntervals(c("chr2", "chr2", "chr1", "chr1"), c(1,1,10,10), c(5,3,12,12) )

sort(gi)
rank(gi)
order(gi)

## Define order on seqnames at your convenience
## by specifying the order of the levels
## compare:
gi = GenomeIntervals(
		c("chr2", "chr2", "chr10", "chr10"),
		c(1,1,10,10),
		c(5,3,12,12)
		)
sort(gi)

## with:
gi2 = GenomeIntervals(
	factor(c("chr2", "chr2", "chr10", "chr10"), levels=c("chr2", "chr10")),
	c(1,1,10,10),
	c(5,3,12,12)
	)
sort(gi2)

Run the code above in your browser using DataLab