\HeaderA{RangesMatching-class}{Matchings between Ranges}{RangesMatching.Rdash.class}
\aliasA{as.matrix,RangesMatching-method}{RangesMatching-class}{as.matrix,RangesMatching.Rdash.method}
\aliasA{as.table,RangesMatching-method}{RangesMatching-class}{as.table,RangesMatching.Rdash.method}
\aliasA{dim,RangesMatching-method}{RangesMatching-class}{dim,RangesMatching.Rdash.method}
\aliasA{length,RangesMatching-method}{RangesMatching-class}{length,RangesMatching.Rdash.method}
\aliasA{matchMatrix}{RangesMatching-class}{matchMatrix}
\aliasA{matchMatrix,RangesMatching-method}{RangesMatching-class}{matchMatrix,RangesMatching.Rdash.method}
\aliasA{queryHits}{RangesMatching-class}{queryHits}
\aliasA{queryHits,RangesMatching-method}{RangesMatching-class}{queryHits,RangesMatching.Rdash.method}
\aliasA{ranges,RangesMatching-method}{RangesMatching-class}{ranges,RangesMatching.Rdash.method}
\aliasA{subjectHits}{RangesMatching-class}{subjectHits}
\aliasA{subjectHits,RangesMatching-method}{RangesMatching-class}{subjectHits,RangesMatching.Rdash.method}
\aliasA{t,RangesMatching-method}{RangesMatching-class}{t,RangesMatching.Rdash.method}
\keyword{methods}{RangesMatching-class}
\keyword{classes}{RangesMatching-class}
\begin{Description}\relax
The \code{RangesMatching} class stores a set of matchings
between the ranges in one \code{\LinkA{Ranges}{Ranges.Rdash.class}} object and the
ranges in another. Currently, \code{RangesMatching} are used to represent
the result of a call to \code{\LinkA{findOverlaps}{findOverlaps}}, though other matching
operations are imaginable.
\end{Description}
\begin{Details}\relax
The \code{as.matrix} method coerces a \code{RangesMatching} to a two
column \code{matrix} with one row for each matching, where the value
in the first column is the index of a range in the first (query)
\code{Ranges} and the index of the matched subject range is in the
second column. The \code{matchMatrix} function returns the same thing,
but use of \code{as.matrix} is preferred.

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

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

To get the actual regions of intersection between the overlapping
ranges, use the \code{ranges} accessor.
\end{Details}
\begin{Section}{Coercion}
In the code snippets below, \code{x} is a \code{RangesMatching}
object.

\describe{
\item[] \code{as.matrix(x)}: Coerces \code{x} to a two
column integer matrix, with each row representing a matching
between a query index (first column) and subject index (second
column).

\item[] \code{as.table(x)}: counts the number of matchings for each
query range in \code{x} and outputs the counts as a \code{table}.

\item[] \code{t(x)}: Interchange the query and subject in \code{x},
returns a transposed \code{RangesMatching}.
}
\end{Section}
\begin{Section}{Accessors}
\describe{
\item[] \code{queryHits(x)}: Gets the indices of overlapping
ranges in the query, equivalent to \code{as.matrix(x)[,1]}.

\item[] \code{subjectHits(x)}: Gets the indices of overlapping
ranges in the subject, equivalent to \code{as.matrix(x)[,2]}.

\item[] \code{matchMatrix(x)}: A synonym for \code{as.matrix}, above.

\item[] \code{ranges(x, query, subject)}: returns a \code{Ranges}
holding the intersection of the ranges in the
\code{Ranges} objects \code{query} and \code{subject}, which
should be the same subject and query used to generate
\code{x}. Eventually, we might store the query and subject inside
\code{x}, in which case the arguments would be redundant.

\item[] \code{length(x)}: get the number of matches
\item[] \code{nrow(x)}: get the number of queries in the matching
\item[] \code{ncol(x)}: get the number of subjects in the matching
\item[] \code{dim(x)}: get a two-element integer vector, essentially
\code{c(nrow(x), ncol(x))}.

}
\end{Section}
\begin{Author}\relax
Michael Lawrence
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{findOverlaps}{findOverlaps}}, which generates an instance of this class.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  query <- IRanges(c(1, 4, 9), c(5, 7, 10))
  subject <- IRanges(c(2, 2, 10), c(2, 3, 12))
  tree <- IntervalTree(subject)
  matchings <- findOverlaps(query, tree)

  as.matrix(matchings)

  as.table(matchings) # hits per query
  as.table(t(matchings)) # hits per subject
\end{ExampleCode}
\end{Examples}

