| Title: | An R Interface to the JBrowse 2 Genome Browser |
|---|---|
| Description: | Provides an R interface to the JBrowse 2 genome browser. Enables embedding a JB2 genome browser in a Shiny app or R Markdown document. The browser can also be launched from an interactive R console. The browser can be loaded with a variety of common genomics data types, and can be used with a custom theme. |
| Authors: | Elliot Hershberg [aut] (ORCID: <https://orcid.org/0000-0003-2068-3366>), Colin Diesh [aut, cre] (ORCID: <https://orcid.org/0000-0003-2629-7570>), the JBrowse 2 Team [aut] |
| Maintainer: | Colin Diesh <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.11.0 |
| Built: | 2026-07-24 09:11:35 UTC |
| Source: | https://github.com/gmod/jbrowser |
Builds an assembly config for a custom genome using the flat { name, uri }
shorthand: JBrowse itself picks the concrete adapter type
(IndexedFastaAdapter/BgzipFastaAdapter/TwoBitAdapter) from the extension,
derives the .fai/.gzi index locations, and fills in the reference sequence
track when the config loads, so only the FASTA URL is required and no
adapter-type table lives in R.
assembly(fasta, name = NULL, aliases = NULL, refname_aliases = NULL)assembly(fasta, name = NULL, aliases = NULL, refname_aliases = NULL)
fasta |
URL to the sequence: a |
name |
Assembly name. Defaults to the FASTA file's base name. |
aliases |
Reference-name aliases for the assembly (e.g. |
refname_aliases |
URL to a reference-name alias table mapping e.g. |
For common human/model genomes you do not need this at all — pass a hub name
straight to JBrowseR() (e.g. JBrowseR("hg38")) and the assembly, reference
name aliases, cytobands, and gene-name search all come preconfigured.
an assembly config list for JBrowseR()
assembly( "https://jbrowse.org/genomes/hg19/fasta/hg19.fa.gz", aliases = "GRCh37" )assembly( "https://jbrowse.org/genomes/hg19/fasta/hg19.fa.gz", aliases = "GRCh37" )
Describe a dotplot view comparing two assemblies
dotplot_view(assemblies, tracks = NULL, ...)dotplot_view(assemblies, tracks = NULL, ...)
assemblies |
Assembly names (or panel lists). |
tracks |
Synteny track ids. |
... |
Extra fields merged onto the view's init blob. |
a view spec list
Renders an interactive, GPU-accelerated JBrowse 2 linear genome view as an htmlwidget for use in R Markdown documents, Shiny apps, or the interactive R console.
JBrowseR( assembly = NULL, tracks = NULL, location = NULL, default_session = NULL, text_search = NULL, theme = NULL, plugins = NULL, config = NULL, width = NULL, height = NULL, elementId = NULL )JBrowseR( assembly = NULL, tracks = NULL, location = NULL, default_session = NULL, text_search = NULL, theme = NULL, plugins = NULL, config = NULL, width = NULL, height = NULL, elementId = NULL )
assembly |
A hub name understood by jbrowse.org (e.g. |
tracks |
A list of track entries: a bare data-file URL, a spec from
|
location |
A region string ( |
default_session |
An optional serialized session (advanced); when given
it owns the initial track layout instead of |
text_search |
One or more aggregate text-search adapters from
|
theme |
A theme config from |
plugins |
A list of JBrowse plugin specs (name + url) to load at runtime. |
config |
Escape hatch: a whole JBrowse config forming the payload base
that explicit arguments override — a list, or the path, URL, or JSON text of
a |
width, height, elementId
|
Standard htmlwidget sizing arguments. |
The API is declarative: describe the browser with plain values and the
helper constructors (assembly(), track(), tracks(), text_index(),
theme()). Nothing is imperative and no JSON strings are assembled by hand.
an htmlwidget of the JBrowse 2 linear genome view
# a whole human genome browser in one line (gene search included) JBrowseR("hg38", location = "BRCA1")# a whole human genome browser in one line (gene search included) JBrowseR("hg38", location = "BRCA1")
Output and render functions for using JBrowseR within Shiny applications and interactive Rmd documents.
JBrowseROutput(outputId, width = "100%", height = "400px") renderJBrowseR(expr, env = parent.frame(), quoted = FALSE)JBrowseROutput(outputId, width = "100%", height = "400px") renderJBrowseR(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width |
Must be a valid CSS unit or a number, which will be coerced to a string and have |
height |
Must be a valid CSS unit or a number, which will be coerced to a string and have |
expr |
An expression that generates a JBrowseR |
env |
The environment in which to evaluate |
quoted |
Is |
Clicking a feature sets input[[paste0(outputId, "_selected_feature")]],
which is namespaced per output and so is safe with several browsers on a
page or inside a Shiny module. It also sets the global input$selectedFeature
for backwards compatibility; prefer the per-output id in new apps.
the Shiny UI bindings for a JBrowseR htmlwidget
the Shiny server bindings for a JBrowseR htmlwidget
Where JBrowseR() shows a single linear genome view, JBrowseRApp() drives
the whole app engine, so views can mix a linear view, a synteny view, a
dotplot, and more. Each views entry is a list(type = ..., init = ...)
spec — the same vocabulary JBrowse Web serializes into its ?session=spec-…
URLs — built most easily with linear_view(), synteny_view(), and
dotplot_view().
JBrowseRApp( assemblies = NULL, tracks = NULL, views = NULL, plugins = NULL, theme = NULL, config = NULL, width = NULL, height = NULL, elementId = NULL )JBrowseRApp( assemblies = NULL, tracks = NULL, views = NULL, plugins = NULL, theme = NULL, config = NULL, width = NULL, height = NULL, elementId = NULL )
assemblies |
A list of assembly configs (each from |
tracks |
A list of full track config lists. Because a synteny track
spans two assemblies there is no single-assembly shorthand; |
views |
A list of view specs, e.g. from |
plugins |
A list of JBrowse plugin specs (name + url) to load at runtime. |
theme |
A theme config from |
config |
Escape hatch: a whole JBrowse config forming the payload base
that explicit arguments override — a list, or the path, URL, or JSON text of
a |
width, height, elementId
|
Standard htmlwidget sizing arguments. |
an htmlwidget of the JBrowse 2 app
## Not run: JBrowseRApp( assemblies = list(assembly(hg38_fa), assembly(mm39_fa)), tracks = list(synteny_track(paf_url, "hg38", "mm39")), views = list(synteny_view(c("hg38", "mm39"), tracks = "hg38-mm39")) ) ## End(Not run)## Not run: JBrowseRApp( assemblies = list(assembly(hg38_fa), assembly(mm39_fa)), tracks = list(synteny_track(paf_url, "hg38", "mm39")), views = list(synteny_view(c("hg38", "mm39"), tracks = "hg38-mm39")) ) ## End(Not run)
JBrowseRApp(views = ...)
Describe a linear genome view for JBrowseRApp(views = ...)
linear_view(assembly, loc = NULL, tracks = NULL, ...)linear_view(assembly, loc = NULL, tracks = NULL, ...)
assembly |
Assembly name. |
loc |
A region string ( |
tracks |
Track ids to show (referencing |
... |
Extra fields merged onto the view's init blob (e.g. |
a view spec list
Build a synteny (PAF) track config spanning two assemblies
synteny_track( uri, target_assembly, query_assembly, name = NULL, track_id = NULL, ... )synteny_track( uri, target_assembly, query_assembly, name = NULL, track_id = NULL, ... )
uri |
URL to a |
target_assembly, query_assembly
|
The two assembly names (PAF target is
the first assembly of a |
name |
Track display name. Defaults to the file's base name. |
track_id |
Track id. Defaults to a slug of |
... |
Extra config merged onto the track. |
a track config list
Describe a linear synteny view comparing two (or more) assemblies
synteny_view(assemblies, tracks = NULL, cigar_mode = NULL, ...)synteny_view(assemblies, tracks = NULL, cigar_mode = NULL, ...)
assemblies |
Assembly names (or |
tracks |
Synteny track ids tying the assemblies together. |
cigar_mode |
|
... |
Extra fields merged onto the view's init blob. |
a view spec list
Builds an aggregate Trix text-search adapter so users can search the browser
by gene name. Pass the result as text_search to JBrowseR().
text_index(ix, ixx, meta, assembly)text_index(ix, ixx, meta, assembly)
ix |
URL to the |
ixx |
URL to the |
meta |
URL to the |
assembly |
Name of the assembly the index applies to. |
Hub assemblies (e.g. JBrowseR("hg38")) already include gene search, so this
is only needed for custom assemblies with your own Trix index.
an aggregate text-search adapter list
text_index( "https://jbrowse.org/genomes/hg19/trix/hg19.ix", "https://jbrowse.org/genomes/hg19/trix/hg19.ixx", "https://jbrowse.org/genomes/hg19/trix/meta.json", "hg19" )text_index( "https://jbrowse.org/genomes/hg19/trix/hg19.ix", "https://jbrowse.org/genomes/hg19/trix/hg19.ixx", "https://jbrowse.org/genomes/hg19/trix/meta.json", "hg19" )
Creates a theme config with up to four palette colors. Pass the result as
theme to JBrowseR(). See
https://jbrowse.org/jb2/docs/config_guide#configuring-the-theme.
theme(primary, secondary = NULL, tertiary = NULL, quaternary = NULL)theme(primary, secondary = NULL, tertiary = NULL, quaternary = NULL)
primary |
the primary palette color (hex) |
secondary |
the secondary palette color (hex) |
tertiary |
the tertiary palette color (hex) |
quaternary |
the quaternary palette color (hex) |
a theme config list
theme("#311b92", "#0097a7")theme("#311b92", "#0097a7")
Builds a loose track spec — list(uri = url) plus whatever you pass — that
the view expands into a full track config when it loads, inferring the track
type and adapter from the file extension with JBrowse's own format plugins
(the same inference the "Add track" flow uses). No extension table lives in
R, so every format a bundled plugin recognizes works: .bam/.cram
(alignments), .vcf (variants), .gff/.gff3/.gtf/.bed (features),
.bb/.bigBed (features), .bw/.bigWig (quantitative), .hic (Hi-C), and
more. A bgzipped file (.gff.gz, …) resolves to its indexed tabix adapter, a
plain one to the whole-file adapter. JBrowse derives index locations
(.bai/.crai/.tbi) and, for CRAM, the reference from the assembly, so
only the data URL is required.
track( url, name = NULL, track_id = NULL, assembly_names = NULL, index = NULL, ... )track( url, name = NULL, track_id = NULL, assembly_names = NULL, index = NULL, ... )
url |
URL to the track data. |
name |
Track display name. Left |
track_id |
A unique id for the track. Left |
assembly_names |
Assembly name(s) the track belongs to. Usually left
|
index |
URL of the index file when it isn't the conventional sibling of
|
... |
Extra config merged onto the track, overriding the inferred
defaults (e.g. |
a loose track spec list
track("https://jbrowse.org/genomes/hg19/gencode.v19.sorted.gff.gz", name = "Genes")track("https://jbrowse.org/genomes/hg19/gencode.v19.sorted.gff.gz", name = "Genes")
Turns a data frame of features into an in-browser track (a
FromConfigAdapter), no files or web server required. This is the natural
way to view results you computed in R — peaks, windows, hits — directly on
the genome.
track_data_frame(data, name, assembly_name = NULL, ...)track_data_frame(data, name, assembly_name = NULL, ...)
data |
A data frame with columns |
name |
Track display name. |
assembly_name |
Assembly the track belongs to. Usually left |
... |
Extra config merged into the track. |
a track config list
df <- data.frame( chrom = c("1", "2"), start = c(123, 456), end = c(789, 101112), name = c("feature1", "feature2") ) track_data_frame(df, "my_features")df <- data.frame( chrom = c("1", "2"), start = c(123, 456), end = c(789, 101112), name = c("feature1", "feature2") ) track_data_frame(df, "my_features")
A thin readability wrapper around list() that gathers track() configs
into the list JBrowseR() expects.
tracks(...)tracks(...)
... |
track configs, e.g. from |
a list of track configs
tracks( track("https://example.com/genes.gff.gz", name = "Genes"), track("https://example.com/reads.bam", name = "Reads") )tracks( track("https://example.com/genes.gff.gz", name = "Genes"), track("https://example.com/reads.bam", name = "Reads") )
JBrowseRApp(views = ...)
The general form behind linear_view(), synteny_view(), and
dotplot_view(): builds the list(type = ..., init = ...) spec any view type
understands, where init is the declarative
session-spec init for
that type. Use it for view types those helpers don't cover, including any a
runtime plugins entry registers — its init fields are the plugin's own, so
nothing here has to keep up with them:
view(type, ...)view(type, ...)
type |
The view type (e.g. |
... |
Fields of the view's init blob; |
view("ProteinView",
url = "https://alphafold.ebi.ac.uk/files/AF-P04637-F1-model_v6.cif",
height = 600)
a view spec list