| Pairs-class {S4Vectors} | R Documentation |
Pairs objects
Description
Pairs is a Vector that stores two parallel vectors (any
object that can be a column in a DataFrame). It
provides conveniences for performing binary operations on the vectors,
as well as for converting between an equivalent list
representation. Virtually all of the typical R vector operations
should behave as expected.
A typical use case is representing the pairing from a
findOverlaps call, for which
findOverlapPairs is a shortcut.
Constructor
Pairs(first, second, ..., names = NULL, hits = NULL):-
Constructs a Pairs object by aligning the vectors
firstandsecond. The vectors must have the same length, unlesshitsis specified. Arguments in...are combined as columns in themcolsof the result. Thenamesargument specifies the names on the result. Ifhitsis notNULL, it should be aHitsobject that collates the elements infirstandsecondto produce the corresponding pairs.
Accessors
In the code snippets below, x is a Pairs object.
names(x),names(x) <- value:-
get or set the names
first(x),first(x) <- value:-
get or set the first member of each pair
second(x),second(x) <- value:-
get or set the second member of each pair
Coercion
zipup(x):Interleaves the
Pairsobjectxinto a list, where each element is composed of a pair. The type of list depends on the type of the elements.zipdown(x):The inverse of
zipup(). Convertsx, a list where every element is of length 2, to aPairsobject, by assuming that each element of the list represents a pair.
Subsetting
In the code snippets below, x is a Pairs object.
x[i]:Subset the Pairs object.
Author(s)
Michael Lawrence
See Also
-
Hits-class, a typical way to define a pairing.
-
findOverlapPairsin the IRanges package, which generates an instance of this class based on overlaps. -
setops-methods in the IRanges package, for set operations on Pairs objects.
Examples
p <- Pairs(1:10, Rle(1L, 10), score=rnorm(10), names=letters[1:10])
identical(first(p), 1:10)
mcols(p)$score
p
as.data.frame(p)
z <- zipup(p)
first(p) <- Rle(1:10)
identical(zipdown(z), p)