[BioC] unique, duplicated, order, etc... on a GRanges object

Hervé Pagès hpages at fhcrc.org
Thu Aug 18 05:07:52 CEST 2011

Hi there,

Seems like there was some need for this.

So I added the standard set of methods for ordering and comparing
genomic ranges i.e. duplicated, unique, order, sort, rank, "==",
"!=", "<=", ">=", "<", ">" now all work with GRanges objects.
It's in GenomicRanges 1.4.8 (release) and 1.5.27 (devel).

With Steve's big GRanges object:

   > system.time(oo <- order(xgr))
      user  system elapsed
    18.600   0.370  19.007

'xgr' obtained with:

   N <- 20000000L  # nb of ranges
   W <- 40L        # average width of the ranges
   start <- 1L
   end <- 55000000L
   x_start <- sample(end - W - 2L, N, replace=TRUE)
   x_width <- W + sample(-3:3, N, replace=TRUE)
   x <- IRanges(start=x_start, width=x_width)

   xgr <- GRanges(sample(c('chr1', 'chr2'), length(x), replace=TRUE), x,
                  sample(c('+', '-'), length(x), replace=TRUE))

You can have a look at ?`GenomicRanges-comparison` for more examples.

Let me know if you find any issue with this.


Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319

More information about the Bioconductor mailing list