Predicting patient disease from single-cell data: pseudobulks, site shifts and ambient RNA
· 7 min read
If you want to predict a patient’s disease state from single-cell or single-nucleus RNA-seq data, your sample size is the number of donors, not the number of cells. Tens of thousands of cells still only give you a few dozen data points at the patient level.
That raises two practical questions that I wanted to test on a real multi-center heart atlas. First, once you split properly by donor, do neural models that read every cell (like DeepSets or Attention-MIL) actually beat a regularized linear model on per-cell-type averages plus cell-type proportions, especially on a held-out collection site? Second, in tissue like heart muscle, lysed cardiomyocytes dump huge amounts of NPPA, NPPB, MYH7 and TTN into the ambient suspension. If a model trained only on macrophages or endothelial cells predicts heart failure well, is it picking up real changes in those cells, or just reading cardiomyocyte soup?
The code and tests for everything below are on GitHub at sindriant/sc-disease-benchmark.
Splitting by cell vs. by donor
Each donor comes with their own baseline shift across genes from sample handling, post-mortem interval, batch effects and ambient background. If you split at the cell level, cells from the same person land in both train and test. Even when there is zero difference between cases and controls (), a classifier can get high test accuracy just by recognizing which donor a cell came from.
You can see how fast that happens on a small simulated cohort of 24 donors below:
On 8,000 nuclei subsampled from the dilated cardiomyopathy (DCM) atlas of Reichart et al. (2022), the same linear classifier gets 0.959 AUROC under a 5-fold cell split vs. 0.919 when folds are grouped by donor. Here the biological signal in heart failure is already very strong, so donor-split accuracy stays high; in weaker phenotypes, that gap is much wider.
Pseudobulks vs. cell-level models
To compare patient-level models head to head, I took up to 800 nuclei per donor across 79 donors (61 DCM and 18 non-failing controls, 63,200 nuclei in total, 2,000 highly variable genes) from Reichart et al. (2022) and fit four models:
- Pseudobulk + CLR proportions: log1p-CPM averages for six major lineages (
Cardiomyocyte,Endothelial,Fibroblast,Myeloid,Mural,Lymphoid) concatenated with centered log-ratio (CLR) cell-type proportions (12,006features), fit with L2-penalized logistic regression. - Global pseudobulk: a single
2,000-gene average per donor, ignoring cell types. - DeepSets: a small MLP encoder run on every cell and averaged across the donor’s bag of cells.
- Gated Attention-MIL (Ilse et al., 2018): the same cell encoder, but pooled with learned attention weights instead of a plain average.
In 5-fold donor cross-validation across the pooled dataset, everything gets 0.991 to 0.997 AUROC, so it looks like model choice barely matters. When you hold out whole collection centers instead (72 donors across 3 groups), Gated Attention-MIL drops to 0.893, while DeepSets gets 0.959 and the linear pseudobulk + proportions model gets 0.971. With ~60 training donors, learning which cells to attend to mostly gives the network another way to overfit to center-specific subpopulations, whereas plain averaging within known lineages holds up better.
The calibration metrics (Brier and ECE) show the flip side. Different centers collected very different ratios of failing to control hearts. Because the logistic regression used unweighted training prevalence in its intercept (while the neural models used inverse class weights and temperature scaling on a validation split), its raw probabilities are systematically shifted when a held-out site has a different case mix (0.151 ECE vs. 0.102 and 0.107 for the neural models), even though its ranking of patients is better.
Checking for ambient cardiomyocyte RNA
When heart tissue is dissociated or nuclei are isolated, abundant cardiomyocyte transcripts end up floating in the buffer and get captured alongside other cell types. If failing hearts shed much more NPPA and NPPB into that background soup than healthy hearts, a macrophage pseudobulk could separate cases from controls without macrophages changing much on their own.
To test that without leaking test labels, inside each donor training fold I ranked the top 50 and top 100 cardiomyocyte-enriched genes on the training cells only, then evaluated non-myocyte pseudobulks on the held-out donors in four ways:
- Unfiltered (
2,000genes). - Masking 50 random sets of 100 genes matched on expression level in that lineage.
- Subtracting an unsupervised per-channel soup profile estimated from the training-fold cardiomyocyte markers.
- Dropping the top 50 or top 100 cardiomyocyte genes altogether and re-normalizing the remaining counts.
Instead of dropping, held-out donor AUROC goes up when the cardiomyocyte markers are removed, especially in Myeloid cells (0.930 unfiltered to 0.961 after masking the top 100 cardiomyocyte genes, compared with 0.932 ± 0.004 for expression-matched random masks). At least in single-nucleus heart data, transcriptional remodeling in fibroblasts, endothelium and macrophages is strong enough on its own that leaked myocyte RNA mostly acts as extra noise diluting those genes after library-size normalization.
As a separate check on GSE288222 (12 left-ventricle samples, 6 non-diseased and 6 end-stage heart failure, leave-one-donor-out), high-UMI called nuclei (top 50% by UMI count) reach 0.917 AUROC, while the lowest-UMI called barcodes (bottom 15%) drop to 0.639.
Two bugs the unit tests caught
Writing synthetic tests before touching the heart data caught two numerical issues that would have quietly changed the conclusions:
The intercept in dual L2 logistic regression (): with features and training donors, running IRLS in dual space using is much faster than solving a system. Because the intercept is unpenalized, the dual vector has to satisfy at every Newton step. Solving
together and setting
matches the primal solution to . My first alternating update had a sign/offset bug on imbalanced labels (
77%cases) that tanked the12,006-feature model to0.65AUROC until I added a primal-vs-dual equivalence test.Clipping soup-subtracted counts per cell: if you subtract expected ambient counts one cell at a time with , Poisson noise around the mean gets clipped only on the negative side, leaving a positive remainder that still tracks : it is close to itself when is small and about when is large. Summing across the target lineage within each channel before clipping (the same idea as cluster-level adjustment in
SoupX) fixes this in Poisson null simulations.
Other info
- The
2,000highly variable genes were chosen once on the63,200-nucleus subset rather than re-selected inside each fold. - Where explicit collection-site metadata was missing, site groups came from donor-ID prefixes, and the logistic regression intercept was not recalibrated to each test site’s case/control prevalence.
- Ambient subtraction used the simple marker-ratio estimator in
estimators.py(max_rho = 0.35) rather than runningSoupXordecontXon raw unfiltered droplet matrices, and theGSE288222files on GEO only include already-called barcodes rather than15–80UMI empty droplets.