IRanges-class {IRanges}R Documentation

IRanges and NormalIRanges objects

Description

The IRanges class is a simple implementation of the Ranges container where 2 integer vectors of the same length are used to store the start and width values. See the Ranges virtual class for a formal definition of Ranges objects and for their methods (all of them should work for IRanges objects).

A NormalIRanges object is just an IRanges object that is guaranteed to be "normal". See the Normality section in the man page for Ranges objects for the definition and properties of "normal" Ranges objects.

Constructor

IRanges(start=NULL, end=NULL, width=NULL): Return the IRanges object containing the ranges specified by start, end and width. Input falls into one of two categories:
Category 1
Exactly two out of the start, end and width arguments must be supplied as integer vectors (with no NAs) and the other argument must be NULL. If start and end are supplied, then they must be vectors of the same length. If start and width (or end and width) are supplied, then the length of width must be <= to the length of start and, if it is <, then width is expanded cyclically to the length of start.
Category 2
The start argument is a logical Rle object and produces the same result as as(start, "IRanges").

Methods for NormalIRanges objects

max(x): The maximum value in the finite set of integers represented by x.
min(x): The minimum value in the finite set of integers represented by x.

Author(s)

H. Pages

See Also

Ranges-class, IRanges-utils, IRanges-setops

Examples

  ## Using an IRanges object for storing a big set of ranges is more
  ## efficient than using a standard R data frame:
  N <- 2000000L  # nb of ranges
  W <- 180L      # width of each range
  start <- 1L
  end <- 50000000L
  set.seed(777)
  range_starts <- sort(sample(end-W+1L, N))
  range_widths <- rep.int(W, N)
  ## Instantiation is faster
  system.time(x <- IRanges(start=range_starts, width=range_widths))
  system.time(y <- data.frame(start=range_starts, width=range_widths))
  ## Subsetting is faster
  system.time(x16 <- x[c(TRUE, rep.int(FALSE, 15))])
  system.time(y16 <- y[c(TRUE, rep.int(FALSE, 15)), ])
  ## Internal representation is more compact
  object.size(x16)
  object.size(y16)

[Package IRanges version 1.1.55 Index]