Tutorials › High-Dimensional Genomic Data Analysis › Centering and Scaling Genotypes for Population Analysis

Population Structure, Ancestry and Relatedness · Tutorial 102 of 795

Centering and Scaling Genotypes for Population Analysis

Learn to encode, center, and scale biallelic diploid genotypes so variant columns have comparable expected variation, while recognizing the assumptions and edge cases behind the transformation.

Intermediate 11 min read

What You'll Learn

  • Encode a diploid biallelic genotype as the count of alternate alleles: zero, one, or two.
  • Estimate an allele frequency from genotype dosages and center each variant at twice that frequency.
  • Derive the genotype variance used to scale centered dosages under Hardy–Weinberg equilibrium.
  • Calculate standardized values and distinguish expected unit variance from observed sample variance.
  • Handle missing and monomorphic genotypes without treating undefined values as ordinary observations.
  • Compare frequency-based scaling with centering alone and sample-standard-deviation scaling.

Why Genotype Columns Need a Common Scale

In population analysis, a genotype data matrix contains columns for genetic variants and rows for individuals. A dosage of two at one variant and a dosage of two at another both count two copies of the designated alternate allele, but the variants may have very different allele frequencies. Their raw variation therefore need not be comparable. Centering removes the frequency-dependent average dosage; scaling further expresses deviations relative to the variation expected at that allele frequency.

The earlier material on population stratification describes how allele frequencies can differ across groups. Here the focus is the transformation of genotype data before population analysis. The transformation does not itself identify groups, correct confounding, or guarantee that every locus contributes equally in the observed data. It supplies a defined, frequency-based scale for each variant.

Definition: For individual \(i\) and biallelic variant \(j\), let \(G_{ij}\) be the diploid genotype dosage: the number of copies of the designated alternate allele, taking values 0, 1, or 2. Let \(\hat p_j\) be the estimated alternate-allele frequency at variant \(j\). The centered dosage is \(G_{ij}-2\hat p_j\). The frequency-standardized genotype is $$ Z_{ij}=\frac{G_{ij}-2\hat p_j}{\sqrt{2\hat p_j(1-\hat p_j)}} , $$ provided \(0<\hat p_j<1\). The denominator is the genotype standard deviation expected under the assumptions described below.

Estimating Frequency, Centering, and Scaling

For complete diploid genotype calls from \(n\) individuals, the alternate-allele frequency estimate is the total alternate-allele count divided by the total number of called allele copies:

$$ \hat p_j=\frac{\sum_{i=1}^{n}G_{ij}}{2n}. $$

The mean dosage is therefore \(\bar G_j=2\hat p_j\). Subtracting it centers the column: when all calls are present, \(\sum_i(G_{ij}-2\hat p_j)=0\). Centering is important because a column's average dosage reflects its allele frequency; without centering, differences in that average are mixed with individual deviations from it.

For missing calls, estimate \(\hat p_j\) using called allele copies only. A common simple convention for a matrix that requires complete entries is to impute a missing dosage with \(2\hat p_j\), making its centered and standardized value zero. This is mean imputation, not a recovered genotype: it adds no individual-specific deviation at that variant. More sophisticated imputation may be appropriate when missing genotypes can be predicted from other data, but its assumptions and uncertainty are separate from this transformation.

Why the Scaling Denominator Has This Form

The denominator follows from a specific model. At a biallelic variant, suppose the two allele copies in an individual are independent Bernoulli variables with probability \(p\) of being the alternate allele. This is the Hardy–Weinberg model for genotype counts within a homogeneous population. If \(A_1\) and \(A_2\) indicate alternate-allele copies, then \(G=A_1+A_2\), \(E(A_k)=p\), and \(\operatorname{Var}(A_k)=p(1-p)\). Independence makes the covariance between the two copies zero.

$$ E(G)=E(A_1)+E(A_2)=2p $$
$$ \operatorname{Var}(G) =\operatorname{Var}(A_1)+\operatorname{Var}(A_2) =2p(1-p). $$

Thus subtracting \(2p\) gives a mean-zero genotype, and dividing by \(\sqrt{2p(1-p)}\) gives a genotype with variance one under this model. Replacing the unknown \(p\) by its estimate \(\hat p_j\) gives the practical transformation in the definition. In a finite sample, the resulting column need not have exactly unit observed variance: the formula uses an expected variance, while the actual genotypes may depart from the model and the frequency itself is estimated.

The assumptions matter. The expected-variance result applies to diploid biallelic genotypes with independent allele copies at frequency \(p\) within the population under consideration. In a pooled sample containing groups with different allele frequencies, the pooled genotype distribution need not satisfy this model. Relatedness, inbreeding, genotyping error, or other departures can also change the observed variance. Frequency-based scaling remains a clearly defined transformation, but unit variance is then not guaranteed.

Worked Example: Centering and Scaling Six Genotypes

Suppose six hypothetical individuals have alternate-allele dosages \(0,1,1,2,0,2\) at one variant. All six calls are complete, diploid, and biallelic. The allele frequency estimate is $$ \hat p=\frac{0+1+1+2+0+2}{2(6)}=\frac{6}{12}=0.5, $$ so the mean dosage is \(2\hat p=1\) and the scaling denominator is $$ \sqrt{2(0.5)(1-0.5)}=\sqrt{0.5}\approx0.7071. $$

For dosage \(G=0\), the standardized value is \((0-1)/0.7071\approx-1.414\). For \(G=1\), it is \(0/0.7071=0\). For \(G=2\), it is \((2-1)/0.7071\approx1.414\). In order, the standardized column is approximately \(-1.414, 0, 0, 1.414, -1.414, 1.414\). Its sum is zero, as expected after centering.

The sample has equal counts of the three genotype dosages, which is not the Hardy–Weinberg genotype distribution expected at \(p=0.5\). The transformation is still computable, but this example does not imply that its observed variance must equal one. Scaling uses the model-based denominator; it is not a guarantee about the empirical genotype pattern.

Worked Example: Checking Rounding at an Unequal Allele Frequency

Consider the hypothetical complete dosages \(0,0,1,1,1,2\) at one variant. The total dosage is 5, so \(\hat p=5/12\) and the mean dosage is \(5/6\). The scaling denominator is $$ \sqrt{2(5/12)(7/12)}=\frac{\sqrt{70}}{12}\approx0.6972. $$

For \(G=0\), the exact standardized value is \((-\frac{5}{6})/(\frac{\sqrt{70}}{12})=-10/\sqrt{70}\approx-1.195\). For \(G=1\), it is \((\frac{1}{6})/(\frac{\sqrt{70}}{12})=2/\sqrt{70}\approx0.2390\). For \(G=2\), it is \((\frac{7}{6})/(\frac{\sqrt{70}}{12})=14/\sqrt{70}\approx1.673\). These values are shown to four significant figures where appropriate. The last value is 1.673, not 1.674.

Using the genotype counts, the column mean is also verified directly: \((0+0+1+1+1+2)/6=5/6=2\hat p\). Thus the standardized values, before rounding, sum to zero across the six observations.

What the Transformation Does—and Does Not—Equalize

Frequency-based scaling gives each variant a denominator tied to its expected genotype variance under the stated model. To see why this is different from using raw dosages, compare two hypothetical variants. At a variant with \(\hat p=0.5\), the denominator is \(\sqrt{0.5}\approx0.7071\). At a variant with \(\hat p=0.1\), it is \(\sqrt{0.18}\approx0.4243\). A dosage of zero at the first variant becomes \(-1.414\), while a dosage of two at the second becomes $$ \frac{2-2(0.1)}{\sqrt{0.18}}=\frac{1.8}{0.4243}\approx4.243. $$ The second value is large because two alternate copies are a substantial deviation from the low-frequency expected dosage. This illustrates why allele-frequency scaling can give unusual observations substantial magnitude; it does not establish that the genotype call is erroneous.

Scaling also does not ensure identical observed variance across loci. Realized genotype counts fluctuate, and departures from Hardy–Weinberg assumptions can change the empirical variance. Nor does the transformation remove dependence among variants, such as correlation due to linkage disequilibrium. It standardizes each column separately, not the joint structure of the matrix.

Worked Example: A Missing Call and a Monomorphic Variant

Suppose five hypothetical individuals have dosages \(0,1,2,\text{missing},1\) at a variant. Estimate frequency from the four called genotypes only: $$ \hat p=\frac{0+1+2+1}{2(4)}=\frac{4}{8}=0.5. $$ The mean dosage is 1 and the scaling denominator is \(\sqrt{0.5}\approx0.7071\). The four called dosages standardize to \(-1.414,0,1.414,0\). If mean imputation is used for the missing entry, its dosage is set to \(2\hat p=1\), and its standardized value is \(0\). The completed column is therefore \(-1.414,0,1.414,0,0\).

That zero is the value assigned by this imputation convention, not evidence that the missing individual truly has one alternate allele. If missingness is systematic across individuals or groups, this simple procedure can conceal a meaningful pattern; inspect call rates and missingness by relevant groups before relying on the completed column.

At a different variant, suppose every called individual has dosage zero. Then \(\hat p=0\), the denominator \(\sqrt{2\hat p(1-\hat p)}\) is zero, and the standardized value is undefined. The variant is monomorphic in the calls and provides no genotype variation for this analysis; it should not be assigned standardized zeros by dividing through a zero denominator.

Choices, Diagnostics, and Limitations

Frequency-based scaling is not the only possible preparation. The main alternatives answer somewhat different questions:

PreparationWhat it doesImportant qualification
Raw dosageRetains counts from 0 to 2 without centering or scaling.Variant means and variances differ with allele frequency.
Center onlySubtracts \(2\hat p_j\) from each dosage.Removes the column mean but leaves variants with different expected spreads.
Frequency-based standardizationCenters and divides by \(\sqrt{2\hat p_j(1-\hat p_j)}\).Targets unit variance under the allele-independence model; observed variance need not be one.
Observed sample-standard-deviation scalingCenters and divides by the empirical sample standard deviation at that variant.Targets unit sample variance for nonconstant complete columns, but uses the realized spread, which may reflect departures or data problems.

Before transformation, verify that dosages use a consistent alternate-allele definition, are diploid, and have plausible values. Check whether frequency estimates use called allele copies, whether variants with no variation have been excluded, and whether missingness is concentrated in particular samples or groups. After transformation, check column means and inspect extreme standardized values alongside genotype calls and allele frequencies. An extreme value can be valid, especially for an uncommon allele, but can also signal a coding error or poor-quality call.

A frequent mistake is to argue, “Every standardized variant has observed variance exactly one, so every variant must contribute equally.” The correction is that the denominator is based on expected variance under a model; finite samples, population mixtures, and genotype departures can yield different observed variances. Moreover, equal marginal scaling would not make variants independent or erase their biological and sampling structure. Scaling is a preparation choice, not a diagnostic result or a correction for population structure.

Key takeaway: For complete diploid biallelic genotypes, estimate \(\hat p_j\) from alternate-allele counts, subtract \(2\hat p_j\), and divide by \(\sqrt{2\hat p_j(1-\hat p_j)}\) when \(0<\hat p_j<1\). Interpret this as model-based standardization, check its assumptions and data quality, and handle missing or monomorphic genotypes explicitly.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. For complete dosages \(0,1,1,2\), calculate \(\hat p\), the centered value for \(G=2\), and its frequency-standardized value.
  2. Why does the denominator \(\sqrt{2p(1-p)}\) arise under Hardy–Weinberg assumptions?
  3. A variant has \(\hat p=0\). What happens to its standardized genotype, and what should be done?
  4. Does frequency-based standardization guarantee that every observed genotype column has sample variance one? Explain.
  5. A missing dosage is replaced by \(2\hat p\). What standardized value does it receive, and what does that value mean?

Solutions. (1) The dosage sum is 4, so \(\hat p=4/8=0.5\). The centered value for \(G=2\) is \(2-2(0.5)=1\); the denominator is \(\sqrt{0.5}\), so the standardized value is \(1/\sqrt{0.5}\approx1.414\). (2) Write \(G=A_1+A_2\), where independent allele indicators each have variance \(p(1-p)\). Therefore \(\operatorname{Var}(G)=p(1-p)+p(1-p)=2p(1-p)\). (3) The denominator is zero, so standardization is undefined. The variant is monomorphic in these calls and should be excluded from this variable-scaling operation. (4) No. The denominator is the model-based expected standard deviation, not the realized sample standard deviation; finite-sample variation and model departures can leave observed variance different from one. (5) Its centered and standardized value is zero. This represents the mean-imputation convention, not a known genotype for that individual.

Clinical Biostats