Tutorials › Statistical Genetics › Centering, Scaling, and LD Pruning Before PCA

Ancestry and Population Structure · Tutorial 143 of 989

Centering, Scaling, and LD Pruning Before PCA

Compare common genotype preprocessing choices and see how they alter the genetic variation that can dominate principal-component analysis.

Intermediate 10 min read

What You'll Learn

  • Define genotype dosage centering using the sample allele frequency
  • Distinguish unscaled genotypes from variance-standardized genotypes
  • Derive the genotype variance used in standard scaling under Hardy–Weinberg equilibrium
  • Calculate how common and rare variants contribute after scaling
  • Explain why LD pruning limits redundant contributions to PCA
  • Evaluate what allele-frequency filters remove and what they do not guarantee

Why preprocessing changes PCA

Principal-component analysis (PCA) finds directions of variation in a matrix, but it does not decide which genetic variation should count most. Before PCA, the way genotype columns are centered, scaled, and filtered determines how strongly each variant can contribute. A run using centered dosages alone can therefore give different leading components from a run using variance-scaled dosages or a set pruned for linkage disequilibrium (LD).

This is not just a computational detail. If many nearby variants carry nearly redundant information, they can collectively give one genomic region more influence than a region represented by fewer variants. If rare genotypes are scaled aggressively, a small number of carriers can also have substantial influence. Preprocessing choices should reflect the goal of the analysis and be reported alongside the PCA.

Genotype dosage, centering, and scaling

Suppose there are \(n\) individuals and \(m\) biallelic variants. Let \(g_{ij}\) be the genotype dosage for individual \(i\) at variant \(j\), coded as the number of copies of a consistently chosen allele: \(0\), \(1\), or \(2\). Let \(\hat{p}_j\) be the sample frequency of that allele among called chromosomes at variant \(j\). If all \(n\) individuals have called genotypes, then \(\hat{p}_j=\sum_i g_{ij}/(2n)\).

Definition: The centered dosage for individual \(i\) at variant \(j\) is \(g_{ij}-2\hat{p}_j\). A commonly used variance-scaled dosage is \((g_{ij}-2\hat{p}_j)/\sqrt{2\hat{p}_j(1-\hat{p}_j)}\). The denominator is the genotype standard deviation expected under Hardy–Weinberg equilibrium (HWE) at allele frequency \(\hat{p}_j\); it is not necessarily the observed standard deviation in the sample.

Centering makes the average of each complete genotype column zero. It removes the column mean, not the variation between individuals. Scaling changes the relative weight of columns. With centered but unscaled dosages, a variant with greater genotype variance can contribute more total squared variation. Under the HWE scaling above, variants have equal expected genotype variance under the model used to set the denominator.

The scaling formula assumes a diploid, biallelic dosage coded from zero to two and an allele frequency strictly between zero and one. Its variance interpretation follows under HWE: each individual’s two allele copies are modeled as independent Bernoulli variables with success probability \(p_j\). The formula is a convention for weighting genotypes, not a claim that every variant or population actually satisfies HWE. Population structure, relatedness, and other departures can make observed genotype variation differ from the HWE expectation.

For a centered genotype matrix \(X\), the matrix \(XX^\mathsf{T}\) is the sum of the individual-level contributions from each variant. Multiplying a column by a constant changes that variant’s contribution to this matrix. PCA then acts on the resulting set of contributions; it cannot undo a preprocessing choice.

Worked Example: Centering and Scaling Two Genotype Columns

Consider six hypothetical individuals. At variant A, the dosages are \(0,0,1,1,2,2\). At variant B, they are \(0,0,0,0,0,1\). Assume all genotypes are called and code the same allele at both variants. Calculate the sample allele frequencies and the centered and scaled values.

At A, the total dosage is \(6\), so \(\hat{p}_A=6/(2\cdot6)=0.5\), and the mean dosage is \(2\hat{p}_A=1\). The centered values are \((-1,-1,0,0,1,1)\). The HWE scaling denominator is \(\sqrt{2(0.5)(0.5)}=\sqrt{0.5}\approx0.7071\), giving scaled values approximately \((-1.414,-1.414,0,0,1.414,1.414)\).

At B, the total dosage is \(1\), so \(\hat{p}_B=1/12\) and the mean dosage is \(1/6\). The centered values are five copies of \(-1/6\) and one value of \(5/6\). The denominator is \(\sqrt{2(1/12)(11/12)}=\sqrt{11/72}\approx0.3909\). Thus each non-carrier has scaled dosage \((-1/6)/0.3909\approx-0.4261\), while the carrier has scaled dosage \((5/6)/0.3909\approx2.132\).

