NEST: Native Expression reconstruction for Spatial Transcriptomics
Project description
NEST
NEST, Native Expression reconstruction for Spatial Transcriptomics, reconstructs biologically faithful spatial transcriptomes under native spatial constraints.
It supports two tasks with one parameter:
mode="missing_gene": imputes unmeasured genes in imaging-based spatial transcriptomics using a matched scRNA-seq reference.mode="dropout": recovers dropout-corrupted false zeros in sequencing-based spatial transcriptomics using ST data only.
Installation for development
git clone https://github.com/yourname/nest-st.git
cd nest-st
pip install -e .
For CUDA environments, install PyTorch and PyTorch Geometric using the wheel index recommended for your CUDA version before installing the package.
Python usage
Missing-gene imputation
import scanpy as sc
from nest_st import NEST, NESTConfig
adata_st = sc.read_h5ad("data/st.h5ad")
adata_sc = sc.read_h5ad("data/sc.h5ad")
sc.pp.log1p(adata_st)
sc.pp.log1p(adata_sc)
config = NESTConfig(mode="missing_gene", ae_epochs=1000, gae_epochs=2000, device="cuda")
adata_imputed = NEST(config).fit_transform(adata_st=adata_st, adata_sc=adata_sc)
adata_imputed.write_h5ad("nest_missing_gene_result.h5ad")
Dropout recovery
import scanpy as sc
from nest_st import NEST, NESTConfig
adata_st = sc.read_h5ad("data/st.h5ad")
sc.pp.log1p(adata_st)
config = NESTConfig(mode="dropout", fill_zeros_only=True, ae_epochs=1000, gae_epochs=2000, device="cuda")
adata_recovered = NEST(config).fit_transform(adata_st=adata_st)
adata_recovered.write_h5ad("nest_dropout_result.h5ad")
Command-line usage
python main.py --mode missing_gene --st data/st.h5ad --sc data/sc.h5ad --output result_gene.h5ad --log1p
python main.py --mode dropout --st data/st.h5ad --output result_dropout.h5ad --log1p --fill-zeros-only
Input requirements
- Input files should be AnnData
.h5adfiles. adata_st.obsm["spatial"]must contain spatial coordinates.- For
missing_genemode,adata_scmust contain genes to be transferred into the ST domain. - For
dropoutmode, no scRNA-seq reference is required.
Upload to PyPI
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
For TestPyPI:
python -m twine upload --repository testpypi dist/*
Update the package name, author information and GitHub URLs in pyproject.toml before publishing.
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 nest_st-0.1.0.tar.gz.
File metadata
- Download URL: nest_st-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33719faa12484d5200101281ad20dc64f591727a08cc07215331944f833da709
|
|
| MD5 |
1a90269ad1db9f2e30ca529e49588266
|
|
| BLAKE2b-256 |
9793fc16ada0d38e712ae52502f1f9c2e1220e5a783f03d41d36191b4c05d4c4
|
File details
Details for the file nest_st-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nest_st-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00fb2e5a7ef61f82dbc68abd9562f7565e8d32236bd385c4162f9b9111c3c436
|
|
| MD5 |
57037e41d385e8228a7e53852c4d4884
|
|
| BLAKE2b-256 |
a24c9beda4dc75fe78c25f74c727d45231ea3e1f49e1657f9b0bea6b36efcd95
|