% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotateInteractions.R
\name{annotateInteractions}
\alias{annotateInteractions}
\title{Associate interactions to gene pairs}
\usage{
annotateInteractions(
  interactions,
  transcripts = NULL,
  tss = NULL,
  keyType = NULL,
  maxDistanceToTSS = 0
)
}
\arguments{
\item{interactions}{object of class \code{Pairs} (of \code{GRanges}) or
\code{GenomicInteractions}}

\item{transcripts}{\code{TxDb} annotation or other \code{GRanges} object}

\item{tss}{object of class \code{GRanges} as returned by
\code{\link{convertTranscriptsToTSS}}}

\item{keyType}{type of gene identifiers, such as "ENTREZID" or "ENSEMBL", if
it cannot be determined from metadata of \code{transcripts} or \code{tss}}

\item{maxDistanceToTSS}{maximal distance to extend the search for nearest
TSS outside the anchor}
}
\value{
A data table with columns \code{interactionID} (index of the
  interaction), \code{chrom1}, \code{start1}, \code{end1}, \code{chrom2},
  \code{start2}, \code{end2} (coordinates of both anchors), \code{geneID1},
  \code{geneID2} (gene identifiers from `transcripts` or `tss` for both
  anchors), \code{tss1}, \code{tss2} (TSS position for both anchors),
  \code{strand1} and \code{strand2} (TSS strand for both anchors).
}
\description{
Both interaction anchors are associated to TSSes as described in
\code{\link{annotateAnchors}}. Briefly, each anchor is associated to all the
TSSes it overlaps, or to all closest TSSes up to \code{maxDistanceToTSS} if
there is no such overlap. The annotation of an interaction is a Cartesian
product of annotations for both anchors.
}
\details{
Either \code{transcripts} or \code{tss} must be provided, but not both.
}
\examples{
library(TxDb.Hsapiens.UCSC.hg19.knownGene)

# take only the transcripts of coding genes by ensuring that the coding
# sequence strand is not NA
transcripts <- transcripts(TxDb.Hsapiens.UCSC.hg19.knownGene,
    columns = "gene_id", filter = list(cds_strand = c("-", "+"))
)

fpath <- system.file("extdata", "GM12878_loops.bedpe.gz", package = "GOaGO")
pairs <- rtracklayer::import(fpath, genome = "hg19")
annotateInteractions(pairs, transcripts, maxDistanceToTSS = 10e3)
}
\seealso{
\code{\link{convertTranscriptsToTSS}},
  \code{\link{annotateAnchors}}
}
