Tutorial For Cytoscape Web - cytoscape/cytoscape-web GitHub Wiki

Table of Contents

  1. Set up the Development environment
  2. Get familier with the Cytoscape-Web
  3. Example of Extending the features
  4. How to debug
  5. How to add a test

Set up the Development environment

Install node and npm

For Linux

  1. Update your package repository:
  • Run sudo apt update
  1. Install Node.js and npm:
  • Run sudo apt install nodejs AND
  • Run sudo apt install npm
  1. Verify the installation:
  • Run node --version (Must be >= 16.8.0) AND
  • Run npm --version

For Mac

  1. Install Homebrew:
  • Run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Node.js and npm:
  • Run brew install node
  1. Verify the installation:
  • Same as in the Linux case.

For Windows

  1. Download the Windows Installer:
  • Visit the Node.js website and download the Windows Installer.
  • Run the installer and follow the prompts to install Node.js and npm.
  1. Verify the installation:
  • Same as in the Linux case(Run the commands in a command prompt or PowerShell).

Run Cytoscape-Web on your local machine

To get Cytoscape-web up and running locally, please follow these steps:

1. Prepare Your Workspace:

  • Choose a directory where you want to store the Cytoscape-web codebase. Navigate to this directory in your terminal or command prompt.

2. Clone the Repository:

  • Run the following command in the terminal: git clone https://github.com/cytoscape/cytoscape-web.
  • The above command creates a new folder named cytoscape-web containing the project files. Now you need to change into the newly cloned repository's directory by running cd cytoscape-web.

3. Install dependencies

  • Install the project's dependencies using npm: npm install.

4. Start the Development Server

  • Once the dependencies are installed, you can start the development server with the command npm run dev.

5. Access the application

  • Open your web browser and navigate to localhost:5500. This address connects to the development server running on your machine.

Get familier with Cytoscape-Web

Basic Architecture and Concept

Cytoscape-Web is a single-page web application, with Backend using REST API and Frontend using React. The main work data flow is shown in the following diagram:

Nav bar and Menu

Workspace

Workspace is the basic unit of user’s data, it represents the working status on a user's Cytoscape-Web. It includes:

  • name: readable name of the Workspace
  • id: unique ID of the Workspace
  • metadata: creationTime, localModificationTime
  • networkIds: list of network IDs
  • current network: the network that is currently loaded in website

CyWebNetwork

The CyWebNetwork is a key object in Cytoscape-Web. It contains every information in a network, which includes:

Network Summary - includes metadata and network attributes
  • UUID of network
  • Network Name
  • Network attributes
  • URL of a thumbnail image
  • A Key to the data model persisted in the client side storage
Visual Style - a reference to the vizmapper object
  • Defaults
  • Mappings
  • Bypasses
Network Topology
  • Edges
  • Nodes
View Model: the key-value pair storing what should be displayed in the actual visualizations
  • Node attribute table
  • Edge attribute table
Tables: a 2-D array where each column represents an attribute and each row represents a node/edge
  • Node attribute table
  • Edge attribute table

Visual Style

Introduction to the code base

β”œβ”€ πŸ“data
    β”œβ”€ πŸ“„empty-db.json                      # Empty database example
β”œβ”€ πŸ“docs
    β”œβ”€ πŸ“„testing.md
β”œβ”€ πŸ“netlify
    β”œβ”€ πŸ“„redirects
β”œβ”€ πŸ“node_modules                           # Dependencies and libraries
    β”œβ”€ πŸ“„...
β”œβ”€ πŸ“src                                    # Main Code Base
    β”œβ”€ πŸ“ assets                                # Static icons, images, and color palettes are stored here
        β”œβ”€ πŸ“„ BrBG.png                              - A color palette
        β”œβ”€ πŸ“„ cytoscape.svg                         - The cytoscpae icon 
        β”œβ”€ πŸ“„ config.json                           - Basic configurations of the website
        β”œβ”€ πŸ“„...
    β”œβ”€ πŸ“components                             # Website components are stored here
        β”œβ”€ πŸ“ Login                                 # User login panel
        β”œβ”€ πŸ“ NetworkPanel                          # Network panel (upper-right side)
            β”œβ”€ πŸ“ CyjsRenderer                          - Network Renderer
        β”œβ”€ πŸ“ TableBrowser                          # The bottom table that contains information on nodes, edges, and networks
        β”œβ”€ πŸ“ ToolBar                               # The top navigation bar
            β”œβ”€ πŸ“ AnalysisMenu                          - Dropdown menu of 'Analysis'
            β”œβ”€ πŸ“ DataMenu                              - Dropdown menu of 'Data'
        β”œβ”€ πŸ“ Workspace                             # The upper-left-side workspace panel
        β”œβ”€ πŸ“„...    
    β”œβ”€ πŸ“features                               # Website components are stored here
        β”œβ”€ πŸ“ HierarchyViewer
        β”œβ”€ πŸ“ LLMQuery
    β”œβ”€ πŸ“models                                 # Models of data or UI components are stored here
        β”œβ”€ πŸ“ Workspace 
        β”œβ”€ πŸ“„...
    β”œβ”€ πŸ“store                                  # Managing the state related to different objects
        β”œβ”€ πŸ“ hooks
        β”œβ”€ πŸ“ io
        β”œβ”€ πŸ“ persist
        β”œβ”€ πŸ“„ NetworkStore.ts
    β”œβ”€ πŸ“utils
        β”œβ”€ πŸ“„...
    β”œβ”€ πŸ“„...
β”œβ”€ πŸ“test
    β”œβ”€ πŸ“„...
β”œβ”€ πŸ“unittest
    β”œβ”€ πŸ“„...
β”œβ”€ πŸ“„.gitignore
β”œβ”€ πŸ“„README.md

Basic design

The main workflow is: the components interact with stores, and stores interacts with database.

Components <--> Stores <--> Database

Currently, there are basically WorkspaceStore

Store Name Role Operation
WorkspaceStore - Set new workspace - Add/remove network(s) to the workspace
NetworkSummaryStore Add/delete network summaries-Update contents of a summary
NetworkStore Add/delete network to the store - Edit network structure - add/delete nodes-add/delete edges
TableStore Add/delete tables -Update a value in a table -Utilities - get all column values
ViewModelStore Add/delete view models - Keep track of selection states
VisualStyleStore

Database:

To avoid data loss caused by accidents, IndexedDB is employed in this project to persist data locally. However, it also brings some limitations:

  • There is always one Workspace database per domain (per browser)
  • This means even if a user opens multiple tabs, the same workspace will be used.

The following tables are stored in the cached

Table Name Key Value
workspace Workspace ID Workspace object
cyNetworkWorks Network ID Network Oject
cyTables Network ID Table Object
cyNetworkViews Network ID View Model Object
cyVisualStyles Network ID Visual Style object
summaries Network ID summary object

Examples of extending the features

Add a new menu item

Code

Create a simple network

Code

Subtract a subnetwork from selection

Code

How to Debug

How to add a test

⚠️ **GitHub.com Fallback** ⚠️