Skip to main content

Spatial Transcriptomics Simulator

Project description

FEAST | Parameter-cloud modeling of spatial transcriptomics for simulation and de novo virtual slices

License: MIT Python 3.11

FEAST (Feature-space-based modeling of Spatial Transcriptomics) is a computational framework for simulating spatial transcriptomics (ST) data. By modeling gene expression through a parameter cloud capturing mean, variance, and sparsity, FEAST generates high-fidelity synthetic ST slices with controllable biological and technical variations.

Key Features

  • High-Fidelity Simulation: Generate realistic ST data that preserves gene-level statistics, spatial patterns, and biological heterogeneity
  • Controllable Alterations: Systematically modify gene expression (mean, variance, sparsity) for robust benchmarking
  • Multiple ST Technologies: Support for Visium, MERFISH, Stereo-seq, Slide-seq, Xenium, and OpenST
  • Alignment Benchmarks: Create paired datasets with controlled geometric transformations (rotation, warping) for testing alignment algorithms
  • Deconvolution Ground Truth: Generate multi-resolution data with known cell-type compositions
  • De Novo Virtual Slices: Generate slices from blueprints, spatial motifs, parameter clouds, and conditional references

Installation

Conda Environment (Recommended)

git clone https://github.com/maiziezhoulab/FEAST
cd FEAST
conda env create -f environment.yml
conda activate feast-py311-conda
pip install --no-deps -r requirements.txt
pip install --no-deps -e .

Existing Source Checkout

cd FEAST
conda env create -f environment.yml
conda activate feast-py311-conda
pip install --no-deps -r requirements.txt
pip install --no-deps -e .

Dependencies

  • Python 3.11
  • scanpy
  • anndata
  • numpy
  • scipy
  • pandas
  • scikit-learn
  • pyvinecopulib
  • POT (Python Optimal Transport)
  • tps (Thin Plate Spline)

Quick Start

Single Slice Simulation

from FEAST import simulator
import scanpy as sc

# Load your reference data
adata = sc.read_h5ad("your_spatial_data.h5ad")

# Simple simulation with default parameters
simulated_adata = simulator.simulate_single_slice(
    adata=adata,
    verbose=True
)

# Simulation with expression alteration
from FEAST.modeling.marginal_alteration import AlterationConfig

alteration_config = AlterationConfig.mean_only(fold_change=2.0)
altered_adata = simulator.simulate_single_slice(
    adata=adata,
    alteration_config=alteration_config
)

Alignment Simulation

from FEAST import alignment

# Generate paired datasets with rotation for alignment benchmarking
original, rotated = alignment.simulate_alignment_rotation(
    adata=adata,
    rotation_angle=30.0,  # degrees
    data_type='imaging'  # or 'sequencing'
)

Deconvolution Simulation

from FEAST import deconvolution

# Generate multi-resolution data with known cell-type compositions
deconv_adata = deconvolution.create_deconvolution_benchmark_data(
    adata=single_cell_adata,
    downsampling_factor=0.25,
    grid_type='hexagonal',
    cell_type_key='cell_type'
)

De Novo Virtual Slice Generation

from FEAST import de_novo

genes = ["GeneA", "GeneB", "GeneC"]
blueprint = (
    de_novo.SimulationBlueprintBuilder.rectangular_grid(4, 4)
    .set_domains(["cortex"] * 8 + ["medulla"] * 8)
    .build()
)
parameter_cloud = (
    de_novo.SimulationParameterBuilder.from_gene_names(genes)
    .set_all(mean=3.0, variance=5.0, zero_prop=0.2)
    .build()
)
patterns = (
    de_novo.SimulationPatternBuilder.from_gene_names(genes)
    .gradient("GeneA", axis="x")
    .hotspot("GeneB", center=[0.5, 0.5], radius=0.25)
    .build()
)

virtual_slice = de_novo.simulate_from_design(
    blueprint,
    parameter_cloud,
    pattern_spec=patterns,
    random_seed=7,
)

# Final rank-normalized quantiles are available when storage is enabled.
quantiles = virtual_slice.layers["feast_quantiles"]

De novo generation builds a latent rank-score field from shared spatial motifs, rank-normalizes that field into feast_quantiles, and decodes counts with the target parameter cloud. Reference-conditioned virtual slices use the same latent H-to-Q path after transporting reference rank evidence.

Tutorials

Try FEAST with notebook! Comprehensive Jupyter notebooks are provided in the repository:

