- 7/16/2016: Version 0.6.0 release. Session Saving and loading API, Preset layout utility method, Numpy array support, Bug fixes.
- 9/1/2015: Version 0.5.0 release. View utilities added.
- 6/27/2014: Version 0.4.3 release. Minor update version for Python 3.4.x.
- 6/26/2014: Version 0.4.2 release. Confirmed to work with cyREST 1.1.0.
- 6/23/2014: Version 0.4.1 release. Graph utility modules have been updated.
- 6/4/2014: Version 0.4.0 release. This is still in alpha.
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 typs 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
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
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
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.
# HTTP Client for Python
import requests
# Standard JSON library
import json
# Basic Setup
PORT_NUMBER = 1234
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': {
'nodes':[],
'edges':[]
}
}
res = requests.post(BASE + '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))
from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
network = cy.network.create(name='My Network', collection='My network collection')
print(network.get_id())
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:
- NetworkX - From / To Cytoscape.js JSON
- igraph - From / To Cytoscape.js JSON
- pandas DataFrame - To Cytoscape.js JSON
And these popular libraries will be supported soon:
- Numpy adj. matrix (binary/weighted)
- graph-tool
- GraphX
- GraphLab