The carrier’s scaled value at B is large in magnitude relative to most values at A. This illustrates why variance scaling can give a rare variant substantial leverage. It does not show that B is more informative about population structure: the example is tiny, and the scaling formula describes expected variance under HWE rather than the reliability of this particular sample’s pattern.

What the HWE scaling does—and does not do

Under the stated HWE model, a genotype dosage \(G\) is the sum of two independent allele-copy indicators. Each indicator has variance \(p(1-p)\), so the variance of their sum is \[ \operatorname{Var}(G)=p(1-p)+p(1-p)=2p(1-p). \] Subtracting the mean \(2p\) does not change the variance. Dividing by \(\sqrt{2p(1-p)}\) therefore gives a variable with variance one under this model:

$$ \operatorname{Var}\left(\frac{G-2p}{\sqrt{2p(1-p)}}\right) = \frac{\operatorname{Var}(G)}{2p(1-p)} =1. $$

This result explains the scaling denominator; it does not guarantee equal observed variances across variants in a finite or structured sample. In particular, using the sample allele frequency in the denominator does not make each column’s empirical variance exactly one. Another possible convention is to divide each centered column by its observed sample standard deviation. That produces unit empirical variance for nonconstant columns, but it is a different choice and can also amplify rare or unusual patterns. Analyses should specify which convention was used.

For unscaled centered dosages, HWE predicts variance \(2p(1-p)\), which is largest at \(p=0.5\) and decreases toward zero as the allele becomes rare. Scaling removes this frequency dependence under the model. That can be useful when the aim is to let variants contribute on a more comparable expected-variance scale. But for a rare variant, the denominator is small, so a dosage difference can translate into a large scaled value. Equal expected variance is not the same as equal precision or equal biological importance.

Worked Example: Comparing Expected Variant Contributions

Consider two hypothetical variants, each observed in a large sample and assumed for this calculation to follow HWE. Variant C has allele frequency \(p_C=0.5\); variant D has \(p_D=0.05\). Compare their expected genotype variances before and after HWE scaling.

For C, the unscaled expected variance is \(2(0.5)(0.5)=0.5\). For D, it is \(2(0.05)(0.95)=0.095\). Thus, before scaling, C has about \(0.5/0.095\approx5.263\) times D’s expected per-variant variance under these assumptions.

After scaling by the square root of each expected variance, both scaled genotypes have expected variance one. For D, the scale denominator is \(\sqrt{0.095}\approx0.3082\). A heterozygote’s centered dosage is \(1-2(0.05)=0.9\), so its scaled dosage is \(0.9/0.3082\approx2.920\). For C, the corresponding denominator is \(\sqrt{0.5}\approx0.7071\), and a heterozygote’s centered dosage is zero.

The arithmetic shows both the purpose and a consequence of scaling: D’s expected variance is brought up to the same level as C’s, while a rare-allele carrier can receive a large individual value. It does not establish that rare variants will dominate every PCA, because their realized patterns, number of carriers, correlations with other variants, and the rest of the data all matter.

LD pruning limits repeated information

LD is non-random association between alleles at different variants. When many nearby variants are strongly correlated, their genotype columns can encode much of the same pattern across individuals. If all are included, that pattern may contribute repeatedly to PCA. LD pruning reduces this redundancy by retaining a subset of variants that are not too strongly correlated according to a chosen rule.

A typical pruning procedure considers variants within genomic windows and removes one or more variants when pairwise \(r^2\) exceeds a specified threshold. The precise window size, step, threshold, and variant retained can vary by software and analysis. Pruning is a pragmatic way to reduce repeated signal; it does not make the retained variants independent, nor does it remove all LD. It also does not identify causal variants.

The weighting effect can be seen directly. If two centered columns are identical, \(x_1=x_2=x\), their joint contribution to the individual-level matrix is \((x_1x_1^\mathsf{T}+x_2x_2^\mathsf{T})=2xx^\mathsf{T}\). One copy contributes \(xx^\mathsf{T}\). Thus, exact duplicates double the contribution of that pattern before considering any other variants. Highly correlated, but not identical, columns can have a similar repeated-weighting effect.

Worked Example: Why Redundant Columns Can Change PCA Weighting

Suppose a hypothetical centered genotype matrix has two columns for variants in a high-LD region, and for simplicity their columns are identical: \(x_1=x_2=( -1,0,1)^\mathsf{T}\) across three individuals. Compare their combined contribution with the contribution after retaining only one column.

For one column, \[ x_1x_1^\mathsf{T}= \begin{pmatrix} 1&0&-1\\ 0&0&0\\ -1&0&1 \end{pmatrix}. \] With both identical columns, the contribution is \(x_1x_1^\mathsf{T}+x_2x_2^\mathsf{T}=2x_1x_1^\mathsf{T}\), so every displayed entry is doubled. Retaining one column halves this region’s contribution from these variants.

