Benchmarking ML Methods for Cell-Type Classification in scRNA-Seq
From the publisher’s feed, collected in the ZeroLabs newsroom.
A controlled comparison of ten classifiers on peripheral blood mononuclear cells, with emphasis on class imbalance and rare cell-type recoveryPhoto by Cassi Josh on UnsplashAbstractAutomated cell-type annotation is a central task in single-cell RNA-sequencing (scRNA-seq) analysis, yet the choice of classification method and the handling of severe class imbalance are frequently treated as afterthoughts. This piece presents a controlled benchmark of ten ML classifiers — spanning linear models, kernel methods, tree ensembles, instance-based learning, and a neural network — on a canonical peripheral blood mononuclear cell (PBMC) dataset comprising 2,638 cells across eight annotated immune cell types with a 76:1 class imbalance ratio. Using stratified five-fold cross-validation and evaluating with accuracy, balanced accuracy, and macro-averaged F1, I find that (1) a class-weighted logistic regression achieves the strongest overall performance (macro F1 = 0.929), outperforming a multilayer perceptron and all tree ensembles; (2) raw accuracy substantially overstates model quality under imbalance, diverging from macro F1 by up to 0.18; (3) explicit class weighting improves rare-cell-type recovery dramatically, more than doubling the F1 score for the rarest population under a radial-basis-function support vector machine; and (4) k-NN classification collapses in the high-dimensional expression space, failing entirely to recover three of eight cell types. These results argue for imbalance-aware evaluation and simple, well-regularized linear models as strong baselines for scRNA-seq cell-type classification. All code and data are available on GitHub.1. IntroductionSingle-cell RNA-sequencing has transformed the study of cellular heterogeneity, enabling the transcriptomic profiling of individual cells across tissues, disease states, and developmental stages. A foundational step in nearly every scRNA-seq analysis pipeline is the assignment of each cell to a biological cell type. While manual annotation by domain experts remains common, it is labor-intensive, subjective, and difficult to scale to the millions of cells produced by modern atlas-scale studies. Automated cell-type classification — training a model to predict cell type from a cell’s gene expression profile — is therefore an increasingly important problem.A large number of machine learning methods have been applied to this task, ranging from simple linear classifiers to deep neural networks. Most recently, the field has moved toward large pretrained “foundation models” for single-cell data — such as scGPT (Cui et al., 2024) and scFoundation (Hao et al., 2024) — and even the direct application of general-purpose large language models to annotation (Hou & Ji, 2024). These approaches are powerful, but they are also computationally heavy, dependent on large-scale pretraining, and often difficult to interpret. Against this backdrop, it is worth asking how far simple, transparent classifiers can go on a well-defined annotation task — a question that motivates the controlled comparison presented here. However, comparisons across methods are frequently confounded by differences in preprocessing, feature selection, evaluation metrics, and datasets, making it difficult to draw clear conclusions about which methods work best and under what conditions. Moreover, scRNA-seq datasets are characterized by severe class imbalance: common cell types may be represented by thousands of cells, while rare but biologically important populations may appear only a handful of times. A classifier that performs well on aggregate accuracy may nonetheless fail entirely on rare cell types — precisely the populations that are often of greatest scientific interest.This paper presents a controlled benchmark that holds preprocessing, feature space, and evaluation protocol fixed while varying only the classification method. The goal is not to identify a single universally superior algorithm, but to characterize the trade-offs between method families, to quantify the effect of class-imbalance handling, and to demonstrate why evaluation metric choice is consequential in this setting. The benchmark is deliberately built on a small, well-characterized, publicly available dataset so that it is fully reproducible.2. Data and Methods2.1 DatasetThe benchmark uses the PBMC 3k dataset, a widely used reference dataset of peripheral blood mononuclear cells from a healthy donor, generated using 10x Genomics droplet-based sequencing. After standard quality-control filtering, the dataset comprises 2,638 cells. Cell-type labels were assigned via the standard Louvain-clustering-and-annotation workflow and treated here as ground truth for the classification task. Eight cell types are represented, with a pronounced class imbalance summarized in Table 1.Table 1. Cell-type composition of the PBMC 3k datasetThe imbalance ratio between the most and least common cell type is approximately 76:1. This is representative of real scRNA-seq experiments, where dominant cell populations coexist with rare but functionally significant subpopulations.A UMAP projection of the dataset colored by annotated cell type, showing well-separated clusters for most populations, partial overlap between CD4 andCD8 T cells, and a transcriptionally isolated Megakaryocyte island.2.2 Feature RepresentationEach cell is represented by its log-normalized, scaled expression profile across 1,838 highly variable genes, following standard scRNA-seq preprocessing. Highly variable gene selection reduces dimensionality while retaining the features most informative for distinguishing cell types. No further feature selection or dimensionality reduction (e.g., PCA) was applied prior to classification, so that all methods operate on an identical feature space.2.3 ClassifiersTen classifiers were evaluated, chosen to span the major families of supervised learning methods:Linear models: Logistic regression, with and without class weighting; linear-kernel support vector machine (SVM)Kernel methods: Radial-basis-function (RBF) kernel SVM, with and without class weightingTree ensembles: Random forest, with and without class weighting; histogram-based gradient boostingInstance-based: k-nearest neighbors (k = 15)Neural network: Multilayer perceptron (MLP) with two hidden layers (256 and 128 units) and early stoppingFor methods that support it, a class-weighted variant was included in which the loss contribution of each class is inversely proportional to its frequency. This allows direct measurement of the effect of imbalance-aware training within an otherwise identical model.2.4 Evaluation ProtocolAll models were evaluated using stratified five-fold cross-validation, preserving class proportions in each fold. Three complementary metrics were computed:Accuracy: the fraction of correctly classified cells. Under class imbalance, this metric is dominated by the most common classes.Balanced accuracy: the average of per-class recall, which weights each class equally regardless of size.Macro-averaged F1: the unweighted mean of per-class F1 scores, which penalizes poor performance on rare classes as heavily as on common ones.Per-class F1 scores and aggregated confusion matrices were also recorded to characterize where each method succeeds and fails. A fixed random seed (42) was used throughout to ensure reproducibility.3. Results3.1 Overall PerformanceTable 2 reports aggregate performance across all ten classifiers, ordered by macro F1. A class-weighted logistic regression achieved the highest macro F1 (0.929) and balanced accuracy (0.916), narrowly ahead of a linear-kernel SVM (macro F1 = 0.926) and standard logistic regression (0.915). Notably, these simple linear models outperformed both the multilayer perceptron (macro F1 = 0.868) and all tree-ensemble methods.Table 2. Classifier performance (5-fold stratified cross-validation)The strong performance of linear models is consistent with the structure of the problem: with 1,838 features and 2,638 cells, the data is high-dimensional relative to the sample size, a regime in which well-regularized linear classifiers are known to be difficult to beat. The class-weighted logistic regression also happens to be the fastest of the competitive models, training in roughly one second — over 250 times faster than histogram gradient boosting for equivalent or better performance.3.2 Accuracy Overstates Performance Under ImbalanceA central finding is that raw accuracy is a misleading metric in this setting. The RBF SVM, for example, achieves 93.1% accuracy — superficially competitive — yet its macro F1 is only 0.753, a gap of 0.18. This divergence arises because accuracy is dominated by the most common classes: a model can score highly by classifying the abundant CD4 T cells and monocytes correctly while failing on rare populations. Balanced accuracy and macro F1, which weight all classes equally, expose this failure.The gap between accuracy and macro F1 is itself informative: it is small for the imbalance-aware linear models (0.02–0.03) and large for methods that neglect rare classes (0.18 for the unweighted RBF SVM). Reporting accuracy alone would rank the RBF SVM as roughly comparable to the top models; reporting macro F1 reveals it to be substantially worse.3.3 Class Weighting Improves Rare-Cell-Type RecoveryThe effect of explicit class weighting is most visible on the rarest cell types. Table 3 reports per-class F1 for the two rarest populations — Dendritic cells (37 cells) and Megakaryocytes (15 cells) — with and without class weighting, for the models that support it.Table 3. Effect of class weighting on rare-cell-type F1For the RBF SVM, class weighting improves the Dendritic cell F1 fourfold (0.13 to 0.52) and the Megakaryocyte F1 from 0.40 to 0.66. The effect is present but smaller for logistic regression, which already handles the rare classes well. In every case, class weighting improves rare-cell-type performance without materially degrading performance on common classes — a favorable trade-off that argues for enabling it by default in imbalanced scRNA-seq classification.3.4 k-Nearest-Neighbors Collapses in High DimensionsThe most dramatic failure is that of k-nearest-neighbors, which achieves a macro F1 of only 0.251. Per-class analysis reveals that k-NN fails entirely — an F1 of 0.00 — on NK cells, FCGR3A+ Monocytes, and Dendritic cells, and performs poorly even on some common classes. This is a textbook manifestation of the curse of dimensionality: in the 1,838-dimensional expression space, Euclidean distances between cells become poorly discriminative, and the majority vote among neighbors collapses onto the most common classes. The result is a stark reminder that distance-based methods require dimensionality reduction to be viable in this domain, whereas the linear and kernel methods operate directly on the full feature space without difficulty.Per-class F1 for every model, with cell types ordered common → rare. Exposes where each method succeeds and fails.Per-class F1 against class size on a log scale, with per-class means and a fitted trend (r ≈ 0.27). Illustrates that rarity contributes to but does not fully determine difficulty.3.5 Where Errors OccurThe confusion matrix for the best model (class-weighted logistic regression) shows that residual errors are concentrated in biologically plausible confusions: CD4 and CD8 T cells are occasionally confused with one another, reflecting their transcriptomic similarity, and the two monocyte populations (CD14+ and FCGR3A+) are the next most common source of error. These are precisely the distinctions that are subtle even for expert human annotators, suggesting the classifier’s errors track genuine biological ambiguity rather than arbitrary mistakes.Row-normalized confusion matrix for the best model, aggregated over folds. Off-diagonal errors fall along biologically expected boundaries (CD4/CD8 T cells; the two monocyte subsets).4. Discussion4.1 Implications for PracticeThree practical recommendations follow from these results. First, simple linear models are strong baselines for scRNA-seq cell-type classification and should be evaluated before reaching for more complex methods; here, a one-second logistic regression outperformed a neural network and a gradient-boosting model that took nearly six minutes to train. Second, class weighting should be enabled by default given its consistent improvement in rare-cell-type recovery at negligible cost to common-class performance. Third, evaluation must be imbalance-aware: reporting accuracy alone would have led to materially wrong conclusions about relative model quality, and macro F1 or balanced accuracy should be reported alongside or instead of accuracy.4.2 LimitationsThis benchmark is deliberately scoped to a single, small, well-characterized dataset to maximize reproducibility, and its conclusions should be interpreted with that scope in mind. The labels used as ground truth are themselves derived from an unsupervised clustering-and-annotation workflow rather than orthogonal experimental validation, so the task is more precisely described as recovering expert cluster annotations than recovering absolute biological truth. The dataset also derives from a single healthy donor; performance on larger, multi-donor, or diseased-tissue datasets — where batch effects and continuous cell-state gradients complicate classification — may differ. Finally, the neural network explored here is a modest multilayer perceptron; larger or specialized architectures might perform differently, though the high-dimension-low-sample regime generally favors simpler models.4.3 ExtensionsSeveral extensions would strengthen and generalize these findings: evaluation across multiple datasets and tissues; incorporation of a dimensionality-reduction step (e.g., PCA) to test whether it rescues distance-based methods such as k-NN; assessment of specialized scRNA-seq classifiers that incorporate marker-gene priors; and evaluation of cross-dataset generalization, in which a model trained on one dataset is applied to another. A particularly interesting comparison would place these lightweight baselines against recent single-cell foundation models (Cui et al., 2024; Hao et al., 2024) on the same task and dataset, quantifying how much — if any — accuracy is gained for the substantial additional computational cost. The benchmark framework provided here is designed to accommodate such extensions with minimal modification.5. ConclusionAutomated cell-type classification is a routine but consequential step in single-cell analysis, and the choice of method and evaluation protocol materially affects results. This controlled benchmark of ten classifiers on a canonical PBMC dataset shows that well-regularized linear models — particularly class-weighted logistic regression — provide an excellent combination of accuracy, rare-cell-type recovery, and computational efficiency, outperforming both neural networks and tree ensembles in this high-dimensional, imbalanced, low-sample regime. It further demonstrates that accuracy alone is a misleading metric under class imbalance, that explicit class weighting substantially improves rare-cell-type recovery, and that distance-based methods fail without dimensionality reduction. These findings argue for simple, imbalance-aware baselines and imbalance-aware evaluation as the default starting point for scRNA-seq cell-type classification.All code, data, and figures are available on GitHub, and the full benchmark is reproducible in a few minutes.ReferencesAbdelaal, T., Michielsen, L., Cats, D., Hoogduin, D., Mei, H., Reinders, M. J. T., & Mahfouz, A. (2019). A comparison of automatic cell identification methods for single-cell RNA sequencing data. Genome Biology, 20(1), 194.Cui, H., Wang, C., Maan, H., Pang, K., Luo, F., Duan, N., & Wang, B. (2024). scGPT: toward building a foundation model for single-cell multi-omics using generative AI. Nature Methods, 21(8), 1470–1480.Hao, M., Gong, J., Zeng, X., Liu, C., Guo, Y., Cheng, X., Wang, T., Ma, J., Zhang, X., & Song, L. (2024). Large-scale foundation model on single-cell transcriptomics. Nature Methods, 21(8), 1481–1491.Hou, W., & Ji, Z. (2024). Assessing GPT-4 for cell type annotation in single-cell RNA-seq analysis. Nature Methods, 21(8), 1462–1465.Luecken, M. D., & Theis, F. J. (2019). Current best practices in single-cell RNA-seq analysis: a tutorial. Molecular Systems Biology, 15(6), e8746.Pedregosa, F., et al. (2011). Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12, 2825–2830.Wolf, F. A., Angerer, P., & Theis, F. J. (2018). SCANPY: large-scale single-cell gene expression data analysis. Genome Biology, 19(1), 15.Zheng, G. X. Y., et al. (2017). Massively parallel digital transcriptional profiling of single cells. Nature Communications, 8, 14049.Benchmarking ML Methods for Cell-Type Classification in scRNA-Seq was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.