Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Neo4j-Cytoscape integration examples for ipycytoscape #353

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

donbr
Copy link

@donbr donbr commented Dec 23, 2024

Description:
This pull request updates the example notebook for integrating Neo4j with ipycytoscape. The updates address compatibility with the official Neo4j Python driver and ensure functionality within modern Jupyter environments. This is designed to help the Cytoscape community by improving reliability and readability, with a focus on reusable retrieval, conversion, and visualization functions.


Key Changes

  1. Transition to Official Neo4j Python Driver:

    • Replaced py2neo with the official Neo4j Python driver to ensure compatibility and maintainability.
    • Added driver lifecycle management (try/finally).
  2. Enhanced Tooltip Functionality:

    • Tooltips for nodes and edges now display properties with clear formatting (line breaks between key-value pairs).
  3. Reusable Helper Functions:

    • Added query_to_subgraph for converting Neo4j query results to ipycytoscape-compatible JSON.
    • Introduced fetch_and_visualize for consistent visualization, reducing redundancy across examples.
  4. Updated Styles and Layouts:

    • Node and edge styles dynamically adjust based on graph data.
    • Examples showcase various layouts (dagre, concentric, klay, and cola).
  5. Notebook Modernization:

    • Verified compatibility with Jupyter Notebook and VSCode Jupyter extensions.
    • Instructions for resolving common widget issues included in the comments.

Examples in the Notebook

  1. City Relationships: Visualize cities linked hierarchically to the world.
  2. Protein Interactions: Explore undirected interactions between proteins, such as SARS-CoV-2 Spike protein.
  3. Data Source Exploration: Investigate data sources used in the COVID-19 knowledge graph.
  4. Metagraph Construction: Create a metagraph of relationships between metadata nodes.

Why This is Useful

This update simplifies Neo4j-Cytoscape workflows, making it easier for users to:

  • Integrate and visualize complex graphs using ipycytoscape.
  • Debug and reuse graph visualizations in Jupyter environments.
  • Leverage modern tools (Neo4j driver) for better performance and compatibility.

How to Test

  1. Install dependencies:
    pip install -qU neo4j ipycytoscape ipywidgets
  2. Run the notebook in Jupyter Notebook, JupyterLab, or VSCode with the Jupyter extension.
  3. Verify that the tooltips, layouts, and styles match the expected behavior for each example.

Copy link

Binder 👈 Launch a binder notebook on branch donbr/ipycytoscape/master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants