Pairs-class: Pairs objects

Description Constructor Accessors Coercion Subsetting Author(s) See Also Examples

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 first and second. The vectors must have the same length, unless hits is specified. Arguments in ... are combined as columns in the mcols of the result. The names argument specifies the names on the result. If hits is not NULL, it should be a Hits object that collates the elements in first and second to 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 Pairs object x into 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(). Converts x, a list where every element is of length 2, to a Pairs object, 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

Examples

1
2
3
4
5
6
7
8
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)

Example output

Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
    intersect, is.unsorted, lapply, lengths, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min


Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

[1] TRUE
 [1] -2.5063410  0.7428989 -0.6765685 -1.2675264 -1.4810910 -0.9271910
 [7] -0.4343612  1.1386224 -0.4337271 -0.3033968
Pairs object with 10 pairs and 1 metadata column:
        first second |              score
    <integer>  <Rle> |          <numeric>
  a         1      1 |  -2.50634099335591
  b         2      1 |  0.742898917425883
  c         3      1 |  -0.67656847911581
  d         4      1 |  -1.26752636006478
  e         5      1 |  -1.48109096591931
  f         6      1 | -0.927191006057048
  g         7      1 | -0.434361222654978
  h         8      1 |   1.13862240850309
  i         9      1 |  -0.43372709039055
  j        10      1 | -0.303396828572137
   first second      score names
1      1      1 -2.5063410     a
2      2      1  0.7428989     b
3      3      1 -0.6765685     c
4      4      1 -1.2675264     d
5      5      1 -1.4810910     e
6      6      1 -0.9271910     f
7      7      1 -0.4343612     g
8      8      1  1.1386224     h
9      9      1 -0.4337271     i
10    10      1 -0.3033968     j
[1] TRUE

S4Vectors documentation built on Dec. 11, 2020, 2:02 a.m.