Skip to main content

NOTE - THIS PACKAGE IS DEPRECATED AND WILL NOT BE UPDATED. The package is now distributed as igv-jupyter.

igv Jupyter Extension

Binder

IGV is an extension for Jupyter Notebook which wraps igv.js. With this extension you can render igv.js in a cell and call its API from the notebook. The extension exposes a python API that mimics the igv.js Browser creation and control APIs. Dictionaries are used for browser and track configuration objects. Track data can be loaded from local or remote URLs, or supplied directly as lists of objects.

Installation

Requirements:

  • python >= 3.6.4
  • jupyter >= 4.2.0
pip install igv

# To install to configuration in your home directory
jupyter serverextension enable --py igv
jupyter nbextension install --py igv
jupyter nbextension enable --py igv


# If using a virtual environment or conda (don't forget to activate
jupyter serverextension enable --py igv --sys-prefix
jupyter nbextension install --py igv --sys-prefix
jupyter nbextension enable --py igv --sys-prefix

Usage

Examples

Example notebooks are available in the github repository. To download without cloning the repository use this link. Notebooks are available in the "examples" directory.

Initialization

To insert an IGV instance into a cell:

(1) create an igv.Browser object,and (2) call showBrowser on the instance.

Example:

import igv

b = igv.Browser({"genome": "hg19"})

The igv.Browser initializer takes a configuration object which is converted to JSON and passed to the igv.js createBrowser function. The configuration object is described in the igv.js documentation.

To instantiate the client side IGV instance in a cell call show()

b.show()

Tracks

To load a track pass a track configuration object to load_track(). Track configuration objects are described in the igv.js documentation. The configuration object will be converted to JSON and passed to the igv.js browser instance.

Data for the track can be loaded by URL or passed directly as an array of JSON objects.

Remote URL

b.load_track(
    {
        "name": "Segmented CN",
        "url": "https://data.broadinstitute.org/igvdata/test/igv-web/segmented_data_080520.seg.gz",
        "format": "seg",
        "indexed": False
    })

Local File

Tracks can be loaded from local files using the Jupyter web server by prepending "files" to the path. The path is relative to the notebook file.

b.load_track(
    {
        "name": "Local VCF",
        "url": "files/data/example.vcf",
        "format": "vcf",
        "type": "variant",
        "indexed": False
    })

Embedded Features

Features can also be passed directly to tracks.

b.load_track({
    "name": "Copy number",
    "type": "seg",
    "displayMode": "EXPANDED",
    "height": 100,
    "isLog": True,
    "features": [
        {
            "chr": "chr20",
            "start": 1233820,
            "end": 1235000,
            "value": 0.8239,
            "sample": "TCGA-OR-A5J2-01"
        },
        {
            "chr": "chr20",
            "start": 1234500,
            "end": 1235180,
            "value": -0.8391,
            "sample": "TCGA-OR-A5J3-01"
        }
    ]
})

Navigation

Zoom in by a factor of 2

b.zoom_in()

Zoom out by a factor of 2

b.zoom_out()

Jump to a specific locus

b.search('chr1:3000-4000')

Jump to a specific gene. This uses the IGV search web service, which currently supports a limited number of genomes: hg38, hg19, and mm10. To configure a custom search service see the igv.js documentation

b.search('myc')

SVG output

Saving the current IGV view as an SVG image requires two calls.

b.get_svg()

b.display_svg()

Events

Note: This is an experimental feature.

def locuschange(data):
    b.locus = data

b.on("locuschange", locuschange)

b.zoom_in()

return b.locus

Development

To build and install from source:

python setup.py build
pip install -e .
jupyter nbextension install --py igv
jupyter nbextension enable --py igv

Creating a conda environment

conda create -n test python=3.7.1
conda activate test
conda install pip
conda install jupyter

Metadata

Release files for igv 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for igv 0.9.6
File Size Uploaded
igv-0.9.6.tar.gz 392.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for igv 0.9.6
File Interpreter ABI Platform
igv-0.9.6-py3-none-any.whl Python 3 none any Details

Total release size: 784.7 kB

Release files / igv-0.9.6.tar.gz

Download URL igv-0.9.6.tar.gz
Size 392.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a33fd25e7c4b2484e05d30eac9dfd0826d05e53c970b131af7839114bbbac25a
BLAKE2b-256 checksum
How to use checksums
ff14c9752e0422d01faa462cf5d876b39a0373a336fcd1e6e5e1c7e815ce5061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release files / igv-0.9.6-py3-none-any.whl

Download URL igv-0.9.6-py3-none-any.whl
Size 392.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97031b373a4e827e51ac2e56d41095d0cbf80c39479f0cf2b631366a175ba3bd
BLAKE2b-256 checksum
How to use checksums
146279eefd2f3c75b14db4818309c45e21b2a48c2d6ebc2a14491424b886b8cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.5

2 release files

0.9.4

3 release files

0.9.1

2 release files

0.2.1

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page