VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Why Mathematics? | CARD for Spatial Cell Composition: Conditional Autoregression, Neighbour Weights, Nonnegative Proportions and Resolution Enhancement

WHY MATHEMATICS?

Why Mathematics? | CARD for Spatial Cell Composition: Conditional Autoregression, Neighbour Weights, Nonnegative Proportions and Resolution Enhancement

How CARD combines a cell-type expression basis with a conditional autoregressive model so nearby tissue locations can share evidence without erasing real boundaries.

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 a cell-type basis and nonnegative composition matrix
  • Encode spatial neighbourhoods in a weight matrix
  • Estimate autocorrelation and proportions with constrained likelihood
  • Interpret interpolated high-resolution maps as model-based estimates

Chapter map

  1. 1. Spatial expression matrix
  2. 2. Reference basis B
  3. 3. Composition matrix V
  4. 4. Matrix product
  5. 5. Gaussian residual model
  6. 6. Neighbour graph
  7. 7. Weight matrix W
  8. 8. CAR conditional mean
  9. 9. Autocorrelation phi
  10. 10. Conditional variance
  11. 11. Multivariate covariance
  12. 12. Constrained likelihood
  13. 13. Worked line of spots
  14. 14. Reference-free mode
  15. 15. Resolution enhancement
  16. 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. Spatial expression matrix

This is where modelling choices begin to affect evidence. Genes by measured locations form X after declared normalization.

A concrete situation

Four thousand genes are measured at 1,500 spots.

What the mathematics does not license

Normalization affects residual assumptions. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Record units and filtering. 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. Reference basis B

The central mathematical idea is concrete. A gene-by-cell-type matrix summarizes expected expression for K types.

A concrete situation

B has 4,000 rows and 12 type columns.

What the mathematics does not license

Reference mismatch shifts proportions. The habit of checking assumptions is one of the practical benefits of learning mathematics.

Try it, check it, transfer it

Swap donors and atlases. 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. Composition matrix V

Here the geometry becomes operational. Each location receives K nonnegative cell-type composition values.

A concrete situation

A spot has epithelial, fibroblast and immune entries.

What the mathematics does not license

Scale and normalization must be defined. The same reasoning helps students move from an exercise to a real dataset.

Try it, check it, transfer it

Preserve raw and normalized values. 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. Matrix product

This step deserves a careful pause. The biological mean is B times V transpose.

A concrete situation

A 4000 by 12 basis times 12 by 1500 proportions reproduces X dimensions.

What the mathematics does not license

Collinear columns reduce identifiability. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Measure condition numbers. 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. Gaussian residual model

The useful question is not only how to calculate, but what the calculation assumes. Residual expression is modeled around the matrix-product mean with variance parameters.

A concrete situation

One gene deviates moderately from its fitted mixture.

What the mathematics does not license

Heavy tails can affect estimates. The habit of checking assumptions is one of the practical benefits of learning mathematics.

Try it, check it, transfer it

Inspect quantile 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.


6. Neighbour graph

A small example makes the mechanism visible. Coordinates define edges among nearby spots or locations.

A concrete situation

Six hexagonal neighbours surround an interior Visium spot.

What the mathematics does not license

Distance alone may cross barriers. The same reasoning helps students move from an exercise to a real dataset.

Try it, check it, transfer it

Overlay edges on histology. 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 matrix W

This is where modelling choices begin to affect evidence. Entries W_ij quantify influence from location j to i, commonly from distance.

A concrete situation

Closer spots receive larger weights.

What the mathematics does not license

Kernel scale changes smoothing. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Compare plausible kernels. 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. CAR conditional mean

The central mathematical idea is concrete. A composition is centered on a type baseline plus phi times weighted neighbouring deviations.

A concrete situation

A fibroblast-rich spot is expected near fibroblast-rich neighbours.

What the mathematics does not license

Neighbour agreement is prior structure. The habit of checking assumptions is one of the practical benefits of learning mathematics.

Try it, check it, transfer it

Check boundaries separately. 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. Autocorrelation phi

Here the geometry becomes operational. Phi controls how strongly locations borrow composition information.

A concrete situation

Phi near zero gives little spatial borrowing.

What the mathematics does not license

Large phi can over-smooth. The same reasoning helps students move from an exercise to a real dataset.

Try it, check it, transfer it

Profile likelihood and 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.


10. Conditional variance

This step deserves a careful pause. Residual spatial variance allows each spot to differ from its neighbours.

A concrete situation

A small variance makes isolated jumps surprising.

What the mathematics does not license

One variance may not fit all regions. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Map standardized deviations. 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. Multivariate covariance

The useful question is not only how to calculate, but what the calculation assumes. The CAR conditionals imply a joint multivariate normal distribution over locations.

