GenomicRanges-comparison {GenomicRanges} | R Documentation |
Methods for ordering and comparing the elements in one or more GenomicRanges objects.
Two elements of a GenomicRanges object (i.e. two genomic ranges) are
considered equal iff they are on the same underlying sequence and strand,
and have the same start and width.
The duplicated
and unique
methods for GenomicRanges objects
are using this equality.
The "natural order" for the elements of a GenomicRanges object is to
order them (a) first by sequence level, (b) then by strand, (c) then by
start, (d) and finally by width.
This way, the space of genomic ranges is totally ordered.
Note that the reduce
method for GenomicRanges uses this
"natural order" implicitly. Also, note that, because we already do (c)
and (d) for regular ranges (see ?`Ranges-comparison`
),
genomic ranges that belong to the same underlying sequence and strand are
ordered like regular ranges.
The order
, sort
and rank
methods for GenomicRanges
objects are using this "natural order".
Also the ==
, !=
, <=
, >=
, <
and >
operators between 2 GenomicRanges objects are using this "natural
order".
GenomicRanges-class, Ranges-comparison
gr <- GRanges( seqnames=Rle(c("chr1", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)), ranges=IRanges(1:10, end=10), strand=Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)), seqlengths=c(chr1=11, chr2=12, chr3=13)) duplicated(gr) duplicated(c(gr[4], gr)) unique(gr) unique(c(gr[4], gr)) order(gr) sort(gr) rank(gr) gr[2] == gr[2] # TRUE gr[2] == gr[5] # FALSE gr == gr[4] gr >= gr[3]