WHY MATHEMATICS?
Why Mathematics? | GPSA for Spatial Genomics Alignment: Deep Gaussian Processes, Common Coordinates, Kernels and Variational Uncertainty
How GPSA learns probabilistic coordinate warps and shared spatial readout functions so samples, modalities and tissue slices can be compared in a common coordinate system.
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
- Model each sample warp as a Gaussian-process function
- Map common coordinates to molecular readouts with a second GP
- Approximate the posterior with inducing points and variational inference
- Use uncertainty and holdouts to test alignment claims
Chapter map
- 1. Observed sample coordinates
- 2. Phenotypic readouts
- 3. Common coordinate system
- 4. Warp Gaussian process
- 5. Warp kernel
- 6. Identity-centred prior
- 7. Readout Gaussian process
- 8. Deep-GP composition
- 9. Kernel covariance matrix
- 10. Inducing locations
- 11. Variational distributions
- 12. Evidence lower bound
- 13. Stochastic optimization
- 14. Posterior common positions
- 15. Downstream spatial tests
- 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. Observed sample coordinates
This is where modelling choices begin to affect evidence. Each sample begins in its own coordinate frame.
A concrete situation
Two slices have unrelated origins and rotations.
What the mathematics does not license
Coordinates alone lack correspondence. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Record units and orientation. 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. Phenotypic readouts
The central mathematical idea is concrete. Genes, proteins or image features guide alignment.
A concrete situation
Fifty selected genes are shared across slices.
What the mathematics does not license
Marker selection can bias the warp. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Use held-out readouts. 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. Common coordinate system
Here the geometry becomes operational. Latent positions provide one frame for all samples.
A concrete situation
Equivalent tissue regions approach one another.
What the mathematics does not license
The frame is identifiable only up to transformations. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Use anchors or conventions. 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. Warp Gaussian process
This step deserves a careful pause. A function maps observed coordinates into common coordinates.
A concrete situation
A smooth nonlinear field bends one slice.
What the mathematics does not license
Flexible warps can fold space. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Inspect Jacobians and grids. 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. Warp kernel
The useful question is not only how to calculate, but what the calculation assumes. Covariance controls spatial smoothness of deformation.
A concrete situation
Nearby points receive correlated displacement.
What the mathematics does not license
One length scale may miss multiscale change. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Compare kernels and length scales. 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. Identity-centred prior
A small example makes the mechanism visible. The model may prefer small departures from original positions.
A concrete situation
A prior keeps an undistorted region near place.
What the mathematics does not license
A strong prior under-aligns real deformation. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Sensitivity-test prior 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.
7. Readout Gaussian process
This is where modelling choices begin to affect evidence. A second function predicts molecular values from common coordinates.
A concrete situation
A shared field predicts a marker gradient.
What the mathematics does not license
Shared fields can erase sample-specific biology. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Model residuals by sample. 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. Deep-GP composition
The central mathematical idea is concrete. Warp and readout functions compose into a nonlinear generative model.
A concrete situation
Observed coordinate flows through latent position to gene value.
What the mathematics does not license
Layer trade-offs create non-identifiability. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Use simulations and anchors. 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. Kernel covariance matrix
Here the geometry becomes operational. Pairwise kernel values define prior correlation.
A concrete situation
An RBF entry decays with squared distance.
What the mathematics does not license
Near-singular matrices hurt computation. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Monitor jitter and conditioning. 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. Inducing locations
This step deserves a careful pause. A smaller set of pseudo-inputs approximates each GP.
A concrete situation
Two hundred inducing points summarize thousands of cells.
What the mathematics does not license
Too few lose local structure. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Run an inducing-point grid. 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. Variational distributions
The useful question is not only how to calculate, but what the calculation assumes. Approximate posteriors describe inducing values and latent positions.
A concrete situation
Means and covariances encode uncertainty.
What the mathematics does not license
Mean-field assumptions can understate dependence. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Check predictive 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.
12. Evidence lower bound
A small example makes the mechanism visible. Expected log likelihood minus KL divergence is optimized.
A concrete situation
Fit improves while the posterior stays near its prior.
What the mathematics does not license
A larger ELBO need not mean better biology. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Validate downstream tasks. 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. Stochastic optimization
This is where modelling choices begin to affect evidence. Minibatches estimate gradients for scalable training.
A concrete situation
A subset of cells updates parameters each step.
What the mathematics does not license
Gradient noise affects convergence. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Repeat seeds and learning rates. 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. Posterior common positions
The central mathematical idea is concrete. Each location has an inferred aligned coordinate distribution.
A concrete situation
A cell has a mean position and uncertainty ellipse.
What the mathematics does not license
Ellipses depend on model calibration. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Check known landmarks. 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. Downstream spatial tests
Here the geometry becomes operational. Aligned data support ANOVA, cross-modality association and 3D atlases.
A concrete situation
A gene field is compared across donors.
What the mathematics does not license
Alignment error propagates to tests. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Propagate uncertainty or use 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.
16. Governance and learning
This step deserves a careful pause. Version readouts, kernels, priors, inducing points and optimizer.
A concrete situation
A student computes one RBF covariance and ELBO term.
What the mathematics does not license
A warp is a probabilistic explanation. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Write a GP alignment card. 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
Gaussian Process Spatial Alignment treats registration as probabilistic function learning. A first Gaussian-process layer maps observed coordinates from each sample into a common coordinate system. A second Gaussian-process layer maps those common coordinates to observed readouts such as gene expression. The two layers are learned together so spatial warps are guided by shared molecular patterns.
Gaussian processes place distributions over smooth functions. Kernel length scales control how quickly a warp or expression field can change, inducing points make computation practical, and stochastic variational inference approximates the intractable posterior. The result can include uncertainty about common positions and latent spatial functions rather than one unqualified transformation.
Flexibility creates risk. A highly flexible warp may align noise, while a rigid kernel may miss real deformation. Identifiability is also delicate because coordinates and readout functions can trade explanations. Use anchors or informative priors where justified, reserve samples and readout channels, inspect posterior uncertainty, and compare downstream conclusions before and after alignment.
Frequently asked questions
What is GPSA?
Gaussian Process Spatial Alignment is a probabilistic model that maps samples into a shared coordinate system using readout information such as gene expression.
What are the two Gaussian-process layers?
The first maps observed sample coordinates to common coordinates; the second maps common coordinates to observed readouts.
What does a kernel do?
It defines how strongly function values at two locations are correlated as a function of distance and other hyperparameters.
Why use inducing points?
They summarize the Gaussian process at a smaller set of locations, reducing computation for large spatial datasets.
What is variational inference doing?
It optimizes an approximate posterior and evidence lower bound so latent coordinates, functions and uncertainties can be learned without exact GP inference.
Does posterior uncertainty include every source of error?
No. It reflects the stated model, kernel and variational approximation, not unmodeled biology, preprocessing error or omitted modalities.
Primary source and fact-check note
Andrew Jones, F. William Townes, Didong Li et al., “Alignment of spatial genomics data using deep Gaussian processes,” Nature Methods 20, 1379–1387 (2023), DOI 10.1038/s41592-023-01972-2. 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
- PASTE probabilistic coupling
- SpaceFlow spatial trajectories
- STAligner multi-slice maps
- 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
Readout audit
Reserve genes or modalities from alignment.
Kernel audit
Compare families and length scales.
Warp audit
Inspect grids, Jacobians and folding.
Prior audit
Vary identity and anchor 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.
Variational audit
Check ELBO, inducing points and coverage.
Sample holdout
Reserve complete sections or donors.
Downstream audit
Repeat conclusions across posterior samples.
Final claim
Uncertainty covers only the stated GP model.
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: Observed sample coordinates
Begin with this mechanism: Each sample begins in its own coordinate frame. Work through the concrete case: Two slices have unrelated origins and rotations. Make the limitation visible: Coordinates alone lack correspondence. Complete the evidence step: Record units and orientation. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Phenotypic readouts
Begin with this mechanism: Genes, proteins or image features guide alignment. Work through the concrete case: Fifty selected genes are shared across slices. Make the limitation visible: Marker selection can bias the warp. Complete the evidence step: Use held-out readouts. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Common coordinate system
Begin with this mechanism: Latent positions provide one frame for all samples. Work through the concrete case: Equivalent tissue regions approach one another. Make the limitation visible: The frame is identifiable only up to transformations. Complete the evidence step: Use anchors or conventions. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Warp Gaussian process
Begin with this mechanism: A function maps observed coordinates into common coordinates. Work through the concrete case: A smooth nonlinear field bends one slice. Make the limitation visible: Flexible warps can fold space. Complete the evidence step: Inspect Jacobians and grids. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Warp kernel
Begin with this mechanism: Covariance controls spatial smoothness of deformation. Work through the concrete case: Nearby points receive correlated displacement. Make the limitation visible: One length scale may miss multiscale change. Complete the evidence step: Compare kernels and length scales. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Identity-centred prior
Begin with this mechanism: The model may prefer small departures from original positions. Work through the concrete case: A prior keeps an undistorted region near place. Make the limitation visible: A strong prior under-aligns real deformation. Complete the evidence step: Sensitivity-test prior strength. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Readout Gaussian process
Begin with this mechanism: A second function predicts molecular values from common coordinates. Work through the concrete case: A shared field predicts a marker gradient. Make the limitation visible: Shared fields can erase sample-specific biology. Complete the evidence step: Model residuals by sample. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Deep-GP composition
Begin with this mechanism: Warp and readout functions compose into a nonlinear generative model. Work through the concrete case: Observed coordinate flows through latent position to gene value. Make the limitation visible: Layer trade-offs create non-identifiability. Complete the evidence step: Use simulations and anchors. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Kernel covariance matrix
Begin with this mechanism: Pairwise kernel values define prior correlation. Work through the concrete case: An RBF entry decays with squared distance. Make the limitation visible: Near-singular matrices hurt computation. Complete the evidence step: Monitor jitter and conditioning. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Inducing locations
Begin with this mechanism: A smaller set of pseudo-inputs approximates each GP. Work through the concrete case: Two hundred inducing points summarize thousands of cells. Make the limitation visible: Too few lose local structure. Complete the evidence step: Run an inducing-point grid. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Variational distributions
Begin with this mechanism: Approximate posteriors describe inducing values and latent positions. Work through the concrete case: Means and covariances encode uncertainty. Make the limitation visible: Mean-field assumptions can understate dependence. Complete the evidence step: Check predictive coverage. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Evidence lower bound
Begin with this mechanism: Expected log likelihood minus KL divergence is optimized. Work through the concrete case: Fit improves while the posterior stays near its prior. Make the limitation visible: A larger ELBO need not mean better biology. Complete the evidence step: Validate downstream tasks. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Stochastic optimization
Begin with this mechanism: Minibatches estimate gradients for scalable training. Work through the concrete case: A subset of cells updates parameters each step. Make the limitation visible: Gradient noise affects convergence. Complete the evidence step: Repeat seeds and learning rates. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Posterior common positions
Begin with this mechanism: Each location has an inferred aligned coordinate distribution. Work through the concrete case: A cell has a mean position and uncertainty ellipse. Make the limitation visible: Ellipses depend on model calibration. Complete the evidence step: Check known landmarks. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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: Downstream spatial tests
Begin with this mechanism: Aligned data support ANOVA, cross-modality association and 3D atlases. Work through the concrete case: A gene field is compared across donors. Make the limitation visible: Alignment error propagates to tests. Complete the evidence step: Propagate uncertainty or use sensitivity. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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 readouts, kernels, priors, inducing points and optimizer. Work through the concrete case: A student computes one RBF covariance and ELBO term. Make the limitation visible: A warp is a probabilistic explanation. Complete the evidence step: Write a GP alignment card. Write the matrices, masses, kernels, costs, couplings, gradients, variational terms, critic scores or transformations with named dimensions and units. Calculate one small example by hand, then change one assumption and explain which output moves and why. Use complete tissue slices, donors, regions, modalities or gene panels 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.
