STAMP for genetic perturbation prediction
Project description
STAMP: Toward subtask decomposition-based learning and benchmarking for genetic perturbation outcome prediction and beyond
Introduction
This repository hosts the official implementation of STAMP, a method that can predict perturbation outcomes using single-cell RNA-sequencing data from perturbational experimental screens using subtask decomposition learning. STAMP can be applied to three challenges in this area, i.e. (1) predict single genetic perturbation outcomes, (2) predict multiple genetic perturbation outcomes and (3) predict genetic perturbation outcomes across cell lines.
Installation
Our experiments were conducted on python=3.9.7 and our CUDA version is 11.4.
conda create -n stamp python==3.9.7
conda install pytorch==1.10.2 torchvision==0.11.3 torchaudio==0.10.2 -c pytorch
Then
pip install .
Example data
We have made available the code necessary to generate example data, serving as a practical illustration for training and testing the STAMP model. Additionally, for guidance on configuring the training process of STAMP, we offer an example config file located at ./Data/example_config.yaml.
python ./Data/GeneratingExampleData.py
The example *.h5ad data file has three distinct layers, namely 'level1', 'level2', and 'level3'. The 'level1' layer is a binary matrix, where '0' represents non-differentially expressed genes (non-DEGs) and '1' indicates differentially expressed genes (DEGs). Similarly, 'level2' is another binary matrix, denoting down-regulated genes with '0' and up-regulated genes with '1'. Lastly, the 'level3' layer is a matrix that quantifies the magnitude of gene expression changes.
Real demo data
We have uploaded a real demo data from RPE1_essential dataset to our Google drive, which can be obtained from here. Please download all these files into the ./Data directory and refer tutorial_for_training.py.ipynb in ./Tutorial directory.
Note: Users are encouraged to change the path of each data in 'Config.yaml' based on their own machines.
Core API interface for model training
Using this API, you can train and test STAMP on your own perturbation datasets using a few lines of code.
from stamp import STAMP, load_config
import scanpy as sc
# load config file
config = load_config("./Data/example_config.yaml")
# set up and train a STAMP
model = STAMP(config)
model.train()
# load trained model
model.load_pretrained(f"{config['Train']['output_dir']}/trained_models")
# use trained model to predict unseen perturbations
model.prediction(config['dataset']['Testing_dataset'], combo_test = True)
# use trained model to predict unseen perturbations; considering Top 40 DEGs
# Top 40 DEGs consisting of Top 20 up-regulation genes and Top 20 down-regulation genes
# load Top 40 test data
top_40_data = sc.read_h5ad("./Data/example_test_top40.h5ad")
# prediction
model.prediction(top_40_data, combo_test = True)
Core API interface for model fine-tuning
Using this API, you can fine-tune and test STAMP on your own perturbation datasets using a few lines of code.
from stamp import STAMP, load_config
import scanpy as sc
# load config file (we use the example config used for model training to illustrate this)
config = load_config("./Data/example_config.yaml")
# set up STAMP
model = STAMP(config)
# load pre-trained model
model.load_pretrained(f"{config['Train']['output_dir']}/trained_models")
# fine-tuning model
model.finetuning()
# use fine-tuned model to predict unseen perturbations
model.prediction(config['dataset']['Testing_dataset'], combo_test = False)
# use fine-tuned model to predict unseen perturbations; considering Top 40 DEGs
# Top 40 DEGs consisting of Top 20 up-regulation genes and Top 20 down-regulation genes
# load Top 40 test data
top_40_data = sc.read_h5ad("./Data/example_test_top40.h5ad")
# prediction
model.prediction(top_40_data, combo_test = False)
Citation
Yicheng Gao, Zhiting Wei, Qi Liu et al. Toward subtask decomposition-based learning and benchmarking for genetic perturbation outcome prediction and beyond, bioRxiv, 2024.
Contacts
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cell_stamp-0.1.0.tar.gz.
File metadata
- Download URL: cell_stamp-0.1.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a10b863039211365c6aa8972b31f7d921e76b7a1bbcd4aa6a90559cd9b7d350
|
|
| MD5 |
ef13ce2b89b711b96cd769f50fee4691
|
|
| BLAKE2b-256 |
bc3560e6aca9b11918077f3f2095e40077643a6f4cd72c137dd9bf8d756b6add
|
File details
Details for the file cell_stamp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cell_stamp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49ed6168b32d2447b19e7c420e6fa9d8b5746e7a03d890b39ea93a7b8eaa8827
|
|
| MD5 |
c0b9c40b1e49f79aea3175aa9c89b3fb
|
|
| BLAKE2b-256 |
ac62c3f68ecf81ff15517ca09ae4b56a65fc994ef21087ffe361962e9d8e18d9
|