RangesMatching-class {IRanges}R Documentation

Matchings between Ranges

Description

The RangesMatching class stores a set of matchings between the ranges in one Ranges instance and the ranges in another. Currently, RangesMatching are used to represent the result of an overlap query, though other matching operations are imaginable.

Details

The matchings between the ranges are stored as a Matrix-class instance. While that structure is accessible, it is usually more convenient to coerce the RangesMatching instance to a more amenable representation.

The as.matrix method coerces a RangesMatching to a two column matrix with one row for each matching, where the value in the first column is the index of a range in the first (query) Ranges and the index of the matched subject range is in the second column.

The as.table method counts the number of matchings for each query range and outputs the counts as a table.

To transpose a RangesMatrix x, so that the subject and query are interchanged, call t(x). This allows, for example, counting the number of subjects that matched using as.table.

Coercion

In the code snippets below, x is a RangesMatching object.

as.matrix(x): Coerces x to a two column integer matrix, with each row representing a matching between a query index (first column) and subject index (second column).
as.table(x): counts the number of matchings for each query range in x and outputs the counts as a table.
t(x): Interchange the query and subject in x, returns a transposed RangesMatching.

Accessors

matchMatrix(x): Get the Matrix-class, which may be a dense logical matrix (lgeMatrix-class) or sparse non-zero pattern matrix (ngCMatrix-class), that encodes the matchings, with columns corresponding to query ranges and rows corresponding to subject ranges. It is not recommended to work with this matrix directly, unless the coercion methods above are inadequate.

Author(s)

Michael Lawrence

See Also

overlap, which generates an instance of this class.

Examples

  query <- IRanges(c(1, 4, 9), c(5, 7, 10))
  subject <- IRanges(c(2, 2, 10), c(2, 3, 12))
  tree <- IntervalTree(subject)
  matchings <- overlap(tree, query)

  as.matrix(matchings)

  as.table(matchings) # hits per query
  as.table(t(matchings)) # hits per subject

[Package IRanges version 1.0.16 Index]