When your genome is one of the hosted hubs,
JBrowseR(assembly = "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.
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.
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.
Hub assemblies include search; for a custom assembly, point at your
own Trix index files with a Trix adapter and pass it in
aggregateTextSearchAdapters. 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")
)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 and end 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"
)When rendered inside Shiny, clicking a feature sets
input$<outputId>_selected_feature to the feature’s
data, so you can build tables, plots, or links from the current
selection. The id is namespaced per output, so several browsers on one
page do not overwrite each other’s.
# server side
output$browser <- renderJBrowseR(
JBrowseR(assembly = hg19, tracks = my_tracks, location = "MYC")
)
observeEvent(input$browser_selected_feature, {
print(input$browser_selected_feature$name)
})To move the browser from R without re-running the render expression,
send it the changed options with update_jbrowse(). A
reactive location fed from
input$browser_location would loop; an observer does
not.
observeEvent(input$goto_myc, {
update_jbrowse("browser", location = "MYC")
})