Problemcore
Batch effect correction
Also called batch correction, single-cell data integration.
Remove differences between samples caused by processing batches while keeping the biological differences between conditions.
Batch effect correction removes the differences between groups of samples that come from how they were processed: the day, the lab, the reagent lot or the machine. It must keep the biological differences, such as cell types or the effect of a treatment. In single-cell data, a batch effect moves all cells of one run, so cells of one type from two runs can form two clusters. The known methods either fit a shift of location and scale per gene and batch, or match cells across batches by their nearest neighbors, under the assumption that the batches share cell types. No method can separate a batch effect from biology when the two are confounded; that is a limit of the design, not of the method.
In plain words
Two people weigh the same kinds of fruit, but one scale reads a little heavy. If both people weighed apples and pears, you can compare their apples, find out how much heavier the second scale reads, and subtract it. If one person weighed only apples and the other only pears, you cannot tell whether pears are heavier or the second scale is wrong. Batch correction is the first case: use what the batches have in common to learn the error of each batch, then remove it.
Definition
Input. An expression matrix of cells (or samples) by genes, a batch label for each cell, and optionally known covariates such as the condition.
Output. A corrected matrix, or a corrected low dimensional embedding, or a corrected neighbor graph, in which cells of the same type from different batches are mixed and cells of different types stay apart.
A model. Write the expression of gene in cell of batch as , where is the biological state of the cell, a shift and a scale of the batch. The goal is to estimate up to a common shift. ComBat assumes that depends only on known covariates; nearest neighbor methods let be unknown but assume that some states occur in more than one batch.
Identifiability (a theorem). If every value of a covariate occurs in only one batch, then batch and covariate are confounded, and the effect of the covariate cannot be estimated. Proof. Let batch 1 hold only the controls and batch 2 only the treated cells. The data distribution under a treatment effect and a batch shift depends on them only through for every gene, so any pair with the same sum fits the data equally well. The same holds for cell types: a type found in only one batch cannot be told apart from a batch effect by the data alone.
Variants
- Bulk samples with known groups. Few samples, many genes, the condition known for each sample; the location and scale model applies.
- Single cells with unknown types. Many cells, types unknown and in different proportions per batch; methods must match cells.
- Output space. Some methods correct the genes, others only an embedding or a graph, which is enough for clustering and display but not for tests per gene.
- Reference mapping. Map new cells onto a fixed, corrected reference instead of correcting all batches together.
- Broader integration. Joining data of different technologies or of different kinds of measurement, such as RNA and chromatin, uses the same ideas with weaker shared structure.
Examples
A balanced design. One gene, two batches, each with two controls and two treated samples. Batch 1 reads 1, 1 for the controls and 3, 3 for the treated; batch 2 reads 3, 3 and 5, 5. A model with a batch term and a condition term fits exactly with a batch shift of 2 and a treatment effect of 2, and subtracting the batch shift leaves 1, 1, 3, 3 in both batches.
A confounded design. Batch 1 holds the controls, which read 1, 1, and batch 2 the treated, which read 5, 5. The difference 4 could be a treatment effect of 4, a batch shift of 4, or any split of the two. By the theorem above, no method can choose. Correcting the batch here would remove the treatment effect.
Different mixes of cell types. Batch 1 holds mostly type A and batch 2 mostly type B. Moving batch 2 by the difference of the batch means mixes the two types; the example on the MNN page shows such a shift going wrong, while matching mutual nearest neighbors finds the right shift.
Known algorithms
- Regression on the batch. Fit a linear model per gene with batch terms and subtract them, as in the removeBatchEffect function of limma; a linear model with known covariates.
- ComBat (Johnson, Li and Rabinovic 2007). A location and scale shift per gene and batch, with the shifts shrunk across genes by empirical Bayes. Exact for its model, and good for bulk data and for single cells with the same mix of types in each batch.
- MNN correction (Haghverdi et al. 2018). Pairs of cells that are mutual nearest neighbors across batches give local correction vectors. It needs only one shared population.
- Seurat anchors (Stuart et al. 2019). Mutual nearest neighbors in a space from canonical correlation analysis, scored and used as anchors.
- Harmony (Korsunsky et al. 2019). Alternates soft clustering of all cells with a correction per cluster in a space of principal components.
- Deep generative models. A variational autoencoder with the batch as an input learns a latent space of the cells without the batch.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| ComBat | O(G (N p^2 + p^3) + G N T) worst | O(G N) extra | deterministicnot exactofflineiterative | 1 language |
| Mutual nearest neighbors batch correction | O(q^2 n^2 (d + log n) + q k n^2 d) worst | O(q n d + k n d) extra | deterministicnot exactofflineiterative | 1 language |
Bounds
There is no general guarantee: the problem is not identifiable when batches and biology are confounded, and the methods differ in what they assume. Under their own models some results are exact: ComBat's location and scale step removes a shift and scale per gene and batch exactly when the model holds, and MNN correction removes a translation exactly when it is shorter than half the smallest distance between reference cells and (both proved on their pages). Everything else is measured. The benchmark of Tran and co-authors (2020) compared 14 methods on several data sets by how well batches mix and cell types stay apart, and recommended Harmony, LIGER and Seurat 3.
Reductions
- To regression: with known covariates and a shared mix of types, correction is the fit of batch terms in a linear model, or in a linear mixed model with the batch as a random effect.
- To matching: with unknown types, correction needs a matching of cells across batches, found from a nearest neighbor graph.
- To clustering: Harmony turns correction into rounds of clustering and of a regression per cluster.
Applications
- Joining single-cell data from several donors, runs or labs before clustering and display on UMAP.
- Building cell atlases from many studies.
- Comparing conditions measured in different runs, when the design is balanced.
- Removing known technical effects from bulk expression data before a test of differential expression, or better, putting the batch into the model of the test.
References
- Jeffrey T. Leek et al., Tackling the widespread and critical impact of batch effects in high-throughput data, Nature Reviews Genetics 11(10), 733 to 739 (2010), the definition of batch effects, the examples in published data, and the advice on study design and confounding
- W. Evan Johnson, Cheng Li and Ariel Rabinovic, Adjusting batch effects in microarray expression data using empirical Bayes methods, Biostatistics 8(1), 118 to 127 (2007), the location and scale model of batch effects and its empirical Bayes fit
- Laleh Haghverdi, Aaron T. L. Lun, Michael D. Morgan and John C. Marioni, Batch effects in single-cell RNA-sequencing data are corrected by matching mutual nearest neighbors, Nature Biotechnology 36(5), 421 to 427 (2018), the three assumptions of the method and the comparison with methods that assume the same cell type mix in each batch
- Ilya Korsunsky et al., Fast, sensitive and accurate integration of single-cell data with Harmony, Nature Methods 16(12), 1289 to 1296 (2019), the Harmony algorithm of soft clustering and correction per cluster
- Hoa Thi Nhu Tran et al., A benchmark of batch-effect correction methods for single-cell RNA sequencing data, Genome Biology 21, article 12 (2020), the comparison of 14 methods and the recommendation of Harmony, LIGER and Seurat 3
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 7DKM06 Edit this page History Report an error Markdown