This Jupyter notebook will show you how to add tracks using your local data. We are able to leverage Jupyter's server to serve local files that exist within the notebook's file tree, but we also provide a separate dev server for additional support in other environments (binder, colab, etc)
!pip install jbrowse-jupyter
Requirement already satisfied: jbrowse-jupyter in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (1.2.5) Requirement already satisfied: jupyter-dash>=0.4.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (0.4.2) Requirement already satisfied: Werkzeug==2.0.3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (2.0.3) Requirement already satisfied: pytest>=6.2.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (7.1.1) Requirement already satisfied: dash==2.3.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (2.3.0) Requirement already satisfied: dash-jbrowse>=1.0.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (1.1.0) Requirement already satisfied: pandas>=1.1.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter) (1.4.2) Requirement already satisfied: plotly>=5.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (5.7.0) Requirement already satisfied: dash-html-components==2.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (2.0.0) Requirement already satisfied: dash-table==5.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (5.0.0) Requirement already satisfied: flask-compress in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (1.11) Requirement already satisfied: Flask>=1.0.4 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (2.1.1) Requirement already satisfied: dash-core-components==2.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from dash==2.3.0->jbrowse-jupyter) (2.0.0) Requirement already satisfied: Jinja2>=3.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (3.1.1) Requirement already satisfied: importlib-metadata>=3.6.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (4.11.3) Requirement already satisfied: click>=8.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (8.1.2) Requirement already satisfied: itsdangerous>=2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (2.1.2) Requirement already satisfied: zipp>=0.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from importlib-metadata>=3.6.0->Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (3.8.0) Requirement already satisfied: MarkupSafe>=2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from Jinja2>=3.0->Flask>=1.0.4->dash==2.3.0->jbrowse-jupyter) (2.1.1) Requirement already satisfied: retrying in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (1.3.3) Requirement already satisfied: ipykernel in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (6.12.1) Requirement already satisfied: ipython in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (8.2.0) Requirement already satisfied: requests in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (2.27.1) Requirement already satisfied: ansi2html in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (1.7.0) Requirement already satisfied: nest-asyncio in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-dash>=0.4.2->jbrowse-jupyter) (1.5.5) Requirement already satisfied: numpy>=1.18.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pandas>=1.1.5->jbrowse-jupyter) (1.22.3) Requirement already satisfied: pytz>=2020.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pandas>=1.1.5->jbrowse-jupyter) (2022.1) Requirement already satisfied: python-dateutil>=2.8.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pandas>=1.1.5->jbrowse-jupyter) (2.8.2) Requirement already satisfied: tenacity>=6.2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from plotly>=5.0.0->dash==2.3.0->jbrowse-jupyter) (8.0.1) Requirement already satisfied: six in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from plotly>=5.0.0->dash==2.3.0->jbrowse-jupyter) (1.16.0) Requirement already satisfied: attrs>=19.2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (21.4.0) Requirement already satisfied: pluggy<2.0,>=0.12 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (1.0.0) Requirement already satisfied: packaging in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (21.3) Requirement already satisfied: tomli>=1.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (2.0.1) Requirement already satisfied: py>=1.8.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (1.11.0) Requirement already satisfied: iniconfig in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pytest>=6.2.5->jbrowse-jupyter) (1.1.1) Requirement already satisfied: brotli in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from flask-compress->dash==2.3.0->jbrowse-jupyter) (1.0.9) Requirement already satisfied: tornado>=6.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (6.1) Requirement already satisfied: psutil in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (5.9.0) Requirement already satisfied: debugpy>=1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (1.6.0) Requirement already satisfied: traitlets>=5.1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (5.1.1) Requirement already satisfied: matplotlib-inline>=0.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.1.3) Requirement already satisfied: appnope in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.1.3) Requirement already satisfied: jupyter-client>=6.1.12 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (7.2.2) Requirement already satisfied: stack-data in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.2.0) Requirement already satisfied: backcall in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.2.0) Requirement already satisfied: decorator in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (5.1.1) Requirement already satisfied: setuptools>=18.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (58.0.4) Requirement already satisfied: pygments>=2.4.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (2.11.2) Requirement already satisfied: jedi>=0.16 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.18.1) Requirement already satisfied: pickleshare in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.7.5) Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (3.0.29) Requirement already satisfied: pexpect>4.3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (4.8.0) Requirement already satisfied: parso<0.9.0,>=0.8.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jedi>=0.16->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.8.3) Requirement already satisfied: jupyter-core>=4.9.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (4.9.2) Requirement already satisfied: pyzmq>=22.3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (22.3.0) Requirement already satisfied: entrypoints in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->ipykernel->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.4) Requirement already satisfied: ptyprocess>=0.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from pexpect>4.3->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.7.0) Requirement already satisfied: wcwidth in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.2.5) Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from packaging->pytest>=6.2.5->jbrowse-jupyter) (3.0.7) Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from requests->jupyter-dash>=0.4.2->jbrowse-jupyter) (2.0.12) Requirement already satisfied: certifi>=2017.4.17 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from requests->jupyter-dash>=0.4.2->jbrowse-jupyter) (2021.10.8) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from requests->jupyter-dash>=0.4.2->jbrowse-jupyter) (1.26.9) Requirement already satisfied: idna<4,>=2.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from requests->jupyter-dash>=0.4.2->jbrowse-jupyter) (3.3) Requirement already satisfied: asttokens in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from stack-data->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (2.0.5) Requirement already satisfied: executing in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from stack-data->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.8.3) Requirement already satisfied: pure-eval in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from stack-data->ipython->jupyter-dash>=0.4.2->jbrowse-jupyter) (0.2.2)
from jbrowse_jupyter import launch, create, serve
from jupyter_dash import JupyterDash
import requests
# Uncomment and run the next line if you are running this in jupyterlab/jupyternotebook
# !pip install jupyter_server_proxy
# Uncomment and run the next line if you are running this in jupyterlab/jupyternotebook
# import jupyter_server_proxy
# JupyterDash.infer_jupyter_proxy_config()
# Create an Hg19 JBrowse config
hg19 = create('LGV', genome='hg19')
The following two sections
are the two ways in which JBrowse Jupyter supports using local data to configure JBrowse views in the development environment.
Before proceeding with the tutorials, download our example gff files to add a track to our hg19 config.
# You can skip this step if you are using your own data.
file1 = 'https://s3.amazonaws.com/jbrowse.org/genomes/hg19/ncbi_refseq/GRCh37_latest_genomic.sort.gff.gz'
file2 = 'https://s3.amazonaws.com/jbrowse.org/genomes/hg19/ncbi_refseq/GRCh37_latest_genomic.sort.gff.gz.tbi'
response1 = requests.get(file1)
response2 = requests.get(file2)
open("GRCh37_latest_genomic.sort.gff.gz", "wb").write(response1.content)
open("GRCh37_latest_genomic.sort.gff.gz.tbi", "wb").write(response2.content)
227612
Note If you have local files that you want to use, proceed to
- Step 3. on the Using the Jupyter server tutorial or
- Step 1. of the Using the JBrowse Jupyter dev server tutorial
This section will show you how to use local files with jbrowse jupyter when your files exist within your jupyterlab/jupyter notebook file system.
!!!! Intended for those running this notebook in jupyter lab or jupyter notebook !!!!
1. Run Jupyter.
$ jupyter lab
or
$ jupyter notebook
Ignore this step if you are already running this notebook with jupyter lab or jupyter notebook.
2. Verify that local files exist within your notebook file system.
Now that we have these new files in your file tree, we will be able to format urls to pass on to our components. Navigate to http://localhost:8888/tree to verify that GRCh37_latest_genomic.sort.gff.gz and GRCh37_latest_genomic.sort.gff.gz.tbi exist within the file tree.
NOTE: Your port and host may be different, so make sure that you use the same port from your jupyter notebook configuration. To ensure you have the correct one, you can look at the port in the url window where your notebook is running. http://your-host:your-port/tree
3. Format the Jupyter URLs of your local data to pass to your JBrowse view.
http://localhost:8888/files/<your_file_name>
You do not need to add tree or lab to this url.
# With the gff files that we just downloaded to our directory, we will add a track.
track_data = 'http://localhost:8888/files/GRCh37_latest_genomic.sort.gff.gz'
track_data_index = 'http://localhost:8888/files/GRCh37_latest_genomic.sort.gff.gz.tbi'
hg19.add_track(track_data, index=track_data_index, track_id='jupyter_server_demo', name='jupyter_server_demo')
hg19.set_default_session(['jupyter_server_demo'],False)
NOTE: You can now skip to launch the Linear Genome View or continue with the next tutorial to checkout our JBrowse dev server.
1. git clone our repo: https://github.com/GMOD/jbrowse-jupyter. You can skip this step if you are already running this tutorial from within this repo.
2. From the root of our directory, run
$ python serve.py
3. You can provide a specific PORT, HOST, and DIRECTORY from where you want to serve your data. None of these are required. PORT will default to 8080 Host will default to 'localhost' The directory will default to your current working directory.
Your terminal should look something like this, if no input was provided.
> python serve.py
Enter a PORT: [default:8080] >
8080
ENTER A HOST: [default:localhost] >
localhost
ENTER PATH TO YOUR LOCAL DATA: [default:(pwd)] >
=============================================
Warning:
This is a development environment.
This is not recommended for production.
=============================================
Server is now running at
"http://localhost:8080"
4. Navigate to the url and verify that your local data is there. If you do not see your files, make sure you moved the files you wish to serve to the directory you provided to the server above.
E.g: if you chose the defaults, the dev server is serving the files in your current working directory (this repo). You can move the files you just donwloaded or that you wish to display into the current working directory. Otherwise, exit the server and rerun the script with the correct path to the folder containing your files.
Now you should be able to provide urls to your local data to the JBrowse Jupyter config. Below you can find an example of our dev server serving files GRCh37_latest_genomic.sort.gff.gz and GRCh37_latest_genomic.sort.gff.gz.tbi on port 8080 on local host.
You can also run the server by using the serve() method from our package. Checkout our docs for more information regarding our local dev server: https://github.com/GMOD/jbrowse-jupyter/blob/main/README.md
NOTE: You can skip the following cell if you did not run the local dev server provided by JBrowse Jupyter.
track_data2 = 'http://localhost:8080/GRCh37_latest_genomic.sort.gff.gz'
track_data_index2 = 'http://localhost:8080/GRCh37_latest_genomic.sort.gff.gz.tbi'
hg19.add_track(track_data2, index=track_data_index2, track_id='jbrowse_dev_server_demo', name='jbrowse_dev_server_demo')
hg19.set_default_session(['jbrowse_dev_server_demo'],False)
You will be able to checkout your newly added tracks by opening the track selector. For more information on our embedded components https://jbrowse.org/storybook/lgv/v2.1.4/?path=/story/getting-started--page
# Uncomment the next line if you wish to see the tracks from both turtorials
# hg19.set_default_session(['jupyter_server_demo', 'jbrowse_dev_server_demo'],False)
config = hg19.get_config()
launch(config, port=3000)
Issues with the JupyterDash proxy?
jupyterlab-dash
extension installed and you have pip installed jupyter_server_proxy
. If you get an error when installing it or after installing it, exit jupyter lab then run $ jupyter lab build
and run jupyter lab again.Issues with the PORT?
Issues with Jupyter Dash?
I am running this notebook in colab and can't access the files?
For other issues, please open a ticket on our repo or contact our gitter channel for more support
Report a bug or request a feature at https://github.com/GMOD/jbrowse-jupyter/issues Join our developers chat at https://gitter.im/GMOD/jbrowse2 Send an email to our mailing list at gmod-ajax@lists.sourceforge.net