Handling Batch Effects in Large-Scale scRNA-seq Datasets
When you are training a foundation model on single-cell data aggregated from hundreds of public studies, batch effects are the first practical obstacle you hit. Not the most conceptually interesting problem, but probably the most consequential one for whether the model learns biology or learns to distinguish protocols.
A batch effect is any systematic difference in measured gene expression that arises from technical variation between experiments rather than from biological differences between cells. In bulk RNA-seq, batch effects are a known issue with well-established correction methods. In single-cell data, they are more severe, more varied in their sources, and harder to correct without inadvertently removing real biological signal. Here is how we think about the problem and what we have found works at scale.
Sources of Batch Variation in scRNA-seq
Single-cell RNA-seq data varies across studies for several overlapping reasons. The most significant sources are:
Protocol variation. 10x Genomics Chromium (v2, v3, v3.1), Smart-seq2, Drop-seq, Parse Biosciences Evercode, and other platforms capture different subsets of the transcriptome with different efficiencies. 3' bias versus full-length coverage, for example, affects which genes are reliably detected. Library size distributions differ substantially between platforms.
Tissue dissociation and processing. The time between tissue excision and cell capture, the dissociation protocol (enzymatic digestion, mechanical, or microfluidic), and whether the sample was fresh, frozen, or fixed all introduce variation. Stress-response genes (heat shock genes, immediate early response genes) are particularly susceptible to capture-time effects.
Sequencing depth. Studies vary enormously in the number of reads per cell, from a few hundred transcript counts per cell in some early studies to tens of thousands in more recent deep-sequencing runs. This affects which genes pass detection thresholds and shapes the distributional properties of the count matrix.
Donor variation. Beyond the technical sources, there is also genuine biological variation between donors: age, sex, genetic background, and disease status all contribute to differences in cell transcriptional profiles. This is not a batch effect in the technical sense; it is biological signal. The challenge is that donor variation and technical batch variation can be confounded when donors and experimental batches are not balanced.
Why Standard Correction Methods Fall Short at Scale
The canonical approaches to batch correction in single-cell analysis (ComBat, Seurat integration, Harmony, scVI) work well in contained settings: integrating three to ten studies of similar tissue with comparable protocols. They were not designed for the problem we face when working with thousands of studies of heterogeneous tissue types, a mixture of protocols, and a wide range of sequencing depths.
The fundamental tension is this: any correction method that aligns cells across batches does so by finding cells that should be similar and adjusting their coordinates toward each other. This works when the similar cells are correctly identified. When the cell-type composition differs substantially between batches (as it does when you are integrating, say, tumour tissue and healthy lung), the anchoring step can assign cross-batch matches incorrectly, producing corrections that distort biological signal.
At the scale of training corpora for foundation models, aggressive correction creates a second problem: it can introduce artificial consistency across datasets that the model then learns as a feature. If the correction aligns datasets by erasing variation that is actually biological, the model learns to ignore dimensions of variation that are real. This affects the quality of embeddings for rare cell states, where the correction has the least reliable anchoring and the highest risk of erasing true signal.
Our Approach: Staged Harmonisation
What we have found works better is a staged approach that minimises the amount of correction applied at the count level while pushing harmonisation into the embedding space.
At the preprocessing stage, we apply only corrections that address known technical artifacts without touching biological signal: ambient RNA removal (using methods like SoupX or CellBender), doublet detection, and per-cell library size normalisation. We do not apply linear batch correction at this stage. The raw count matrix, after ambient RNA and doublet removal, is what goes into model training.
The model itself is then the primary harmonisation mechanism. By training with study identity as a conditioning variable (similar to the approach used in scVI), the encoder learns to produce embeddings that separate batch-specific variation from cell-identity-specific variation. This is more flexible than a linear correction because it allows non-linear batch effects to be accounted for. It also keeps the correction in a space where it is supervised by the reconstruction objective, giving us a signal about when the correction is going too far.
We also use careful data curriculum design: ensuring that each training batch contains cells from multiple studies, multiple donors, and multiple cell types, rather than allowing homogeneous batches that could reinforce batch-specific representations. This is analogous to the data diversity requirements for language model training, where exposure to diverse context at each training step prevents the model from overfitting to surface features of any one data source.
Evaluation: What Does Clean Harmonisation Look Like?
The standard metrics for evaluating batch correction in single-cell data are kBET (batch effect testing using k-nearest neighbours), the silhouette score for batch labels (lower is better post-correction), and LISI scores for both batch and biological label mixing. These are useful diagnostics but they have a known problem: they reward aggressive harmonisation that may have removed biological signal, because they only measure batch mixing, not biological preservation.
We use a set of additional evaluations that probe biological preservation directly. First, marker gene consistency: after harmonisation, do the known marker genes for well-characterised cell types still show the expected expression patterns? If CD3E is no longer enriched in T cells after correction, something has gone wrong. Second, cross-study cell-type clustering: do cells annotated as the same type in independent studies cluster together in embedding space? This tests integration quality without assuming anything about what was corrected.
Third, and most important for our use case, does the model produce consistent expression specificity scores for well-characterised target genes across studies? If a gene is known from multiple independent studies to be enriched in activated CD4 T cells, the model should assign it high specificity to that cell type regardless of which study the cells come from. This is the downstream task we care about, so it is the most direct test of whether harmonisation is preserving what matters.
Practical Limits and What We Do Not Claim to Solve
Batch harmonisation is not a solved problem and we do not treat it as one. There are genuine cases where technical and biological variation cannot be separated cleanly with current methods. A study of severe COVID-19 lung samples and a study of healthy lung tissue have different cell-type compositions, different tissue states, and different technical protocols. Integrating these is a hard problem where no method fully succeeds.
What we can say is that our staged approach produces better results than applying aggressive linear correction across the full training corpus, and that the evaluation metrics we use give us early warning when harmonisation is going wrong in a specific data subset. When evaluation flags a problematic integration, we exclude that subset from training rather than including it with aggressive correction applied: a model trained on less data with cleaner biology is better than one trained on more data with systematic distortions.
This is an ongoing engineering problem. As the volume and diversity of public single-cell data increases, and as new protocols continue to be developed, harmonisation will remain a core challenge. The methods that work well today at a few million cells may need revision at ten or fifty million. We are treating this as an active research area rather than infrastructure that is done and stable.