py2cytoscape Build Status PyPI version ReadtheDocs

What is py2cytoscape?

py2cytoscape is a collection of utilities to use Cytoscape and Cytoscape.js from Python. Network visualization feature is still limited in Python, but with this tool, you can access both of Cytoscape and Cytoscape.js as network visualization engines for your Python code!

This package is still experimental and in alpha status.


Cytoscape is a de-facto standard desktop application for network visualization in bioinformatics community. But actually, it is a domain-independent graph visualization software for all types of network data analysis. We want to introduce cy2cytoscape, along with cyREST and Jupyter Notebook, to broader data science community.


py2cytoscape supports both Python 2.7 and 3.5.

py2cytocape depends on python-igraph and optionary depends on scipy. (We do not include scipy to py2cytoscape prerequisite dependencies.)

You can install py2cytoscape with pip.


pip install py2cytoscape
#if you use the scipy dependent py2cytoscape method
pip install scipy

Ubuntu Linux

apt install g++ make libxml2-dev python-dev python3-dev zlib1g-dev
pip install py2cytoscape
#if you use the scipy dependent py2cytoscape method
pip install scipy


To install py2cytoscape dependencies, we recommend that you use Miniconda Python package manager.

Miniconda has scipy binary package, but do not have python-igraph binary package. So download the python-igraph whl for your Python (2 or 3, 32bit or 64bit) from Christoph’s site. And install it with pip. Please install python-igraph before you install py2cytoscape, otherwise pip will try to build python-igraph (and will fail).

(In the case of Python3.5 64bit)

pip install .\python_igraph-0.7.1.post6-cp35-none-win_amd64.whl
pip install py2cytoscape
conda install scipy


cyREST Wrapper (New from 0.4.0)

cyREST is a language-agnostic RESTful API for Cytoscape 3. Of course you can drive Cytoscape by calling raw RESTful API using requests or other http client library, but with this wrapper, you can significantly reduce your lines of code.

Example: Creating an empty network in Cytoscape from Python

Without py2cytoscape (raw cyREST API call)
# HTTP Client for Python
import requests

# Standard JSON library
import json

# Basic Setup
BASE = 'http://localhost:' + str(PORT_NUMBER) + '/v1/'

# Header for posting data to the server as JSON
HEADERS = {'Content-Type': 'application/json'}

# Define dictionary of empty network
empty_network = {
        'data': {
            'name': 'I\'m empty!'
        'elements': {

res = + 'networks?collection=My%20Collection', data=json.dumps(empty_network), headers=HEADERS)
new_network_id = res.json()['networkSUID']
print('Empty network created: SUID = ' + str(new_network_id))
With py2cytoscape
from import CyRestClient

cy = CyRestClient()
network ='My Network', collection='My network collection')

Embedded Visualization Widget for Jupyter Notebook

You can use Cytoscape.js network visualization widget in Jupyter Notebook. This is particulaly useful when you share your network analysis results with others.

Data Conversion Utilities from/to Cytoscape.js JSON

Cytoscape.js JSON is one of the standard data exchange formats in Cytoscape community. py2cytoscape includes some graph data conversion utilities for popular graph analysis packages in Python.

Currently, the following graph objects are supported:

And these popular libraries will be supported soon: