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.
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 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")
)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"
)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)
})