Single-cell RNA-seq: data & QC

Week 5 — Single-cell RNA-seq: data & QC

Quantitative biology and integrative omics

About this lecture

Until now a gene-expression experiment gave you one number per gene per sample — a bulk average over millions of cells. Single-cell RNA-seq gives you one number per gene per cell, for thousands of cells at once. That changes both the biology we can ask and the data structure we handle.

  • The data object: a sparse cells × genes count matrix, mostly zeros.
  • Where the numbers come from: the droplet workflow, at a high level.
  • Why the counts are noisy and sparse, and what that forces us to do.
  • Quality control: removing empty droplets and other low-quality cells.
  • Preprocessing: normalization, pseudolog transform log(1 + x), and picking highly variable genes.

This is a concept + data-handling day. No new by-hand math; the linear algebra payoff (PCA, UMAP) comes next, in Dimensionality reduction & clustering.

Single cells reveal cell types a bulk average hides

A tumour biopsy is not one thing. It is tumour cells, immune cells (T cells, B cells, macrophages), fibroblasts, and endothelial cells — all mixed together.

  • Bulk RNA-seq measures the average expression across all of them. A gene that is high in a rare T-cell population but absent elsewhere looks like faint background.
  • Single-cell RNA-seq measures each cell separately, so you can ask: which cell types are present, in what proportions, and what is each one doing?

The biological question — what cell types make up this tissue, and how do they differ? — is only answerable if we can read out expression one cell at a time.

The data: a cells × genes count matrix

The output of a single-cell experiment is a table of counts:

  • rows = cells (often 1,000–50,000+),
  • columns = genes (often ~20,000 for human/mouse),
  • entry X_{cg} = the number of RNA molecules of gene g detected in cell c (a non-negative integer count).

X = \begin{pmatrix} X_{11} & X_{12} & \cdots & X_{1G} \\ X_{21} & X_{22} & \cdots & X_{2G} \\ \vdots & & \ddots & \vdots \\ X_{C1} & X_{C2} & \cdots & X_{CG} \end{pmatrix}

Same sample × feature shape you met with bulk expression tables — just with cells as the samples, and a lot more rows.

It is mostly zeros: sparsity

Most entries in the matrix are exactly 0. Typically 90–95% of the matrix is zero.

Two reasons a zero appears:

  • Biological: the gene is genuinely not expressed in that cell.
  • Technical (“dropout”): the gene is expressed, but its few molecules were not captured or sequenced — a false zero from limited sensitivity.

We usually cannot tell the two apart from the count alone. Because so few molecules are sampled per cell, single-cell data is sparse and noisy by nature.

Practically, we store it as a sparse matrix (only the non-zero entries) — a dense 20{,}000 \times 50{,}000 table of doubles would be tens of gigabytes.

Where the counts come from: droplets

The dominant technology (e.g. 10x Genomics) is droplet-based. High level:

  1. A microfluidic chip pairs single cells with barcoded gel beads inside tiny oil droplets — ideally one cell per droplet.
  2. The cell is lysed; each captured mRNA is tagged with that droplet’s cell barcode (which cell) and a UMI — unique molecular identifier (which original molecule).
  3. All droplets are pooled, reverse-transcribed, amplified, and sequenced together.
  4. Computationally, reads are sorted by cell barcode back into cells, and UMIs are counted to rebuild the count matrix.

UMIs correct for repeated sequencing of the same input molecule

Sequencing involves a PCR amplification step that copies molecules unevenly. Without correction, a gene that happened to amplify well would look highly expressed.

  • A UMI is a short random barcode attached to each original mRNA molecule before amplification.
  • After sequencing, all reads sharing the same UMI (and cell barcode and gene) came from one original molecule — so we count them once.

Counting unique UMIs instead of raw reads removes most amplification bias, giving counts that better reflect the true number of molecules captured.

The count matrix is raw — it needs cleaning

The matrix that comes off the pipeline is not ready for analysis. The “one cell per droplet” ideal breaks down, and not every captured cell is healthy:

  • Empty droplets: a droplet with no cell still captures stray ambient RNA → a “cell” that is really background.
  • Low-quality cells: dying or damaged cells (leaked cytoplasm, stressed).

If we skip QC, these masquerade as real cells and create fake cell types and fake intermediate states downstream. QC is not optional bookkeeping — it protects every conclusion that follows.

Few counts or genes per cell flag empty droplets

For each cell we compute two simple numbers:

  • total counts (library size): n_c = \sum_g X_{cg} — total UMIs in the cell.
  • number of genes detected: \#\{g : X_{cg} > 0\} — how many distinct genes are non-zero.

