JBrowse Jupyter: a Python interface to JBrowse 2

Abstract Motivation JBrowse Jupyter is a package that aims to close the gap between Python programming and genomic visualization. Web-based genome browsers are routinely used for publishing and inspecting genome annotations. Historically they have been deployed at the end of bioinformatics pipelines, typically decoupled from the analysis itself. However, emerging technologies such as Jupyter notebooks enable a more rapid iterative cycle of development, analysis and visualization. Results We have developed a package that provides a Python interface to JBrowse 2’s suite of embeddable components, including the primary Linear Genome View. The package enables users to quickly set up, launch and customize JBrowse views from Jupyter notebooks. In addition, users can share their data via Google’s Colab notebooks, providing reproducible interactive views. Availability and implementation JBrowse Jupyter is released under the Apache License and is available for download on PyPI. Source code and demos are available on GitHub at https://github.com/GMOD/jbrowse-jupyter.


Introduction
Genome browsers are popular tools for displaying genome annotations (Kent et al., 2002). Web-based browsers, particularly JavaScript tools such as IGV.js (Robinson et al., 2023) and JBrowse 2 (Diesh et al., 2022), allow for a more responsive user experience by performing computation on the client, reducing server and network load. These genome browsers are versatile and widely adopted (Wang et al., 2013).
Although JBrowse is straightforward to deploy, the need to administer a web server could present a barrier to entry for some users, particularly those more comfortable working within Python or R. Motivated by this, we recently released JBrowseR, a version of JBrowse designed to run in an R environment or a Shiny app (Hershberg et al., 2021). This was enabled by the React-based architecture of JBrowse 2, which allows JBrowse components to be re-used programmatically.
Python, similarly to R, is one of the most widely used programming languages in computational biology. The Jupyter notebook, a web-based interactive environment for Python (and other languages), is one of the leading open-source platforms for data analysis (Cock et al., 2009;Shen, 2014). Several tools exist for interacting with genome browsers in Python. D3GB and IGV.js's integration with Dash provide interactive linear displays of the genome whereas pygbrowse (https://github.com/phageghost/python-genome-browser) provides static snapshots (Barrios and Prieto, 2017;Robinson et al., 2023). Mango, Gosling's Python library Gos and wrappers to IGV.js including ipyigv (https://github.com/QuantStack/ipyigv) and igv-notebook (https://github.com/igvteam/igv-notebook) also exist and provide integration to Jupyter notebooks (L' Yi et al., 2022;Manz et al., 2022;Morrow et al., 2018). However, some of these tools either have limited extensibility and or customization capabilities including limited color theming, text indexing for text searching and support of additional views such as the Circular Genome View.
To broaden the options for users of genome browsers in Python environments, we created JBrowse Jupyter, a Python package for configuring, creating and launching JBrowse views from Jupyter notebooks and other Python applications. JBrowse Jupyter uses the Dash framework, a bridge from React components to Python code (Hossain, 2019). The JBrowse Jupyter package currently allows users to embed two of the most popular JBrowse 2 views: the Linear Genome View and the Circular Genome View. The package aims to make it easier for users to configure genome browsers in Jupyter notebooks and to enable interactive exploration and visualization of genomic data from within Python. Users can take advantage of the existing tools available for Jupyter notebooks. Visual Studio Code provides a Jupyter extension that allows users to create and run cells with the embedded genome browser in their development environments. With Binder and Colab, the community is able to share reproducible notebooks with configured JBrowse views (Bisong, 2019;Project Jupyter et al., 2018).

Materials and methods
The package is distributed by the Python Package Index and is compatible with Python 3.6 and higher. The project follows continuous integration and continuous delivery practices that enable automated deployments. Flake8 and Pytest support automatic testing and linting to ensure code quality, and Sphinx automatically generates documentation.

Discussion
JBrowse Jupyter is a flexible tool that reduces the effort required to embed an interactive genome browser in a Jupyter notebook: a user can launch a JBrowse View with fewer than 10 lines of code (Fig. 1).
We provide several Python Dash applications and Jupyter notebooks along with source code to show the versatility of JBrowse Jupyter. The browser.ipynb notebook demonstrates how to add a track from a Pandas DataFrame, add tracks in bulk from distinct data files and specify initial location in the configuration of the Linear Genome View. The local_support.ipynb notebook demonstrates how to utilize local data to configure JBrowse views by leveraging the development http server provided by JBrowse Jupyter.
To illustrate application to real data, we provide the skbr3.ipynb Jupyter notebook that visualizes genome sequencing and annotation data from the SK-BR-3 cell line (Nattestad et al., 2017). This demo shows how to create an application that allows users to navigate around genomic locations involved in gene fusions.

Funding
This work was supported by the National Institutes of Health (NIH) [HG004483 and GM080203].
Conflict of Interest: none declared.

Data availability
The package is available for download on PyPI. Source code and demos can be found at https://github.com/GMOD/jbrowse-jupyter.