FAQ
Developers
How can I start the JBrowse 2 app as a developer
We recommend that you have the following:
Then you can follow the steps from our README.
It basically boils down to:
git clone https://github.com/GMOD/jbrowse-components
cd jbrowse-components
yarn
cd products/jbrowse-web
yarn start
This will boot up a development instance of jbrowse-web
on port 3000
.
You can use PORT=8080 yarn start
to manually specify a different port.
Alternatively, to boot up JBrowse Desktop, you can go to the
products/jbrowse-desktop
directory.
For the embedded components e.g. products/jbrowse-react-linear-genome-view
,
use yarn storybook
instead of yarn start
.
General
What is special about JBrowse 2
One thing that makes JBrowse 2 special is that we can create new view types via our plugin system, e.g. circular, dotplot, etc. Anything you want can be added as a view, and can be shown alongside our other views.
This makes JBrowse 2 more than just a genome browser: it is a platform that can be built upon.
What are new features in JBrowse 2
See the https://jbrowse.org/jb2/features page for an overview of features
Setup
What web server do I need to run JBrowse 2
JBrowse 2 by itself is just a set of JS, CSS, and HTML files that can be statically hosted on a web server without any backend services running.
Therefore, running JBrowse 2 generally involves just copying the JBrowse 2
folder to your web server HTML folder e.g. copy /var/www/html/
to Amazon S3.
If you use a different platform, such as Django, you may want to put jbrowse-web in the static resources folder, but note that data files are not properly served by the Django static resources folder: you will want to use a different external server. See https://github.com/cmdcolin/django-jbrowse2-nonworking-example for notes
Note that the server that you use should support byte-range requests (e.g. the Range HTTP header) so that JBrowse can get small slices of large binary data files.
BAM files do not work on my server
If you are using Apache then you will probably want to disable mime_magic. If mime_magic is enabled, you may see that your server responds with the HTTP header Content-Encoding: gzip which JBrowse does NOT want, because this instructs the browser to unzip the data but JBrowse should be in charge of this.
How can I setup JBrowse 2 on my web server
We recommend following the steps in the quickstart web via CLI guide.
The general procedure is using the jbrowse create /var/www/html/jb2
and this
will download the latest version of jbrowse to your web folder e.g. in
/var/www/html
.
You can also use jbrowse upgrade /var/www/html/jb2
to get the latest version.
How do I install or update the @jbrowse/cli tool
To install the @jbrowse/cli tool, you can use npm install -g @jbrowse/cli
Re-running that command will get the latest version of the @jbrowse/cli.
This command will give you a command named jbrowse
which should automatically
be in your path if you have a standard installation of nodejs. We recommend
using nodesource or nvm to get your nodejs for this.
Also note that the @jbrowse/cli tool is just made for preparing your config.json, it is not used to run any server-side code.
How can I make a header on a jbrowse-web instance
You can edit the index.html that comes with jbrowse-web to have custom contents.
The jbrowse-web app just looks at the div
that it renders into, but any
contents outside that you can edit for custom purposes. If you need more
advanced embedding, you can consider @jbrowse/react-linear-genome-view or
similar, but the jbrowse-web app is not available as an npm installable package
yet.
How do I update my instance of jbrowse-web
You can use the command, after installing:
jbrowse upgrade /path/to/your/jbrowse2
This will download the latest release from github and overwrite it onto your jbrowse-web instance.
If you've manually downloaded jbrowse-web, the newest releases can be found here.
How can I setup JBrowse 2 without the CLI tools
The jbrowse CLI tools are basically a convenience, and are not strictly required.
Simple tasks can be done without it.
For example, for jbrowse create, you can visit the releases page and download the latest jbrowse-web release tag, and unzip it into your web directory.
Checkout our quickstart web guide for a speedy start to using a manually downloaded JBrowse instance.
For other things, like add-assembly and add-track, you can manually edit the
config.json
; reviewing the config docs and sample configs
will be valuable.
To configure JBrowse using the admin-server GUI, checkout our tutorial.
Understanding the config basics will come in handy also because you can manually edit in advanced configs after your tracks are loaded; however be careful as corrupt configs can produce hard to understand errors, because our config system is strongly typed.
Reach out to the team on gitter or in the discussions if you have any complex configuration issues.
How do I load a track into JBrowse 2
With the JBrowse CLI tools, you can easily add tracks with the add-track
command, e.g.:
jbrowse add-track myfile.bw -a hg19
This will set up a bigwig track on the hg19 assembly in your config.json.
Make sure to run the command inside your current jbrowse2 folder e.g. /var/www/html/jbrowse2 or wherever you are currently setting up a config.json (you can have multiple configs).
Note that you can also use remote URLs
jbrowse add-track http://yourremote/myfile.bam
The add-track command will do as much as possible to infer from the file extension how to configure this track, and automatically infer the index to be myfile.bam.bai.
As mentioned above, you can also manually edit your config file, or use the GUI.
How do I customize the color of the features displayed on my track
We use Jexl for defining configuration callbacks, including feature coloration.
An example of a Jexl configuration callback might look like this:
"color": "jexl:get(feature,'strand')==-1?'red':'blue'"
See our configuration callbacks guide for more information.
My jexl is too complicated, how can I simplify it?
You can create a small plugin that adds a new function to the jexl language.
See here for an example of making a color callback.
Adding color callbacks in the GUI
In brief, to add a configuration callback to a track using the GUI, perform the following steps:
- On the track you intend to color, click on the three vertical dots '...' on the right side of the track label
- Click "Settings" (if this option is greyed out, copy the track with "Copy Track", then open up the track under "Session Tracks" and repeat steps 1-2)
- Scroll down to the "display 1 renderer" heading (this is typically the display you want to edit, if not scroll to display 2)
- Click on the circle to the right of the color you'd like to change
- In this text box, enter in the Jexl
callback for the feature coloration, e.g.
get(feature,'strand') == -1 ? 'red' : 'blue'
Adding color callbacks via the command line
Adding color callbacks via the command line can be a little tricky because the coloration property exists within the renderer.
In brief, to add a configuration callback to a track using the CLI, your
add-track
is going to look something like this:
jbrowse add-track somevariants.vcf --load copy --config '{"displays": [{"displayId": "my_BasicDisplay", "type": "LinearBasicDisplay", "renderer": {"color1": "jexl:get(feature, '\''strand'\'') == -1 ? '\''red'\'' : '\''blue'\''" }}]}'
While adding the track to the config.json
, you're adding additional
configurations using the --config option. This additional configuration is a
"renderer" on the display that your track will be using. In this case, this .vcf
will be using the LinearBasicDisplay
.
How do I get (more) categories to filter on in the faceted track selector?
The faceted track selector displays all the different adapters, categories, and
all the metadata. Categories are also used to group tracks in the track
selector. New categories can be added with the --category
option from
jbrowse add-track
.
Alternatively, you can add a metadata key to a track, which will be used in the faceted track selector:
{
"name": "mytrack",
...
"metadata": {
"origin": "public",
"data_added": "2024-02-20"
}
}
Can I compress the config.json, it's large and users have to download it?
You can set up your server to serve zipped files. Most cloud-based services, like AWS Amplify and AWS CloudFront, already do this automatically. However, for Apache and Nginx, you need to configure them manually.
For Nginx, you can enable gzip compression by editing the config.template. See for instance for a set of reasonable nginx defaults: https://gist.github.com/sydcanem/3e00c09b3361927b2fd1#file-nginx-gzip-conf
server {
...
# Enable gzip compression.
# Default: off
gzip on;
# make sure to **at least** allow json to be compressed, multiple
gzip_types
application/json
}
To enable compression in Apache, you can use the mod_deflate module.
sudo a2enmod deflate
sudo systemctl restart apache2
Add the following configuration to your Apache configuration file (e.g., /etc/apache2/sites-available/000-default.conf):
<IfModule mod_deflate.c>
# Compress output
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>
By enabling gzip compression, your config.json and other specified files will be served in a compressed format, reducing the file size and improving download times for your users.
Curiosities
Why do all the tracks need an assembly specified
We require that all tracks have a specific genome assembly specified in their config. This is because JBrowse 2 is a multi-genome-assembly browser (and can compare genomes given the data). This may be different to using, say, JBrowse 1 where it knows which genome assembly you are working with at any given time.
How are the menus structured in the app
In JBrowse 1, the app level menu operated on the single linear genome view, but with JBrowse 2, the top level menu only performs global operations and the linear genome view has its own hamburger menu. Note that each track also has its own track level menu.
Why do some of my reads not display soft-clipping
Some reads, such as secondary reads, do not have a SEQ
field on their records,
so they will not display soft-clipping.
The soft-clipping indicators on these reads will appear black.
Do you have any tips for learning React and mobx-state-tree
Here is a short guide to React and mobx-state-tree that could help get you oriented:
https://gist.github.com/cmdcolin/94d1cbc285e6319cc3af4b9a8556f03f