Jupyter extension for embedding the genome visualation igv.js in a notebook
Project description
igv.js Jupyter Extension
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:
- jupyter >= 4.2.0
pip install igv
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(
{"reference": {
"id": "hg19",
"fastaURL": "files/data/hg19.snippet.fasta",
"indexed": False,
"cytobandURL": "files/data/cytoband.hg19.snippet.txt",
"tracks": [
{
"name": "RefGene",
"url": "files/data/refgene.hg19.snippet.bed"
}
]
}}
)
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. This method is
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')
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file igv-0.9.1.tar.gz
.
File metadata
- Download URL: igv-0.9.1.tar.gz
- Upload date:
- Size: 668.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60687206a98172a8482673ebe11edbf51f7916d538c0289dfb0cef7366c810ea |
|
MD5 | 04705cf9ddcf51b39dcaa3c54ecfbd7d |
|
BLAKE2b-256 | efb39c426ebc138d50f477fe9a679c8bb8a96d29e41012f8388e99ef65ab84e0 |
File details
Details for the file igv-0.9.1-py2-none-any.whl
.
File metadata
- Download URL: igv-0.9.1-py2-none-any.whl
- Upload date:
- Size: 673.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad5fb2f9c4b0c5e7cb18a5322878937d2e6d36476fcd1e021f04188569f4198 |
|
MD5 | 645a7720fe87e4a775bc3e2e1893b9d9 |
|
BLAKE2b-256 | 7f476c85d5346614fa1782b595c2fd3841725832d430537fe83fe6baa7517818 |