When your genome is one of the hosted hubs, JBrowseR("hg38") is all you need. This tutorial covers the other case: building a browser for a genome you host yourself, with your own tracks, gene-name search, and theme.

Describe the assembly

An assembly is a list with a name and a uri. JBrowse derives the index locations (.fai, plus .gzi for bgzipped FASTA) from the URL, so you only point at the FASTA itself. Add reference-name aliases so chr1/1 both resolve.

hg19 <- list(
  name = "hg19",
  uri = "https://jbrowse.org/genomes/hg19/fasta/hg19.fa.gz",
  aliases = list("GRCh37"),
  refNameAliases = list(uri = "https://jbrowse.org/genomes/hg19/hg19_aliases.txt")
)

Add tracks

A track is a list too. uri alone is enough — the view infers the track type and adapter from the file extension, and derives the index location. You do not need to set assemblyNames on each track; the view fills it in from the assembly you load.

my_tracks <- list(
  list(
    uri =
    "https://jbrowse.org/genomes/hg19/GRCh37_latest_genomic.sort.gff.gz",
    name = "NCBI RefSeq Genes"
  )
)

Hub assemblies include search; for a custom assembly, point at your own Trix index files with a Trix adapter and pass it as text_search. Now location can be a gene name.

hg19_search <- list(
  type = "TrixTextSearchAdapter",
  textSearchAdapterId = "hg19-index",
  assemblyNames = list("hg19"),
  ixFilePath = list(uri = "https://jbrowse.org/genomes/hg19/trix/hg19.ix"),
  ixxFilePath = list(uri = "https://jbrowse.org/genomes/hg19/trix/hg19.ixx"),
  metaFilePath = list(uri = "https://jbrowse.org/genomes/hg19/trix/meta.json")
)

Put it together

JBrowseR(
  assembly = hg19,
  tracks = my_tracks,
  text_search = hg19_search,
  theme = list(palette = list(primary = list(main = "#311b92"))),
  location = "MYC"
)

Show results computed in R

track_data_frame() turns a data frame into an in-browser track with no files and no server — the natural way to put an analysis you ran in R onto the genome. The frame needs chrom, start, end, and name columns; an optional score column makes it a quantitative track.

regions <- data.frame(
  chrom = c("10", "10"),
  start = c(29838737, 29850000),
  end   = c(29840000, 29855000),
  name  = c("regionA", "regionB"),
  score = c(42, 88)
)

JBrowseR(
  assembly = hg19,
  tracks = list(track_data_frame(regions, "my_regions")),
  location = "10:29,838,737..29,855,000"
)

Reacting to clicks in Shiny

When rendered inside Shiny, clicking a feature sets input$selectedFeature to the feature’s data, so you can build tables, plots, or links from the current selection.

# server side
output$browser <- renderJBrowseR(
  JBrowseR(assembly = hg19, tracks = my_tracks, location = "MYC")
)
observeEvent(input$selectedFeature, {
  print(input$selectedFeature$name)
})