Caution
Very early results from work in progress!
Genome browser tracks as ggplot2 layers.
- In: a region of a BAM, CRAM, GFF3, GTF, BED, BigBed, BigWig or VCF, or two regions a PAF aligns.
- Out: the tables JBrowse 2's displays draw from, run in V8, in their colors.
- Also: reads CRAM, which Rsamtools cannot, and needs no Bioconductor packages.
- Drawn with: a geom per table, so a figure is an ordinary ggplot;
autoplot()composes a track.
remotes::install_github("GMOD/ggjbrowse")- Every figure is drawn from data installed with the package, by
jb2export(left) and ggjbrowse (right). - A title links to the figure's R and
jb2exportrecipes in docs/gallery.md.
library(ggjbrowse)
e <- function(f) system.file("extdata", f, package = "ggjbrowse")
a <- jbrowse_alignments(e("gapdh_direct_rna.bam"), "chr12:6,534,201-6,538,700")
autoplot(a)a is a list of data frames, so the figure is also ordinary ggplot2:
library(ggplot2)
ggplot(a) +
geom_jbrowse_reads(aes(fill = mapq)) +
geom_jbrowse_mismatches() +
scale_fill_viridis_c() +
scale_y_reverse()- Data: every example runs on clips of public human data installed with the package.
- Regions:
"chr12:6,534,201-6,538,700", a contig name, achrom/start/enddata frame or a GRanges. - Several regions draw end to end.
- Whole files: leave out the region and a reader reads every contig the file lists.
- Files: a path or a URL. CRAM needs its FASTA as
assembly. - Filters:
a$reads <- subset(a$reads, mapq >= 20)drops their mismatches, gaps and clips too. - Colors and keys: the geoms paint the display's colors;
guides_jbrowse(a)adds its keys. - The display's decisions are columns:
a$junctions$shown <- a$junctions$count >= 5hides thin junctions. - Saved results: a result saved with
saveRDS()draws again without its files. - The file's own fields (GFF3 attributes, autoSql columns, VCF INFO and FORMAT) are columns.
- Contig names:
chr7here,7there? Give each readerassembly = jbrowse_assembly(fasta, aliases).
Whole analyses done in R, each on the data and question of a JBrowse tutorial:
- Methylation (bisulfite) in R: per-read CpG, CHG and CHH calls, checked against MethylDackel
- Methylation (long-read) in R: HG002 5mC by haplotype at SNRPN, checked against modkit
- Differential transcript usage in R: satuRn on ENCODE muscle and liver, drawn over coverage
- Selection scans (Drosophila DGRP) in R: Fst, π and Tajima's D at Cyp6g1 and
In(2L)t - A loss-of-function allele across breeds (Dog10K) in R: the CYP1A2 stop codon per breed
- RNA-seq splicing and strand in R: ACTB junctions, strand-specific coverage and IsoSeq
- Complex rearrangements and derivative alleles (COLO829) in R: the chr3, chr10 and chr12 chain
- Get started: a track, its tables, a stack, genotypes and synteny
- docs/alignments.md: BAM and CRAM (
jbrowse_alignments()): color, filter, sort, split, methylation - docs/features.md: GFF3, GTF, BED and BigBed (
jbrowse_features()): gene glyphs, labels, facets - docs/wiggle.md: BigWig (
jbrowse_wiggle()): bars, lines, density, rows per source, clustering - docs/variants.md: VCF (
jbrowse_variants()): genotypes by sample, bands, clustering - docs/synteny.md: PAF, PIF, delta, chain and MashMap: ribbons, dotplots, several genomes
- docs/stack.md: several tracks (
jbrowse_stack()): end-to-end regions, collapsed introns - docs/grammar.md: the geoms, keys, scales and facets that
autoplot()composes - docs/api.md: every reader, helper and geom, what each returns, and the table keys
- docs/gallery.md: the R and
jb2exportcode of each figure - docs/faq.md: how the engine works, what one call does, common errors
- CONTRIBUTING.md: setup, rebuilding the engine, CI
- A CRAN submission: the new-submission NOTE from
R CMD check --as-cran, and the 7.9 MB installed size
Other R tools
Written with NHGRI funding as part of JBrowse; please cite its most recent paper.
Apache License 2.0 © Colin Diesh
















































