RangesList-utils {IRanges}R Documentation

RangesList utility functions

Description

Utility functions for manipulating RangesList objects.

Usage

## S4 method for signature 'RangesList':
shift(x, shift, use.names=TRUE)
## S4 method for signature 'RangesList':
restrict(x, start=NA, end=NA, keep.all.ranges=FALSE, use.names=TRUE)
## S4 method for signature 'RangesList':
narrow(x, start=NA, end=NA, width=NA, use.names=TRUE)
## S4 method for signature 'RangesList':
resize(x, width, start=TRUE, use.names=TRUE)
## S4 method for signature 'RangesList':
flank(x, width, start=TRUE, both=FALSE, use.names=TRUE)
## S4 method for signature 'RangesList':
gaps(x, start=NA, end=NA)
## S4 method for signature 'RangesList':
disjoin(x)
## S4 method for signature 'RangesList':
reduce(x, with.inframe.attrib=FALSE)
## S4 method for signature 'RangesList':
range(x, ..., na.rm = FALSE)

# Set operations
## S4 method for signature 'RangesList,RangesList':
union(x, y)
## S4 method for signature 'RangesList,RangesList':
intersect(x, y)
## S4 method for signature 'RangesList,RangesList':
setdiff(x, y)

Arguments

x, y A RangesList
start, end A single integer or NA for all functions except narrow, resize, and flank.

For narrow, the supplied start and end arguments must be vectors of integers, eventually with NAs, that contain coordinates relative to the current ranges.

For resize and flank, start is a logical indicating whether x should be flanked at the start (TRUE) or the end (FALSE). Recycled as necessary so that each element corresponds to a range in x.

width For narrow, a vector of integers, eventually with NAs. See the SEW (Start/End/Width) interface for the details (?solveUserSEW).

For resize and flank, the width of the resized or flanking regions. Note that if both is TRUE, this is effectively doubled. Recycled as necessary so that each element corresponds to a range in x.

shift A single integer.
both If TRUE, extends the flanking region width positions into the range. The resulting range thus straddles the end point, with width positions on either side.
use.names TRUE or FALSE. Should names be preserved?
keep.all.ranges TRUE or FALSE. Should ranges that don't overlap with the interval specified by start and end be kept? Note that "don't overlap" means that they end strictly before start - 1 or start strictly after end + 1. Ranges that end at start - 1 or start at end + 1 are always kept and their width is set to zero in the returned RangesList object.
with.inframe.attrib TRUE or FALSE. For internal use.
... Additional RangesList to consider.
na.rm Ignored

Details

The shift method shifts all the ranges in x.

The restrict method restricts the ranges in x to the interval specified by the start and end arguments.

The narrow method narrows the ranges in x i.e. each range in the returned RangesList object is a subrange of the corresponding range in x.

The resize method resizes the ranges to the specified width where either the start or end is used as an anchor.

The flank method generates flanking ranges for each range in x.

The gaps method takes the complement (via gaps) of each element in the list and returns the result as a RangesList.

The disjoin method returns disjoint ranges by finding the within element union of the end points of x.

The reduce method merges (via reduce) each of the elements in the list and returns the result as a RangesList.

range finds the range, i.e. a Ranges with one range, from the minimum start to the maximum end, on each element in x and returns the result as a RangesList. If there are additional RangesList objects in ..., they are merged into x by name, if all objects have names, otherwise, if they are all of the same length, by position. Else, an exception is thrown.

The union method performs elementwise union operations for two RangesList objects.

The intersect method performs elementwise intersect operations for two RangesList objects.

The setdiff method performs elementwise setdiff operations for two RangesList objects.

Value

A RangesList object. For shift, restrict, narrow, resize, flank, gaps and range, length is the same as that of x. For reduce, length is one.

Author(s)

Michael Lawrence, H. Pages, P. Aboyoun

See Also

RangesList, IRanges-utils

Examples

  # 'gaps'
  range1 <- IRanges(start=c(1,2,3), end=c(5,2,8))
  range2 <- IRanges(start=c(15,45,20,1), end=c(15,100,80,5))
  collection <- RangesList(one = range1, range2)

  shift(collection, shift=5)
  restrict(collection, start=2, end=8)
  resize(collection, width=200)
  flank(collection, width=10)
  disjoin(collection)

  # these two are the same
  RangesList(gaps(range1), gaps(range2))
  gaps(collection)

  # 'reduce'
  range2 <- IRanges(start=c(45,20,1), end=c(100,80,5))
  collection <- RangesList(one = range1, range2)

  # and these two are the same
  reduce(collection)
  RangesList(asNormalIRanges(IRanges(c(1,20), c(8, 100)), force=FALSE))

  # 'range'
  rl <- RangesList(a = IRanges(c(1,2),c(4,3)), b = IRanges(c(4,6),c(10,7)))
  rl2 <- RangesList(c = IRanges(c(0,2),c(4,5)), a = IRanges(c(4,5),c(6,7)))
  range(rl, rl2) # matched by names
  names(rl2) <- NULL
  range(rl, rl2) # now by position

  # set operations
  union(rl, rl2)
  intersect(rl, rl2)
  setdiff(rl, rl2)

[Package IRanges version 1.4.16 Index]