Advanced JSON tutorial

The introduction and custom browser tutorial cover the declarative API, which is enough for most browsers. This tutorial covers the escape hatch: handing JBrowseR() a whole JBrowse 2 configuration through the config argument, for full control over every option.

library(JBrowseR)

When to use it

Reach for config when you need something the helpers don’t expose — a saved defaultSession, per-track display options, internet accounts for authenticated data, or runtime plugins. A JBrowse config mirrors the format documented in the JBrowse config guide and may contain assembly, tracks, defaultSession, aggregateTextSearchAdapters, theme, and plugins.

From a config file

config takes the path or URL of a config.json and reads it for you (JSON text works too). A config file is portable — the same file works in the JBrowse web app and desktop.

JBrowseR(config = "https://jbrowse.org/genomes/hg19/config.json")

From an R list

Because htmlwidgets serializes R lists to JSON, you can also assemble the config inline. Mix in the declarative helpers wherever they are convenient — they return plain lists.

cfg <- list(
  assembly = assembly(
    "https://jbrowse.org/genomes/hg19/fasta/hg19.fa.gz",
    aliases = "GRCh37"
  ),
  tracks = tracks(
    track(
      "https://jbrowse.org/genomes/hg19/GRCh37_latest_genomic.sort.gff.gz",
      name = "NCBI RefSeq Genes"
    )
  ),
  defaultSession = list(
    name = "My session",
    view = list(
      type = "LinearGenomeView",
      tracks = list(list(
        type = "FeatureTrack",
        configuration = "NCBI RefSeq Genes"
      ))
    )
  )
)

JBrowseR(config = cfg, location = "10:29,838,737..29,838,819")

location still applies alongside a config, unless the config’s defaultSession already positions the view.