Learn R Programming

S4Vectors (version 0.4.0)

Hits-class: Hits objects

Description

The Hits class stores a set of hits between 2 vector-like objects, one called the "query" and the other one the "subject".

For example, the findOverlaps function, defined and documented in the IRanges package, returns the hits between the query and subject arguments in a Hits object.

Arguments

Coercion

In the code snippets below, x is a Hits object.
as.matrix(x): Coerces x to a two column integer matrix, with each row representing a hit between a query index (first column) and subject index (second column).
as.table(x): counts the number of hits for each query element in x and outputs the counts as a table.
t(x): Interchange the query and subject in x, returns a transposed Hits.

Subsetting

x[i]: Subset the Hits object.

Accessors

length(x): get the number of hits
queryHits(x): Equivalent to as.data.frame(x)[[1]].
subjectHits(x): Equivalent to as.data.frame(x)[[2]].
queryLength(x), nrow(x): get the number of elements in the query
subjectLength(x), ncol(x): get the number of elements in the subject
countQueryHits(x): Counts the number of hits for each query, returning an integer vector.
countSubjectHits(x): Counts the number of hits for each subject, returning an integer vector.

Other operations

remapHits(x, query.map=NULL, new.queryLength=NA, subject.map=NULL, new.subjectLength=NA): Remaps the hits in x thru a "query map" and/or a "subject map" map. The query hits are remapped thru the "query map", which is specified via the query.map and new.queryLength arguments. The subject hits are remapped thru the "subject map", which is specified via the subject.map and new.subjectLength arguments. The "query map" is conceptually a function (in the mathematical sense) and is also known as the "mapping function". It must be defined on the 1..M interval and take values in the 1..N interval, where N is queryLength(x) and M is the value specified by the user via the new.queryLength argument. Note that this mapping function doesn't need to be injective or surjective. Also it is not represented by an R function but by an integer vector of length M with no NAs. More precisely query.map can be NULL (identity map), or a vector of queryLength(x) non-NA integers that are >= 1 and <= new.queryLength, or a factor of length queryLength(x) with no NAs (a factor is treated as an integer vector, and, if missing, new.queryLength is taken to be its number of levels). Note that a factor will typically be used to represent a mapping function that is not injective. The same apply to the "subject map". remapHits returns a Hits object where all the query and subject hits (accessed with queryHits and subjectHits, respectively) have been remapped thru the 2 specified maps. This remapping is actually only the 1st step of the transformation, and is followed by 2 additional steps: (2) the removal of duplicated hits, and (3) the reordering of the hits (first by query hits, then by subject hits). Note that if the 2 maps are injective then the remapping won't introduce duplicated hits, so, in that case, step (2) is a no-op (but is still performed). Also if the "query map" is strictly ascending and the "subject map" ascending then the remapping will preserve the order of the hits, so, in that case, step (3) is also a no-op (but is still performed).

Details

The as.matrix method coerces a Hits object to a two column matrix with one row for each hit, where the value in the first column is the index of an element in the query and the value in the second column is the index of an element in the subject.

The as.table method counts the number of hits for each query element and outputs the counts as a table.

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

See Also

  • findOverlaps in the IRanges package, which generates an instance of this class.

  • Hits-examples in the IRanges package, for some examples of Hits object basic manipulation.

  • setops-methods in the IRanges package, for set operations on Hits objects.

Examples

Run this code
## See ?`Hits-examples` in the IRanges package for examples of basic
## manipulation of Hits objects.

Run the code above in your browser using DataLab