Package: igv-notebook
igv.js notebook moduleJupyter NotebookJupyterLabGoogle Colab============igv-notebook is a Python package which wrapsigv.jsfor embedding in an IPython notebook.
Both Jupyter and Google Colab platforms are supported.Related projectsOther projects enabling embedding igv.js in notebooks includeigv-jupyter(wrapper around igv-notebook that adds g2nb integration)igv-jupyterlabipyigvThe main differences between igv-notebook and these other projects are:igv-notebook is a Python package, while the projects listed above are Jupyter extensions;igv-notebook works with Google Colab, in addition to Jupyter and JupyterLab; andigv-notebook supports loading data files from any location on the local or mounted file system when used with Jupyter Notebook or
Google Colab.NOTE: General local file paths do not work with JupyterLab, for JupyterLab the files must be in the JupyterLab file tree.ExamplesExample notebooks are available in the github repository, and can be run from the Binder and Colab links above.
To download examples without cloning the repository use thislink. Notebooks are available in the
"examples" directory.UsageTypical usage proceeds as followInstall igv-notebookInitialize igv-notebookCreate igv "browser" objectAdd tracks to browserNavigate to loci of interestInstallationpipinstalligv-notebookInitializationAfter installing, import and intialize igv_notebook as follows.importigv_notebookigv_notebook.init()For a Jupyter notebook this should be done once per notebook.   Colab notebooks display output in a sandboxed iFrame
for each cell, so initialization must be repeated for each cell in which  igv-notebook is used.
`Browser creationThe Browser initializer takes a configuration dictionary which is converted to JSON and passed to the igv.js
createBrowser function. The configuration options are described in theigv.js documentation.Example:importigv_notebookigv_notebook.init()igv_browser=igv_notebook.Browser({"genome":"hg19","locus":"chr22:24,376,166-24,376,456","tracks":[{"name":"BAM","url":"https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam","indexURL":"https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam.bai","format":"bam","type":"alignment"}],"roi":[{"name":"ROI set 1","url":"https://s3.amazonaws.com/igv.org.test/data/roi/roi_bed_1.bed","indexed":False,"color":"rgba(94,255,1,0.25)"}]})URLS and pathsConfiguration objects for igv.js have properties to specify URLs to files for data and indexes.  These properties are
supported in igv-notebook, however igv-notebook also provides equivalentpathproperties for specfiying paths to
local files when used with Jupyter Notebook or Colab.  (Note: Thepathproperties cannot be used with JupyterLab, however local files can
be loaded by URL if they are in the Jupyter file tree).  Thepathproperties are useful for:loading data in a Colab notebook from the local Colab file system or a mounted Google Drive; andloading data in Jupyter Notebook from the local file system that is outside the Jupyter file tree.URL and Path propertiesigv.js url propertyigv-notebook path propertyurlpathindexURLindexPathfastaURLfastaPathcytobandURLcytobandPathaliasURLaliasPathFor Jupyter servers (Notebook and Lab), local files can be also be loaded via the url property if the file is in the Jupyter
startup directory tree.  This will usually yield better performance than usingpathproperties.  URL paths
that begin with a "/" are relative to the Jupyter server startup directory, i.e. the directory from where you
started Jupyter Notebook or JupyterLab.  For Jupyter Notebook, URL paths without a leading slash can be used and are
assumed to be relative to the notebook  directory.  See below for examples.  You can also use the "download url" for
the file, obtainable through the JupyterLab UI, as the URL for igv.TracksTo load a track, pass a track configuration object toigv_browser.load_track(). Track configuration
objects are described in theigv.js documentation, however
see the note onURLs and pathsabove. 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, file path, or passed directly as an array of JSON objects.Examples:Local file - Jupyter. URL relative to the location of the notebookigv_browser.load_track({"name":"Local BAM","url":"data/gstt1_sample.bam","indexURL":"data/gstt1_sample.bam.bai","format":"bam","type":"alignment"})Local file - Jupyter.  URL relative to root of Jupyter file treeigv_browser.load_track({"name":"Local BAM","url":"/examples/data/gstt1_sample.bam","indexURL":"/examples/data/gstt1_sample.bam.bai","format":"bam","type":"alignment"})Local file - Jupyter.  Absolute file path, potentially outside the Jupyter file tree.  Note the use ofpathandindexPath.igv_browser.load_track({"name":"Local BAM","path":"/any_path_you_like/data/gstt1_sample.bam","indexPath":"/any_path_you_like/data/gstt1_sample.bam.bai","format":"bam","type":"alignment"})Local file - Colab.  In Colab files are loaded by file path.igv_browser.load_track({"name":"Local BAM","path":"/content/igv-notebook/examples/data/gstt1_sample.bam","indexPath":"/content/igv-notebook/examples/data/gstt1_sample.bam.bai","format":"bam","type":"alignment"})Remote file - Jupyter.igv_browser.load_track({"name":"BAM","url":"https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam","indexURL":"https://s3.amazonaws.com/igv.org.demo/gstt1_sample.bam.bai","format":"bam","type":"alignment"})APIMost IGV options can be specified in the initial browser configuration, including specifying genome, locus, tracks, and regions-of-interest.  Additional methods are provided to perform actions on the browser post-creation.  These are described belowLoad a track**To load a trackigv_browser.load_track(track_config)See example track configurations above.   Alsoigv.js  wikiExample:igv_browser.load_track({"name":"Local BAM","url":"data/gstt1_sample.bam","indexURL":"data/gstt1_sample.bam.bai","format":"bam","type":"alignment"})Load regions of interest**  (version >= 0.4.0)Regions-of-interest are overlays marking genomic ranges of interest.  They are defined by track configurations, often backed by a "bed" file, and usually with a translucent color.  These can be specified at browser creation with the "roi" property, or loaded afterwards with the ```loadROIs`` function.  This function takes an array of track configuration objects.   See the notebook examples/ROI.ipynb for example usage.igv_browser.loadROIs([roi_configs])NavigationJump to a specific genomic rangeigv_browser.search('chr1:3000-4000')Jump to a specific gene. This uses the IGV search web service, which currently supports a limited number ofgenomes.  To customize the search, load a non-indexed annotation
track with the "searchable" property set to true (seeigv.js documentation).igv_browser.search('myc')Zoom in by a factor of 2igv_browser.zoom_in()Zoom out by a factor of 2igv_browser.zoom_out()SVG conversion - Jupyter Notebook onlyTo convert the current igv view to a static SVG imageigv_browser.to_svg()This action can also be invoked with the "To SVG" button on the igv.js command bar.  This is useful when converting
the notebook to formats such as HTML and PDF.Note: This action is not reversible.VersionTo verify the currently installed igv-notebook version (versions >= 0.3.1 only)igv_notebook.version()To verify the current version of igv.js (igv-notebook versions >= 0.4.0 only)igv_notebook.igv_version()Developmentrequires python >= 3.9.1Development installpipinstall-e.Buildpythonsetup.pybuildUpdating igv.js versionEdit VERSION_IGV - enter igv.js version with no line feed.  Visitnpmjs.comto find latest versionRunpython updateIGV.pyRelease Notes0.5.2Bug fix -- igv undefined0.5.1Update igv.js version to 2.15.70.5.0Add support for loading an igv sessionGenerate links to igv-web0.4.5Fix path/url problems when using JupyterLab0.4.4Add missing requirements to setup.pyUpdate igv.js version to 2.13.100.4.3Fix file-not-found error with version() and igv_version() functions0.4.1Update documentation0.4.0Add support for regions-of-interestAddigv_notebook.igv_version()function.0.3.1Updatebrowser.to_svg()function to support Python 3.6.Addigv_notebook.version()function.0.3.0Addbrowser.to_svg()function to convert igv instance to static SVG image (Jupyter Notebook only).