% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods_anchors.R
\name{anchors}
\alias{anchors}
\alias{anchors_PESCAn}
\alias{anchors_CSCAn}
\alias{anchors_APA}
\alias{anchors_ATA}
\alias{anchors_ARA}
\alias{anchors_extendedloops}
\title{Anchors for Hi-C}
\usage{
anchors_PESCAn(
  IDX,
  res,
  bed,
  dist_thres = c(5000000L, Inf),
  min_compare = 10L,
  mode = c("cis", "trans", "both")
)

anchors_CSCAn(
  IDX,
  res,
  bedlist,
  dist_thres = c(50000, 2e+06),
  min_compare = 10L,
  mode = c("cis", "trans", "both"),
  group_direction = FALSE
)

anchors_APA(
  IDX,
  res,
  bedpe,
  dist_thres = c(0, Inf),
  mode = c("both", "cis", "trans")
)

anchors_ATA(IDX, bed, dist_thres = c(225000, Inf), padding = 1)

anchors_ARA(IDX, bed, strand = NULL)

anchors_extendedloops(IDX, res, bedpe, dist_thres = c(30000, 3e+06))
}
\arguments{
\item{IDX}{The indices slot of a GENOVA \code{contacts} object.}

\item{res}{The resolution attribute of a GENOVA \code{contacts} object.\emph{
Not for ATA}.}

\item{bed, bedlist}{A BED-formatted \code{data.frame} with the following 3
columns: \enumerate{ \item A \code{character} giving the chromosome names.
\item An \code{integer} with start positions. \item An \code{integer} with
end positions. } For the \code{bedlist} variant, a named \code{list} of the 
above. (\emph{CSCAn only}).}

\item{dist_thres}{An \code{integer} vector of length 2 indicating the minimum
and maximum distances in basepairs between anchorpoints. For ATA-type
anchors, the minimum and maximum sizes of TADs.}

\item{min_compare}{An \code{integer} vector of length 1 indicating the
minimum number of pairwise interactions on a chromosome to consider.
\emph{PE-SCAn and C-SCAn only}.}

\item{mode}{A \code{character} vector of length 1 indicating which
interactions to retain. Possible values: \code{"cis"}, \code{"trans"} or
\code{"both"}. \emph{PE-SCAn, C-SCAn and APA only}.}

\item{group_direction}{A \code{logical} of length 1 which when \code{TRUE} 
will mirror groups for anchors where the left anchor location is larger 
than the right anchor location. Left and right refer to bedlist elements 
generating combinations. \emph{CSCAn only}.}

\item{bedpe}{A BEDPE-formatted \code{data.frame} with the following 6
columns. \emph{APA only}: \enumerate{ \item A \code{character} giving the
chromosome names of the first coordinate. \item An \code{integer} giving
the start positions of the first coordinate. \item An \code{integer} giving
the end positions of the first coordinate. \item A \code{character} giving
the chromosome names of the second coordinate. \item An \code{integer}
giving the start positions of the second coordinate. \item An
\code{integer} giving the end positions of the second coordinate. }}

\item{padding}{A \code{numeric} of length 1 to determine the padding around
TADs, expressed in TAD widths. \emph{ATA only}.}

\item{strand}{A \code{character} of the length \code{nrow(bed)}. Overrules
an attempt to infer strand from \code{start > end} information. 
\emph{ARA only}.}
}
\value{
A \code{anchors} object with two colums in \code{matrix} format.
}
\description{
Anchors are indices to the matrix in a \code{contacts} object.
  Anchor functions translate genomic coordinates, typically BED-formatted
  \code{data.frame}s, into indices corresponding to locations in the Hi-C
  matrix. Anchors are used in aggregate analysis functions to indicate where
  parts of the matrix should be looked up. Anchors come in different types,
  depending on the aggregate analysis functions they are used for.
}
\details{
Anchors are calculated within aggregate repeated matrix lookup
  analysis, but can also be provided as the '\code{anchors}' argument for
  these functions.

  Anchors are specific for a resolution of a \code{contacts} object and
  cannot be interchanged freely between resolutions.

  The '\code{mode}' argument determines what pairwise interactions are
  reported for \code{APA} and \code{PE-SCAn}. \code{"cis"} returns pairwise
  interactions within a chromosome; \code{"trans"} gives these between
  chromosomes and \code{"both"} returns both these types of interactions.
}
\section{Anchor types}{


  \subsection{PE-SCAn anchors}{ \code{anchors_PESCAn()} takes all pairwise
  interactions of genomic coordinates from a BED-like \code{data.frame} and
  maps these to indices of the Hi-C matrix. It is used within the
  \code{\link[GENOVA]{PESCAn}} function. Wether these pairwise interactions
  are allowed to cross chromosome boundaries is determined by the
  '\code{mode}' argument, which default to \code{"cis"} to only take pairwise
  interactions on the same chromosome.}

  \subsection{C-SCAn anchors}{ \code{anchors_CSCan()}, like
  \code{anchors_PESCAn}, takes all pairwise interactions of genomic
  coordinates, but crosswise between unique combinations of BED-like
  \code{data.frame}s in the \code{bedlist} argument. It is used within the
  \code{\link[GENOVA]{CSCAn}} function. Has a \code{group} attribute to
  keep track from which combination of BED-like \code{data.frame} the anchor
  originated.}

  \subsection{APA anchors}{ \code{anchors_APA()} takes a BEDPE-formatted
  \code{data.frame} and translates the coordinates in the first 3 and last 3
  columns to indices of the Hi-C matrix. It is used within the
  \code{\link[GENOVA]{APA}} function. The '\code{mode}' argument defaults to
  \code{"both"} but optionally allows for either cis- or trans-interactions
  too. }

  \subsection{Extended loops anchors}{ \code{anchors_extendedloops()} takes
  the same input as \code{anchors_APA()}, but transforms these coordinates to
  combinations of 5' and 3' anchors outside existing loops to get 'extended'
  loops. Based on the extended loops algorithm described in Haarhuis \emph{et
  al.} (2017).}

  \subsection{ATA anchors}{ \code{anchors_ATA()} takes the genomic
  coordinates of TADs in a BED-formatted \code{data.frame} and translates to
  indices of the Hi-C matrix. It is used within the \code{\link[GENOVA]{ATA}}
  function. In contrast to the PE-SCAn anchors and ATA anchors, ATA anchors
  are positions on the matrix's diagonal. The '\code{padding}' argument
  controls how large the region around a TAD should be expanded. Since TADs
  have variable sizes, ATA anchors can be calculated without resolution.}

  \subsection{ARA anchors}{ \code{anchors_ARA()} takes a BED-formatted
  \code{data.frame} and translates these to Hi-C matrix indices on the
  diagonal. It is used within the \code{\link[GENOVA]{ARA} function}. In
  contrast to other anchors, ARA anchors can take on a directionality. If the
  start positions are larger than the end positions, the anchor is assigned a
  \emph{reverse} direction. Else they are given the \emph{forward}
  direction.}
}

\examples{
\dontrun{
# PE-SCAn
anch <- anchors_PESCAn(WT_20kb$IDX, attr(WT_20kb, "resolution"),
                       super_enhancers)
PESCAn(list(WT_20kb, KO_20kb), anchors = anch)

# APA
anch <- anchors_APA(WT_20kb$IDX, attr(WT_20kb, "resolution"), loops)
APA(list(WT_20kb, KO_20kb), anchors = anch)

# APA with extended loops
ex_anch <- anchors_extendedloops(WT_20kb$IDX, attr(WT_20kb, "resolution"),
                                 loops)
APA(list(WT_20kb, KO_20kb), anchors = ex_anch)

# ATA
anch <- anchors_ATA(WT_10kb$IDX, tads)
ATA(list(WT_10kb, KO_10kb), anchors = anch)

# ARA
anch <- anchors_ARA(WT_20kb$IDX, ctcf_sites)
ARA(list(WT_20kb, KO_20kb), anchors = anch)
}
}
\seealso{
\code{\link[GENOVA]{bed2idx}} for general genomic coordinates to
  Hi-C index conversion.
}
