ipycytoscape

repository·master·Indexed 43 days ago

https://github.com/cytoscape/ipycytoscape

A Jupyter widget for interactive graph visualization using the cytoscape.js library. Version 1.3.3 supports seamless data conversion from NetworkX, Pandas DataFrames, and Neo4j, allowing users to create and style graphs within Jupyter Notebooks and JupyterLab.

Tokens
16.1K
Snippets
69
Records
79
Agent score
54%

What's inside ipycytoscape

  1. Overview of ipycytoscape graph sources

    master

    ipycytoscape allows you to visualize graphs in Jupyter Notebooks using Cytoscape.js. Graphs can be created via the native ipycytoscape API or imported from several common data formats and libraries:

    • NetworkX: Using add_graph_from_networkx().
    • JSON: Importing graph data in JSON format.
    • Pandas: Creating graphs from DataFrames.
    • Native API: Building graphs directly using ipycytoscape methods.
  2. Autobuild the documentation

    master

    You can use sphinx-autobuild to continuously watch for changes in source files and automatically rebuild the documentation. This is configured via the project's Makefile.

    ```bash
    cd docs
    make watch

    Note: If you are modifying a notebook that is included in the documentation via nblink, you will still need to manually rebuild to capture changes to that specific file.

  3. Build the documentation manually

    master

    To view recent adjustments to the documentation, you must first install the documentation requirements and then build the HTML files using make.

    ```bash
    # Install documentation requirements
    cd ipycytoscape
    pip install -e.[docs]
    
    # Build the HTML documentation
    cd docs
    make html

    Once built, you can view the rendered documentation by opening build/html/index.html in your browser.

  4. Set up ipycytoscape for development

    master

    To develop ipycytoscape, you need npm and a configured environment.

    1. Create and activate a conda environment with jupyterlab and nodejs.
    2. Clone the repository.
    3. Install the package in editable mode with test and docs extras. This runs npm install and npm run build automatically.
    4. Use jupyter labextension develop to link the extension.

    For classic notebook development, use jupyter nbextension install with the --symlink flag (note: --symlink is not supported on Windows).

    # Environment setup
    conda create -n ipycytoscape -c conda-forge jupyterlab nodejs
    conda activate ipycytoscape
    
    # Clone and install
    git clone https://github.com/cytoscape/ipycytoscape.git
    cd ipycytoscape
    
    pip install jupyter_packaging==0.7.9
    pip install -e ".[test, docs]"
    
    # Link extension
    jupyter labextension develop . --overwrite
  5. Install ipycytoscape for Jupyter Notebook < 5.3

    master

    If you are using a version of Jupyter Notebook older than 5.3 (specifically the classic notebook), you must manually install and enable the front-end extension. If you installed via conda, these steps are usually unnecessary, but if required, use the --sys-prefix flag.

    # Install the extension
    jupyter nbextension install --sys-prefix --py ipycytoscape
    
    # Enable the extension
    jupyter nbextension enable --sys-prefix --py ipycytoscape
  6. How to see changes during development

    master

    To see your changes reflected in the browser:

    TypeScript changes: Run npm run watch in one terminal to monitor and rebuild code. In a separate terminal, start jupyter lab. Once the webpack rebuild completes, refresh the JupyterLab page.

    Python changes: Restart the notebook kernel to apply changes made to Python code.

    # Watch TypeScript changes
    npm run watch
    
    # In another terminal
    jupyter lab
  7. Install ipycytoscape

    master

    You can install ipycytoscape using pip or conda/mamba.

    Note for JupyterLab 1.x or 2.x users: You must follow additional installation instructions for the JupyterLab manager extension to ensure the widget renders correctly.

    # Using pip
    pip install ipycytoscape
    
    # Using conda
    conda install -c conda-forge ipycytoscape
    
    # Using mamba
    mamba install -c conda-forge ipycytoscape
  8. Configure ipycytoscape for JupyterLab 1.x or 2.x

    master

    If you are using older versions of JupyterLab (1.x or 2.x), you must install nodejs and the jupyterlab-manager extension, then build JupyterLab.

    # installing nodejs
    conda install -c conda-forge nodejs
    
    # install jupyterlab-manager extension
    jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0 --no-build
    
    # if you have previously installed the manager you still to run jupyter lab build
    jupyter lab build