Hosting data for JBrowseR

Every JBrowseR function that accepts data takes a URL. Genomics files are far too large to inline as Shiny static resources, and the browser fetches only the slices it needs directly from the host — so the data lives at a URL and JBrowse reads from it in place.

For human and model organisms you often need no hosting at all: pass a hub name straight to JBrowseR() and the assembly, reference-name aliases, cytobands, and gene-name search all load from the CORS-enabled hub at jbrowse.org.

JBrowseR("hg38", location = "BRCA1")

For your own data you host the files yourself. On the JBrowse 2 team we use Amazon S3 — each object has its own URL — but any web server works, e.g. Apache or a cloud bucket.

Server requirements

Whichever host you pick, it must satisfy two requirements:

  • HTTP Range requests, so the browser can use byte serving to fetch only the chunks needed to render the current view instead of the whole file.
  • CORS, because the request originates from wherever the browser is running, not from where the data is hosted.

Here is an example CORS configuration for an S3 bucket:

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "Accept-Ranges",
            "Content-Range",
            "Content-Encoding",
            "Content-Length"
        ],
        "MaxAgeSeconds": 3000
    }
]

If you use S3 and plan to deploy with shinyapps.io, put the bucket in Amazon’s US-East region — shinyapps.io is hosted entirely there, so co-locating the data gives faster performance.

Viewing local files

To view files from your own machine, serve the directory with any static server that supports range requests and CORS, then point assembly() / track() at the resulting http://localhost:... URLs. For example, with http-server:

npx http-server --cors -p 5000 ~/path/to/my-data
JBrowseR(
  assembly = assembly("http://127.0.0.1:5000/genome.fa.gz"),
  tracks = tracks(track("http://127.0.0.1:5000/genes.gff.gz", name = "Genes")),
  location = "chr1:1-10000"
)