Architecture

FEAST/
├── FEAST_core/          # Core simulation engine
│   ├── simulator.py     # Main deterministic simulation logic
│   ├── count_decoding.py # Shared rank and quantile count decoding
│   ├── parameter_cloud.py  # Parameter cloud modeling
│   └── APIs.py          # Unified FEAST API
├── alignment/           # Alignment simulation
│   ├── alignment_simulator.py
│   └── spatial_align_alter.py  # Rotation & warping transformations
├── deconvolution/       # Deconvolution simulation
│   ├── deconvolution_simulator.py
│   └── generate_deconvolution.py
├── de_novo/             # Blueprint and conditional virtual-slice generation
│   ├── builder.py
│   ├── conditional.py
│   ├── quantile_field.py
│   └── pattern.py
└── modeling/            # Statistical models
    ├── StudentT_mixture_model.py
    ├── Beta_mixture_model.py
    └── marginal_alteration.py

Reproduction Scripts

The reproduction/ folder contains scripts to reproduce all benchmarking results from the paper. Each subdirectory corresponds to a specific analysis:

reproduction/
├── 1_Simulator_benchmark/     # Figure 2: Simulation fidelity evaluation
├── 2_Clustering_simulation/   # Figure 3: Clustering robustness testing
├── 3_Alignment_simulation/    # Figure 4: Alignment algorithm benchmarking
└── 4_Deconvolution_simulation/# Supp Fig: Deconvolution ground truth generation

Interpolation APIs and external reconstruction wrappers are intentionally excluded from this version.

Dataset Organization

All scripts expect datasets in a data/ directory with the following naming convention:

data/
├── DLPFC_{sample_id}.h5ad          # Human DLPFC sections
├── MERFISH_{slice_id}.h5ad         # Mouse brain MERFISH slices
├── OpenST_{slice_id}.h5ad          # Lymph node OpenST slices
├── Stereoseq_{sample_id}.h5ad      # Mouse embryo Stereo-seq slices
├── Slideseq_{sample_id}.h5ad       # Slide-seqV2 slices
└── Xenium_{sample_id}.h5ad         # Xenium tissue slices

Required Datasets

Dataset Technology Source Usage Files
DLPFC 10X Visium spatialLIBD Simulation, Clustering, Alignment DLPFC_151670.h5ad
DLPFC_151676.h5ad
DLPFC_151675.h5ad
MERFISH MERFISH Allen Brain Atlas Simulation, Deconvolution MERFISH_006.h5ad
MERFISH_007.h5ad
OpenST OpenST GEO: GSE251926 Simulation OpenST_005.h5ad
OpenST_006.h5ad
Stereo-seq Stereo-seq MOSTA Simulation Stereoseq_E14_5_E2S2.h5ad
Slide-seq Slide-seqV2 SODB Simulation Slideseq_001.h5ad
Xenium Xenium 10X Genomics Simulation Xenium_LymphNode.h5ad

Note: FEAST is actively maintained. If you have any question, please let me know!

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

feast_py-1.0.2.tar.gz (95.6 kB view details)

Uploaded Source

Built Distribution

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

feast_py-1.0.2-py3-none-any.whl (105.3 kB view details)

Uploaded Python 3

File details

Details for the file feast_py-1.0.2.tar.gz.

File metadata

  • Download URL: feast_py-1.0.2.tar.gz
  • Upload date:
  • Size: 95.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for feast_py-1.0.2.tar.gz
Algorithm Hash digest
SHA256 eaeec8ec6cbe580c58b193850a210ef0d91239a19f0bd935f6916aa8e64a066f
MD5 590688f3fcbcb481927072b95debed31
BLAKE2b-256 dcc81ce351e3ba9780d383269317ab4f1bfaf7c96d550b16e8824b866a380fdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for feast_py-1.0.2.tar.gz:

Publisher: publish.yml on maiziezhoulab/FEAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file feast_py-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: feast_py-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 105.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for feast_py-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 74f0e3d2c6b5da01e3be0bcb04e42e61ce42c89ac02871004736a8d75d8b1693
MD5 bd49f1ed7f095543a2a309ae801dcf4e
BLAKE2b-256 1c8358bdcbc11d598971e7d70be1412730d15d1439d1675655cf2752ed177108

See more details on using hashes here.

Provenance

The following attestation bundles were made for feast_py-1.0.2-py3-none-any.whl:

Publisher: publish.yml on maiziezhoulab/FEAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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