Hits-class

Hits objects

The Hits class is a container for representing a set of hits between a set of left nodes and a set of right nodes. Note that only the hits are stored in the object. No information about the left or right nodes is stored, except their number.

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.

Keywords
classes, methods
Usage
## Constructor functions

Hits(from=integer(0), to=integer(0), nLnode=0L, nRnode=0L, ..., sort.by.query=FALSE)

SelfHits(from=integer(0), to=integer(0), nnode=0L, ..., sort.by.query=FALSE)

Arguments
from, to
2 integer vectors of the same length. The values in from must be >= 1 and <= nLnode. The values in to must be >= 1 and <= nRnode.
nLnode, nRnode
Number of left and right nodes.
...
Metadata columns to set on the Hits object. All the metadata columns must be vector-like objects of the same length as from and to.
sort.by.query
Should the hits in the returned object be sorted by query? If yes, then a SortedByQueryHits object is returned (SortedByQueryHits is a subclass of Hits).
nnode
Number of nodes.
See Also

  • Hits-comparisonfor comparing and ordering hits.
  • ThefindOverlapsfunction in theIRangespackage which returns SortedByQueryHits object.
  • Hits-examplesin theIRangespackage, for some examples of Hits object basic manipulation.
  • setops-methodsin theIRangespackage, for set operations on Hits objects.

Aliases
  • class:Hits
  • Hits-class
  • Hits
  • class:SelfHits
  • SelfHits-class
  • SelfHits
  • class:SortedByQueryHits
  • SortedByQueryHits-class
  • SortedByQueryHits
  • class:SortedByQuerySelfHits
  • SortedByQuerySelfHits-class
  • SortedByQuerySelfHits
  • parallelSlotNames,Hits-method
  • from
  • from,Hits-method
  • to
  • to,Hits-method
  • nLnode
  • nLnode,Hits-method
  • nRnode
  • nRnode,Hits-method
  • nnode
  • nnode,SelfHits-method
  • countLnodeHits
  • countLnodeHits,Hits-method
  • countRnodeHits
  • countRnodeHits,Hits-method
  • queryHits
  • subjectHits
  • queryLength
  • subjectLength
  • countQueryHits
  • countSubjectHits
  • updateObject,Hits-method
  • coerce,Hits,SortedByQueryHits-method
  • as.matrix,Hits-method
  • as.table,Hits-method
  • extractROWS,classNameForDisplay,ANY-method
  • classNameForDisplay,Hits-method
  • classNameForDisplay,SelfHits-method
  • show,Hits-method
  • c,Hits-method
  • t,Hits-method
  • remapHits
  • isSelfHit
  • isRedundantHit
Examples
from <- c(5, 2, 3, 3, 3, 2)
to <- c(11, 15, 5, 4, 5, 11)
id <- letters[1:6]

Hits(from, to, 7, 15, id)
Hits(from, to, 7, 15, id, sort.by.query=TRUE)

## ---------------------------------------------------------------------
## selectHits()
## ---------------------------------------------------------------------

x <- c("a", "b", "a", "c", "d")
table <- c("a", "e", "d", "a", "a", "d")
hits <- findMatches(x, table)  # sorts the hits by query
hits

selectHits(hits, select="all")  # no-op
selectHits(hits, select="first")
selectHits(hits, select="last")
selectHits(hits, select="arbitrary")
selectHits(hits, select="count")

## ---------------------------------------------------------------------
## remapHits()
## ---------------------------------------------------------------------

Lnodes.remapping <- factor(c(a="A", b="B", c="C", d="D")[x],
                           levels=LETTERS[1:4])
remapHits(hits, Lnodes.remapping=Lnodes.remapping)

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

## ---------------------------------------------------------------------
## SelfHits objects
## ---------------------------------------------------------------------

hits2 <- SelfHits(c(2, 3, 3, 3, 3, 3, 4, 4, 4), c(4, 3, 2:4, 2, 2:3, 2), 4)
## Hits 2 and 4 are self hits (from 3rd node to itself):
which(isSelfHit(hits2))
## Hits 4, 6, 7, 8, and 9, are redundant hits:
which(isRedundantHit(hits2))

hits3 <- findMatches(x)
hits3[!isSelfHit(hits3)]
hits3[!(isSelfHit(hits3) | isRedundantHit(hits3))]
Documentation reproduced from package S4Vectors, version 0.10.1, License: Artistic-2.0

Community examples

Looks like there are no examples yet.