Bone-marrow cell populations

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.

1. A patient's composition​

Flow cytometry passes cells one by one through a laser and records two scatter intensities and one fluorescence intensity per marker: twelve numbers per cell here. In the FlowCyt benchmark (© Bini, Nassajian Mojarrad, Liarou, Matthes, Marchand-Maillet (CHIL 2024), licensed CC-BY-NC-SA-4.0, from its source repository) an expert has labelled every cell of thirty bone-marrow aspirates as one of six populations: T cells, B cells, monocytes, mast cells, the CD34-positive progenitors (HSPCs), and everything else. A report states the composition, the fraction of a patient's cells in each population.

Cell-population composition of every patientOne stacked bar per patient, split into the five target populations at their true fractions; the dominant remaining compartment is left out. Held-out patients are marked; reference patients are not.Case 1Case 1 — T cells: 12.2%Case 1 — B cells: 2.2%Case 1 — monocytes: 2.3%Case 1 — mast cells: 0.0%Case 1 — HSPCs: 0.7%Case 2Case 2 — T cells: 2.9%Case 2 — B cells: 1.1%Case 2 — monocytes: 2.2%Case 2 — mast cells: 0.0%Case 2 — HSPCs: 1.8%Case 3Case 3 — T cells: 8.5%Case 3 — B cells: 2.3%Case 3 — monocytes: 1.5%Case 3 — mast cells: 0.0%Case 3 — HSPCs: 2.2%Case 4Case 4 — T cells: 7.2%Case 4 — B cells: 1.2%Case 4 — monocytes: 2.7%Case 4 — mast cells: 0.0%Case 4 — HSPCs: 1.1%▸ Case 5Case 5 — T cells: 5.2%Case 5 — B cells: 1.0%Case 5 — monocytes: 2.7%Case 5 — mast cells: 0.0%Case 5 — HSPCs: 1.8%▸ Case 6Case 6 — T cells: 2.7%Case 6 — B cells: 0.5%Case 6 — monocytes: 3.1%Case 6 — mast cells: 0.0%Case 6 — HSPCs: 1.4%Case 7Case 7 — T cells: 6.3%Case 7 — B cells: 0.8%Case 7 — monocytes: 0.5%Case 7 — mast cells: 0.0%Case 7 — HSPCs: 0.8%▸ Case 8Case 8 — T cells: 3.1%Case 8 — B cells: 1.1%Case 8 — monocytes: 0.3%Case 8 — mast cells: 0.0%Case 8 — HSPCs: 0.4%▸ Case 9Case 9 — T cells: 2.7%Case 9 — B cells: 0.0%Case 9 — monocytes: 0.9%Case 9 — mast cells: 0.0%Case 9 — HSPCs: 1.8%Case 10Case 10 — T cells: 12.9%Case 10 — B cells: 9.0%Case 10 — monocytes: 0.7%Case 10 — mast cells: 0.0%Case 10 — HSPCs: 0.1%▸ Case 11Case 11 — T cells: 2.9%Case 11 — B cells: 0.5%Case 11 — monocytes: 3.4%Case 11 — mast cells: 0.0%Case 11 — HSPCs: 1.6%Case 12Case 12 — T cells: 3.9%Case 12 — B cells: 0.3%Case 12 — monocytes: 1.0%Case 12 — mast cells: 0.0%Case 12 — HSPCs: 0.1%Case 13Case 13 — T cells: 5.5%Case 13 — B cells: 0.9%Case 13 — monocytes: 2.0%Case 13 — mast cells: 0.1%Case 13 — HSPCs: 0.6%Case 14Case 14 — T cells: 5.0%Case 14 — B cells: 1.3%Case 14 — monocytes: 0.6%Case 14 — mast cells: 0.0%Case 14 — HSPCs: 0.4%▸ Case 15Case 15 — T cells: 9.3%Case 15 — B cells: 1.3%Case 15 — monocytes: 1.2%Case 15 — mast cells: 0.0%Case 15 — HSPCs: 0.5%Case 16Case 16 — T cells: 17.3%Case 16 — B cells: 5.0%Case 16 — monocytes: 1.9%Case 16 — mast cells: 0.0%Case 16 — HSPCs: 0.9%Case 17Case 17 — T cells: 3.8%Case 17 — B cells: 4.0%Case 17 — monocytes: 2.1%Case 17 — mast cells: 0.0%Case 17 — HSPCs: 1.1%Case 18Case 18 — T cells: 6.3%Case 18 — B cells: 0.7%Case 18 — monocytes: 1.3%Case 18 — mast cells: 0.0%Case 18 — HSPCs: 0.8%Case 19Case 19 — T cells: 3.0%Case 19 — B cells: 0.8%Case 19 — monocytes: 0.6%Case 19 — mast cells: 0.0%Case 19 — HSPCs: 0.2%▸ Case 20Case 20 — T cells: 7.6%Case 20 — B cells: 0.6%Case 20 — monocytes: 0.9%Case 20 — mast cells: 0.0%Case 20 — HSPCs: 0.8%Case 21Case 21 — T cells: 5.6%Case 21 — B cells: 1.4%Case 21 — monocytes: 0.8%Case 21 — mast cells: 0.0%Case 21 — HSPCs: 0.9%Case 22Case 22 — T cells: 4.7%Case 22 — B cells: 1.6%Case 22 — monocytes: 0.6%Case 22 — mast cells: 0.0%Case 22 — HSPCs: 0.6%▸ Case 23Case 23 — T cells: 5.7%Case 23 — B cells: 1.5%Case 23 — monocytes: 0.9%Case 23 — mast cells: 0.1%Case 23 — HSPCs: 0.9%Case 24Case 24 — T cells: 11.1%Case 24 — B cells: 0.6%Case 24 — monocytes: 1.1%Case 24 — mast cells: 0.0%Case 24 — HSPCs: 0.6%Case 25Case 25 — T cells: 3.7%Case 25 — B cells: 0.1%Case 25 — monocytes: 1.1%Case 25 — mast cells: 0.0%Case 25 — HSPCs: 0.4%Case 26Case 26 — T cells: 13.6%Case 26 — B cells: 0.3%Case 26 — monocytes: 5.2%Case 26 — mast cells: 0.1%Case 26 — HSPCs: 2.0%Case 27Case 27 — T cells: 3.9%Case 27 — B cells: 5.4%Case 27 — monocytes: 1.0%Case 27 — mast cells: 0.0%Case 27 — HSPCs: 0.4%▸ Case 28Case 28 — T cells: 3.0%Case 28 — B cells: 0.0%Case 28 — monocytes: 1.3%Case 28 — mast cells: 0.0%Case 28 — HSPCs: 0.8%Case 29Case 29 — T cells: 5.0%Case 29 — B cells: 0.3%Case 29 — monocytes: 0.6%Case 29 — mast cells: 0.0%Case 29 — HSPCs: 0.5%▸ Case 30Case 30 — T cells: 9.2%Case 30 — B cells: 0.1%Case 30 — monocytes: 0.6%Case 30 — mast cells: 0.0%Case 30 — HSPCs: 2.3%
  • T cells
  • B cells
  • monocytes
  • mast cells
  • HSPCs
