/cytoscape-jupyter-widget

Cytoscape.js based network visualizer for Jupyter Notebook

Primary LanguageJavaScript

CyJupyter (cytoscape-jupyter-widget)

Overview

CyJupyter is a simple interactive network visualizer for Jupyter Notebook. For additional features and capabilities, we recommend you try the new ipycytoscape package instead.

Limitations

CyJupiter is not supported in JupyterLab. There is another visualizer specifically created for JupyterLab:

This package is still under development, but we will add more features to it and release the final version once the JupyterLab extention API is finalized.

Introduction

With the CyJupyter widget, you can easily visualize network data in JSON / Python Dict using the built-in Cytoscape.js visualizer.

About Cytoscape

Cytoscape is a de-facto standard software for biological network analysis and visualization. It has a rich ecosystem for network analysis and visualization, and this Jupyter Widget is part of it. It was developed for biologists, but it core functions are domain-independent and you can use it for all types of network data.

In addition, you can use it from Jupyter Notebook via CyRest API. Since you are interested in Jupyter Notebook environment, combination of Jupyter, CyJupyter, and Cytoscape Desctop with CyREST will be a very powerful workbench for your network analysis workflows.

If you want to interactively edit (large) networks, create PDF/SVG, try the Cytoscape Desktop. It can read/write CX / Cytoscape.js JSON files and many standard network file formats. Please visit here for more information.

Status

  • 10/10/2018 - First public version released (0.2.0)

Quick Start

> pip install cyjupyter
> jupyter nbextension enable --py --sys-prefix cyjupyter
> jupyter notebook

Features

CyJupyter is a simple data visualization widget, but yet very powerful tool once you understand its engine, Cytoscape.js.

  • Interactive network visualization using Cytoscape.js
  • Full support for Cytoscape.js compatible Styles
    • Mapping data points to color, size, shape, etc.

(Fig. 1: Betweenness cetrarity is mapped to node size, edge width, and node opacity)

  • Support for complex network structures, including compound nodes

(Fig. 2: Network with hierachical struture, visualized as Compound Nodes)

  • Support for built-in automatic layouts (circle, grid, cose, etc.)
  • Support for Cytoscape.js and CX JSON formats
    • You can easily converted network data from/to these formats using popular network analysis libraries, such as NetworkX
  • Adjustable cell size
  • Custom background

(Fig. 3: Network visualization with custom background using CSS gradient)

  • Can be used with popular network analysis tools, such as NetworkX

(Fig. 4: Network generated with NetworkX, visualized with CyJupyer)

Installation

From PyPI

To install this widget, use pip:

# Install the widget from PyPI repository
> pip install cyjupyter

# Enable it
> jupyter nbextension enable --py --sys-prefix cyjupyter

Install from source

For a development installation (requires npm),

$ git clone https://github.com/idekerlab/cytoscape-jupyter-widget.git
$ cd cytoscape-jupyter-widget
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix cyjupyter
$ jupyter nbextension enable --py --sys-prefix cyjupyter

How to use the widget

Once you install this widget, you can use it by importing it to your notebook:

from cyjupyter import Cytoscape

Cytoscape is the only Class in this Widget. Basic usage is:

Cytoscape(data=network_data, format=cx)

where data is the actual network data in Python Dictionary or List (for CX) and format is the network data format name.

Supported Data Format

Currently, this Widget supports two network formats:

If you have data in JSON file, you can use Python's standard json library to convert it into Python Dict/List.

Cytoscape.js JSON

The data should be in the following format:

{
  "elements": {
    "nodes":[],
    "edges": []
  }
}

for more information about this data model, please visit Cytoscape.js web site.

CX JSON Array

This is always a JSON Array and is a fairly complex data format, but you can use this Python library to simplify your work:

Also, for network biologists, NDEx is a great resource. All data sets are availabe in CX format.

Internally, it uses Cytoscape.js as the rendering engine, and if you provide your data in Cytoscape.js format, it is the most efficient way yo visualize your data. If you provide your data as CX, the Widget automatically convert the data into Cytoscape.js compatible data structure and then visualizes it.

Examples

The best way to learn this widget is actually visualize some network data. Please try this notebook to learn how to use this widget.

API Reference

(TBD)

  • data
  • format
  • style
  • background
  • layout_name
  • layout

License

MIT

Questions / Bugs / Feature Requests?

Please use GitHub Issue Tracker.


© 2018 Keiichiro ONO

University of California, San Diego: Trey Ideker Lab / The Cytoscape Consortium / National Resource for Network Biology