Skip to content
GMODPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

ggjbrowse

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")

Gallery

  • 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 jb2export recipes in docs/gallery.md.
JBrowseR
GENCODE genes over direct RNA reads chr12:6,534,201-6,538,700
GENCODE genes over direct RNA reads in JBrowse. Junction arcs join each splice over the coverage band, and the reads split at every intron.GENCODE genes over direct RNA reads drawn by ggjbrowse. Junction arcs join each splice over the coverage band, and the reads split at every intron.
COLO829 der(3) split reads chained across its two chr3 breakpoints chr3:25,358,500-25,359,800
COLO829 der(3) split reads chained across its two chr3 breakpoints in JBrowse. Coverage steps down at the first breakpoint, and each read's segments share a row, overlapping in dark grey and colored by strand past it, joined by duplication-type arcs and by connectors looping back under the rows.COLO829 der(3) split reads chained across its two chr3 breakpoints drawn by ggjbrowse. Coverage steps down at the first breakpoint, and each read's segments share a row, overlapping in dark grey and colored by strand past it, joined by duplication-type arcs and by connectors looping back under the rows.
Reads sorted by the base at the center, over a somatic deletion chr10:122,831,700-122,840,800
Reads sorted by the base at the center, over a somatic deletion in JBrowse. Coverage halves across the deletion, and the reads sorted to the top span it with dark deletion bars, each labelled with its length.Reads sorted by the base at the center, over a somatic deletion drawn by ggjbrowse. Coverage halves across the deletion, and the reads sorted to the top span it with dark deletion bars, each labelled with its length.
Compact reads over the same deletion chr10:122,831,700-122,840,800
Compact reads over the same deletion in JBrowse. Sorted by the base at the center, at 3 pixels a row the pileup takes far less height, the deletion's dark bars banded through it.Compact reads over the same deletion drawn by ggjbrowse. Sorted by the base at the center, at 3 pixels a row the pileup takes far less height, the deletion's dark bars banded through it.
Base-level zoom at the deletion's left edge chr10:122,835,300-122,835,420
Base-level zoom at the deletion's left edge in JBrowse. At 120 bp the pileup writes out each mismatch's base, and every read sorted to the top carries a G a few bases before its deletion.Base-level zoom at the deletion's left edge drawn by ggjbrowse. At 120 bp the pileup writes out each mismatch's base, and every read sorted to the top carries a G a few bases before its deletion.
Split reads chained across an inversion, with their arcs chr1:197,786,900-197,789,700
Split reads chained across an inversion, with their arcs in JBrowse. The split reads, in their own section above the unsplit ones, are colored inverted between the two breakpoints, where inversion-type arcs join their segments.Split reads chained across an inversion, with their arcs drawn by ggjbrowse. The split reads, in their own section above the unsplit ones, are colored inverted between the two breakpoints, where inversion-type arcs join their segments.
CpG methylation from MM/ML tags 20:10,001-22,000
CpG methylation from MM/ML tags in JBrowse. Each read's 5mC calls in red where methylated and blue where not.CpG methylation from MM/ML tags drawn by ggjbrowse. Each read's 5mC calls in red where methylated and blue where not.
CHH methylation from bisulfite reads NC_003070.9:4,398,001-4,412,000
CHH methylation from bisulfite reads in JBrowse. RefSeq genes and RepeatMasker over MethylDackel's three context bigWigs and each read's methylated CHH cytosines in red: CHH is dense over the LTR/Copia element on the right and rare over the gene on the left, which carries CpG methylation only.CHH methylation from bisulfite reads drawn by ggjbrowse. RefSeq genes and RepeatMasker over MethylDackel's three context bigWigs and each read's methylated CHH cytosines in red: CHH is dense over the LTR/Copia element on the right and rare over the gene on the left, which carries CpG methylation only.
DNase in twelve cell lines over the beta-globin locus chr11:5,270,001-5,320,000
DNase in twelve cell lines over the beta-globin locus in JBrowse. Most lines share one peak near 5,281,000, and K562 alone shows several more to either side.DNase in twelve cell lines over the beta-globin locus drawn by ggjbrowse. Most lines share one peak near 5,281,000, and K562 alone shows several more to either side.
DNase in twelve cell lines as density, clustered by signal chr11:5,270,001-5,320,000
DNase in twelve cell lines as density, clustered by signal in JBrowse. K562 splits off alone from the other eleven lines.DNase in twelve cell lines as density, clustered by signal drawn by ggjbrowse. K562 splits off alone from the other eleven lines.
phyloP conservation across GAPDH as bars, a line and density chr12:6,534,201-6,538,700
phyloP conservation across GAPDH as bars, a line and density in JBrowse. The exons stand out as runs of high scores in bars, in a mean line over its min-max band, and in a density strip.phyloP conservation across GAPDH as bars, a line and density drawn by ggjbrowse. The exons stand out as runs of high scores in bars, in a mean line over its min-max band, and in a density strip.
Genes, conservation and strand-colored reads over two regions end to end chr12:6,534,201-6,535,700 chr12:6,537,201-6,538,700
Genes, conservation and strand-colored reads over two regions end to end in JBrowse. A grey divider separates the two loci, and each tick gives a position in its own region.Genes, conservation and strand-colored reads over two regions end to end drawn by ggjbrowse. A grey divider separates the two loci, and each tick gives a position in its own region.
Amino acids over GAPDH's first coding exons, read in frame across the intron chr12:6,534,811-6,534,880 chr12:6,536,476-6,536,545
Amino acids over GAPDH's first coding exons, read in frame across the intron in JBrowse. GAPDH's coding transcripts open MGKVKVGVNG, the last codon split by the intron and lettered red on each side, the frame running on in the next exon.Amino acids over GAPDH's first coding exons, read in frame across the intron drawn by ggjbrowse. GAPDH's coding transcripts open MGKVKVGVNG, the last codon split by the intron and lettered red on each side, the frame running on in the next exon.
100 people's genotypes across DCST2 (GRCh37), colored by superpopulation 1:155,000,001-155,050,000
100 people's genotypes across DCST2 (GRCh37), colored by superpopulation in JBrowse. 20 people from each superpopulation genotyped at 249 variants, a column per record, the East Asians homozygous for the alt allele at many of the first 40.100 people's genotypes across DCST2 (GRCh37), colored by superpopulation drawn by ggjbrowse. 20 people from each superpopulation genotyped at 249 variants, a column per record, the East Asians homozygous for the alt allele at many of the first 40.
100 people's genotypes across DCST2 clustered, the tree beside the rows 1:155,000,001-155,050,000
100 people's genotypes across DCST2 clustered, the tree beside the rows in JBrowse. Most East Asians gather near the top, the Africans and Europeans further down.100 people's genotypes across DCST2 clustered, the tree beside the rows drawn by ggjbrowse. Most East Asians gather near the top, the Africans and Europeans further down.
100 people's genotypes across DCST2 in a band per superpopulation, each band clustered 1:155,000,001-155,050,000
100 people's genotypes across DCST2 in a band per superpopulation, each band clustered in JBrowse. Each superpopulation clusters apart in its own band, and the records crowding a pixel fade by how many share it.100 people's genotypes across DCST2 in a band per superpopulation, each band clustered drawn by ggjbrowse. Each superpopulation clusters apart in its own band, and the records crowding a pixel fade by how many share it.
GAPDH's nine exons side by side, with the junctions between them as arcs ENST00000229239.10's exons, each padded by 20 bp
GAPDH's nine exons side by side, with the junctions between them as arcs in JBrowse. An arc over the coverage joins each pair of exons, and the direct RNA reads run across.GAPDH's nine exons side by side, with the junctions between them as arcs drawn by ggjbrowse. An arc over the coverage joins each pair of exons, and the direct RNA reads run across.
HG002's maternal chr8 over its paternal copy at 8p23.1 chr8_MATERNAL:5,250,001-14,250,000 chr8_PATERNAL:5,250,001-14,250,000
HG002's maternal chr8 over its paternal copy at 8p23.1 in JBrowse. Forward blocks in tomato flank the 4 Mb inversion, whose reverse ribbon crosses in blue.HG002's maternal chr8 over its paternal copy at 8p23.1 drawn by ggjbrowse. Forward blocks in tomato flank the 4 Mb inversion, whose reverse ribbon crosses in blue.
HG002's maternal chr8 against its paternal copy as a dotplot chr8_MATERNAL chr8_PATERNAL
HG002's maternal chr8 against its paternal copy as a dotplot in JBrowse. One forward diagonal runs the length of chr8, broken only by the inversion's short reverse segment near 10 Mb.HG002's maternal chr8 against its paternal copy as a dotplot drawn by ggjbrowse. One forward diagonal runs the length of chr8, broken only by the inversion's short reverse segment near 10 Mb.
Peach against grape, every chromosome whole genome
Peach against grape, every chromosome in JBrowse. Short diagonal runs scatter over most pairs of peach and grape chromosomes.Peach against grape, every chromosome drawn by ggjbrowse. Short diagonal runs scatter over most pairs of peach and grape chromosomes.
GRCh38 over HG00133 at the amylase genes GRCh38#0#chr1:103,520,894-103,832,637
GRCh38 over HG00133 at the amylase genes in JBrowse. Forward blocks flank a reversed copy in the middle, with alignments of the other copies crossing over it.GRCh38 over HG00133 at the amylase genes drawn by ggjbrowse. Forward blocks flank a reversed copy in the middle, with alignments of the other copies crossing over it.
3 kb at the amylase genes, the match block cut by an 80 bp deletion GRCh38#0#chr1:103,619,501-103,622,500
3 kb at the amylase genes, the match block cut by an 80 bp deletion in JBrowse. The deletion shows as a purple wedge narrowing to a point on HG00133's row.3 kb at the amylase genes, the match block cut by an 80 bp deletion drawn by ggjbrowse. The deletion shows as a purple wedge narrowing to a point on HG00133's row.
HG002's maternal chr8 over its paternal copy, each with its genes chr8_MATERNAL:5,250,001-14,250,000 chr8_PATERNAL:5,250,001-14,250,000
HG002's maternal chr8 over its paternal copy, each with its genes in JBrowse. Forward blocks in tomato, the 4 Mb inversion crossing in blue, and the genes above and below.HG002's maternal chr8 over its paternal copy, each with its genes drawn by ggjbrowse. Forward blocks in tomato, the 4 Mb inversion crossing in blue, and the genes above and below.
The TP53 neighbourhood on hg38 over chimp, gorilla and orangutan chr17:7,400,001-7,700,000
The TP53 neighbourhood on hg38 over chimp, gorilla and orangutan in JBrowse. Each lane runs in its own genome's coordinates, every liftOver ribbon in hg38's orientation, with gaps where a genome lacks sequence the one above has.The TP53 neighbourhood on hg38 over chimp, gorilla and orangutan drawn by ggjbrowse. Each lane runs in its own genome's coordinates, every liftOver ribbon in hg38's orientation, with gaps where a genome lacks sequence the one above has.

Quick start

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)

Nanopore direct RNA reads from NA12878 across GAPDH: junction arcs joining each splice, the coverage band and the reads split at the introns

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, a chrom/start/end data 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 >= 5 hides 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: chr7 here, 7 there? Give each reader assembly = jbrowse_assembly(fasta, aliases).

Tutorials

Whole analyses done in R, each on the data and question of a JBrowse tutorial:

Docs

  • 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 jb2export code of each figure
  • docs/faq.md: how the engine works, what one call does, common errors
  • CONTRIBUTING.md: setup, rebuilding the engine, CI

Not yet

  • A CRAN submission: the new-submission NOTE from R CMD check --as-cran, and the 7.9 MB installed size

See also

Other R tools

  • ggbandage - pangenome graphs as ggplot2 layers
  • ggtubemap - pangenome tubemaps as ggplot2 layers

Academic use

Written with NHGRI funding as part of JBrowse; please cite its most recent paper.

License

Apache License 2.0 © Colin Diesh

About

No description, website, or topics provided.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages