soGEN
soGEN generates realistic omics readouts (RNA, surface protein, chromatin accessibility, ...) from spatial niche context — e.g. the multi-scale neighborhood composition around each cell or spot — using zero-inflated / count / continuous likelihood models. It supports both single-modal (one omics readout) and multi-modal (two jointly modeled readouts) generation.
Full documentation: https://baolab-fudan.github.io/soGEN/ · Demo notebooks: single-modal · multi-modal
Installation
pip install sogen-bio
Requires Python >= 3.9 and PyTorch (installed automatically as a dependency).
Quickstart
from sogen import soGEN
# niches: list of niche/context feature matrices (DataFrame or array), one row per spot/cell
# x: target omics matrix (DataFrame or array), one row per spot/cell, one column per feature
model = soGEN(niches, x, mode="ZINB", device="cpu")
model.fit(niches, x, epochs=300, lr=1e-4, batch_size=256)
generated = model.generate(niches_new) # DataFrame, same columns as x
model.save_model("model.pt")
For two jointly modeled omics readouts (e.g. RNA + protein):
from sogen import soGEN_multimodal
model = soGEN_multimodal(niches, x1, x2, mode="ZINBZIPoisson", device="cpu")
model.fit(niches, x1, x2, epochs=300, lr=5e-4, batch_size=256)
x1_gen, x2_gen = model.generate(niches_new)
See examples/demo_1_single_modal.ipynb (Visium spatial
transcriptomics) and examples/demo_2_multimodal.ipynb
(spatial CITE-seq, RNA + protein) for complete, runnable walkthroughs on real data, including
how to build niche features from spatial coordinates and cluster labels.
Choosing a distribution mode
| Data type | Single-modal mode |
Multi-modal mode (x1, x2) |
|---|---|---|
| Sparse counts (RNA, ATAC) | ZINB, NB |
ZINBGaussian, ZINBPoisson, ZINBZIPoisson |
| Moderately sparse counts (protein, ATAC) | ZIPoisson, Poisson |
ZIPoissonGaussian, PoissonGaussian |
| Continuous (imaging features, embeddings) | Gaussian |
combine with any of the above |
Development
git clone https://github.com/BaoLab-fudan/soGEN.git
cd soGEN
pip install -e ".[dev,examples]"
python -m pytest tests/
Citation
If you use soGEN in your research, please cite the accompanying manuscript (Bao Lab, Fudan University). Citation details will be added upon publication.
License
MIT — see LICENSE.
Metadata
Release files for sogen-bio 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sogen_bio-0.1.0.tar.gz | 11.8 kB | Without provenance | Details for sogen_bio-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sogen_bio-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sogen_bio-0.1.0-py3-none-any.whl |
Total release size: 22.7 kB
Release files / sogen_bio-0.1.0.tar.gz
| Download URL | sogen_bio-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c101ff41e4b69308b73e196a549ee31ecc5797e34c6d89749b66769ffa87cca
|
|
BLAKE2b-256 checksum How to use checksums |
df72c6ca91f6330eaf8c56de7163b89a4d49644d91a94480d119f58df6e76339
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / sogen_bio-0.1.0-py3-none-any.whl
| Download URL | sogen_bio-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b72b0d011201f244c0598bd3dcdcb6f53ea6c77057c0605d7075de1c76619d69
|
|
BLAKE2b-256 checksum How to use checksums |
27db608617f862df58392aab11ff2e5d90b5cb94d203320e0ae60e3e8d16d249
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for sogen-bio 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.