% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pyramids.R
\name{pyramidtracks}
\alias{pyramidtracks}
\alias{as_track}
\alias{as_track.LayerInstance}
\alias{add_bed_track}
\alias{add_bed_graph}
\alias{add_ctcf_sites}
\alias{ggplot_add.track_layer}
\alias{as_track.CS_discovery}
\alias{as_track.IS_discovery}
\alias{as_track.DI_discovery}
\alias{as_track.domainogram_discovery}
\alias{as_track.virtual4C_discovery}
\alias{ggplot_add.genomescore_discovery}
\title{Adding tracks to a pyramid plot.}
\usage{
as_track(x, height = 0.1, name, scale_y, ...)

\method{as_track}{LayerInstance}(x, height = 0.1, name, scale_y = NULL, ...)

add_bed_track(bed, height = 0.1, name, ...)

add_bed_graph(bedgraph, height = 0.1, name, ...)

add_ctcf_sites(bed, strand, height = 0.05, name = "CTCF", scale_y = NULL, ...)

\method{as_track}{CS_discovery}(
  x,
  height = 0.1,
  name = "Compartment\\nScore",
  scale_y = NULL,
  ...,
  geom = "area"
)

\method{as_track}{IS_discovery}(
  x,
  height = 0.1,
  name = "Insulation\\nScore",
  scale_y = NULL,
  ...,
  geom = "area"
)

\method{as_track}{DI_discovery}(
  x,
  height = 0.1,
  name = "Directionality\\nIndex",
  scale_y = NULL,
  ...,
  geom = "area"
)

\method{as_track}{domainogram_discovery}(x, height = 0.1, name = NULL, scale_y = NULL, ...)

\method{as_track}{virtual4C_discovery}(x, height = 0.1, name = NULL, scale_y = NULL, ..., geom = "area")
}
\arguments{
\item{x}{A ggplot layer instance}

\item{height}{A \code{numeric} of length one noting the relative size to the
main facet panel.}

\item{name}{A \code{character} of length one title to display as facet strip
label.}

\item{scale_y}{A ggplot position scale with the y-aesthetic to control
parameters of the track's y-scale.}

\item{...}{Additional arguments to pass to \code{ggplot2::layer()}.}

\item{bed}{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. }}

\item{bedgraph}{A \code{data.frame} with four columns wherein the first three
columns are as in the \code{bed} argument and the fourth a score for the 
region.}

\item{strand}{[\code{add_ctcf_sites()} only] A \code{character} vector of the
same length as \code{bed} with either \code{"+"} or \code{"-"} values that
determine the orientation of triangles.}

\item{geom}{[discovery only] A \code{character} of length one. One of the 
following: \itemize{
  \item{\code{"area"} for a filled polygon plot.}
  \item{\code{"line"} for a line plot.}
  \item{\code{"point"} for a point plot.}
} Does not apply to \code{domainogram_discovery} class discoveries.}
}
\value{
A \code{track_layer} object.
}
\description{
These functions add new facets to a pyramid plot with additional
  annotations. You can add annotations to the pyramid plot with BED regions,
  bedgraphs, CTCF sites, discoveries that run along the genome and ggplot 
  layers.
}
\details{
Currently, \code{as_track()} only accepts layers wherein the
  \code{data} argument is explicitly defined before evaluation. For example,
  \code{geom_point(aes(x = 1, y = 1))} is not an appropriate track, while
  \code{geom_point(aes(x + 1, y = y), data = data.frame(x = 1, y = 1))} is an
  appropriate track.
  
  An attempt is made to subset the input based on the x-coordinates of the
  main \code{pyramid()} plot, but this requires the layer-data to have 
  column-names that match x-position names, e.g. \code{"x"}, \code{"xend"}, 
  \code{"xmax"} etc. Likewise, when the layer-data contains a 
  \code{"chrom"}-column, this is also subsetted to match the location of the
  main \code{pyramid()} plot.
}
\examples{
\dontrun{
# Initialising a pyramid
p <- pyramid(exp, "chr2", 25e6, 30e6)

# Adding a bed annotation
p + add_bed_track(bed, fill = "blue", name = "bed")

# Adding a bedgraph annotation
p <- p + add_bed_graph(bedgraph, linetype = 2, name = "Some statistic")
p

# Adding custom annotation
# Use the name to display in the same panel as previous annotation
p + as_track(ggplot2::geom_vline(xintercept = 27.5e6),
             name = "Some statistic")

# Adding discovery annotation
insula <- insulation_score(exp)
p + insula

# Using `as_track()` gives more control over the appearance of discoveries
p + as_track(insula, geom = "line", linetype = 2)

# When a discovery contains multiple samples, all are added
compart <- compartment_score(list(exp1, exp2), bed = H3K4me1_peaks)
p + compart

# To seperate discoveries as individual tracks, they have to be unbundled and
# named differently
compart <- unbundle(compart)
p + as_track(compart[[1]], name = "exp1") + 
 as_track(compart[[2]], name = "exp2")
}
}
\keyword{internal}