▸ 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.

2. The counts recover the composition​

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.

Estimated against expert population fractions for the held-out patientsLog-log scatter of the fitted fraction of each population against the expert composition, one mark per held-out patient and population. Filled marks are the estimates from the bin counts; hollow marks are the unbinned classifier-ratio estimates. The diagonal is perfect agreement.Case 5, T cells: expert 0.0522, from counts 0.0486Case 5, T cells: expert 0.0522, unbinned 0.0519Case 5, B cells: expert 0.0098, from counts 0.0085Case 5, B cells: expert 0.0098, unbinned 0.0095Case 5, monocytes: expert 0.0273, from counts 0.0285Case 5, monocytes: expert 0.0273, unbinned 0.0278Case 5, mast cells: expert 0.0001, from counts 0.0000Case 5, mast cells: expert 0.0001, unbinned 0.0001Case 5, HSPCs: expert 0.0181, from counts 0.0189Case 5, HSPCs: expert 0.0181, unbinned 0.0178Case 6, T cells: expert 0.0274, from counts 0.0232Case 6, T cells: expert 0.0274, unbinned 0.0269Case 6, B cells: expert 0.0049, from counts 0.0056Case 6, B cells: expert 0.0049, unbinned 0.0064Case 6, monocytes: expert 0.0307, from counts 0.0284Case 6, monocytes: expert 0.0307, unbinned 0.0277Case 6, mast cells: expert 0.0001, from counts 0.0000Case 6, mast cells: expert 0.0001, unbinned 0.0001Case 6, HSPCs: expert 0.0144, from counts 0.0144Case 6, HSPCs: expert 0.0144, unbinned 0.0136Case 8, T cells: expert 0.0306, from counts 0.0268Case 8, T cells: expert 0.0306, unbinned 0.0288Case 8, B cells: expert 0.0109, from counts 0.0104Case 8, B cells: expert 0.0109, unbinned 0.0106Case 8, monocytes: expert 0.0031, from counts 0.0009Case 8, monocytes: expert 0.0031, unbinned 0.0026Case 8, mast cells: expert 0.0001, from counts 0.0000Case 8, mast cells: expert 0.0001, unbinned 0.0000Case 8, HSPCs: expert 0.0040, from counts 0.0027Case 8, HSPCs: expert 0.0040, unbinned 0.0033Case 9, T cells: expert 0.0269, from counts 0.0226Case 9, T cells: expert 0.0269, unbinned 0.0225Case 9, B cells: expert 0.0003, from counts 0.0000Case 9, B cells: expert 0.0003, unbinned 0.0000Case 9, monocytes: expert 0.0088, from counts 0.0088Case 9, monocytes: expert 0.0088, unbinned 0.0091Case 9, mast cells: expert 0.0001, from counts 0.0000Case 9, mast cells: expert 0.0001, unbinned 0.0000Case 9, HSPCs: expert 0.0175, from counts 0.0148Case 9, HSPCs: expert 0.0175, unbinned 0.0137Case 11, T cells: expert 0.0285, from counts 0.0250Case 11, T cells: expert 0.0285, unbinned 0.0262Case 11, B cells: expert 0.0053, from counts 0.0037Case 11, B cells: expert 0.0053, unbinned 0.0050Case 11, monocytes: expert 0.0340, from counts 0.0370Case 11, monocytes: expert 0.0340, unbinned 0.0348Case 11, mast cells: expert 0.0001, from counts 0.0000Case 11, mast cells: expert 0.0001, unbinned 0.0000Case 11, HSPCs: expert 0.0158, from counts 0.0116Case 11, HSPCs: expert 0.0158, unbinned 0.0111Case 15, T cells: expert 0.0934, from counts 0.0948Case 15, T cells: expert 0.0934, unbinned 0.0956Case 15, B cells: expert 0.0134, from counts 0.0114Case 15, B cells: expert 0.0134, unbinned 0.0120Case 15, monocytes: expert 0.0123, from counts 0.0118Case 15, monocytes: expert 0.0123, unbinned 0.0122Case 15, mast cells: expert 0.0001, from counts 0.0000Case 15, mast cells: expert 0.0001, unbinned 0.0000Case 15, HSPCs: expert 0.0046, from counts 0.0032Case 15, HSPCs: expert 0.0046, unbinned 0.0038Case 20, T cells: expert 0.0757, from counts 0.0710Case 20, T cells: expert 0.0757, unbinned 0.0715Case 20, B cells: expert 0.0062, from counts 0.0048Case 20, B cells: expert 0.0062, unbinned 0.0051Case 20, monocytes: expert 0.0086, from counts 0.0080Case 20, monocytes: expert 0.0086, unbinned 0.0087Case 20, mast cells: expert 0.0001, from counts 0.0000Case 20, mast cells: expert 0.0001, unbinned 0.0000Case 20, HSPCs: expert 0.0078, from counts 0.0094Case 20, HSPCs: expert 0.0078, unbinned 0.0092Case 23, T cells: expert 0.0570, from counts 0.0541Case 23, T cells: expert 0.0570, unbinned 0.0567Case 23, B cells: expert 0.0154, from counts 0.0161Case 23, B cells: expert 0.0154, unbinned 0.0157Case 23, monocytes: expert 0.0086, from counts 0.0070Case 23, monocytes: expert 0.0086, unbinned 0.0081Case 23, mast cells: expert 0.0015, from counts 0.0007Case 23, mast cells: expert 0.0015, unbinned 0.0014Case 23, HSPCs: expert 0.0089, from counts 0.0083Case 23, HSPCs: expert 0.0089, unbinned 0.0084Case 28, T cells: expert 0.0303, from counts 0.0303Case 28, T cells: expert 0.0303, unbinned 0.0307Case 28, B cells: expert 0.0001, from counts 0.0000Case 28, B cells: expert 0.0001, unbinned 0.0000Case 28, monocytes: expert 0.0132, from counts 0.0137Case 28, monocytes: expert 0.0132, unbinned 0.0138Case 28, mast cells: expert 0.0001, from counts 0.0000Case 28, mast cells: expert 0.0001, unbinned 0.0001Case 28, HSPCs: expert 0.0084, from counts 0.0037Case 28, HSPCs: expert 0.0084, unbinned 0.0038Case 30, T cells: expert 0.0918, from counts 0.0831Case 30, T cells: expert 0.0918, unbinned 0.0810Case 30, B cells: expert 0.0008, from counts 0.0000Case 30, B cells: expert 0.0008, unbinned 0.0010Case 30, monocytes: expert 0.0058, from counts 0.0046Case 30, monocytes: expert 0.0058, unbinned 0.0049Case 30, mast cells: expert 0.0001, from counts 0.0000Case 30, mast cells: expert 0.0001, unbinned 0.0000Case 30, HSPCs: expert 0.0227, from counts 0.0223Case 30, HSPCs: expert 0.0227, unbinned 0.0202
  • 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.

