igv.js Jupyter Extension
This extension can be installed through pip or conda.
pip install igv
conda install -c igv igv
This extension can be enabled in Jupyter Notebook by running the following on the command line:
jupyter nbextension install --py igv
jupyter nbextension enable --py igv
Using the extension
This extension consists of a Python package that wraps igv.js functionality and an nbextension that's used for rendering igv.js when it is displayed in a notebook. Once the extension is installed and enabled, it can be used by importing IGV and associated classes, then returning them in a cell. Example code:
from igv import IGV, Reference, Track IGV(locus="chr1:155,160,475-155,184,282", reference=Reference(id="hg19"), tracks=[Track( name="Genes", url="//s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/gencode.v18.collapsed.bed", index_url="//s3.amazonaws.com/igv.broadinstitute.org/annotations/hg19/genes/gencode.v18.collapsed.bed.idx", display_mode="EXPANDED")])
If using the built-in Jupyter webserver take note of the "Range" header requirements desribed here: Server Requirements. In general you will be restricted to serving non-indexed annotation (bed, gff) and wig files from the Jupyter web server.
error: can't copy 'igv/static/igvjs/img': doesn't exist or not a regular file
If you see the above error when trying to install through PIP, you may be experiencing a known issue with Python 2.7.6. To get around this error we recommend either updating your system's version of Python or simply installing through the conda package manager (described above).