WHY MATHEMATICS?
Why Mathematics? | scClassify for Hierarchical Cell Typing: Weighted kNN, Ensemble Learning, Multiscale Trees and Multiple References
How scClassify combines a cell-type hierarchy with thirty weighted-neighbour classifiers at each branch, stops when finer evidence is weak and can learn jointly from several references.
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 multibranch hierarchy from reference labels
- Train diverse weighted-kNN classifiers at each node
- Weight and combine base predictions by training error
- Classify top-down, stop honestly and reconcile references
Chapter map
- 1. Why cell types form levels
- 2. HOPACH hierarchy
- 3. Branch-specific learning
- 4. Five gene-selection views
- 5. Six similarity metrics
- 6. Thirty base classifiers
- 7. Weighted nearest neighbours
- 8. Training-error ensemble weights
- 9. Top-down prediction
- 10. Intermediate and unassigned labels
- 11. Post hoc clustering of unassigned cells
- 12. Multiple-reference joint classification
- 13. Sample-size estimation
- 14. Held-out study validation
- 15. A student ensemble project
- 16. Governance and careers
Visit the How Mathematics Works hub for the wider series and its connections to education, reasoning, science, computing, design and careers.
1. Why cell types form levels
This is where modelling choices begin to affect evidence. Biological labels range from broad lineage to fine subtype. Evidence may support one level without the next.
A concrete situation
A cell is confidently lymphoid but uncertain T-cell subtype.
What the mathematics does not license
Flat labels hide partial correctness. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Draw the intended hierarchy. 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. HOPACH hierarchy
The central mathematical idea is concrete. Hierarchical ordered partitioning and collapsing hybrid can split a parent into multiple children.
A concrete situation
One immune parent divides into T, B and NK branches.
What the mathematics does not license
A data-driven tree may not equal ontology. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Compare tree and expert definitions. 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. Branch-specific learning
Here the geometry becomes operational. A separate classifier is trained at every branch using only its child labels.
A concrete situation
T-cell subtypes use different genes from root lineages.
What the mathematics does not license
Small branches have weak training data. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Record cells and classes per node. 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. Five gene-selection views
This step deserves a careful pause. Differential expression, variability, distribution, detection proportion and bimodality capture different discriminatory signals.
A concrete situation
One marker separates means; another separates detection frequency.
What the mathematics does not license
Selection tests add multiplicity and instability. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Repeat inside training folds. 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. Six similarity metrics
The useful question is not only how to calculate, but what the calculation assumes. Alternative measures compare query and reference cells under different geometric assumptions.
A concrete situation
Correlation and distance rank neighbours differently.
What the mathematics does not license
No metric is universally best. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Publish metric-specific performance. 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. Thirty base classifiers
A small example makes the mechanism visible. Crossing five gene rules with six metrics creates diverse weighted-kNN models.
A concrete situation
Different models succeed on different branches.
What the mathematics does not license
Highly correlated models add little diversity. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Measure disagreement and error. 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. Weighted nearest neighbours
This is where modelling choices begin to affect evidence. Closer reference cells receive more vote weight than farther members of the K-neighbour set.
A concrete situation
A query’s nearest subtype examples dominate its score.
What the mathematics does not license
Density and class imbalance affect neighbours. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Calculate Dudani-style 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.
8. Training-error ensemble weights
The central mathematical idea is concrete. Base predictions are combined using reliability learned from training performance.
A concrete situation
A strong branch model contributes more.
What the mathematics does not license
Training error can be optimistic. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Use internal validation and lock 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.
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. Top-down prediction
Here the geometry becomes operational. The query moves from the root through child decisions as long as each branch has adequate support.
A concrete situation
Lineage is chosen before subtype.
What the mathematics does not license
An early wrong turn blocks later recovery. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Report the full decision path. 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. Intermediate and unassigned labels
This step deserves a careful pause. When fine classification fails, the cell can retain a parent label or enter post hoc analysis.
A concrete situation
Unknown subtype remains T cell.
What the mathematics does not license
Stopping rules trade detail for error. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Plot depth against accuracy. 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. Post hoc clustering of unassigned cells
The useful question is not only how to calculate, but what the calculation assumes. Unassigned cells can be grouped to reveal repeated unsupported structure.
A concrete situation
A novel population forms a coherent cluster.
What the mathematics does not license
Clustering does not itself identify the group. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Inspect markers and donors. 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. Multiple-reference joint classification
A small example makes the mechanism visible. Each reference trains its own ensembles; predictions are weighted by reference performance.
A concrete situation
Pancreas references vote on a new study.
What the mathematics does not license
Shared biases can agree incorrectly. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Report each reference vote. 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. Sample-size estimation
This is where modelling choices begin to affect evidence. Learning curves estimate how many cells may be needed to classify nodes accurately.
A concrete situation
Rare subtypes require more examples.
What the mathematics does not license
Extrapolation depends on representative sampling. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Plot error versus training size. 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. Held-out study validation
The central mathematical idea is concrete. Complete datasets are reserved for final testing across technology and complexity.
A concrete situation
A new protocol tests transfer.
What the mathematics does not license
Random cells share technical structure. The habit of checking assumptions is one of the practical benefits of learning mathematics.
Try it, check it, transfer it
Choose tree and weights first. 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. A student ensemble project
Here the geometry becomes operational. Build a three-level tree and combine several weighted-kNN models using cross-validated error.
A concrete situation
Known classes reveal early and late mistakes.
What the mathematics does not license
Real data add many genes and references. The same reasoning helps students move from an exercise to a real dataset.
Try it, check it, transfer it
Compare flat and multiscale accuracy. 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 careers
This step deserves a careful pause. Version trees, genes, metrics, neighbours, weights, paths and stopping. Ensemble annotation joins statistics, biology and software.
A concrete situation
Students can begin with weighted votes.
What the mathematics does not license
A leaf label proves no function or diagnosis. That distinction matters because a correct formula can still answer the wrong operational question.
Try it, check it, transfer it
Write a hierarchy evidence 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
A scClassify audit starts with one or more annotated references and a query set. HOPACH builds a multibranch cell-type hierarchy. At every branch, 30 weighted-kNN base classifiers combine five gene-selection rules with six similarity metrics, and training error determines ensemble weights.
Record hierarchy construction, branch labels, gene sets, metrics, neighbour number, base-classifier errors, ensemble weights, intermediate labels, unassigned cells, sample-size estimates and multi-reference weights. Hierarchical prediction can stop above the leaves when finer evidence is weak.
Validate with donor- and study-held-out data, class-specific performance, hierarchy-aware error, reference disagreement, rare states, unassigned-cell clustering and sample-size curves. A multiscale result should communicate what level is supported rather than force maximum detail.
Frequently asked questions
What is multiscale classification?
It predicts from broad parent types toward finer subtypes and can stop at an intermediate node when the next decision lacks support.
Why use HOPACH?
It builds a hierarchy in which one parent may have more than two child groups, matching multibranch cell-type relationships.
What are the thirty base classifiers?
They are weighted-kNN models formed from five gene-selection methods crossed with six similarity metrics.
How are ensemble votes weighted?
Base classifiers receive weights from training performance, so more reliable combinations contribute more to the final branch decision.
How are multiple references used?
Separate ensembles are trained and their predictions are combined with reference-specific reliability weights.
How should scClassify be validated?
Use study-held-out data, hierarchy-aware errors, rare-state results, intermediate labels, reference disagreement and sample-size curves.
Primary source and fact-check note
Yingxin Lin, Shila Ghazanfar, Kevin Y. X. Wang et al., “scClassify: sample size estimation and multiscale classification of cells using single and multiple reference,” Molecular Systems Biology 16, e9389 (2020), DOI 10.15252/msb.20199389. 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
Tree audit
Compare the HOPACH tree with an external ontology and expert expectations. Preserve disagreements. A data-driven hierarchy is an analytical object, not a universal taxonomy.
Base-model ledger
Store each gene-selection rule, metric, neighbour set, training error and ensemble weight at every branch. This reveals whether a final label rests on broad agreement or one dominant model.
Neighbour-weight calculation
For selected queries, calculate distance-weighted votes explicitly and show how K changes the winning child. Density and class imbalance should remain visible.
Early-error challenge
Inject or identify one wrong root decision and trace the blocked downstream labels. Hierarchical accuracy must report path errors, not only leaf agreement.
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.
Intermediate-label policy
Plot coverage and error at each hierarchy depth. A useful system may return more parent labels to avoid unsupported subtype claims.
Multiple-reference disagreement
Publish every reference vote and reliability weight. Agreement across references strengthens evidence only when their errors and provenance are not shared.
Learning curve
Subsample training cells by biological replicate, not only random cells, and estimate performance versus size. Rare classes need separate curves and uncertainty.
Final claim
Name the tree, base models, weights, stopping rule, reference set and held-out performance by depth. A multiscale label communicates supported resolution without promising biological certainty.
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: Why cell types form levels
Start with the mechanism: Biological labels range from broad lineage to fine subtype. Evidence may support one level without the next. The worked case is concrete: A cell is confidently lymphoid but uncertain T-cell subtype. Expose the boundary: Flat labels hide partial correctness. Complete this evidence step: Draw the intended hierarchy. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 2: HOPACH hierarchy
Start with the mechanism: Hierarchical ordered partitioning and collapsing hybrid can split a parent into multiple children. The worked case is concrete: One immune parent divides into T, B and NK branches. Expose the boundary: A data-driven tree may not equal ontology. Complete this evidence step: Compare tree and expert definitions. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 3: Branch-specific learning
Start with the mechanism: A separate classifier is trained at every branch using only its child labels. The worked case is concrete: T-cell subtypes use different genes from root lineages. Expose the boundary: Small branches have weak training data. Complete this evidence step: Record cells and classes per node. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 4: Five gene-selection views
Start with the mechanism: Differential expression, variability, distribution, detection proportion and bimodality capture different discriminatory signals. The worked case is concrete: One marker separates means; another separates detection frequency. Expose the boundary: Selection tests add multiplicity and instability. Complete this evidence step: Repeat inside training folds. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion 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: Six similarity metrics
Start with the mechanism: Alternative measures compare query and reference cells under different geometric assumptions. The worked case is concrete: Correlation and distance rank neighbours differently. Expose the boundary: No metric is universally best. Complete this evidence step: Publish metric-specific performance. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 6: Thirty base classifiers
Start with the mechanism: Crossing five gene rules with six metrics creates diverse weighted-kNN models. The worked case is concrete: Different models succeed on different branches. Expose the boundary: Highly correlated models add little diversity. Complete this evidence step: Measure disagreement and error. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 7: Weighted nearest neighbours
Start with the mechanism: Closer reference cells receive more vote weight than farther members of the K-neighbour set. The worked case is concrete: A query’s nearest subtype examples dominate its score. Expose the boundary: Density and class imbalance affect neighbours. Complete this evidence step: Calculate Dudani-style weights. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 8: Training-error ensemble weights
Start with the mechanism: Base predictions are combined using reliability learned from training performance. The worked case is concrete: A strong branch model contributes more. Expose the boundary: Training error can be optimistic. Complete this evidence step: Use internal validation and lock weights. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion 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: Top-down prediction
Start with the mechanism: The query moves from the root through child decisions as long as each branch has adequate support. The worked case is concrete: Lineage is chosen before subtype. Expose the boundary: An early wrong turn blocks later recovery. Complete this evidence step: Report the full decision path. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 10: Intermediate and unassigned labels
Start with the mechanism: When fine classification fails, the cell can retain a parent label or enter post hoc analysis. The worked case is concrete: Unknown subtype remains T cell. Expose the boundary: Stopping rules trade detail for error. Complete this evidence step: Plot depth against accuracy. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 11: Post hoc clustering of unassigned cells
Start with the mechanism: Unassigned cells can be grouped to reveal repeated unsupported structure. The worked case is concrete: A novel population forms a coherent cluster. Expose the boundary: Clustering does not itself identify the group. Complete this evidence step: Inspect markers and donors. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 12: Multiple-reference joint classification
Start with the mechanism: Each reference trains its own ensembles; predictions are weighted by reference performance. The worked case is concrete: Pancreas references vote on a new study. Expose the boundary: Shared biases can agree incorrectly. Complete this evidence step: Report each reference vote. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion 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: Sample-size estimation
Start with the mechanism: Learning curves estimate how many cells may be needed to classify nodes accurately. The worked case is concrete: Rare subtypes require more examples. Expose the boundary: Extrapolation depends on representative sampling. Complete this evidence step: Plot error versus training size. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 14: Held-out study validation
Start with the mechanism: Complete datasets are reserved for final testing across technology and complexity. The worked case is concrete: A new protocol tests transfer. Expose the boundary: Random cells share technical structure. Complete this evidence step: Choose tree and weights first. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 15: A student ensemble project
Start with the mechanism: Build a three-level tree and combine several weighted-kNN models using cross-validated error. The worked case is concrete: Known classes reveal early and late mistakes. Expose the boundary: Real data add many genes and references. Complete this evidence step: Compare flat and multiscale accuracy. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.
Workshop 16: Governance and careers
Start with the mechanism: Version trees, genes, metrics, neighbours, weights, paths and stopping. Ensemble annotation joins statistics, biology and software. The worked case is concrete: Students can begin with weighted votes. Expose the boundary: A leaf label proves no function or diagnosis. Complete this evidence step: Write a hierarchy evidence card. Write inputs, the mathematical operation, expected output, uncertainty and one observation that would contradict the claim. Repeat under a nearby defensible setting and compare scores, neighbours, paths or labels. Use untouched donors, studies or simulated truth because random cells can share hidden structure with training data. Keep measurement, model estimate, interpretation and decision on separate notebook lines so the conclusion remains auditable.