Tutorials

Batch effects: what they are and how to spot them

What batch effects are, why they arise in RNA-seq, how to spot them in PCA and sample distances, and what to do when batch is confounded with condition.

A batch effect is a difference between groups of samples that comes from how they were processed rather than from the biology being studied. The classic example is an experiment where all treated samples were extracted on Monday and all controls on Friday. The treated and control groups then differ in two ways at once, and no statistical method can tell the two apart. Batch effects are not a sign of careless work; they are a normal consequence of doing experiments over time. What matters is recognising them before they are mistaken for biology.

What a batch effect is

High-throughput assays measure thousands of features at once, and many steps in the process can shift the measurements for a whole set of samples. Common sources include:

  • Reagents and lots. A new batch of culture medium, serum, enzyme or antibody can change the signal.
  • People and days. Different operators, different days and different levels of experience can introduce small systematic differences.
  • Equipment. Sequencers, flow cells, PCR machines, scanners and pipetting robots can drift or behave differently between runs.
  • Library preparation. Changes in input RNA, fragmentation time, adapter lot or PCR cycle number affect the final library.
  • Sample storage and handling. Freeze–thaw cycles, time at room temperature and RNA integrity can vary between batches.
  • Environment. Temperature, humidity and airborne contamination can affect sensitive assays.

A batch effect is not the same as random noise. Random noise makes measurements less precise; a batch effect makes them systematically wrong in a way that is shared by samples processed together. That is why it can create apparently strong but biologically meaningless group differences.

Why high-throughput data is vulnerable

In a small assay with a few measurements, a shift caused by a reagent lot might be obvious or might average out. In an RNA-seq or microarray experiment, the same shift is applied to thousands of genes at once, and the analysis searches thousands of genes for differences. A small systematic shift can therefore produce a long list of "significant" genes that all move together for technical reasons.

The problem is made worse by the fact that batch variables are often not recorded. If nobody wrote down which samples were prepared together, the pattern may still be visible in the data, but its cause cannot be confirmed. This is why sample sheets should include extraction date, library-prep batch, sequencing lane and operator even when those variables seem unimportant at the time.

How to spot a batch effect

The first check is visual. After normalisation and a variance-stabilising transformation, make a PCA plot and colour the samples by condition and by batch. If the first principal component separates samples by processing date, sequencing lane or sex rather than by the experimental group, that is a warning. The same pattern may appear in a sample-to-sample distance heatmap or a correlation matrix.

Other signs include:

  • Samples cluster by batch in hierarchical clustering, with replicates of the same condition split across clusters.
  • Normalised distributions differ by batch, even after library-size correction.
  • Known control genes or spike-ins differ by batch, when they should not.
  • A batch variable explains more variance than the condition, which can be estimated by fitting models with and without the variable.
  • Results change substantially when batch is added to the model, suggesting that the original comparison was partly measuring processing differences.

It is important to look at more than one plot. A PCA plot can be dominated by a single strong effect, and a heatmap can be hard to read with many samples. Combining several views, and tabulating condition against batch, gives a more reliable picture.

Confounding versus non-confounding

The critical distinction is whether batch is balanced across the groups you want to compare.

Non-confounding batch. If each condition appears in each batch, batch and condition are at least partly separable. The model can estimate a batch effect and a condition effect, although precision is lost if the design is unbalanced. This is the situation you want.

Confounding batch. If every treated sample is in batch 1 and every control in batch 2, the two variables are perfectly aligned. A model cannot separate them. Any "correction" either removes the condition effect along with the batch effect or leaves the batch effect in place. No software can recover the missing information.

Partial confounding. Some conditions appear in both batches but others do not. This is common in real projects. It may still be possible to estimate some effects, but the analysis needs to be explicit about which comparisons are supported and which are not.

The article on how many replicates you need explains why replication alone does not rescue a confounded design: adding more samples to the same batch makes the confounding worse, not better.

What to do about it

The right response depends on when the problem is discovered.

Before the experiment, the best strategy is design. Spread conditions across batches, randomise sample order within a batch, and record every batch variable. If a batch is unavoidable, make sure each condition is represented in each batch. This is more effective than any downstream correction.

During analysis, include known batch variables in the design formula. For DESeq2 or edgeR this means a model such as ~ batch + condition, which estimates the condition effect while accounting for batch. For limma-voom the same principle applies. This is usually preferable to correcting the data first and then testing, because the uncertainty in the batch adjustment is carried through the model.

When the batch variable is unknown, methods such as surrogate variable analysis (SVA) or RUV can estimate latent factors from the data. These methods are useful but require care: they can also capture real biological variation, especially if the design is small or confounded. They are not a substitute for recording metadata.

For visualisation or clustering, batch correction methods such as ComBat, ComBat-seq for counts, or removal of principal components associated with batch can make samples easier to compare. These methods change the data, so they should be reported and should not be used to hide a design problem. A corrected PCA plot is not evidence that the original experiment was balanced.

What not to do

Do not correct for batch and condition together as if they were separate technical variables when they are confounded. Do not remove a batch effect simply because it makes the desired result appear. Do not compare corrected and uncorrected results and report only the one that supports the hypothesis. And do not treat batch correction as a routine step that can be applied without checking what it did to the data.

It is also a mistake to assume that a batch effect is always bad. If the batch is part of the biological question, such as comparing fresh and frozen tissue, it should be modelled as a factor of interest rather than removed. The distinction is whether the variable is a nuisance or a feature of the design.

Key points

  • A batch effect is a systematic difference caused by processing, not by the biology under study.
  • Reagent lots, operators, days, equipment and library preparation are common sources.
  • PCA, sample-distance heatmaps and variance partitioning can reveal batch patterns.
  • Balanced batch is manageable; perfectly confounded batch cannot be separated from condition.
  • Record batch variables before the experiment, and spread conditions across batches.
  • Include known batch in the design formula rather than correcting the data first.
  • Latent-variable methods can help when batch is unknown, but they can also capture biology.
  • Report any correction and do not use it to disguise a confounded design.

When to ask for help

If your PCA plot separates by batch, or if you are unsure whether a batch variable is confounded with condition, get advice before removing samples or applying a correction. The choice changes what the experiment can claim. You can order an analysis or discuss the design through our RNA-seq analysis service. The RNA-seq quality-control checklist covers the plots that reveal batch patterns, and the DESeq2, edgeR and limma-voom comparison explains how each tool incorporates covariates.

Sources

When to ask for help. If your data or design do not fit a tutorial, order an analysis and we will reply with a fixed price.

Written by the Solagene team for research and education. Found an error? Tell us and we will correct it.