GRanges-setops {GenomicRanges}R Documentation

GRanges and GRangesList Set and Parallel Set Operations

Description

Set and parallel set operations for GRanges/GRangesList objects.

Usage

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

  ## Parallel set operations
  ## S4 method for signature 'GRanges,GRanges':
punion(x, y, fill.gap = FALSE, ...)
  ## S4 method for signature 'GRanges,GRanges':
pintersect(x, y, resolve.empty = c("none", "max.start", "start.x"), ...)
  ## S4 method for signature 'GRanges,GRanges':
psetdiff(x, y, ...)

Arguments

x, y GRanges or GRangesList objects of equal length (i.e. length(x) == length(y)). For union, intersect, setdiff, x and y must both be GRanges objects. For pintersect, x and y cannot both be GRangesList objects. For psetdiff, x and must be a GRanges object.
fill.gap Logical indicating whether or not to force a union by using the rule start = min(start(x), start(y)), end = max(end(x), end(y)).
resolve.empty One of "none", "max.start", or "start.x" denoting how to handle ambiguous empty ranges formed by intersections. "none" - throw an error if an ambiguous empty range is formed, "max.start" - associate the maximum start value with any ambiguous empty range, and "start.x" - associate the start value of x with any ambiguous empty range. (See pintersect for the definition of an ambiguous range.)
... Further arguments to be passed to or from other methods.

Details

The pintersect methods involving GRanges and GRangesList objects use the triplet (sequence name, range, strand) to determine the element by element intersection of features, where a strand value of "*" is treated as occurring on both the "+" and "-" strand.

The psetdiff methods involving GRanges and GRangesList objects use the triplet (sequence name, range, strand) to determine the element by element set difference of features, where a strand value of "*" is treated as occurring on both the "+" and "-" strand.

Value

For union, intersect, and setdiff a GRanges.

For punion and pintersect either a GRanges object when both x and y are GRanges objects or a GRangesList object when one of the arguments is a GRangesList object.

For psetdiff either a GRanges object when both x and y are GRanges objects or a GRangesList object when y is a GRangesList object.

Author(s)

P. Aboyoun

See Also

GRanges, GRangesList, findOverlaps,GRanges,GRanges-method, pintersect,GRanges,GRanges-method

Examples

  ## GRanges object
  gr <-
    GRanges(seqnames = c("chr2", "chr1", "chr1"),
            ranges = IRanges(1:3, width = 12),
            strand = Rle(strand(c("-", "*", "-"))))
  gr

  ## GRangesList object
  gr1 <-
    GRanges(seqnames = "chr2", ranges = IRanges(3, 6),
            strand = "+", score = 5L, GC = 0.45)
  gr2 <-
    GRanges(seqnames = c("chr1", "chr1"),
            ranges = IRanges(c(7,13), width = 3),
            strand = c("+", "-"), score = 3:4, GC = c(0.3, 0.5))
  gr3 <-
    GRanges(seqnames = c("chr1", "chr2"),
            ranges = IRanges(c(1, 4), c(3, 9)),
            strand = c("-", "-"), score = c(6L, 2L), GC = c(0.4, 0.1))
  grlist <- GRangesList("gr1" = gr1, "gr2" = gr2, "gr3" = gr3)


  ## Union, intersection, and set difference of two GRanges objects
  union(gr2, gr3)
  intersect(gr2, gr3)
  setdiff(gr2, gr3)


  ## Parallel intersection of two GRanges objects
  pintersect(gr2, shift(gr2, 3))

  ## Parallel intersection of a GRanges and a GRangesList object
  pintersect(gr, grlist)
  pintersect(grlist, gr)


  ## Parallel set difference of two GRanges objects
  psetdiff(gr2, shift(gr2, 3))

  ## Parallel set difference of a GRanges and a GRangesList object
  psetdiff(gr, grlist)

[Package GenomicRanges version 1.0.7 Index]