Variable genes and PCA: capturing the main variation
After the Seurat tutorial removes genes detected in almost no cells, pbmc3k still has 13,714 genes. Most of them are barely expressed or only fluctuate at random between cells. The analysis first picks the few thousand most informative highly variable genes, then compresses them with PCA into a few dozen principal components; clustering and UMAP both work in that space.
Variable genes: keep the informative ones
The obvious idea is to pick the genes with the highest variance, but count data have a catch: the higher a gene’s expression, the higher its variance by nature. Ranking by raw variance mostly selects highly expressed genes.
Seurat’s vst method first fits the trend of variance against mean across all genes, then asks how far each gene sits above that trend, and keeps the top 2,000. The widget’s mean–variance plot marks the variable genes. In the Seurat tutorial’s pbmc3k results, the top of the list holds cell-type-specific genes such as PPBP, LYZ, S100A9 and GNLY: each is high only in platelets, monocytes or NK cells, so it varies a lot between cells.
obj <- FindVariableFeatures(obj, selection.method = "vst", nfeatures = 2000)
PCA: from two thousand dimensions to a few dozen
ScaleData first standardizes each gene, then PCA runs on the variable genes. PCA finds a set of orthogonal directions: PC1 is the direction of largest variation between cells, PC2 the largest among directions perpendicular to PC1, and so on. Each PC is a weighted combination of genes, and the weights (loadings) show which genes drive it.
In the Seurat tutorial’s pbmc3k results, one end of PC1 holds myeloid genes such as CST3 and TYROBP and the other end lymphoid genes such as LTB and IL7R; PC2 separates B cells (CD79A, MS4A1) from NK and cytotoxic cells (NKG7, GZMB). The sign of a PC is arbitrary and may flip in another tool. Colour the PC1/PC2 scatter in the widget by LYZ, MS4A1 and NKG7 to see this for yourself.
How many PCs to keep? The elbow plot shows the variance each PC explains, and where the curve flattens is a guide. The pbmc3k tutorial uses the first 10. Signals of rare populations (dendritic cells, platelets) can sit in later PCs, so the Seurat tutorial advises erring on the higher side.
Common pitfalls
- Treating the number of variable genes as a fact. 2,000 is a parameter; anything from 1,000 to a few thousand is common, and a key result should not hold at only one setting.
- Running PCA without ScaleData. Highly expressed genes then dominate the components.
- Reading one PC as one cell type. A PC is a direction of variance and often mixes the differences between several cell types.
- Keeping too few PCs. Rare populations merge into large ones and vanish from the clustering.
- Ignoring PCs driven by technical factors. If a PC’s loadings are mostly mitochondrial or stress genes, or it tracks nCount_RNA closely, it reflects the bench rather than biology.