Package: juicebox-notebook
juicebox notebook moduleJupyter NotebookJupyterLabjuicebox-notebook is an module for Jupyter and Colab notesbooks which exposes a python API that
enables creation and interaction with ajuicebox.jsinstance in a cell.ExamplesExample notebooks are available in the github repository in the "examples" directory of thegithub repository.InstallationRequirements:python >= 3.6.4jupyter >= 4.2.0pipinstalljuicebox-notebookInitializationAfter installing import and intialize igv_notebook as follows.importjuicebox_notebookjuicebox_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 these steps must be repeated for each cell in which  juicebox-notebook is used.Browser creationThe juicebox_notebook.Browser constructor takes a configuration object which is converted to JSON and passed to the juicebox.js
createBrowser function.   The configuration object is described in thejuicebox.js documentation.  To open an empty "browser" to dynamically
load maps pass an empty dictionary.Example:importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","url":"https://www.encodeproject.org/files/ENCFF179HVU/@@download/ENCFF179HVU.hic","tracks":[{"url":"https://www.encodeproject.org/files/ENCFF000ARJ/@@download/ENCFF000ARJ.bigWig","name":"CTCF","color":"rgb(22, 129, 198)"}]})Dynamically loading maps and tracksTypically maps and tracks are loaded in the initialjuicebox.Browsercreation.  However its also possible to
load them post creation using theb.load_map(configandb.load_trackfunctions.MapsTo load a map into an existing browser pass a hic file configuration object to the load_map functionimportjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({})b.load_map({"url":"https://hicfiles.s3.amazonaws.com/hiseq/gm12878/in-situ/primary.hic"})TracksTo load a track pass a track configuration object to load_track.  Track configuration
objects are described in thejuicebox.js documentation.
The configuration object will be converted to JSON and passed to the juicebox.js browser
instance.importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","url":"https://www.encodeproject.org/files/ENCFF179HVU/@@download/ENCFF179HVU.hic"})b.load_track({"url":"https://www.encodeproject.org/files/ENCFF000ARJ/@@download/ENCFF000ARJ.bigWig","name":"CTCF","color":"#ff8802"})URLS and pathsConfiguration objects for juicebox.js maps (.hic files) and tracks have properties to specify URLs to files for
data and indexes.  These properties are  supported in juicebox-notebook, however juicebox-notebook also provides
equivalentpathproperties for specfiying paths to  local files when used with Jupyter Notebook or Colab.Thepathproperties are useful forLoading data in a Colab notebook from the local Colab file system or a mounted Google DriveLoading data in Jupyter Notebook from the local file system that is outside the Jupyter file tree.URL and Path propertiesjuicebox.js url propertyjuicebox-notebook path propertynotesurlpathindexURLindexPathUsed in some track configurations.  Seeigv.js(Note: Thepathproperties cannot be used with JupyterLab, however local files can
be loaded by URL).For Jupyter servers (Notebook and Lab) local files can be also be loaded via the url property if the file is in
Jupyter  directory tree.  This will usually yield better performance than usingpathproperties.  URLs that begin
with a "/" are relative to the Jupyter server startup directory, that is the directory from where you started
Jupyter Notebook or JupyterLab.  URL paths without a leading slash are assumed to be relative to the notebook directory.See below for examples.  You can also use the JupyterLab "download url" for the file, obtainable through the JupyterLab UI, as the
URL for juicebox.Examples:Jupyter Notebook and Colab.  Local files using absolute file paths, potentially outside the Jupyter file tree.  Note the use
ofpathinstead ofurl.importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","path":"/TestData/juicebox/HCT-116_Untreated.hic","tracks":[{"path":"/TestData/juicebox/CTCF_Untreated.bw","type":"wig","name":"CTCF","color":"rgb(22, 129, 198)"}]})Jupyter Notebook and JupyterLab.  Local files using urls relative to the startup directory of the Jupyter server.importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","url":"/TestData/juicebox/HCT-116_Untreated.hic","tracks":[{"url":"/TestData/juicebox/CTCF_Untreated.bw","type":"wig","name":"CTCF","color":"rgb(22, 129, 198)"}]})Jupyter Notebook and Lab. Local files using urls relative to the directory of the notebook.importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","url":"TestData/juicebox/HCT-116_Untreated.hic","tracks":[{"path":"TestData/juicebox/CTCF_Untreated.bw","type":"wig","name":"CTCF","color":"rgb(22, 129, 198)"}]})All platforms. Remote files using urls.importjuicebox_notebookjuicebox_notebook.init()b=juicebox_notebook.Browser({"name":"GM12878","url":"https://www.encodeproject.org/files/ENCFF179HVU/@@download/ENCFF179HVU.hic","tracks":[{"url":"https://www.encodeproject.org/files/ENCFF000ARJ/@@download/ENCFF000ARJ.bigWig","name":"CTCF","color":"rgb(22, 129, 198)"}]})