WHY MATHEMATICS?
Why Mathematics? | RCTD for Spatial Mixtures: Poisson Counts, Platform Effects, Cell-Type Weights and Doublet Decisions
How robust cell type decomposition uses Poisson count probability, cross-platform correction and penalized mixture decisions to map reference cell types into spatial transcriptomics measurements.
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
- Build reference cell-type profiles from annotated single-cell counts
- Correct systematic gene differences between sequencing platforms
- Fit nonnegative cell-type weights with a Poisson count model
- Distinguish singlets, doublets and uncertain mixtures with model comparison
Chapter map
- 1. Reference cells
- 2. Cell-type averages
- 3. Spatial library size
- 4. Poisson count law
- 5. Mixture mean
- 6. Platform-effect vector
- 7. Weight optimization
- 8. Log likelihood
- 9. Singlet score
- 10. Doublet comparison
- 11. Full mixture mode
- 12. Worked two-gene example
- 13. Residual map
- 14. Reference-swap test
- 15. Spatial expression after decomposition
- 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. Reference cells
This is where modelling choices begin to affect evidence. Annotated single-cell counts define the profiles available to explain spatial measurements.
A concrete situation
Three donors contribute neuronal, glial and vascular labels.
What the mathematics does not license
Wrong or missing labels redirect weights. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Audit donors, labels and condition coverage. 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. Cell-type averages
The central mathematical idea is concrete. For every gene and type, the reference estimates an average expression rate after filtering.
A concrete situation
A vascular marker has a high endothelial rate and low neuronal rates.
What the mathematics does not license
Averages hide within-type states. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Compare donor- and state-specific profiles. 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. Spatial library size
Here the geometry becomes operational. The total count at a pixel scales all expected gene counts for that location.
A concrete situation
A pixel with twice the reads has twice the expected counts under equal composition.
What the mathematics does not license
Depth can correlate with tissue density. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Plot depth against histology and fitted weights. 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. Poisson count law
This step deserves a careful pause. Each gene count is modeled as Poisson with variance tied to its expected mean.
A concrete situation
A mean of 6 makes counts near 6 most plausible.
What the mathematics does not license
Extra-Poisson variation can weaken fit. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Use residual and dispersion 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.
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. Mixture mean
The useful question is not only how to calculate, but what the calculation assumes. The expected expression is a nonnegative weighted sum of reference type profiles.
A concrete situation
Weights 0.7 and 0.3 mix two gene-rate vectors.
What the mathematics does not license
Similar profiles are hard to separate. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Measure profile correlations. 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. Platform-effect vector
A small example makes the mechanism visible. A positive gene-specific factor aligns relative expression between reference and spatial technologies.
A concrete situation
A ribosomal gene needs a 0.6 correction while a marker stays near one.
What the mathematics does not license
Biology can be mistaken for technology. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Estimate effects across diverse locations. 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. Weight optimization
This is where modelling choices begin to affect evidence. Numerical optimization finds the nonnegative weights that maximize the spatial count likelihood.
A concrete situation
A grid search on two types shows one clear likelihood peak.
What the mathematics does not license
Local choices and constraints matter. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Repeat with diagnostics and perturbations. 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. Log likelihood
The central mathematical idea is concrete. Products of Poisson probabilities become sums of count times log mean minus mean terms.
A concrete situation
One implausible high marker count changes the score.
What the mathematics does not license
Large genes can dominate totals. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Inspect gene contributions. 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. Singlet score
Here the geometry becomes operational. The best one-type model supplies a simple explanation and baseline likelihood.
A concrete situation
An oligodendrocyte-only fit explains nearly every marker.
What the mathematics does not license
Simple does not mean true. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Compare residual markers. 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. Doublet comparison
This step deserves a careful pause. Two-type candidates are compared with penalties or thresholds that discourage gratuitous complexity.
A concrete situation
Adding microglia sharply improves a mixed pixel.
What the mathematics does not license
Thresholds create borderline cases. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Publish score margins. 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. Full mixture mode
The useful question is not only how to calculate, but what the calculation assumes. A location may be represented by more than two types when resolution and tissue biology require it.
A concrete situation
A Visium spot contains immune, stromal and epithelial RNA.
What the mathematics does not license
More flexibility increases ambiguity. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Test sparsity and stability. 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. Worked two-gene example
A small example makes the mechanism visible. Multiply two type profiles by weights, apply depth and platform factors, then compute Poisson probabilities.
A concrete situation
Observed counts 9 and 3 favour a 75:25 mixture.
What the mathematics does not license
Two genes are not identifiable in practice. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Add genes and correlated types. 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. Residual map
This is where modelling choices begin to affect evidence. Observed minus expected counts reveal genes and regions the reference mixture does not explain.
A concrete situation
A disease programme leaves positive residuals along a lesion.
What the mathematics does not license
Residuals mix biology and technical failure. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Follow with condition-matched data. 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. Reference-swap test
The central mathematical idea is concrete. Fit plausible atlases from different donors or technologies and compare weights.
A concrete situation
A rare subtype disappears with a shallow atlas.
What the mathematics does not license
Agreement may reflect shared bias. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Use orthogonal staining. 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. Spatial expression after decomposition
Here the geometry becomes operational. Cell-type localization can support tests of within-type spatial expression when uncertainty is respected.
A concrete situation
A neuronal gene changes near a boundary.
What the mathematics does not license
Localization error propagates downstream. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Carry weights and uncertainty forward. 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
This step deserves a careful pause. Version counts, labels, effects, thresholds, modes and residual checks.
A concrete situation
A student traces one pixel from counts to a doublet decision.
What the mathematics does not license
A colour is not an explanation. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Write a complete 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
An RCTD analysis begins with annotated single-cell RNA sequencing and spatial transcript counts. It estimates a reference expression profile for each declared cell type, models spatial counts with a Poisson distribution, and corrects gene-level platform effects between technologies. The nonnegative weights at each pixel or spot describe how strongly each reference type contributes to that location.
The mathematics separates three questions that are often blended in casual language: which reference profiles are plausible, how much of each profile is supported at a location, and whether one or two cell types explain the signal better than a more complex mixture. Doublet mode is therefore a model-comparison procedure under explicit penalties and thresholds, not a visual guess from a coloured map.
Validate with simulations, reference-donor swaps, absent-type tests, known anatomical markers, pixels held out by section and sensitivity to cell-type similarity. A fitted weight is conditional on the reference and platform correction. It is not direct observation of a whole cell, and a doublet label does not prove that exactly two intact cells occupied the capture region.
Frequently asked questions
What is RCTD?
RCTD is a supervised spatial transcriptomics decomposition method that uses cell-type profiles learned from single-cell data to estimate which types contribute to each spatial location while correcting cross-platform differences.
Why a Poisson model?
RCTD treats spatial transcript counts as discrete events whose expected value is built from cell-type weights, reference profiles, library size and gene platform effects. Model checks are needed when variability exceeds the assumptions.
What is a platform effect?
It is a systematic gene-specific difference between the reference and spatial technologies. RCTD estimates correction factors so a gene that is relatively easier to detect on one platform does not automatically distort cell-type weights.
What are the weights?
They are nonnegative fitted contributions of reference cell types at a location. Their interpretation depends on normalization, reference quality and the count model.
What is doublet mode?
Doublet mode compares simpler one-type and two-type explanations and penalizes unnecessary complexity. It produces a statistical decision under thresholds, not a direct count of physical cells.
Can RCTD discover a missing cell type?
It may reveal poor fit or unusual residuals, but a supervised decomposition cannot name a type absent from its reference. Novelty requires additional evidence and revised references.
Primary source and fact-check note
Dylan M. Cable, Evan Murray, Luli S. Zou et al., “Robust decomposition of cell type mixtures in spatial transcriptomics,” Nature Biotechnology 40, 517–526 (2022), DOI 10.1038/s41587-021-00830-w. 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
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
Reference audit
Check labels, donors, platform and absent states.
Poisson audit
Inspect means, zeros, tails and spatial residuals.
Platform audit
Review gene corrections for biology-technology confounding.
Mode audit
State singlet, doublet or full mode and every threshold.
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.
Similarity test
Challenge closely related reference types.
Section holdout
Reserve complete tissue sections.
External check
Use histology or targeted spatial markers.
Final claim
A mixture weight and doublet decision are model-based evidence.
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: Reference cells
Begin with this mechanism: Annotated single-cell counts define the profiles available to explain spatial measurements. Work through the concrete case: Three donors contribute neuronal, glial and vascular labels. Make the limitation visible: Wrong or missing labels redirect weights. Complete the evidence step: Audit donors, labels and condition coverage. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 2: Cell-type averages
Begin with this mechanism: For every gene and type, the reference estimates an average expression rate after filtering. Work through the concrete case: A vascular marker has a high endothelial rate and low neuronal rates. Make the limitation visible: Averages hide within-type states. Complete the evidence step: Compare donor- and state-specific profiles. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 3: Spatial library size
Begin with this mechanism: The total count at a pixel scales all expected gene counts for that location. Work through the concrete case: A pixel with twice the reads has twice the expected counts under equal composition. Make the limitation visible: Depth can correlate with tissue density. Complete the evidence step: Plot depth against histology and fitted weights. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 4: Poisson count law
Begin with this mechanism: Each gene count is modeled as Poisson with variance tied to its expected mean. Work through the concrete case: A mean of 6 makes counts near 6 most plausible. Make the limitation visible: Extra-Poisson variation can weaken fit. Complete the evidence step: Use residual and dispersion diagnostics. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
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: Mixture mean
Begin with this mechanism: The expected expression is a nonnegative weighted sum of reference type profiles. Work through the concrete case: Weights 0.7 and 0.3 mix two gene-rate vectors. Make the limitation visible: Similar profiles are hard to separate. Complete the evidence step: Measure profile correlations. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 6: Platform-effect vector
Begin with this mechanism: A positive gene-specific factor aligns relative expression between reference and spatial technologies. Work through the concrete case: A ribosomal gene needs a 0.6 correction while a marker stays near one. Make the limitation visible: Biology can be mistaken for technology. Complete the evidence step: Estimate effects across diverse locations. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 7: Weight optimization
Begin with this mechanism: Numerical optimization finds the nonnegative weights that maximize the spatial count likelihood. Work through the concrete case: A grid search on two types shows one clear likelihood peak. Make the limitation visible: Local choices and constraints matter. Complete the evidence step: Repeat with diagnostics and perturbations. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 8: Log likelihood
Begin with this mechanism: Products of Poisson probabilities become sums of count times log mean minus mean terms. Work through the concrete case: One implausible high marker count changes the score. Make the limitation visible: Large genes can dominate totals. Complete the evidence step: Inspect gene contributions. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
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: Singlet score
Begin with this mechanism: The best one-type model supplies a simple explanation and baseline likelihood. Work through the concrete case: An oligodendrocyte-only fit explains nearly every marker. Make the limitation visible: Simple does not mean true. Complete the evidence step: Compare residual markers. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 10: Doublet comparison
Begin with this mechanism: Two-type candidates are compared with penalties or thresholds that discourage gratuitous complexity. Work through the concrete case: Adding microglia sharply improves a mixed pixel. Make the limitation visible: Thresholds create borderline cases. Complete the evidence step: Publish score margins. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 11: Full mixture mode
Begin with this mechanism: A location may be represented by more than two types when resolution and tissue biology require it. Work through the concrete case: A Visium spot contains immune, stromal and epithelial RNA. Make the limitation visible: More flexibility increases ambiguity. Complete the evidence step: Test sparsity and stability. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 12: Worked two-gene example
Begin with this mechanism: Multiply two type profiles by weights, apply depth and platform factors, then compute Poisson probabilities. Work through the concrete case: Observed counts 9 and 3 favour a 75:25 mixture. Make the limitation visible: Two genes are not identifiable in practice. Complete the evidence step: Add genes and correlated types. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
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: Residual map
Begin with this mechanism: Observed minus expected counts reveal genes and regions the reference mixture does not explain. Work through the concrete case: A disease programme leaves positive residuals along a lesion. Make the limitation visible: Residuals mix biology and technical failure. Complete the evidence step: Follow with condition-matched data. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 14: Reference-swap test
Begin with this mechanism: Fit plausible atlases from different donors or technologies and compare weights. Work through the concrete case: A rare subtype disappears with a shallow atlas. Make the limitation visible: Agreement may reflect shared bias. Complete the evidence step: Use orthogonal staining. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 15: Spatial expression after decomposition
Begin with this mechanism: Cell-type localization can support tests of within-type spatial expression when uncertainty is respected. Work through the concrete case: A neuronal gene changes near a boundary. Make the limitation visible: Localization error propagates downstream. Complete the evidence step: Carry weights and uncertainty forward. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
Workshop 16: Governance and learning
Begin with this mechanism: Version counts, labels, effects, thresholds, modes and residual checks. Work through the concrete case: A student traces one pixel from counts to a doublet decision. Make the limitation visible: A colour is not an explanation. Complete the evidence step: Write a complete evidence ledger. Write the relevant vectors, matrices, probability distribution, graph, loss or posterior update with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Test transfer on complete donors, tissue sections, capture locations or gene sets outside tuning. Keep measurement, fitted parameter, prediction, interpretation and decision on separate notebook lines so the mathematical claim remains auditable.