A concrete situation

Matrix inversion links W and phi to covariance.

What the mathematics does not license

Near-singularity harms computation. The habit of checking assumptions is one of the practical benefits of learning mathematics.

Try it, check it, transfer it

Check eigenvalues. 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. Constrained likelihood

A small example makes the mechanism visible. Maximum likelihood estimates spatial and mixture parameters while enforcing V at or above zero.

A concrete situation

A multiplicative update preserves nonnegativity.

What the mathematics does not license

Optimization can depend on starts. The same reasoning helps students move from an exercise to a real dataset.

Try it, check it, transfer it

Repeat and check convergence. 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. Worked line of spots

This is where modelling choices begin to affect evidence. Use three locations on a line to calculate W, one conditional mean and an updated composition.

A concrete situation

The middle spot averages its two neighbours before its residual.

What the mathematics does not license

Real tissue is not a line. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Add irregular spacing. 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-free mode

The central mathematical idea is concrete. When a reference is unavailable, shared spatial and expression structure can support a different factorization workflow.

A concrete situation

Latent factors recover broad compartments.

What the mathematics does not license

Factors are not automatically named cell types. The habit of checking assumptions is one of the practical benefits of learning mathematics.

Try it, check it, transfer it

Validate labels independently. 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. Resolution enhancement

Here the geometry becomes operational. Predict compositions and expression at finer coordinates from the fitted spatial model.

A concrete situation

One measured spot becomes a grid of estimated locations.

What the mathematics does not license

No new counts were observed. The same reasoning helps students move from an exercise to a real dataset.

Try it, check it, transfer it

Report interpolation uncertainty. 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 B, X, W, phi, constraints, starts and prediction grid in a reproducible record.

A concrete situation

A student traces one boundary through W and its effect.

What the mathematics does not license

Smoothness is not truth. That distinction matters because a correct formula can still answer the wrong operational question.

Try it, check it, transfer it

Write a spatial-model 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

  1. Day 1: define the decision, observation unit, X variables and Y or reference condition.
  2. Day 2: reproduce the smallest worked example and check every dimension, unit and sign.
  3. Day 3: build a transparent baseline and write what it assumes.
  4. Day 4: fit the main method inside a training-only pipeline; record every parameter.
  5. Day 5: challenge one assumption with a deliberately difficult dataset or operating regime.
  6. Day 6: compare validation metrics with the practical workload created by errors.
  7. 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

CARD represents the spatial expression matrix as a product of a cell-type expression basis and a nonnegative composition matrix, plus residual noise. It then adds a conditional autoregressive model: nearby locations are expected, but never forced, to have related proportions. A spatial weight matrix states which locations count as neighbours and how strongly they are connected.

The spatial parameter controls borrowing across locations. When it is near zero, the model behaves more like an ordinary nonnegative deconvolution. Larger values allow neighbouring evidence to stabilize sparse spots. The same fitted spatial structure can support interpolation at unmeasured coordinates, but higher visual resolution does not create new measurements.

Validation requires more than a smooth map. Check known mixtures, tissue-boundary errors, alternative distance kernels, reference mismatch, leave-one-section-out prediction and comparison with histology. Enhanced-resolution values are conditional estimates from the basis, covariance model and observed spots; report their uncertainty and avoid describing them as directly sequenced subspots.


Frequently asked questions

What is CARD?

CARD is a spatially informed deconvolution method that estimates cell-type composition by combining a reference expression basis with correlation among nearby spatial locations.

What is conditional autoregression?

A CAR model expresses a location value conditionally around a baseline plus a weighted average of neighbouring deviations, with residual variance controlling local departure.

What is the neighbour matrix?

It is a matrix W whose entries encode which locations are neighbours and often how influence decays with distance. Different W choices express different spatial assumptions.

Why require nonnegative proportions?

Negative cell abundance has no additive mixture interpretation. Nonnegative constraints keep estimates within a physically meaningful direction before normalization.

How does resolution enhancement work?

CARD uses fitted spatial covariance and observed compositions to predict at unmeasured coordinates. These values are interpolated estimates, not new sequence measurements.

Can spatial smoothing erase boundaries?

Yes. Strong autocorrelation or an unsuitable neighbour graph can borrow across a real tissue border. Boundary-aware validation and alternative kernels are essential.


Primary source and fact-check note

Ying Ma and Xiang Zhou, “Spatially informed cell-type deconvolution for spatial transcriptomics,” Nature Biotechnology 40, 1349–1359 (2022), DOI 10.1038/s41587-022-01273-7. 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

Basis audit

Check reference basis, labels and gene overlap.

Graph audit

Overlay neighbour edges and distance weights on tissue.

Phi audit

Profile spatial autocorrelation and boundary behaviour.

Constraint audit