Real LD is rarely exact identity, but the example isolates the principle: repeated correlated measurements can overweight a shared pattern. Pruning may therefore help PCA reflect broad variation rather than the density of correlated markers in one region. The appropriate pruning level depends on the analysis; overly aggressive pruning can discard useful information.

Allele-frequency filters and missing genotypes

A minor-allele-frequency (MAF) filter removes variants whose less frequent allele is below a chosen frequency threshold. In a biallelic sample, MAF is the smaller of the two allele frequencies. Filtering can exclude nearly invariant variants and reduce the influence of very low-count alleles, which are especially sensitive to genotyping error and can receive large values under variance scaling. It also changes which genetic variation is represented: a stringent threshold removes genuine rare variation as well as potentially unreliable observations.

There is no universally correct MAF threshold for PCA. The choice depends on sample size, genotype quality, population composition, and the purpose of the analysis. A frequency filter does not guarantee that all retained variants are well measured or free of population-specific frequency patterns. Report the threshold and whether frequencies were calculated across the full sample or within a defined group; pooled frequencies can differ from within-group frequencies when the sample is structured.

Missing genotypes also require a stated policy. One common simple choice is to impute a missing dosage with the variant’s mean dosage, \(2\hat{p}_j\), so its centered value is zero. This avoids treating missingness as an additional allele state, but it also treats the missing observation as contributing no deviation from the column mean. More elaborate imputation may be appropriate in other settings. Whatever method is used, unexplained or ancestry-related missingness can create patterns that preprocessing alone does not resolve.

Worked Example: A Frequency Filter Changes the Variant Set

In a hypothetical sample of 1,000 diploid individuals, a variant has 40 copies of its minor allele among 2,000 called chromosomes. Its MAF is \(40/2{,}000=0.02\). Consider applying an illustrative MAF threshold of 0.01, then an illustrative threshold of 0.03.

At 0.01, the variant passes because \(0.02\geq0.01\). At 0.03, it is excluded because \(0.02<0.03\). Under HWE, its expected genotype variance is \(2(0.02)(0.98)=0.0392\), and the scaling denominator is \(\sqrt{0.0392}\approx0.1980\). That small denominator explains why scaling can magnify dosage deviations at this frequency.

These thresholds are hypothetical, not recommendations. The calculation shows that frequency filtering determines whether the variant enters PCA at all, while scaling determines how its dosage column is weighted if included. Neither decision alone establishes whether the variant is accurate, representative, or informative about the structure of interest.

A practical sequence and common pitfall

1
Check the genotype data.
Confirm allele coding, variant quality, sample quality, ploidy assumptions, and the treatment of missing genotypes before calculating frequencies or transforming dosages.
2
Apply and document filters.
State any missingness and allele-frequency thresholds, and note the sample used to calculate frequencies. Exclude monomorphic variants because they have no centered variation and cannot be variance-scaled with a positive denominator.
3
Choose a weighting and LD strategy.
Decide whether PCA uses centered dosages or HWE variance-scaled dosages, and whether LD pruning is appropriate. Record the scaling formula and pruning settings.
4
Check sensitivity.
When preprocessing choices could plausibly affect the analysis, compare results under defensible alternatives. A change in the leading components indicates sensitivity to those choices, not by itself which choice is correct.

A common mistake is to assume that variance scaling is automatically more fair because it gives each variant unit expected variance. That reasoning overlooks the small denominator for rare alleles and the influence of a few carriers. Another is to assume that a large number of variants guarantees balanced genomic representation; a dense LD block can supply many redundant columns and be counted repeatedly. The correction is to treat scaling, filtering, and pruning as explicit modeling choices, justify them for the aim of the PCA, and report them so the weighting can be understood.

Key takeaway: Centering removes variant means; scaling changes relative variant weights; LD pruning reduces repeated contributions from correlated markers; and allele-frequency filters determine which frequency ranges are represented. None is a neutral switch, and none substitutes for checking genotype quality or assessing sensitivity to reasonable preprocessing choices.

Check Your Understanding

Answer these questions using the definitions and assumptions above.

  1. For a variant with allele frequency \(p=0.2\), what is its expected genotype variance under HWE, and what is the corresponding scaling denominator?
  2. Why does dividing by \(\sqrt{2p(1-p)}\) not guarantee that every observed genotype column has sample variance one?
  3. Explain how two identical centered genotype columns affect their combined contribution to \(XX^\mathsf{T}\).
  4. Give one reason to filter very low-frequency variants and one important consequence of doing so.
  5. Why can a rare-allele carrier have a large scaled dosage even when the variant’s expected scaled variance is one under HWE?
Clinical Biostats