pyramidtracks: Adding tracks to a pyramid plot.

pyramidtracksR Documentation

Adding tracks to a pyramid plot.

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.

Usage

as_track(x, height = 0.1, name, scale_y, ...)

## S3 method for class 'LayerInstance'
as_track(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, ...)

## S3 method for class 'CS_discovery'
as_track(
  x,
  height = 0.1,
  name = "Compartment\nScore",
  scale_y = NULL,
  ...,
  geom = "area"
)

## S3 method for class 'IS_discovery'
as_track(
  x,
  height = 0.1,
  name = "Insulation\nScore",
  scale_y = NULL,
  ...,
  geom = "area"
)

## S3 method for class 'DI_discovery'
as_track(
  x,
  height = 0.1,
  name = "Directionality\nIndex",
  scale_y = NULL,
  ...,
  geom = "area"
)

## S3 method for class 'domainogram_discovery'
as_track(x, height = 0.1, name = NULL, scale_y = NULL, ...)

## S3 method for class 'virtual4C_discovery'
as_track(x, height = 0.1, name = NULL, scale_y = NULL, ..., geom = "area")

Arguments

x

A ggplot layer instance

height

A numeric of length one noting the relative size to the main facet panel.

name

A character of length one title to display as facet strip label.

scale_y

A ggplot position scale with the y-aesthetic to control parameters of the track's y-scale.

...

Additional arguments to pass to ggplot2::layer().

bed

A BED-formatted data.frame with the following 3 columns:

  1. A character giving the chromosome names.

  2. An integer with start positions.

  3. An integer with end positions.

bedgraph

A data.frame with four columns wherein the first three columns are as in the bed argument and the fourth a score for the region.

strand

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

geom

[discovery only] A character of length one. One of the following:

  • "area" for a filled polygon plot.

  • "line" for a line plot.

  • "point" for a point plot.

Does not apply to domainogram_discovery class discoveries.

Details

Currently, as_track() only accepts layers wherein the data argument is explicitly defined before evaluation. For example, geom_point(aes(x = 1, y = 1)) is not an appropriate track, while 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 pyramid() plot, but this requires the layer-data to have column-names that match x-position names, e.g. "x", "xend", "xmax" etc. Likewise, when the layer-data contains a "chrom"-column, this is also subsetted to match the location of the main pyramid() plot.

Value

A track_layer object.

Examples

## Not run: 
# 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")

## End(Not run)

robinweide/GENOVA documentation built on March 14, 2024, 11:16 p.m.