Verify nonnegativity and convergence.

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.

Kernel challenge

Repeat with alternative distance scales.

Section holdout

Predict complete sections or regions.

Enhancement audit

Label fine-grid values as interpolation.

Final claim

Higher resolution is conditional inference, not extra counts.

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: Spatial expression matrix

Begin with this mechanism: Genes by measured locations form X after declared normalization. Work through the concrete case: Four thousand genes are measured at 1,500 spots. Make the limitation visible: Normalization affects residual assumptions. Complete the evidence step: Record units and filtering. 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: Reference basis B

Begin with this mechanism: A gene-by-cell-type matrix summarizes expected expression for K types. Work through the concrete case: B has 4,000 rows and 12 type columns. Make the limitation visible: Reference mismatch shifts proportions. Complete the evidence step: Swap donors and atlases. 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: Composition matrix V

Begin with this mechanism: Each location receives K nonnegative cell-type composition values. Work through the concrete case: A spot has epithelial, fibroblast and immune entries. Make the limitation visible: Scale and normalization must be defined. Complete the evidence step: Preserve raw and normalized values. 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: Matrix product

Begin with this mechanism: The biological mean is B times V transpose. Work through the concrete case: A 4000 by 12 basis times 12 by 1500 proportions reproduces X dimensions. Make the limitation visible: Collinear columns reduce identifiability. Complete the evidence step: Measure condition numbers. 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: Gaussian residual model

Begin with this mechanism: Residual expression is modeled around the matrix-product mean with variance parameters. Work through the concrete case: One gene deviates moderately from its fitted mixture. Make the limitation visible: Heavy tails can affect estimates. Complete the evidence step: Inspect quantile residuals. 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: Neighbour graph

Begin with this mechanism: Coordinates define edges among nearby spots or locations. Work through the concrete case: Six hexagonal neighbours surround an interior Visium spot. Make the limitation visible: Distance alone may cross barriers. Complete the evidence step: Overlay edges on histology. 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 matrix W

Begin with this mechanism: Entries W_ij quantify influence from location j to i, commonly from distance. Work through the concrete case: Closer spots receive larger weights. Make the limitation visible: Kernel scale changes smoothing. Complete the evidence step: Compare plausible kernels. 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: CAR conditional mean

Begin with this mechanism: A composition is centered on a type baseline plus phi times weighted neighbouring deviations. Work through the concrete case: A fibroblast-rich spot is expected near fibroblast-rich neighbours. Make the limitation visible: Neighbour agreement is prior structure. Complete the evidence step: Check boundaries separately. 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: Autocorrelation phi

Begin with this mechanism: Phi controls how strongly locations borrow composition information. Work through the concrete case: Phi near zero gives little spatial borrowing. Make the limitation visible: Large phi can over-smooth. Complete the evidence step: Profile likelihood and sensitivity. 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: Conditional variance

Begin with this mechanism: Residual spatial variance allows each spot to differ from its neighbours. Work through the concrete case: A small variance makes isolated jumps surprising. Make the limitation visible: One variance may not fit all regions. Complete the evidence step: Map standardized deviations. 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: Multivariate covariance

Begin with this mechanism: The CAR conditionals imply a joint multivariate normal distribution over locations. Work through the concrete case: Matrix inversion links W and phi to covariance. Make the limitation visible: Near-singularity harms computation. Complete the evidence step: Check eigenvalues. 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: Constrained likelihood

Begin with this mechanism: Maximum likelihood estimates spatial and mixture parameters while enforcing V at or above zero. Work through the concrete case: A multiplicative update preserves nonnegativity. Make the limitation visible: Optimization can depend on starts. Complete the evidence step: Repeat and check convergence. 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: Worked line of spots

Begin with this mechanism: Use three locations on a line to calculate W, one conditional mean and an updated composition. Work through the concrete case: The middle spot averages its two neighbours before its residual. Make the limitation visible: Real tissue is not a line. Complete the evidence step: Add irregular spacing. 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-free mode

Begin with this mechanism: When a reference is unavailable, shared spatial and expression structure can support a different factorization workflow. Work through the concrete case: Latent factors recover broad compartments. Make the limitation visible: Factors are not automatically named cell types. Complete the evidence step: Validate labels independently. 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: Resolution enhancement

Begin with this mechanism: Predict compositions and expression at finer coordinates from the fitted spatial model. Work through the concrete case: One measured spot becomes a grid of estimated locations. Make the limitation visible: No new counts were observed. Complete the evidence step: Report interpolation uncertainty. 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 B, X, W, phi, constraints, starts and prediction grid in a reproducible record. Work through the concrete case: A student traces one boundary through W and its effect. Make the limitation visible: Smoothness is not truth. Complete the evidence step: Write a spatial-model 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.