Interactive Cytoscape Widget for Jupyter

1.3.3 · active · verified Fri Apr 17

ipycytoscape is a Python library that provides a Cytoscape widget for Jupyter notebooks and JupyterLab environments. It allows users to visualize and interact with complex networks directly within their Jupyter workflows, leveraging the powerful rendering capabilities of Cytoscape.js. The current version is 1.3.3, with minor releases occurring every few months for bug fixes and compatibility updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a Cytoscape widget, populate it with data from a NetworkX graph, apply a layout, and display it in a Jupyter environment. The `set_layout()` call is essential for proper rendering.

import ipycytoscape
import networkx as nx

# Create a Cytoscape widget instance
cy = ipycytoscape.CytoscapeWidget()

# Create a simple graph using NetworkX
G = nx.Graph()
G.add_edge('A', 'B')
G.add_edge('B', 'C')
G.add_node('D')

# Add the graph data to the widget
cy.graph.add_graph_from_networkx(G, directed=False)

# Set a layout; this is crucial for the graph to display properly
cy.set_layout(name='cose') # Other options: 'cola', 'grid', 'circle', etc.

# Display the widget
cy

view raw JSON →