GRangePairs-class: GRangePairs objects

Description Details Constructor Accessors Vector methods List methods Coercion Other methods Author(s) See Also Examples

Description

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

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.

Constructor

GRangePairs(first=GRanges(), second=GRanges(), ..., names=NULL, hits=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), second(x): Get the ‘first’ or ‘last’/‘second’ GRange for each grange pair in x. The result is a GRanges object of the same length as x.

first(x)<-, second(x)<-: Set the ‘first’ or ‘second’ 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.

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 passed 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.

swap(x): Swap the first, last GRanges.

unique(x): Get the unique GRangePairs.

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.

Author(s)

Ge Tan

See Also

Axt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  ## Constructor
  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 and setters
  names(grangesPairs1)
  names(grangesPairs2) <- namesGRangePairs
  
  first(grangesPairs1)
  first(grangesPairs1) <- second(grangesPairs1)
  
  second(grangesPairs1)
  second(grangesPairs1) <- first(grangesPairs1)
  
  length(grangesPairs1)
  seqnames(grangesPairs1)
  strand(grangesPairs1)
  seqinfo(grangesPairs1)
  
  ## Vector methods
  grangesPairs1[1]
  
  ## List methods
  unlist(grangesPairs1)
  
  ## Coersion
  grglist(grangesPairs1)
  as(grangesPairs1, "GRangesList")
  as(grangesPairs1, "GRanges")
  as(grangesPairs1, "DataFrame")
  as.data.frame(grangesPairs1)
  
  ## Combining
  c(grangesPairs1, grangesPairs2)
  
  ## Swap
  swap(grangesPairs1)
  
  ## Unique
  unique(c(grangesPairs1, grangesPairs1))

CNEr documentation built on Nov. 8, 2020, 5:36 p.m.