Metadata-Version: 2.4
Name: nest-st
Version: 0.1.0
Summary: NEST: Native Expression reconstruction for Spatial Transcriptomics
Author-email: Tianyi Liu <1694414073@qq.com>
License: MIT
Project-URL: Homepage, https://github.com/lty10086/NEST
Project-URL: Repository, https://github.com/lty10086/NEST
Project-URL: Issues, https://github.com/lty10086/NEST/issues
Keywords: spatial transcriptomics,single-cell,imputation,dropout,graph autoencoder
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Requires-Dist: scipy>=1.9
Requires-Dist: anndata>=0.9
Requires-Dist: scanpy>=1.9
Requires-Dist: scikit-learn>=1.2
Requires-Dist: matplotlib>=3.6
Requires-Dist: torch>=2.0
Requires-Dist: torch-geometric>=2.3

# 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

```bash
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

```python
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

```python
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

```bash
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 `.h5ad` files.
- `adata_st.obsm["spatial"]` must contain spatial coordinates.
- For `missing_gene` mode, `adata_sc` must contain genes to be transferred into the ST domain.
- For `dropout` mode, no scRNA-seq reference is required.

## Upload to PyPI

```bash
python -m pip install --upgrade build twine
python -m build
python -m twine upload dist/*
```

For TestPyPI:

```bash
python -m twine upload --repository testpypi dist/*
```

Update the package name, author information and GitHub URLs in `pyproject.toml` before publishing.
