Skip to contents

Plot range-based annotation tracks (e.g. peaks)

Usage

trackplot_genome_annotation(
  loci,
  region,
  color_by = NULL,
  colors = NULL,
  label_by = NULL,
  label_size = 11 * 0.8/ggplot2::.pt,
  show_strand = FALSE,
  annotation_size = 2.5,
  track_label = "Peaks",
  return_data = FALSE
)

Arguments

loci

Genomic loci given as GRanges, data.frame, or list. See help("genomic-ranges-like") for details on format and coordinate systems. Required attributes:

  • chr, start, end: genomic position

region

Region to plot, e.g. output from gene_region(). String of format "chr1:100-200", or list/data.frame/GRanges of length 1 specifying chr, start, end. See help("genomic-ranges-like") for details

color_by

Name of a metadata column in loci to use for coloring, or a data vector with same length as loci. Column must be numeric or convertible to a factor.

colors

Vector of hex color codes to use for the color scale. For numeric color_by data, this is passed to ggplot2::scale_color_gradientn(), otherwise it is interpreted as a discrete color palette in ggplot2::scale_color_manual()

label_by

Name of a metadata column in loci to use for labeling, or a data vector with same length as loci. Column must hold string data.

label_size

size for labels in units of mm

show_strand

If TRUE, show strand direction as arrows

annotation_size

size for annotation lines in mm

return_data

If true, return data from just before plotting rather than a plot.

Value

Plot of genomic loci if return_data is FALSE, otherwise returns the data frame used to generate the plot