A spatial-transcriptomics spot (e.g. a 10x Visium spot) rarely captures a single cell — it pools mRNA from several adjacent cells of possibly different types. The observed expression at a spot is a linear mixture of per-cell-type reference signatures, weighted by how much of each cell type sits under that spot:
o_g = Σ_k S[g,k]·p_k + ε_g
o = observed expression across G marker genes
S = reference signature matrix (G genes × K cell types)
p = true per-spot proportions, Σ_k p_k = 1, p_k ≥ 0
ε = measurement noise
Deconvolution inverts this: given the known signature matrix S and the observed vector o, recover p. Because p must stay non-negative, this simulator uses the classic non-negative matrix-factorization multiplicative update (Lee & Seung) applied per spot, renormalised to sum to 1 after every step:
p_k ← p_k · (Sᵀo)_k / (Sᵀ S p)_k
then p ← p / Σ_k p_k
- Paint true tissue — pick a cell type and click/drag on the grid to add a real attractor of that type at the cursor, pulling the true regional composition of nearby spots toward it. This directly edits the ground truth the deconvolution never sees.
- Niche blend width σ — how smoothly the true tissue niches (base + painted) blend into one another; a small σ gives sharp, near-pure spots, a large σ gives heavily mixed spots that are harder to unmix.
- Measurement noise — Gaussian noise added to each spot's gene readout before deconvolution, mimicking real sequencing/imaging noise.
- NNLS iterations — how many multiplicative-update steps the algorithm runs; at 0 every spot starts from an equal 1/K guess, and the stacked tiles visibly converge toward the true composition as iterations increase.
- Show ground truth / Show estimate — toggles every spot's stacked-tile fill between the true generative proportions (including anything you painted) and the algorithm's current estimate, computed from the mixed signal only, so you can see exactly where deconvolution over- or under-calls a cell type.
This is the same core math behind real tools like Cell2location, RCTD and SPOTlight, used to turn spot-resolution spatial transcriptomics into single-cell-resolution tissue maps for atlases such as tumor microenvironment studies.