Skip to main content

Generative modeling of omics readouts from spatial niche context, for single- and multi-modal spatial omics data.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sogen_bio-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sogen_bio-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file sogen_bio-0.1.0.tar.gz.

File metadata

  • Download URL: sogen_bio-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for sogen_bio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c101ff41e4b69308b73e196a549ee31ecc5797e34c6d89749b66769ffa87cca
MD5 a19db5af1b5b32ac2181c67fe47fd919
BLAKE2b-256 df72c6ca91f6330eaf8c56de7163b89a4d49644d91a94480d119f58df6e76339

See more details on using hashes here.

File details

Details for the file sogen_bio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sogen_bio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for sogen_bio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b72b0d011201f244c0598bd3dcdcb6f53ea6c77057c0605d7075de1c76619d69
MD5 9edd4ecc7e8937cb9f48b36788dfec59
BLAKE2b-256 27db608617f862df58392aab11ff2e5d90b5cb94d203320e0ae60e3e8d16d249

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page