Learn R Programming

CNEr (version 1.8.3)

GRangePairs-class: GRangePairs objects

Description

The GRangePairs class is a container for a pair of GRanges object that have same lengths.

Arguments

Constructor

GRangePairs(first=GRanges(), last=GRanges(), names=NULL): GRangePairs constructor.

Accessors

In the code snippets below, x is a GRangePairs object.
length(x): Return the number of granges pairs in x.
names(x), names(x) <- value: Get or set the names on x.
first(x), last(x): Get the "first" or "last" GRange for each grange pair in x. The result is a GRanges object of the same length as x.
seqnames(x): Get the seqname of first GRanges and last GRanges and return in a DataFrame object.
strand(x): Get the strand for each grange pair in x.
seqinfo(x): Get the information about the underlying sequences.

Vector methods

In the code snippets below, x is a GRangePairs object.
x[i]: Return a new GRangePairs object made of the selected genomic ranges pairs.

List methods

In the code snippets below, x is a GRangePairs object.
x[[i]]: Extract the i-th alignment pair as a GRangePairs object of length 2. As expected x[[i]][1] and x[[i]][2] are respectively the "first" and "last" granges in the pair.
unlist(x, use.names=TRUE): Return the GRangePairs object conceptually defined by c(x[[1]], x[[2]], ..., x[[length(x)]]). use.names determines whether x names should be propagated to the result or not.

Coercion

In the code snippets below, x is a GRangePairs object.
grglist(x, use.mcols=FALSE): Return a GRangesList object of length length(x) where the i-th element represents the ranges (with respect to the reference) of the i-th grange pair in x. Note that this results in the ranges being always ordered consistently with the original "query template", that is, being in the order defined by walking the "query template" from the beginning to the end. If use.mcols is TRUE and x has metadata columns on it (accessible with mcols(x)), they're propagated to the returned object.
as(x, "GRangesList"): Alternate ways of doing grglist(x, use.mcols=TRUE).
as(x, "GRanges"): Equivalent of unlist(x, use.names=TRUE).

Other methods

In the code snippets below, x is a GRangesList object.
show(x): By default the show method displays 5 head and 5 tail elements. This can be changed by setting the global options showHeadLines and showTailLines. If the object length is less than (or equal to) the sum of these 2 options plus 1, then the full object is displayed.

Details

A GRangePairs object is a list-like object where each element describes a pair of genomic range. They do not necessarily have the same seqinfo, i.e., the coordinates from the same assembly.

See Also

Axt

Examples

Run this code
  library(GenomicRanges)
  first <- GRanges(seqnames=c("chr1", "chr1", "chr2", "chr3"),
                   ranges=IRanges(start=c(1, 20, 2, 3),
                                  end=c(10, 25, 10, 10)),
                   strand="+")
  last <- GRanges(seqnames=c("chr1", "chr10", "chr10", "chr20"),
                  ranges=IRanges(start=c(1, 25, 50, 5),
                                 end=c(8, 40, 55, 16)),
                  strand="+")
  namesGRangePairs <- c("a","b","c","d")
  grangesPairs1 <- GRangePairs(first, last, names=namesGRangePairs)
  grangesPairs2 <- GRangePairs(first, last)
  
  ## getters
  names(grangesPairs1)
  length(grangesPairs1)
  first(grangesPairs1)
  last(grangesPairs1)
  seqnames(grangesPairs1)
  strand(grangesPairs1)
  seqinfo(grangesPairs1)
  
  ## setters
  names(grangesPairs2) <- namesGRangePairs
  
  ## Vector methods
  grangesPairs1[1]
  
  ## List methods
  grangesPairs1[[1]]
  unlist(grangesPairs1)
  
  ## Coersion
  grglist(grangesPairs1)
  as(grangesPairs1, "GRangesList")
  as(grangesPairs1, "GRanges")
  as(grangesPairs1, "DataFrame")
  as.data.frame(grangesPairs1)
  
  ## Combining
  c(grangesPairs1, grangesPairs2)

Run the code above in your browser using DataLab