WHY MATHEMATICS?
Why Mathematics? | STAMP for Spatial Topics: Gamma-Poisson Counts, Spatial Priors, Sparse Gene Modules and Interpretable Dimension Reduction
How STAMP turns high-dimensional spatial counts into mixtures of interpretable topics and sparse gene modules while keeping boundaries, uncertainty and batch effects visible.
Why mathematics is important becomes easier to see when a real decision depends on it. This guide follows the mechanism from definitions and dimensions to a worked calculation, validation, practical learning and responsible use. It keeps factual evidence separate from interpretation and treats every illustrative scenario as an example rather than a promise of results.
Choose a reading route
- Express each cell as a mixture of nonnegative topics
- Model overdispersed counts with library-size-aware Gamma-Poisson means
- Encourage spatial coherence and structured sparsity
- Interpret gene modules across sections and time without causal overclaiming
Chapter map
- 1. Count matrix
- 2. Library size
- 3. Topic proportions
- 4. Gene embeddings
- 5. Mean expression
- 6. Gamma-Poisson likelihood
- 7. Gene dispersion
- 8. Spatial prior
- 9. Sparse modules
- 10. Across-topic sparsity
- 11. Within-topic sparsity
- 12. Dominant topic
- 13. Batch contributions
- 14. Time-series topics
- 15. Scalable inference
- 16. Governance and learning
Visit the How Mathematics Works hub for the wider series and its connections to education, reasoning, science, computing, design and careers.
1. Count matrix
The central mathematical idea is concrete. Cells by genes provide nonnegative expression counts.
A concrete situation
Three thousand cells measure ten thousand genes.
What the mathematics does not license
Filtering changes rare signals. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Record every threshold. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
2. Library size
Here the geometry becomes operational. A cell-specific scale accounts for total measured counts.
A concrete situation
A cell with twice the depth has a larger expected total.
What the mathematics does not license
Depth may also reflect biology. A trustworthy workflow records the choice before seeing the final test result.
Try it, check it, transfer it
Inspect normalization assumptions. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
3. Topic proportions
This step deserves a careful pause. A simplex vector gives each cell a mixture over K topics.
A concrete situation
A boundary cell is 0.6 topic one and 0.4 topic two.
What the mathematics does not license
Too many topics fragment interpretation. Evidence becomes stronger when the limitation is tested instead of hidden.
Try it, check it, transfer it
Compare nearby K. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
4. Gene embeddings
The useful question is not only how to calculate, but what the calculation assumes. Each topic assigns nonnegative weights across genes.
A concrete situation
Topic two emphasizes myelin genes.
What the mathematics does not license
Weights depend on model scale. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Use normalized rankings. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
Did You Know? In this chapter, the most important number is useful only together with its construction rule. Changing scaling, sample membership or validation design can change the numerical answer without changing the arithmetic.
5. Mean expression
A small example makes the mechanism visible. Library size multiplies the sum of topic proportion times gene weight.
A concrete situation
Two topics contribute to one expected count.
What the mathematics does not license
A mean is not an observed count. A trustworthy workflow records the choice before seeing the final test result.
Try it, check it, transfer it
Calculate both explicitly. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
6. Gamma-Poisson likelihood
This is where modelling choices begin to affect evidence. The count distribution allows extra variance beyond Poisson.
A concrete situation
A gene has mean five with wider count spread.
What the mathematics does not license
Tail fit can vary by gene. Evidence becomes stronger when the limitation is tested instead of hidden.
Try it, check it, transfer it
Inspect predictive residuals. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
7. Gene dispersion
The central mathematical idea is concrete. A gene-specific parameter controls overdispersion.
A concrete situation
One marker varies more than a housekeeping gene.
What the mathematics does not license
Small samples make dispersion unstable. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Use shrinkage diagnostics. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
8. Spatial prior
Here the geometry becomes operational. Neighbour information encourages locally related topic mixtures.
A concrete situation
Adjacent cortex cells share some proportions.
What the mathematics does not license
Strong priors blur real boundaries. A trustworthy workflow records the choice before seeing the final test result.
Try it, check it, transfer it
Sweep spatial strength. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
Did You Know? In this chapter, the most important number is useful only together with its construction rule. Changing scaling, sample membership or validation design can change the numerical answer without changing the arithmetic.
9. Sparse modules
This step deserves a careful pause. Priors set many topic-gene contributions near zero.
A concrete situation
A topic retains a concise marker set.
What the mathematics does not license
Sparsity may drop weak coordinated genes. Evidence becomes stronger when the limitation is tested instead of hidden.
Try it, check it, transfer it
Report full posterior ranks. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
10. Across-topic sparsity
The useful question is not only how to calculate, but what the calculation assumes. A gene can be encouraged to belong selectively across topics.
A concrete situation
One marker distinguishes topic three.
What the mathematics does not license
Shared biology may be artificially separated. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Inspect multi-topic genes. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
11. Within-topic sparsity
A small example makes the mechanism visible. Only part of the gene set carries one topic.
A concrete situation
A module contains dozens rather than thousands of genes.
What the mathematics does not license
Prior strength controls module size. A trustworthy workflow records the choice before seeing the final test result.
Try it, check it, transfer it
Publish prior sensitivity. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
12. Dominant topic
This is where modelling choices begin to affect evidence. The largest proportion can label a clearly dominated cell.
A concrete situation
A cell with 0.9 topic four receives that interpretation.
What the mathematics does not license
Boundary cells may have no clear dominant topic. Evidence becomes stronger when the limitation is tested instead of hidden.
Try it, check it, transfer it
Keep mixtures visible. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
Did You Know? In this chapter, the most important number is useful only together with its construction rule. Changing scaling, sample membership or validation design can change the numerical answer without changing the arithmetic.
13. Batch contributions
The central mathematical idea is concrete. Gene- and topic-wise terms represent selected batch shifts.
A concrete situation
A technical effect is large for a subset of genes.
What the mathematics does not license
Batch and condition can be confounded. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Use balanced designs. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
14. Time-series topics
Here the geometry becomes operational. Shared topics connect stages while allowing changing gene contributions.
A concrete situation
One embryonic structure recurs over time.
What the mathematics does not license
Shared labels do not prove lineage. A trustworthy workflow records the choice before seeing the final test result.
Try it, check it, transfer it
Validate with developmental evidence. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
15. Scalable inference
This step deserves a careful pause. Amortized variational methods approximate posterior quantities.
A concrete situation
A neural encoder predicts topic parameters.
What the mathematics does not license
Approximation may understate uncertainty. Evidence becomes stronger when the limitation is tested instead of hidden.
Try it, check it, transfer it
Use held-out likelihood and calibration. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
16. Governance and learning
The useful question is not only how to calculate, but what the calculation assumes. Version counts, K, graph, priors, batches, seeds and convergence.
A concrete situation
A student calculates one Gamma-Poisson mean.
What the mathematics does not license
Topics are interpretable hypotheses. Keeping this boundary clear makes the result easier to audit and transfer.
Try it, check it, transfer it
Write a STAMP evidence ledger. Then explain the result to someone who has not seen the formula. If the explanation needs a hidden assumption, add that assumption to the model record.
Did You Know? In this chapter, the most important number is useful only together with its construction rule. Changing scaling, sample membership or validation design can change the numerical answer without changing the arithmetic.
A seven-day practice lab
- Day 1: define the decision, observation unit, X variables and Y or reference condition.
- Day 2: reproduce the smallest worked example and check every dimension, unit and sign.
- Day 3: build a transparent baseline and write what it assumes.
- Day 4: fit the main method inside a training-only pipeline; record every parameter.
- Day 5: challenge one assumption with a deliberately difficult dataset or operating regime.
- Day 6: compare validation metrics with the practical workload created by errors.
- Day 7: present one supported conclusion, one unresolved uncertainty and one safe next experiment.
Questions for a student, parent or mentor
- Which part of the model is a mathematical definition, and which part is a choice?
- What small calculation would catch a sign, scale or dimension error?
- What evidence comes from training, validation and the untouched test?
- What benign condition could look like a fault or prediction failure?
- How would the answer change for another response, asset, school project or time period?
- What should a human review before acting on the score?
A method-specific audit before deployment
STAMP is a Bayesian topic model for spatial transcriptomics. Each cell receives nonnegative topic proportions, and each topic receives a gene embedding or gene module. The expected expression for a gene is library size multiplied by a sum of topic proportion times topic-specific gene weight.
Observed counts follow a Gamma-Poisson model with gene-specific dispersion, which accommodates overdispersion beyond a simple Poisson. Spatial information enters the topic proportions so nearby cells can support coherent topics, while structured sparsity-inducing priors make gene modules selective across topics and within each topic.
A dominant topic can label a cell when one proportion is clearly largest, but mixtures remain important at boundaries. STAMP can also model shared topics across time-series spatial data and topic- and gene-specific batch contributions. These are conditional decompositions, not direct observations of cell fate or causal regulation.
Students can take three cells, four genes and two topics, choose topic proportions and sparse gene weights, and calculate the Gamma-Poisson mean for one cell-gene pair. Adjust the library size, dispersion or spatial prior and observe which part changes counts, uncertainty or map continuity.
Frequently asked questions
What is STAMP?
STAMP is a spatially aware Bayesian topic model that represents cells as mixtures of topics and topics as gene modules.
How are counts modeled?
Observed expression follows a Gamma-Poisson distribution whose mean combines library size, topic proportions and topic-specific gene weights, with gene-specific dispersion.
Why are topic proportions useful?
They preserve mixtures at boundaries instead of forcing every cell immediately into one hard cluster.
What does structured sparsity do?
It encourages gene modules to be selective across topics and within topics, which can make the learned factors easier to interpret.
Can STAMP compare time points or batches?
The model includes formulations for shared topics across time-series data and gene- and topic-specific batch contributions.
Does a topic prove a biological programme?
No. A topic is a fitted decomposition requiring marker, anatomy, perturbation and replication evidence before mechanistic claims.
Primary source and fact-check note
Chengwei Zhong, Kok Siong Ang and Jinmiao Chen, “Interpretable spatially aware dimension reduction of spatial transcriptomics with STAMP,” Nature Methods 21, 2072–2083 (2024), DOI 10.1038/s41592-024-02463-8. Definitions and core claims in this article were checked against this primary publication. Calculations shown here were independently recomputed. Examples are educational illustrations; they are not reported industrial performance results.
Useful next reading
- SpatialPCA low-dimensional spatial factors
- SOTIP microenvironment geometry
- PRECAST shared slide structure
- How Mathematics Works
Keep the options open. Mathematics education supports clearer questions, transferable problem-solving skills and informed choices across science, engineering, computing, AI, statistics, design and many other careers. It does not guarantee intelligence, income, admission or employment; those outcomes depend on far more than one subject or model.
Extended laboratory: topic-specific validation and responsible use
Count audit
Record filtering, counts and library sizes.
Topic audit
Compare K and seed stability.
Dispersion audit
Inspect gene-wise predictive residuals.
Spatial audit
Sweep neighbourhood and prior strength.
Did You Know? A sophisticated adjustment can be algebraically correct and still answer the wrong scientific question when samples, labels, batches or validation boundaries are wrong.
Sparsity audit
Report module size and prior sensitivity.
Batch audit
Check design overlap and residual shifts.
Time audit
Separate shared topics from lineage claims.
Final claim
A topic is an interpretable fitted hypothesis.
Did You Know? A sophisticated adjustment can be algebraically correct and still answer the wrong scientific question when samples, labels, batches or validation boundaries are wrong.
Mechanism workshop: calculate, challenge and transfer
Workshop 1: Count matrix
Begin with this mechanism: Cells by genes provide nonnegative expression counts. Work through the concrete case: Three thousand cells measure ten thousand genes. Make the limitation visible: Filtering changes rare signals. Complete the evidence step: Record every threshold. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 2: Library size
Begin with this mechanism: A cell-specific scale accounts for total measured counts. Work through the concrete case: A cell with twice the depth has a larger expected total. Make the limitation visible: Depth may also reflect biology. Complete the evidence step: Inspect normalization assumptions. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 3: Topic proportions
Begin with this mechanism: A simplex vector gives each cell a mixture over K topics. Work through the concrete case: A boundary cell is 0.6 topic one and 0.4 topic two. Make the limitation visible: Too many topics fragment interpretation. Complete the evidence step: Compare nearby K. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 4: Gene embeddings
Begin with this mechanism: Each topic assigns nonnegative weights across genes. Work through the concrete case: Topic two emphasizes myelin genes. Make the limitation visible: Weights depend on model scale. Complete the evidence step: Use normalized rankings. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Did You Know? A sophisticated adjustment can be algebraically correct and still answer the wrong scientific question when samples, labels, batches or validation boundaries are wrong.
Workshop 5: Mean expression
Begin with this mechanism: Library size multiplies the sum of topic proportion times gene weight. Work through the concrete case: Two topics contribute to one expected count. Make the limitation visible: A mean is not an observed count. Complete the evidence step: Calculate both explicitly. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 6: Gamma-Poisson likelihood
Begin with this mechanism: The count distribution allows extra variance beyond Poisson. Work through the concrete case: A gene has mean five with wider count spread. Make the limitation visible: Tail fit can vary by gene. Complete the evidence step: Inspect predictive residuals. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 7: Gene dispersion
Begin with this mechanism: A gene-specific parameter controls overdispersion. Work through the concrete case: One marker varies more than a housekeeping gene. Make the limitation visible: Small samples make dispersion unstable. Complete the evidence step: Use shrinkage diagnostics. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 8: Spatial prior
Begin with this mechanism: Neighbour information encourages locally related topic mixtures. Work through the concrete case: Adjacent cortex cells share some proportions. Make the limitation visible: Strong priors blur real boundaries. Complete the evidence step: Sweep spatial strength. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Did You Know? A sophisticated adjustment can be algebraically correct and still answer the wrong scientific question when samples, labels, batches or validation boundaries are wrong.
Workshop 9: Sparse modules
Begin with this mechanism: Priors set many topic-gene contributions near zero. Work through the concrete case: A topic retains a concise marker set. Make the limitation visible: Sparsity may drop weak coordinated genes. Complete the evidence step: Report full posterior ranks. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 10: Across-topic sparsity
Begin with this mechanism: A gene can be encouraged to belong selectively across topics. Work through the concrete case: One marker distinguishes topic three. Make the limitation visible: Shared biology may be artificially separated. Complete the evidence step: Inspect multi-topic genes. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 11: Within-topic sparsity
Begin with this mechanism: Only part of the gene set carries one topic. Work through the concrete case: A module contains dozens rather than thousands of genes. Make the limitation visible: Prior strength controls module size. Complete the evidence step: Publish prior sensitivity. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 12: Dominant topic
Begin with this mechanism: The largest proportion can label a clearly dominated cell. Work through the concrete case: A cell with 0.9 topic four receives that interpretation. Make the limitation visible: Boundary cells may have no clear dominant topic. Complete the evidence step: Keep mixtures visible. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Did You Know? A sophisticated adjustment can be algebraically correct and still answer the wrong scientific question when samples, labels, batches or validation boundaries are wrong.
Workshop 13: Batch contributions
Begin with this mechanism: Gene- and topic-wise terms represent selected batch shifts. Work through the concrete case: A technical effect is large for a subset of genes. Make the limitation visible: Batch and condition can be confounded. Complete the evidence step: Use balanced designs. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 14: Time-series topics
Begin with this mechanism: Shared topics connect stages while allowing changing gene contributions. Work through the concrete case: One embryonic structure recurs over time. Make the limitation visible: Shared labels do not prove lineage. Complete the evidence step: Validate with developmental evidence. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 15: Scalable inference
Begin with this mechanism: Amortized variational methods approximate posterior quantities. Work through the concrete case: A neural encoder predicts topic parameters. Make the limitation visible: Approximation may understate uncertainty. Complete the evidence step: Use held-out likelihood and calibration. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.
Workshop 16: Governance and learning
Begin with this mechanism: Version counts, K, graph, priors, batches, seeds and convergence. Work through the concrete case: A student calculates one Gamma-Poisson mean. Make the limitation visible: Topics are interpretable hypotheses. Complete the evidence step: Write a STAMP evidence ledger. Write the dimensions, counts, coordinates, mixture parameters, graph edges, priors, losses, dispersions, topic proportions or update rules with named units. Calculate one small example by hand, then vary one assumption and explain which result moves and why. Reserve complete sections, donors, tissue regions, genes or image sets outside tuning when testing transfer. Keep measurement, fitted representation, statistical evidence, biological interpretation and decision on separate notebook lines so a student, parent or reviewer can audit the mathematics.