% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotateInteractions.R
\name{annotateAnchors}
\alias{annotateAnchors}
\title{Associate interaction anchors to the nearest TSSes}
\usage{
annotateAnchors(
  anchors,
  transcripts = NULL,
  tss = NULL,
  keyType = NULL,
  maxDistanceToTSS = 0
)
}
\arguments{
\item{anchors}{object of class \code{GRanges}}

\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
  anchor), \code{chrom}, \code{start}, \code{end} (coordinates of the
  anchor), \code{geneID} (gene identifier from `transcripts` or `tss`),
  \code{tss} (TSS position) and \code{strand} (TSS strand).
}
\description{
Interaction anchors are associated to TSSes as follows. Each anchor is
associated to all the TSSes it overlaps. If there is no such overlap, then
the anchor is associated to all TSSes with the shortest distance to the
anchor, if this distance is not larger than \code{maxDistanceToTSS}.
}
\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("-", "+"))
)

tss <- convertTranscriptsToTSS(transcripts)
gr <- GRanges("chr1", IRanges(c(42001, 890001), c(62000, 900000)))

# note that anchors are associated to TSSes outside the anchor only if there
# are no TSSes overlapping the anchor
annotateAnchors(gr, tss, maxDistanceToTSS = 10e3)

# this may yield more associations to TSSes outside the anchors
annotateAnchors(gr + 10e3, tss)
}
\seealso{
\code{\link{convertTranscriptsToTSS}}
}
