Skip to content

Tong-Chen/py2cytoscape

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py2cytoscape

Tools to use Cytoscape and Cytoscape.js from Python

Status

  • 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.

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.

Background

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.

Features

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
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))
With py2cytoscape
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:

And these popular libraries will be supported soon:

About

Python utilities for Cytoscape and Cytoscape.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 97.5%
  • HTML 1.9%
  • JavaScript 0.6%