Interpreting the extremes:

  • Very low on both → an empty droplet or a broken cell with little RNA. Filter out.
  • Very high on both → unusually much RNA for one cell — also suspicious. Inspect.

These are cheap, per-cell summaries — the first thing you look at.

Empty droplets hold only background RNA

When cells are lysed during prep, some mRNA floats freely in the suspension — ambient RNA. Every droplet, even an empty one, captures a little.

  • A droplet with no cell yields a low-count profile that is just ambient background.
  • Ranking barcodes by total counts shows a sharp “knee”: real cells (high counts) drop off steeply to the empty-droplet background (low counts).

Simple low-count filtering removes the obvious empties; dedicated tools (e.g. EmptyDrops) model the ambient profile statistically to rescue small real cells and remove background.

Dividing by total counts makes cells comparable

Cells differ in total counts just from technical capture efficiency, not biology — one cell might have 2,000 UMIs and another 20,000. Comparing raw counts across cells is unfair.

Library-size normalization: divide each cell’s counts by its total, then rescale to a common size (a “scale factor”, e.g. 10,000):

\tilde{X}_{cg} = \frac{X_{cg}}{\sum_{g'} X_{cg'}} \times s

This makes cells comparable — it converts counts into relative expression per cell. It is the single-cell cousin of CPM/TPM from bulk RNA-seq.

The log stops a few very high genes from dominating

After scaling we apply \log(1+x) (often written log1p):

Y_{cg} = \log\!\big(1 + \tilde{X}_{cg}\big)

Why log?

  • Expression spans orders of magnitude; a few very-high-count genes would otherwise dominate every distance and variance calculation.
  • Log compresses the large values and stabilizes variance, so highly and lowly expressed genes contribute more comparably.
  • The +1 keeps zeros as zeros (\log(1+0)=0) and avoids \log 0 = -\infty.

The pair (library-size normalize, then log1p) is the standard baseline single-cell transform. More on the pseudocount and the scale factor in the optional unit Log and pseudolog transforms.

Keep the genes that vary more than expected

Of ~20,000 genes, most are uninformative for telling cell types apart — housekeeping genes are steadily on everywhere; many genes are just noise.

Highly variable genes (HVGs): keep the genes whose variation across cells is larger than expected for their mean expression level.

  • Genes with real biological signal (cell-type markers) vary more than technical noise predicts.
  • We rank genes by variability relative to a mean–variance trend and keep the top ~2,000.

Working with ~2,000 informative genes instead of 20,000 cuts noise and computation — and sets up the dimensionality reduction that comes next.

The standard pipeline in code (read, don’t run)

Seurat-style pseudocode for the whole QC + preprocessing pass:

library(Seurat)

# 1. Load the raw counts (cells x genes) into an object
counts <- Read10X("filtered_feature_bc_matrix/")
obj    <- CreateSeuratObject(counts, min.cells = 3, min.features = 200)

# 2. Filter on genes per cell (thresholds are dataset-dependent!)
obj <- subset(obj,
              subset = nFeature_RNA > 200 &
                       nFeature_RNA < 6000)

# 3. Normalize + log, then select highly variable genes
obj <- NormalizeData(obj)                       # library-size + log1p
obj <- FindVariableFeatures(obj, nfeatures = 2000)

What we deliberately deferred

Today stopped at a clean, normalized, HVG-selected matrix. Not covered yet:

  • PCA / UMAP — reducing the ~2,000-gene matrix to a few dimensions you can plot and cluster. (Single-cell RNA-seq: dimensionality reduction.)
  • Clustering & cell-type annotation — grouping cells and naming the types.
  • Count-aware models — Poisson / negative-binomial treatments of the counts, connecting to the overdispersion ideas from the distributions block.
  • Ambient-RNA correction and advanced normalization (Pearson residuals / SCTransform).
  • More QC checks — mitochondrial and ribosomal fractions, doublets: see the optional unit Single-cell QC in depth.

The eigenvalue/eigenvector and PCA machinery you built earlier is exactly what Dimensionality reduction & clustering applies to this cleaned matrix.

Summary

Concept Key fact
Data object sparse cells × genes integer count matrix
Sparsity ~90%+ zeros; zeros can be real or technical dropout
Droplet workflow cell + barcoded bead in oil; barcode = which cell, UMI = which molecule
Empty droplets low counts = ambient background; seen as a knee in the barcode-rank plot
QC metrics total counts and genes detected per cell
Normalization library-size scale, then \log(1+x)
Feature selection keep ~2,000 highly variable genes (variance above the mean trend)
Biology payoff resolve cell-type heterogeneity a bulk average hides

Next (Nonlinear embeddings): PCA, a neighbour graph and UMAP on this cleaned matrix.