{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Use local data to configure a Linear Genome View\n",
"\n",
"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).\n",
"\n",
"You can run this notebook completely with jupyterlab or jupyter notebook.\n",
"\n",
"```\n",
"$ jupyter lab\n",
"```\n",
"or\n",
"```\n",
"$ jupyter notebook\n",
"```\n",
"\n",
"If you decide to run this in colab, you can skip the first part of adding tracks (Using the Jupyter server) and go straight to (Using the JBrowse Jupyter dev server)\n",
"\n",
"## Overview:\n",
"1. Create an hg19 config\n",
"2. There are 2 ways to add Tracks utilizing local data\n",
" 1. Add a feature track using local data from within the Jupyter File Tree (Only if you are running this notebook in jupyter lab or jupyter notebook)\n",
" * The first tutorial is intended for those running this notebook with jupyter lab and jupyter notebook\n",
" 2. Add a feature track by spinning JBrowse Jupyter's dev server\n",
" * This tutorial is for anyone wanting to serve local files to use in colab notebooks,jupyter lab, jupyter notebook,binder and more.\n",
"3. Launch a linear genome view\n",
"\n",
"\n",
"#### Resources\n",
"* [Here are the docs on how Jupyter handles urls and file navigation with /tree.](https://jupyterlab.readthedocs.io/en/stable/user/urls.html)\n",
"* [Additional information on the Jupyter Server](https://jupyter-server.readthedocs.io/en/latest/users/configuration.html)\n",
"* [Additional information on the Jupyter Notebook Server](https://jupyter-notebook.readthedocs.io/en/stable/notebook.html#starting-the-notebook-server)\n",
"* [Additional information on JBrowse dev server](https://github.com/GMOD/jbrowse-jupyter/blob/main/README.md)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting git+https://github.com/GMOD/jbrowse-jupyter.git@path_support_two\n",
" Cloning https://github.com/GMOD/jbrowse-jupyter.git (to revision path_support_two) to /private/var/folders/96/hq94_1qd3c9_q87bwqhg05s80000gn/T/pip-req-build-2d1iovvr\n",
" Running command git clone -q https://github.com/GMOD/jbrowse-jupyter.git /private/var/folders/96/hq94_1qd3c9_q87bwqhg05s80000gn/T/pip-req-build-2d1iovvr\n",
" Running command git checkout -b path_support_two --track origin/path_support_two\n",
" Switched to a new branch 'path_support_two'\n",
" Branch 'path_support_two' set up to track remote branch 'path_support_two' from 'origin'.\n",
" Resolved https://github.com/GMOD/jbrowse-jupyter.git to commit 55b815a085f1bfbc8c8b9d3627b708b3c47ebf30\n",
"Requirement already satisfied: dash==2.3.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter==1.3.5) (2.3.0)\n",
"Requirement already satisfied: dash-jbrowse==1.1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter==1.3.5) (1.1.0)\n",
"Requirement already satisfied: jupyter_dash>=0.4.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter==1.3.5) (0.4.2)\n",
"Requirement already satisfied: Werkzeug==2.0.3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter==1.3.5) (2.0.3)\n",
"Requirement already satisfied: pandas>=1.1.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jbrowse-jupyter==1.3.5) (1.4.2)\n",
"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==1.3.5) (2.1.3)\n",
"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.3.5) (1.11)\n",
"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==1.3.5) (5.0.0)\n",
"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==1.3.5) (2.0.0)\n",
"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==1.3.5) (5.7.0)\n",
"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==1.3.5) (2.0.0)\n",
"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==1.3.5) (3.1.2)\n",
"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==1.3.5) (4.11.3)\n",
"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==1.3.5) (8.1.3)\n",
"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==1.3.5) (2.1.2)\n",
"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==1.3.5) (3.8.0)\n",
"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==1.3.5) (2.0.1)\n",
"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==1.3.5) (2.27.1)\n",
"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.5) (1.3.3)\n",
"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==1.3.5) (8.2.0)\n",
"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.3.5) (1.7.0)\n",
"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==1.3.5) (6.12.1)\n",
"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.3.5) (1.5.5)\n",
"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.3.5) (1.22.3)\n",
"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==1.3.5) (2.8.2)\n",
"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==1.3.5) (2022.1)\n",
"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==1.3.5) (8.0.1)\n",
"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.3.5) (1.16.0)\n",
"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.3.5) (1.0.9)\n",
"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==1.3.5) (0.1.3)\n",
"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==1.3.5) (7.2.2)\n",
"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.3.5) (1.6.0)\n",
"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==1.3.5) (6.1)\n",
"Requirement already satisfied: packaging in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from ipykernel->jupyter_dash>=0.4.2->jbrowse-jupyter==1.3.5) (21.3)\n",
"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==1.3.5) (5.1.1)\n",
"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==1.3.5) (0.1.3)\n",
"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==1.3.5) (5.9.0)\n",
"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==1.3.5) (3.0.29)\n",
"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==1.3.5) (2.11.2)\n",
"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==1.3.5) (4.8.0)\n",
"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==1.3.5) (0.2.0)\n",
"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==1.3.5) (5.1.1)\n",
"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==1.3.5) (0.7.5)\n",
"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==1.3.5) (0.2.0)\n",
"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==1.3.5) (58.0.4)\n",
"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==1.3.5) (0.18.1)\n",
"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==1.3.5) (0.8.3)\n",
"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==1.3.5) (0.4)\n",
"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==1.3.5) (4.9.2)\n",
"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==1.3.5) (22.3.0)\n",
"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==1.3.5) (0.7.0)\n",
"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==1.3.5) (0.2.5)\n",
"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->ipykernel->jupyter_dash>=0.4.2->jbrowse-jupyter==1.3.5) (3.0.7)\n",
"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==1.3.5) (2021.10.8)\n",
"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.3.5) (1.26.9)\n",
"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==1.3.5) (2.0.12)\n",
"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==1.3.5) (3.3)\n",
"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==1.3.5) (0.2.2)\n",
"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==1.3.5) (0.8.3)\n",
"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==1.3.5) (2.0.5)\n"
]
}
],
"source": [
"!pip install jbrowse-jupyter"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from jbrowse_jupyter import launch, create, serve\n",
"from dash import jupyter_dash\n",
"import requests"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: jupyter_server_proxy in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (3.2.1)\n",
"Requirement already satisfied: aiohttp in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter_server_proxy) (3.8.1)\n",
"Requirement already satisfied: simpervisor>=0.4 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter_server_proxy) (0.4)\n",
"Requirement already satisfied: jupyter-server>=1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter_server_proxy) (1.16.0)\n",
"Requirement already satisfied: jupyter-core>=4.7.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (4.9.2)\n",
"Requirement already satisfied: Send2Trash in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (1.8.0)\n",
"Requirement already satisfied: nbconvert>=6.4.4 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (6.4.5)\n",
"Requirement already satisfied: terminado>=0.8.3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (0.13.3)\n",
"Requirement already satisfied: anyio>=3.1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (3.5.0)\n",
"Requirement already satisfied: traitlets>=5.1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (5.1.1)\n",
"Requirement already satisfied: jupyter-client>=6.1.12 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (7.2.2)\n",
"Requirement already satisfied: websocket-client in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (1.3.2)\n",
"Requirement already satisfied: packaging in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (21.3)\n",
"Requirement already satisfied: nbformat>=5.2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (5.3.0)\n",
"Requirement already satisfied: prometheus-client in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (0.14.1)\n",
"Requirement already satisfied: pyzmq>=17 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (22.3.0)\n",
"Requirement already satisfied: tornado>=6.1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (6.1)\n",
"Requirement already satisfied: argon2-cffi in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (21.3.0)\n",
"Requirement already satisfied: jinja2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-server>=1.0->jupyter_server_proxy) (3.1.2)\n",
"Requirement already satisfied: sniffio>=1.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from anyio>=3.1.0->jupyter-server>=1.0->jupyter_server_proxy) (1.2.0)\n",
"Requirement already satisfied: idna>=2.8 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from anyio>=3.1.0->jupyter-server>=1.0->jupyter_server_proxy) (3.3)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->jupyter-server>=1.0->jupyter_server_proxy) (2.8.2)\n",
"Requirement already satisfied: entrypoints in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->jupyter-server>=1.0->jupyter_server_proxy) (0.4)\n",
"Requirement already satisfied: nest-asyncio>=1.5.4 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jupyter-client>=6.1.12->jupyter-server>=1.0->jupyter_server_proxy) (1.5.5)\n",
"Requirement already satisfied: beautifulsoup4 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (4.11.1)\n",
"Requirement already satisfied: MarkupSafe>=2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (2.0.1)\n",
"Requirement already satisfied: defusedxml in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.7.1)\n",
"Requirement already satisfied: pygments>=2.4.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (2.11.2)\n",
"Requirement already satisfied: bleach in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (5.0.0)\n",
"Requirement already satisfied: pandocfilters>=1.4.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (1.5.0)\n",
"Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.5.13)\n",
"Requirement already satisfied: mistune<2,>=0.8.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.8.4)\n",
"Requirement already satisfied: testpath in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.6.0)\n",
"Requirement already satisfied: jupyterlab-pygments in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.2.0)\n",
"Requirement already satisfied: jsonschema>=2.6 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (3.2.0)\n",
"Requirement already satisfied: fastjsonschema in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (2.15.3)\n",
"Requirement already satisfied: attrs>=17.4.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jsonschema>=2.6->nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (21.4.0)\n",
"Requirement already satisfied: setuptools in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jsonschema>=2.6->nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (58.0.4)\n",
"Requirement already satisfied: six>=1.11.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jsonschema>=2.6->nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (1.16.0)\n",
"Requirement already satisfied: pyrsistent>=0.14.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from jsonschema>=2.6->nbformat>=5.2.0->jupyter-server>=1.0->jupyter_server_proxy) (0.18.1)\n",
"Requirement already satisfied: ptyprocess in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from terminado>=0.8.3->jupyter-server>=1.0->jupyter_server_proxy) (0.7.0)\n",
"Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (2.0.12)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (1.3.0)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (4.0.2)\n",
"Requirement already satisfied: yarl<2.0,>=1.0 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (1.7.2)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (1.2.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from aiohttp->jupyter_server_proxy) (6.0.2)\n",
"Requirement already satisfied: argon2-cffi-bindings in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from argon2-cffi->jupyter-server>=1.0->jupyter_server_proxy) (21.2.0)\n",
"Requirement already satisfied: cffi>=1.0.1 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from argon2-cffi-bindings->argon2-cffi->jupyter-server>=1.0->jupyter_server_proxy) (1.15.0)\n",
"Requirement already satisfied: pycparser in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->jupyter-server>=1.0->jupyter_server_proxy) (2.21)\n",
"Requirement already satisfied: soupsieve>1.2 in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from beautifulsoup4->nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (2.3.2)\n",
"Requirement already satisfied: webencodings in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (from bleach->nbconvert>=6.4.4->jupyter-server>=1.0->jupyter_server_proxy) (0.5.1)\n",
"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->jupyter-server>=1.0->jupyter_server_proxy) (3.0.7)\n"
]
}
],
"source": [
"# Uncomment and run the next line if you are running this in jupyterlab/jupyternotebook\n",
"\n",
"!pip install jupyter_server_proxy"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# Uncomment and run the next line if you are running this in jupyterlab/jupyternotebook\n",
"\n",
"from dash import jupyter_dash\n",
"jupyter_dash.infer_jupyter_proxy_config() "
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Create an Hg19 JBrowse config\n",
"\n",
"hg19 = create('LGV', genome='hg19')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Adding Tracks from local data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following two sections\n",
"1. Using the Jupyter server and\n",
"2. Using the JBrowse dev server\n",
"are the two ways in which JBrowse Jupyter supports using local data to configure JBrowse views in the development environment."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before proceeding with the tutorials, download our example gff files to add a track to our hg19 config.\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"227612"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# You can skip this step if you are using your own data.\n",
"\n",
"file1 = 'https://s3.amazonaws.com/jbrowse.org/genomes/hg19/ncbi_refseq/GRCh37_latest_genomic.sort.gff.gz'\n",
"file2 = 'https://s3.amazonaws.com/jbrowse.org/genomes/hg19/ncbi_refseq/GRCh37_latest_genomic.sort.gff.gz.tbi'\n",
"response1 = requests.get(file1)\n",
"response2 = requests.get(file2)\n",
"open(\"GRCh37_latest_genomic.sort.gff.gz\", \"wb\").write(response1.content)\n",
"open(\"GRCh37_latest_genomic.sort.gff.gz.tbi\", \"wb\").write(response2.content)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"> **Note**\n",
"> If you have local files that you want to use, proceed to \n",
"> * **Step 3.** on the *Using the Jupyter server* tutorial or\n",
"> * **Step 1.** of the *Using the JBrowse Jupyter dev server* tutorial\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using the Jupyter server \n",
"\n",
"This section will show you how to use local files with jbrowse jupyter when your files exist within your jupyterlab/jupyter notebook file system.\n",
"\n",
"**!!!! Intended for those running this notebook in jupyter lab or jupyter notebook !!!!**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**1.** Run Jupyter."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**2.** Verify that local files exist within your notebook file system.\n",
"\n",
"Now that we have these new files in your file tree, we will be able to format urls to pass on to our components.\n",
"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.\n",
"\n",
"> **_NOTE_:** \n",
"> 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*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**3.** Create Paths for your files. Paths should be **relative to the root of the Jupyter file tree**. \n",
"\n",
"Example:\n",
"\n",
"jbrowse-jupyter/\n",
" local_support.ipynb\n",
" GRCh37_latest_genomic.sort.gff.gz\n",
" GRCh37_latest_genomic.sort.gff.gz.tbi\n",
" \n",
"Path relative to the root of the Jupyter file tree since we ran jupyter lab/jupyter notebook from the root of the repo. Path to the gff files would be e.g /GRCh37_latest_genomic.sort.gff.gz"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# With the gff files that we just downloaded to our directory, we will add a track.\n",
"track_data = '/GRCh37_latest_genomic.sort.gff.gz'\n",
"track_data_index = '/GRCh37_latest_genomic.sort.gff.gz.tbi'"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"notebook port: 8888\n",
"notebook host: localhost\n"
]
},
{
"data": {
"text/plain": [
"('localhost', 8888)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# you can check your jupyter host and port match that used by JBrowse by running\n",
"hg19.get_env()\n",
"# if they do not match, you can change it using the command below "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# uncomment the line below and modify according to your Jupyter config.\n",
"# hg19.set_env(\"localhost\", 8889)\n",
"# The command above is changing the port to 8889 since my jupyter config is set to port 8889 and localhost"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"hg19.add_track(track_data, index=track_data_index, track_id='jupyter_server_demo', name='jupyter_server_demo')\n",
"hg19.set_default_session(['jupyter_server_demo'],False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> **_NOTE_:**\n",
"> You can now skip to launch the Linear Genome View or continue with the next tutorial to checkout our JBrowse dev server. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using the JBrowse Jupyter dev server\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**1.** git clone our repo: [https://github.com/GMOD/jbrowse-jupyter](https://github.com/GMOD/jbrowse-jupyter). You can skip this step if you are already running this tutorial from within this repo.\n",
"\n",
"**2.** From the root of our directory, run \n",
"```$ python serve.py```\n",
"\n",
"**3.** You can provide a specific PORT, HOST, and DIRECTORY from where you want to serve your data.\n",
"None of these are required. \n",
"PORT will default to 8080\n",
"Host will default to 'localhost'\n",
"The directory will default to your current working directory.\n",
"\n",
"Your terminal should look something like this, if no input was provided.\n",
"```\n",
"> python serve.py \n",
"Enter a PORT: [default:8080] > \n",
"8080\n",
"ENTER A HOST: [default:localhost] > \n",
"localhost\n",
"ENTER PATH TO YOUR LOCAL DATA: [default:(pwd)] > \n",
"\n",
"=============================================\n",
"Warning: \n",
"This is a development environment.\n",
"This is not recommended for production.\n",
"=============================================\n",
"Server is now running at \n",
" \"http://localhost:8080\"\n",
"```\n",
"**4.** Navigate to the url and verify that your local data is there.\n",
"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. \n",
"\n",
"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 downloaded 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.\n",
"\n",
"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 \n",
"*GRCh37_latest_genomic.sort.gff.gz* and *GRCh37_latest_genomic.sort.gff.gz.tbi* on port 8080 on local host.\n",
"\n",
"\n",
"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:\n",
"https://github.com/GMOD/jbrowse-jupyter/blob/main/README.md\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> **_NOTE_:** You can skip the following cell if you did not run the local dev server provided by JBrowse Jupyter. \n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"track_data2 = 'http://localhost:8080/GRCh37_latest_genomic.sort.gff.gz'\n",
"track_data_index2 = 'http://localhost:8080/GRCh37_latest_genomic.sort.gff.gz.tbi'\n",
"hg19.add_track(track_data2, index=track_data_index2, track_id='jbrowse_dev_server_demo', name='jbrowse_dev_server_demo')\n",
"hg19.set_default_session(['jbrowse_dev_server_demo'],False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Launch a Linear Genome View \n",
"\n",
"You will be able to checkout your newly added tracks by opening the track selector. For more information on our embedded components\n",
"https://jbrowse.org/storybook/lgv/v2.1.4/?path=/story/getting-started--page\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# Uncomment the next line if you wish to see the tracks from both tutorials \n",
"hg19.set_default_session(['jupyter_server_demo', 'jbrowse_dev_server_demo'],False)\n",
"config = hg19.get_config()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"launch(config, port=3232)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## FAQ & Troubleshooting\n",
"Issues with the JupyterDash proxy?\n",
"\n",
"* This tutorial works in both jupyter notebook and jupyter lab. If you have issues with the proxy and you are working in jupyter lab, make sure that you have the `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.\n",
"\n",
"Issues with the PORT?\n",
"\n",
"* Make sure that the PORT that your notebook is running is different from the one that you use to launch the JBrowse view and or the JBrowse Dev Server. To change the PORT in JBrowse Jupyter, simply pass a new port number to the launch() method or pass a different port to the dev server. \n",
"\n",
"Issues with Jupyter Dash?\n",
"\n",
"* Our package has dependencies on JupyterDash and Dash, please make sure that you are using jupyter lab version 2.0 and greater. This tutorial is currently working with the latest version of jupyter lab 3.4.6.\n",
"\n",
"I am running this notebook in colab and can't access the files?\n",
"\n",
"* You can manually download the files provided in the demo by clicking on the links to aws and store them in directory hosted by the dev server.\n",
"\n",
"## Contact Us\n",
"For other issues, please open a ticket on our repo or contact our gitter channel for more support\n",
"\n",
"Report a bug or request a feature at https://github.com/GMOD/jbrowse-jupyter/issues\n",
"Join our developers chat at https://gitter.im/GMOD/jbrowse2\n",
"Send an email to our mailing list at gmod-ajax@lists.sourceforge.net\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
},
"vscode": {
"interpreter": {
"hash": "aaf81c8f28912d07c45359b3a81eb2244c23c90e1b370733684a5666e4e4597e"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}