3. Why gates and clusters fall short​

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 bb with weights WbW_b and mean scores μb\mu_b, the information kept about the fractions and the information lost are exactly

Ibin=∑bWb μbμb⊤,I−Ibin=∑b∑i∈bwi (si−μb)(si−μb)⊤.I_{\mathrm{bin}}=\sum_b W_b\,\mu_b\mu_b^\top, \qquad I-I_{\mathrm{bin}}=\sum_b\sum_{i\in b} w_i\,(s_i-\mu_b)(s_i-\mu_b)^\top .

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.

Held-out macro RMSE against bin budget, by binning methodLower is better. ScoreQuant methods are drawn solid and coloured; convenience baselines are dashed and grey. The horizontal line is the unbinned classifier-ratio estimate.Unbinned classifier ratio
  • 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.

4. Categories drawn in score space​

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

table = np.load("examples/data/flowcyt_walkthrough.npz")
reference = sq.ScoreSample(
table["partition_scores"].astype(float),
table["partition_weights"],
schema=sq.ScoreSchema(tuple(str(name) for name in table["schema"])),
provenance=sq.ScoreProvenance(
kind="estimated_ratio",
description="patient-cross-fitted calibrated FlowCyt mixture score",
),
)

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)).

quantizer = sq.fit_quantizer(
reference,
n_bins=8,
criterion=sq.DOptimality(),
config=sq.SoftVoronoiConfig(seed=2026, initializer_restarts=4, max_iter=160),
)

