A patient's bone marrow is measured one cell at a time, and the report is the fraction of cells in each of six populations. Can every cell be reduced to one of 8 categories, chosen once on reference patients, and still give the composition of patients the categories never saw? On this benchmark it can: the counts estimate held-out compositions almost as well as the cells themselves, and an order of magnitude better than gating or clustering on the markers.
▸ marks the ten held-out patients, frozen before any fitting.
Each bar is one patient over the five target populations; the remaining compartment, about nine tenths of every patient, is left out so the variation is visible. That spread between patients is what an estimate has to resolve.
A category rule and a few integer counts per patient make a summary a laboratory can archive, audit and compare across instruments; a hundred thousand continuous classifier outputs do not. The question is what the compression costs. The cohort was split once, before anything was fitted, into twenty reference patients and 10 held-out patients. The categories and their calibration come from the reference patients only, and every error and retention on this page is measured on the held-out ones.
The 8 categories are fitted on the reference cells and frozen. Each held-out patient's cells are sorted into them, and a mixture fit turns the counts into six fractions; the expert labels only score the result.
T cells
B cells
monocytes
mast cells
HSPCs
Filled: fitted from the eight counts. Hollow: fitted from the unbinned classifier ratios. An estimate of exactly zero is drawn on the lower edge.
Every held-out patient and target population sits on the diagonal, from the mast cells near one part in ten thousand to the T cells near one in ten. Averaged over the five target populations, the root-mean-square error of the fitted fractions is 0.001929 from the counts, against 0.001728 when the classifier's continuous output for every cell goes into the same fit with no compression. The reason is simple: the categories were chosen to keep what a cell says about the composition, and the fit needs nothing else. Compression still costs a little, as it must, but far less than the spread between patients.
Near the reference composition, a category enters the information about the fractions through only two things: the share of cells it holds and the mean score of those cells, where a cell's score is the gradient of its log-likelihood with respect to the fractions. For categories b with weights Wb and mean scores μb, the information kept about the fractions and the information lost are exactly
What a category loses is the scatter of the scores inside it (user guide (opens in a new tab)). A rectangular gate on two marker axes, or a cluster of cells with similar marker vectors, groups cells by how they look, and cells that look alike in a few channels can say very different things about the composition. Such categories keep a large scatter, and with it they lose most of the information.
D exchange (compiled)
k-means on raw markers
One score direction
Normalized trace (k-means)
Soft Voronoi
Two-dimensional grid
Unbinned classifier ratio
Dashed lines are the conventional reductions, given the same reference cells and budget. At 8 categories, k-means on the twelve marker channels reaches an error of 0.028892, and a grid on the two leading principal components of the markers 0.083325. Cutting one score direction into intervals does little better. None closes the gap at any budget.
The population densities a score needs are unknown, so a classifier cross-fitted across the reference patients estimates them: its calibrated probabilities become density ratios, and the ratios become a five-coordinate score (the density-ratio walkthrough explains the step). Because the score is estimated, the library reports the information it carries as a surrogate, never as exact Fisher information; the unbinned fit of the second section is the check that the estimate is good.
import numpy as np
import scorequant as sq
from examples.cell_population import fit_binned_mixture, fit_unbinned_mixture
from examples.cell_population.likelihood import estimate_bin_templates
The weights make every reference patient count equally within a population, so no single patient's abundance sets the categories. DOptimality asks for categories that keep information about all five fractions at once, and fit_quantizer returns a rule, a map from a cell's score to a category, which is what lets it label the next patient rather than only the cells it was fitted on (user guide (opens in a new tab)).
A five-dimensional partition cannot be drawn, but each category can be described by the populations of the cells it collects.
Reference population composition of each learned bin, as probabilities that sum to one across a row.
Bin
T cells
B cells
monocytes
mast cells
HSPCs
other
bin 6
0.94
0.00
0.00
0.00
0.00
0.06
bin 1
0.01
0.86
0.01
0.00
0.01
0.11
bin 4
0.16
0.33
0.17
0.03
0.19
0.12
bin 2
0.15
0.31
0.15
0.08
0.18
0.13
bin 5
0.01
0.03
0.84
0.00
0.01
0.10
bin 3
0.02
0.04
0.02
0.00
0.78
0.14
bin 0
0.00
0.00
0.00
0.00
0.00
1.00
bin 7
0.06
0.12
0.06
0.01
0.31
0.45
Each row is one of the 8 learned categories; each entry is the probability that a cell in that category belongs to the column population, at the reference composition.
Six of the 8 categories act as gates, each dominated by one population, including one for the rare progenitors and one for the mast cells. The other two are mixed, and they are not a failure of the fit. They hold the cells the classifier is unsure about, and keeping them as their own counts is what lets the fit separate the populations the gates confuse.
The rule is applied to a separate set of labelled reference cells, which gives each category's probability under each population, and to the held-out cells, whose categories are counted per patient. The counts and that calibration table are the whole input to the mixture fit.
This code runs on a committed fixture-scale table, while the figures come from the full study on 600,000 cells. On the table the counts give 0.0090 against 0.0016 unbinned, because the calibration table is estimated from only 3,518 cells: at that size the calibration, not the categories, limits the fit. The classifier and the full study are in examples/cell_population.
There is a floor, and it is exact. Six fractions that sum to one have 5 free coordinates, and a fixed number of cells spread over B categories gives only B−1 independent counts. Five categories therefore give 4 independent counts for 5 unknowns, the fit has a flat direction whatever the categories are, and they keep only 0.3911 of the score's information on held-out cells. At 8 categories the curve reaches its knee, 0.9846. More categories keep slightly more, but the fractions get no better: each new category adds calibration entries to estimate from the same reference cells, and the smallest ones run empty for some patients.
A patient's composition does not need every cell. It needs the part of each cell that bears on the fractions, which is its score, and categories that group cells by score keep almost all of it in a handful of counts. Gates and clusters drawn on the markers group cells by appearance instead, and lose most of it at every budget. Because the categories were frozen before the held-out patients were touched, this is a statement about new patients, not about the cells the rule was fitted on. What no choice of categories can repair is the classifier behind the score: binning can only lose information, so the counts never carry more than the score they compress.