| 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.14.0 |
| Built: | 2026-10-10 22:58:46 UTC |
| Source: | https://github.com/gmod/jbrowser |
Renders an interactive, GPU-accelerated JBrowse 2 linear genome view as an htmlwidget for R Markdown documents, Shiny apps, or the R console.
JBrowseR( ..., local_files = NULL, width = NULL, height = NULL, elementId = NULL )JBrowseR( ..., local_files = NULL, width = NULL, height = NULL, elementId = NULL )
... |
|
local_files |
Files on this machine to open without a web server: a
path, a vector of paths, or a list mixing paths with |
width, height, elementId
|
Standard htmlwidget sizing arguments. |
Every named argument in ... is an option of JBrowse's
createLinearGenomeView,
sent verbatim under JBrowse's own camelCase name: assembly, tracks,
location, session, aggregateTextSearchAdapters, internetAccounts,
plugins, configuration, and whatever JBrowse adds next. This package
names none of them, so a whole options object is
do.call(JBrowseR, jsonlite::read_json("options.json")).
assembly takes a hub name ("hg38", a GenArk accession), a sequence-file
URL, or an assembly config. A tracks entry takes a bare data-file URL, a
list(uri = ), a track_data_frame() result, or a full track config.
plugins entries are list(name = , url = ).
A length-1 vector serializes to a JSON scalar, so fields JBrowse reads as
arrays take list(): assemblyNames = list("hg38").
an htmlwidget
JBrowseR(assembly = "hg38", location = "BRCA1")JBrowseR(assembly = "hg38", location = "BRCA1")
Output and render functions for JBrowseR() in Shiny apps 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, height
|
a valid CSS unit, or a number coerced to pixels |
expr |
An expression that generates a JBrowseR |
env |
The environment in which to evaluate |
quoted |
Is |
The widget reports three inputs, namespaced by output id:
input[[paste0(outputId, "_selected_feature")]] is the clicked feature,
_location the visible region as the location box prints it (thousands
separators included), and _session the layout in the shape session =
takes. Each settles after a gesture rather than firing per frame.
A re-render whose options differ only in tracks, location or
local_files is applied to the browser on the page, keeping the user's zoom
and track order; any other changed option builds a new browser. Reading
_location or _session in the reactive that feeds renderJBrowseR() builds
a loop: navigate from an observer with update_jbrowse() instead.
the Shiny UI bindings for a JBrowseR htmlwidget
the Shiny server bindings for a JBrowseR htmlwidget
Where JBrowseR() shows one linear genome view, JBrowseRApp() runs the
whole app, so views can mix a linear view, a synteny view, a dotplot, and
more.
JBrowseRApp( ..., local_files = NULL, width = NULL, height = NULL, elementId = NULL )JBrowseRApp( ..., local_files = NULL, width = NULL, height = NULL, elementId = NULL )
... |
|
local_files |
Files on this machine to open without a web server: a
path, a vector of paths, or a list mixing paths with |
width, height, elementId
|
Standard htmlwidget sizing arguments. |
Every named argument in ... is an option of JBrowse's
createApp, sent
verbatim under JBrowse's own camelCase name: assemblies, tracks, views,
session, connections, internetAccounts, aggregateTextSearchAdapters,
configuration, plugins, and whatever JBrowse adds next. A whole options
object is do.call(JBrowseRApp, jsonlite::read_json("options.json")).
A views entry is list(type = , ...) with the view's settings beside
type, the object a config.json's defaultSession.views holds. An
assemblies entry may be a hub name or sequence-file URL, as
JBrowseR()'s assembly takes.
an htmlwidget
## Not run: JBrowseRApp( assemblies = list( list(name = "hg38", uri = hg38_fa), list(name = "mm39", uri = mm39_fa) ), tracks = list(list( type = "SyntenyTrack", trackId = "hg38_mm39", name = "hg38 vs mm39", assemblyNames = list("hg38", "mm39"), adapter = list( type = "PAFAdapter", targetAssembly = "hg38", queryAssembly = "mm39", uri = paf_url ) )), views = list(list( type = "LinearSyntenyView", views = list(list(assembly = "hg38"), list(assembly = "mm39")), tracks = list("hg38_mm39") )) ) ## End(Not run)## Not run: JBrowseRApp( assemblies = list( list(name = "hg38", uri = hg38_fa), list(name = "mm39", uri = mm39_fa) ), tracks = list(list( type = "SyntenyTrack", trackId = "hg38_mm39", name = "hg38 vs mm39", assemblyNames = list("hg38", "mm39"), adapter = list( type = "PAFAdapter", targetAssembly = "hg38", queryAssembly = "mm39", uri = paf_url ) )), views = list(list( type = "LinearSyntenyView", views = list(list(assembly = "hg38"), list(assembly = "mm39")), tracks = list("hg38_mm39") )) ) ## End(Not run)
Output and render functions for JBrowseRApp(). The app is a separate
widget with its own bundle, so it cannot render into a JBrowseROutput().
JBrowseRAppOutput(outputId, width = "100%", height = "400px") renderJBrowseRApp(expr, env = parent.frame(), quoted = FALSE)JBrowseRAppOutput(outputId, width = "100%", height = "400px") renderJBrowseRApp(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width, height
|
a valid CSS unit, or a number coerced to pixels |
expr |
An expression that generates a JBrowseRApp |
env |
The environment in which to evaluate |
quoted |
Is |
The app reports input[[paste0(outputId, "_session")]] in the shape
session = takes, _selected_feature for the clicked feature, and
_location as a list with one entry per open view. A re-render that changes
only session restores it in the app on the page; any other changed option
builds a new app.
the Shiny UI bindings for a JBrowseRApp htmlwidget
the Shiny server bindings for a JBrowseRApp htmlwidget
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 |
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") # a point per row at its log2 fold-change, coloured by call de <- data.frame( chrom = "7", start = c(1e6, 2e6), end = c(1e6, 2e6) + 6000, log2fc = c(2.1, -1.7), sig = c("up", "down") ) track_data_frame(de, "de", displays = list(list( type = "LinearMarkDisplay", marks = list(list( mark = "point", encoding = list(y = "log2fc", color = list(field = "sig", scale = "categorical")) )) )))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 point per row at its log2 fold-change, coloured by call de <- data.frame( chrom = "7", start = c(1e6, 2e6), end = c(1e6, 2e6) + 6000, log2fc = c(2.1, -1.7), sig = c("up", "down") ) track_data_frame(de, "de", displays = list(list( type = "LinearMarkDisplay", marks = list(list( mark = "point", encoding = list(y = "log2fc", color = list(field = "sig", scale = "categorical")) )) )))
Sends option changes to a JBrowseR() or JBrowseRApp() already on the
page, without re-running its render expression. The changes are named the
way the widget's own options are.
update_jbrowse(outputId, ..., domain = shiny_domain())update_jbrowse(outputId, ..., domain = shiny_domain())
outputId |
The browser's output id. Inside a Shiny module, pass the bare
id, as you would to |
... |
Options to change, each named. |
domain |
The Shiny session, defaulting to the current one. Not named
|
observeEvent(input$gene, update_jbrowse("browser", location = input$gene))
A JBrowseR() applies tracks and location in place and a JBrowseRApp()
applies session in place; any other option builds a new browser from the
rendered options plus the changes. A later re-render compares against what
it rendered last, so a change sent here survives a re-render that does not
restate that option.
outputId, invisibly.