{ "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", "## 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": [ "Requirement already satisfied: jbrowse-jupyter in /Users/teresamartinez/opt/anaconda3/envs/jbrowse-jupyter/lib/python3.8/site-packages (1.2.5)\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) (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) (2.0.3)\n", "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)\n", "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)\n", "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)\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.4.2)\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) (5.7.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) (2.0.0)\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) (5.0.0)\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.11)\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) (2.1.1)\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) (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) (3.1.1)\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) (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) (8.1.2)\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) (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) (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) (2.1.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.3)\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) (6.12.1)\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) (8.2.0)\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) (2.27.1)\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.7.0)\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.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.22.3)\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) (2022.1)\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) (2.8.2)\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) (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.16.0)\n", "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)\n", "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)\n", "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)\n", "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)\n", "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)\n", "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)\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.0.9)\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) (6.1)\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) (5.9.0)\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.6.0)\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) (5.1.1)\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) (0.1.3)\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) (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) (7.2.2)\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) (0.2.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) (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) (5.1.1)\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) (58.0.4)\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) (2.11.2)\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) (0.18.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) (0.7.5)\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) (3.0.29)\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) (4.8.0)\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) (0.8.3)\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) (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) (22.3.0)\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) (0.4)\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) (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) (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->pytest>=6.2.5->jbrowse-jupyter) (3.0.7)\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) (2.0.12)\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) (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.26.9)\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) (3.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) (2.0.5)\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) (0.8.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) (0.2.2)\n" ] } ], "source": [ "!pip install jbrowse-jupyter" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from jbrowse_jupyter import launch, create, serve\n", "from jupyter_dash import JupyterDash\n", "import requests" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "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": 52, "metadata": {}, "outputs": [], "source": [ "# Uncomment and run the next line if you are running this in jupyterlab/jupyternotebook\n", "\n", "# import jupyter_server_proxy\n", "# JupyterDash.infer_jupyter_proxy_config() " ] }, { "cell_type": "code", "execution_count": 3, "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 Jupyter 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": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "227612" ] }, "execution_count": 4, "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": [ "\n", "```\n", "$ jupyter lab\n", "```\n", "or\n", "```\n", "$ jupyter notebook\n", "```\n", "\n", "Ignore this step if you are already running this notebook with jupyter lab or jupyter notebook." ] }, { "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.** Format the Jupyter URLs of your local data to pass to your JBrowse view. \n", "\n", "\n", "* To format your urls: `http://localhost:8888/files/`\n", "* e.g 'http://localhost:8888/files/' + 'GRCh37_latest_genomic.sort.gff.gz' = 'http://localhost:8888/files/GRCh37_latest_genomic.sort.gff.gz'\n", "\n", "You do not need to add tree or lab to this url." ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [], "source": [ "# With the gff files that we just downloaded to our directory, we will add a track.\n", "track_data = 'http://localhost:8888/files/GRCh37_latest_genomic.sort.gff.gz'\n", "track_data_index = 'http://localhost:8888/files/GRCh37_latest_genomic.sort.gff.gz.tbi'\n", "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 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.\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": 5, "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": 6, "metadata": {}, "outputs": [], "source": [ "# Uncomment the next line if you wish to see the tracks from both turtorials \n", "# hg19.set_default_session(['jupyter_server_demo', 'jbrowse_dev_server_demo'],False)\n", "config = hg19.get_config()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "launch(config, port=3000)" ] }, { "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 lastest 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" ] } ], "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 }