5. What the categories are​

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.
BinT cellsB cellsmonocytesmast cellsHSPCsother
bin 60.940.000.000.000.000.06
bin 10.010.860.010.000.010.11
bin 40.160.330.170.030.190.12
bin 20.150.310.150.080.180.13
bin 50.010.030.840.000.010.10
bin 30.020.040.020.000.780.14
bin 00.000.000.000.000.001.00
bin 70.060.120.060.010.310.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.

6. Applying the frozen rule​

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.

templates = estimate_bin_templates(
table["template_labels"],
quantizer.predict_scores(table["template_scores"].astype(float)),
table["template_patients"],
n_bins=8,
)

held_out_patients = table["held_out_patients"]
held_out_bins = quantizer.predict_scores(table["held_out_scores"].astype(float))
patients = np.unique(held_out_patients)
masks = [held_out_patients == p for p in patients]

counts = [np.bincount(held_out_bins[m], minlength=8) for m in masks]
binned = np.array([fit_binned_mixture(c, templates).fractions for c in counts])
ratios = table["held_out_ratios"].astype(float)
unbinned = np.array([fit_unbinned_mixture(ratios[m]).fractions for m in masks])
expert = np.array([np.bincount(table["held_out_labels"][m], minlength=6) / m.sum() for m in masks])


def macro_rmse(estimate):
per_population = np.sqrt(np.mean((estimate - expert) ** 2, axis=0))
return float(np.mean(per_population[:5]))


binned_rmse, unbinned_rmse = macro_rmse(binned), macro_rmse(unbinned)

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.

7. How many categories​

Held-out D-efficiency against bin budget, by binning methodHigher is better, on a linear axis from zero to one. ScoreQuant methods are drawn solid and coloured; convenience baselines are dashed and grey.
  • D exchange (compiled)
  • k-means on raw markers
  • One score direction
  • Normalized trace (k-means)
  • Soft Voronoi
  • Two-dimensional grid

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 BB categories gives only B−1B-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.

8. What the result means​

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.