First public release of spatial-smooth — composable smoothing of gene-set signatures over space and cell state for single-cell and spatial transcriptomics.
Install
pip install "spatial-smooth[all]"Only numpy, scipy, pandas and anndata are required; every backend is an optional extra, imported lazily (dm, embedding, plot, squidpy, kde).
What's in it
- One-line smoothing of a gene-set signature over physical space (
KnnGaussian, the default), cell state (KompotGPover a diffusion map), or both composed —ss.smooth(adata, genes, name, steps=...). - Composable pipelines: each step smooths the expression matrix over one embedding and hands the result to the next; shorthands (
"spatial","dm","dm+spatial","spatial-kde","spatial-gp") or explicitStepobjects. - Smoothers:
KnnGaussian(Gaussian kernel over k spatial neighbours),Kde(FFT Nadaraya–Watson on a fine grid),KompotGP(Gaussian-process regression). - Compute once, plot forever: results are written into the
AnnData(obs[name],obs[f"{name}_raw"], provenance inuns); plotting reads only those keys.ss.pl.signature/ss.pl.comparewrap scanpy and squidpy. - Scale-invariant bandwidths (multiples of the median nearest-neighbour distance) and provenance that records the effective bandwidth, retained kernel mass, and a truncation warning when it bites.
Important
This package smooths for visualization. Smoothed values are spatially autocorrelated by construction — never run statistics (differential expression, clustering, correlations, p-values) on them. Every call also writes the unsmoothed score to adata.obs[f"{name}_raw"]; run statistics on those.
Docs
Documentation: https://settylab.github.io/spatial-smooth/ · Tutorial notebook and Concepts pages included.
Full API and tutorial: https://settylab.github.io/spatial-smooth/