Train a graph neural network on cell graphs.
Project description
cg-gnn
cg-gnn
(short for "Cell Graph - Graph Neural Networks") is a library to train a graph neural network model on graphs built out of cell spatial data to predict patient outcomes or any other y-variable you choose. This library is designed to be used with the Spatial Profiling Toolbox (SPT), although independent functionality is also possible provided you can provide cell graphs in the same format as SPT (as implemented in the graphs
submodule).
In addition to standalone use, cg-gnn
also serves as an example implementation of an SPT-compatible graph neural network pipeline, for open source developers to reference when building their own deep learning tools that use cell graphs created by SPT. The key features that have to be implemented are
- model training and inference
- cell-level importance score calculation If the input and output schema is followed, your tool will be compatible with the SPT ecosystem, allowing users to easily integrate your tool into their SPT workflows and upload your model's results to an SPT database.
This library is a heavily modified version of histocartography and two of its applications, hact-net and patho-quant-explainer.
Installation
Using pip
In addition to installing via pip,
pip install cg-gnn
you must also install using the instructions on their websites,
From source
- Clone this repository
- Create a conda environment that can run this software using
conda env create -f environment.yml
Docker
For convenience, Dockerized versions of this package are provided at nadeemlab/spt-cg-gnn. We recommend using the CUDA-enabled version, provided it will run on your machine.
Quickstart
Use spt graphs extract
and spt graphs generate-graphs
to create cell graphs from a SPT database instance that this python package can use.
This module includes two scripts that you can call from the command line, or you can use the modules directly in Python.
cg-gnn-train
trains a graph neural network model on a set of cell graphs, saves the model to file, and updates the cell graphs it was trained on with cell-level importance-to-classification scores if an explainer model type is provided.cg-gnn-separability
calculates class separability metrics given a trained model and other metadata.
Credits
As mentioned above, this repository is a heavily modified version of the histocartography project and two of its applications: hact-net and patho-quant-explainer. Specifically,
- Cell graph formatting, saving, and loading using DGL is patterned on how they were implemented in hact-net
- The neural network training and inference module is modified from the hact-net implementation for cell graphs
- Importance score and separability calculations are sourced from patho-quant-explainer
- The dependence on histocartography is indirect, through the functionality used by the above features
Due to dependency issues that arose when using the version of histocartography published on PyPI, we've chosen to copy and make slight updates to only the modules of histocartography used by the features supported in this library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cg_gnn-0.3.2.tar.gz
.
File metadata
- Download URL: cg_gnn-0.3.2.tar.gz
- Upload date:
- Size: 49.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/4.18.0-193.el8.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7901e44caddd7fc0275124f9f3a3c8f9a02bc4e3b629e655227149261848e27f |
|
MD5 | 97c515d392ef29d9bebdb7bf66ee1cae |
|
BLAKE2b-256 | 28a4df71465e1534c320ed134a9a727cce5dee3ee8061aa560476b31c65bee59 |
File details
Details for the file cg_gnn-0.3.2-py3-none-any.whl
.
File metadata
- Download URL: cg_gnn-0.3.2-py3-none-any.whl
- Upload date:
- Size: 59.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/4.18.0-193.el8.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd9db6c36f0bf86159ba70bfc67f42d524ac9ad9f76a71450d7610c4bac9b62 |
|
MD5 | 5a0a10d33763345774468311123c5a42 |
|
BLAKE2b-256 | 1a447b92e2903f23c01d2013a3adcd5b472fb641bc208e83eef7d798ddc98989 |