Spider
Spider is a flexible and unified framework for simulating spatial transcriptomics (ST) data. It represents cellular spatial organization with two interpretable inputs: cell-type proportions and a transition probability matrix between adjacent cells. Spider then assigns cell types on a spatial neighbor graph with a batched simulated annealing strategy and can aggregate single-cell profiles into spot-level ST data.
Publication
Yang J, Wei N, Qu Y, et al. Spider: a flexible and unified framework for simulating spatial transcriptomics data. Bioinformatics. 2026;42(1):btaf562. https://doi.org/10.1093/bioinformatics/btaf562
Key Features
- Reference-free simulation driven by cell-type proportions and transition matrices.
- Predefined spatial patterns including attractive, repulsive, layered, and gyrus-like structures.
- Batched simulated annealing for scalable cell-type assignment.
- Cell-level simulation with optional spot-level aggregation.
- Optional compatibility helpers for benchmark-style simulators such as RCTD, STRIDE, stereoscope, and FICT-style workflows.
- Optional image and interactive workflows for histology-derived coordinates and custom domain structures.
Installation
Install the core package:
pip install st-spider
Install optional feature groups only when needed:
pip install "st-spider[plot]"
pip install "st-spider[spatial]"
pip install "st-spider[image]"
pip install "st-spider[torch]"
The core installation avoids heavy optional dependencies such as torch, scanpy, squidpy, napari, and cellpose. This keeps the main simulator easier to install while preserving advanced workflows for users who need them.
Quick Start
import spider
prior = [0.6, 0.3, 0.1]
target = spider.make_transition_matrix("attractive", n_celltypes=3, strength=0.8)
sim = spider.simulate_cells(
n_cells=1000,
n_celltypes=3,
prior=prior,
transition=target,
plate_shape=(100, 100),
random_state=1,
)
print(sim.summary())
adata = sim.to_anndata()
See the tutorials at https://spider-analyses.readthedocs.io/en/latest/.
3D Cell Simulation
simulate_10X_3d supports more than 10,000 cells using a three-axis coarse-to-fine grid. It returns one cell-type label and one (x, y, z) coordinate per cell. The final annealing step uses a 3D nearest-neighbor graph.
import numpy as np
import spider
prior = np.array([0.3, 0.25, 0.2, 0.15, 0.1])
target = spider.make_transition_matrix("mixed", n_celltypes=5)
cell_types, locations = spider.simulate_10X_3d(
cell_num=20000,
Num_celltype=5,
prior=prior,
target_trans=target,
image_width=1000,
image_height=1000,
image_depth=1000,
)
assert locations.shape == (20000, 3)
Estimating Parameters From Real Data
Spider can estimate cell-type proportions and neighborhood transition matrices from annotated spatial data:
params = spider.estimate_parameters_from_adata(
adata,
label_key="celltype",
spatial_key="spatial",
n_neighbors=8,
)
sim = spider.simulate_cells(
n_cells=adata.n_obs,
prior=params.prior,
transition=params.transition,
coordinates=adata.obsm["spatial"],
random_state=1,
)
Spatially Varying Patterns
For tissues where a single global transition matrix is too restrictive, pass zone-specific targets:
zone_transitions = {
"tumor_core": spider.make_transition_matrix("attractive", 3, strength=0.85),
"invasion_front": spider.make_transition_matrix("mixed", 3),
}
sim = spider.simulate_cells(
n_cells=adata.n_obs,
n_celltypes=3,
prior=[0.5, 0.3, 0.2],
coordinates=adata.obsm["spatial"],
zone_labels=adata.obs["region"].to_numpy(),
zone_transitions=zone_transitions,
random_state=1,
)
Development
Install development dependencies:
pip install -e ".[dev,plot,spatial]"
pytest
Build release artifacts outside version control:
python -m build
Metadata
Release files for st-spider 1.2.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 |
|---|---|---|---|---|
| st_spider-1.2.0.tar.gz | 56.1 kB | Without provenance | Details for st_spider-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| st_spider-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for st_spider-1.2.0-py3-none-any.whl |
Total release size: 114.9 kB
Release files / st_spider-1.2.0.tar.gz
| Download URL | st_spider-1.2.0.tar.gz |
|---|---|
| Size | 56.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab59f01481efc380f28bb8b1526f9005b60a1c5aa74228dda21d01d5c3036181
|
|
BLAKE2b-256 checksum How to use checksums |
ef4b90208b03cb9197495c79b6ceaf0da2ac7acd66d167f2a512a5dabc1112cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Release files / st_spider-1.2.0-py3-none-any.whl
| Download URL | st_spider-1.2.0-py3-none-any.whl |
|---|---|
| Size | 58.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
773a8d5008fd6f1e0eb19eff3e327eeb2f1a724ee80d82c8372eec6ae492c61e
|
|
BLAKE2b-256 checksum How to use checksums |
2c2ca742c7a4e2bf1fef5b757f804cff2fb74b6d08207e8f09ee4c7ef6016d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Security for st-spider 1.2.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.