mzwiki Mass spectrometry
knowledge commons by UniMZ
Guides & terminologyAll Guides
Guide 41 · Computation

PCA and scaling: explore variation without overclaiming

Read scores, loadings, and explained variance while checking how transformation, scaling, missingness, and study design shape the picture.

Ask what varies before asking why

Principal component analysis (PCA) summarizes a numeric matrix using linear combinations of its variables. This Guide uses mean-centered PCA throughout. Here rows are samples and columns are measured features or explicitly defined molecule summaries. PCA orders mutually perpendicular directions by the variance they capture in the matrix actually supplied. The first direction need not represent the biology of interest; it may capture injection variation, a batch effect, or an unusual sample.

Start with QC and normalization, missing-data handling, and the study design. PCA cannot undo an ambiguous experimental unit or reconstruct information lost through complete batch–condition confounding. An exploratory picture helps generate and inspect hypotheses; it does not replace a design-aware test.

Define the matrix and its preprocessing

Record the row identities, column identities, excluded observations, and meaning of each value. Repeated injections are not additional biological replicates. Several adduct or isotope features from one compound are correlated measurements, not independent confirmations of a biological pattern.

Three operations answer different questions. A log transformation changes the shape and relative size of differences; centering subtracts each column's mean; scaling changes its weight relative to other columns. Autoscaling divides a centered column by its standard deviation. These operations are not interchangeable with sample-wise normalization. In R's prcomp, centering and unit-variance scaling are separately controlled options. [1]

Choose the workflow from the measurement and question, not whichever version makes groups look most separate. Autoscaling can prevent high-variance variables dominating, but can also give weak, noisy variables substantial influence. A metabolomics comparison demonstrates how preprocessing changes the interpretation; its preferred choices for that dataset are not universal defaults. [2] Resolve missingness explicitly and retain its flags; filling gaps can create or strengthen apparent structure.

Read scores, loadings, and variance together

A score gives a sample's coordinate along a component. Here “loadings” means each component's unit-length vector of variable coefficients used to form that coordinate, following prcomp; some displays use differently scaled loadings. State the convention before interpreting a biplot. Scores and loadings are connected, but arrows and sample distances do not share an automatic universal scale. [1]

The explained-variance fraction compares a component's variance with the total variance of the preprocessed matrix. It is not the fraction of biology explained. Two displayed components omit the remaining directions: nearby points on the plot may differ outside that plane. Reversing a component's loading and score signs changes neither its reconstruction nor its interpretation.

Worked example: scaling changes the question

Constructed four-sample example: two complete feature columns have arbitrary signal values A = [9, 9, 11, 11] and B = [90, 110, 90, 110]. No log transformation or sample normalization is applied. Their means are 10 and 100, so centering produces A = [−1, −1, 1, 1] and B = [−10, 10, −10, 10].

Using sample variances with divisor 4 − 1 = 3, their variances are 4/3 and 400/3. Their covariance is zero because the sum of centered cross-products is 10 − 10 − 10 + 10 = 0. Centered, unscaled PCA therefore puts its first direction along B and assigns it (400/3)/(404/3) = 100/101 ≈ 99.01% of total variance.

Autoscaling divides A by sqrt(4/3) and B by sqrt(400/3). Each then has variance 1 and their covariance remains zero. The two eigenvalues are equal, so each component accounts for 50%, and the individual axes are not uniquely determined within this plane. The data have not gained new biological information. We changed their weighting, exposing two equally variable standardized directions. Four invented samples demonstrate arithmetic, not a sufficient study size.

Inspect explanations other than the desired one

Color the same score plot by biological condition, batch, run order, and other relevant recorded factors. Inspect the raw traces and QC history of unusual samples before deciding whether they are faulty. Removing a point because it spoils separation selects for the desired result. Likewise, a large loading prioritizes a variable for inspection; it supplies neither a p-value nor a molecular identification.

Compare justified preprocessing choices, inspect missingness patterns, and record which conclusions change. For a predictive application, fit learned preprocessing and PCA on training data, then apply that fixed transformation to held-out samples; choosing a pipeline using the final test plot compromises the evaluation. Report design, preprocessing, and validation decisions with the result. [3]

Check your understanding

Does 99.01% explained variance establish that B is the important biological feature?

No. It describes variation on the chosen unscaled signal coordinates. Measurement response, technical variation, and the scientific question still matter.

Does a reflected score plot contradict the original analysis?

Not if the corresponding loading signs are also reversed. Component signs are arbitrary. Equal or nearly equal eigenvalues can make individual directions additionally unstable.

Do two separated groups establish a classifier's accuracy?

No. A visual pattern is not an independent prediction test. Use appropriate held-out evaluation and retain the experimental unit.

Move from exploration to a defined question

Use differential-abundance analysis for an explicit, design-aware contrast. For biology-level summaries, pathway enrichment introduces additional mapping and background assumptions. Neither conclusion follows from the shape of a PCA plot alone.

References & further reading

  1. R stats package. prcomp: Principal Components Analysis.

    Official documentation for centering, optional unit-variance scaling, singular-value decomposition, score and loading definitions, sample-variance divisor, and arbitrary component signs. The constructed example is calculated independently.

  2. van den Berg et al. (2006). Centering, scaling, and transformations: improving the biological information content of metabolomics data. BMC Genomics 7, 142.

    Primary comparison of preprocessing choices on a metabolomics dataset. DOI: 10.1186/1471-2164-7-142. Supports the effect of variable weighting and noise amplification; does not establish one universally preferred scaling method.

  3. Goodacre et al. (2007). Proposed minimum reporting standards for data analysis in metabolomics. Metabolomics 3, 231–241.

    MSI reporting recommendations. Publisher text supports recording design, acquisition scheduling, preprocessing, algorithms, validation splits, and blind testing. The batch-confounding example and modern audit checklist are explicitly pedagogical reasoning built on those principles.

Help make this article clearer.Edit this article →Suggest a correction →