Genomic track visualizations built within the ggplot2 framework
ggGenomicTracks provides genomic tracks as standard ggplot2 layers that can be stacked, themed, and combined like any other plot: copy number (total and allele-specific), structural variant junctions, binned coverage, genes, mutations, chromatin states, and ideograms. Coordinate systems place one or more genomic windows, cis or trans, or the whole genome on a single x-axis, so junctions can be drawn between loci in the style of gTrack. It is the graphical companion to devgru, and by default is anchored to hg38.
Full documentation and the function reference are available at https://pblaney.github.io/ggGenomicTracks/.
Installation
You can install the current development version of ggGenomicTracks with:
devtools::install_github("pblaney/ggGenomicTracks")Some dependencies are only available on GitHub (pblaney/devgru and mskilab-org/gUtils); these are declared as Remotes and resolved automatically by devtools/remotes.
Function Overview
See the reference page for full details on each function.
Quick Start
Draw copy number with junctions anchored at the copy number of each breakpoint, across several windows:
library(ggGenomicTracks)
library(ggplot2)
cn <- data.table::fread("sample.jabba.cnv.bed")
data.table::setnames(cn, "chrom", "seqnames")
junctions <- devgru::read_bedpe_file("sample.jabba.junctions.bedpe", output_type = "dt")
junctions <- annotate_junctions(junction_copy_number(junctions, cn))
windows <- c(MYC = "chr8:126000001-130000000", IGH = "chr14:105000001-107000000")
ggplot() +
geom_copy_number(data = cn) +
geom_junction(data = junctions, aes(y = cn1, yend = cn2, colour = sv_class)) +
scale_colour_sv_class() +
coord_loci(windows) +
theme_genomic()Stack copy number, allele-specific copy number, and coverage tracks on shared coordinates, here genome-wide:
coverage <- readRDS("sample.fragcounter.cov.rds")
stack_tracks(
ggplot() + geom_copy_number(data = cn) + theme_genomic(),
ggplot() + geom_copy_number(data = cn, alleles = TRUE) + theme_genomic(),
ggplot(coverage) + geom_coverage(y_range = c(0, 3)) + theme_genomic(),
windows = "genome",
heights = c(1.3, 1, 0.8)
)Bundled Data
ggGenomicTracks ships with hg38 cytobands (cytobands_hg38) for ideograms. The raw file it was built from is in inst/extdata/.
Contributing
Bug reports and feature requests are welcome on the issue tracker.
