Tutorials › Statistical Genetics › Principal Components of Genotype Data

Ancestry and Population Structure · Tutorial 142 of 989

Principal Components of Genotype Data

Learn how singular value decomposition turns centered genotype data into principal components and how to quantify the genetic variation those components capture.

Intermediate 10 min read

What You'll Learn

  • Represent allele dosages as a matrix and center each variant across individuals.
  • Connect the SVD of the centered matrix to principal-component scores and variant loadings.
  • Derive the covariance eigenvalues from singular values.
  • Calculate explained-variance proportions and low-rank approximations.
  • Interpret leading components as axes summarizing variation in the analyzed sample.
  • Recognize sign ambiguity, tied components, and limits on biological interpretation.

Why Use Principal Components for Genotype Data?

A genotype data set can contain many variants measured on many individuals. Even when each genotype is recorded simply as an allele dosage, the variants may vary together across individuals. Principal component analysis (PCA) summarizes this multivariate variation with a smaller set of axes. In population-structure work, those axes can reveal major patterns in the analyzed genotype data, but they do not, by themselves, identify a unique biological cause for a pattern.

The central calculation is an SVD of a centered genotype matrix. The SVD separates the matrix into directions describing patterns across individuals and directions describing patterns across variants. Its singular values quantify how much variation lies along the corresponding axes. The connections are exact: the right singular vectors are eigenvectors of the variant covariance matrix, and multiplying the centered matrix by a right singular vector gives the individual scores on that component.

Definition: Let \(n\) individuals have genotype dosages at \(p\) variants, with dosage \(G_{ij}\in\{0,1,2\}\) for individual \(i\) and variant \(j\). Define the mean dosage at variant \(j\) as \(\bar{G}_j=\frac{1}{n}\sum_{i=1}^{n}G_{ij}\). The centered genotype matrix \(X\) has entries \(X_{ij}=G_{ij}-\bar{G}_j\). Thus each column of \(X\) has mean zero.

Here the analysis concerns centering only: each variant is shifted by its sample mean. The choice of whether and how to scale variants is a separate preprocessing decision. Write the compact SVD of \(X\) as \(X=UDV^\mathsf{T}\), where \(r=\operatorname{rank}(X)\), the columns of \(U\) and \(V\) are orthonormal, and \(D\) is diagonal with positive singular values \(d_1\ge d_2\ge\cdots\ge d_r>0\). The columns of \(U\) describe directions across individuals; the columns of \(V\) describe directions across variants.

Definition: The score vector for component \(k\) is \(t_k=Xv_k=d_k u_k\), where \(v_k\) and \(u_k\) are the \(k\)th columns of \(V\) and \(U\). Each entry of \(t_k\) is one individual's score on that component. The vector \(v_k\) is the component's loading direction across the \(p\) variants.

Why the SVD Gives Principal Components

The sample covariance matrix among variants is \(S=X^\mathsf{T}X/(n-1)\). For any unit-length vector \(a\) of variant weights, the \(n\) values in \(Xa\) are the individuals' scores along that direction. Since \(X\) is centered, their sample variance is \(a^\mathsf{T}Sa\). PCA chooses a direction that maximizes this variance, then chooses further directions that maximize variance subject to being orthogonal to the directions already chosen.

The SVD gives the covariance matrix directly:

$$ S=\frac{X^\mathsf{T}X}{n-1} =\frac{VD^\mathsf{T}U^\mathsf{T}UDV^\mathsf{T}}{n-1} =V\frac{D^2}{n-1}V^\mathsf{T}. $$

Because \(U^\mathsf{T}U\) is the identity matrix, this expression shows that \(v_k\) is an eigenvector of \(S\) with eigenvalue \(d_k^2/(n-1)\). It also shows that the sample variance of the scores \(t_k=Xv_k\) is \(d_k^2/(n-1)\). The scores for distinct components are uncorrelated in this sample because \(T=XV=UD\) has \(T^\mathsf{T}T=D^2\), a diagonal matrix.

Theorem: For centered \(X=UDV^\mathsf{T}\), the \(k\)th principal component has loading vector \(v_k\), score vector \(t_k=d_ku_k\), and sample variance \(d_k^2/(n-1)\). Its proportion of the total sample variance is \(d_k^2/\sum_{\ell=1}^{r}d_\ell^2\). Only components with positive singular values are included in this sum.

The variance-maximization result follows from the eigenvalue decomposition. Express any unit vector \(a\) as \(a=\sum_{k=1}^{r}c_kv_k+a_0\), where \(a_0\) is in the null space of \(S\) and \(\sum_k c_k^2+\|a_0\|^2=1\). Then

$$ a^\mathsf{T}Sa =\sum_{k=1}^{r}\frac{d_k^2}{n-1}c_k^2 \le \frac{d_1^2}{n-1}\sum_{k=1}^{r}c_k^2 \le \frac{d_1^2}{n-1}. $$

Equality is achieved by \(a=v_1\). After restricting to directions orthogonal to \(v_1\), the same argument gives \(v_2\) as a direction of greatest remaining variance, and continues for later components. Centering also implies \(\operatorname{rank}(X)\le \min(p,n-1)\): the \(n\) rows of \(X\) lie in the \((n-1)\)-dimensional subspace whose entries sum to zero. Thus a centered data set cannot have more than \(n-1\) nonzero components.

Worked Example: Identical Genotype Patterns at Two Variants

Consider four hypothetical individuals genotyped at two variants. At both variants, their allele dosages are \(0,0,2,2\). Find the centered matrix, its nonzero SVD, component scores, and covariance eigenvalues.

The mean dosage at each variant is \((0+0+2+2)/4=1\). Subtracting this mean from each entry gives

$$ X= \begin{bmatrix} -1&-1\\ -1&-1\\ 1&1\\ 1&1 \end{bmatrix}. $$

The columns are identical, so \(X\) has rank one. A unit right singular vector is \(v_1=(1/\sqrt{2},1/\sqrt{2})^\mathsf{T}\). Multiplication gives

$$ Xv_1= \begin{bmatrix} -\sqrt{2}\\ -\sqrt{2}\\ \sqrt{2}\\ \sqrt{2} \end{bmatrix}, \qquad d_1=\|Xv_1\|=\sqrt{8}=2\sqrt{2}\approx 2.828. $$

Normalizing this score vector gives \(u_1=(-1/2,-1/2,1/2,1/2)^\mathsf{T}\), so \(d_1u_1=Xv_1\). The rank-one reconstruction is exactly \(d_1u_1v_1^\mathsf{T}=X\). The variant covariance matrix is

$$ S=\frac{X^\mathsf{T}X}{3} =\begin{bmatrix}4/3&4/3\\4/3&4/3\end{bmatrix}. $$

Its eigenvalues are \(d_1^2/3=8/3\approx2.667\) and \(0\). The nonzero component explains all the variation in this matrix: the two variants have exactly the same centered pattern, so there is no second independent direction.

Reading Scores, Loadings, and Explained Variance

A score tells where an individual lies along a component axis. A loading describes the variant weights defining that axis. For a fixed component, the score for individual \(i\) is \(\sum_{j=1}^{p}X_{ij}v_{jk}\). Scores are centered across individuals, and their sample variance is the component's covariance eigenvalue. A positive or negative score is a position relative to the sample mean on that axis, not an amount of ancestry or a direct biological measurement.

The proportion of total variance explained by component \(k\) is its score variance divided by the sum of score variances. Since the common denominator \(n-1\) cancels, this is the squared singular value divided by the sum of all squared singular values. It measures the share of variation in the centered matrix represented by that component. It does not measure the fraction of an individual's genome explained.

Worked Example: Two Orthogonal Genotype Patterns

For four hypothetical individuals, suppose the uncentered dosages at two variants are as follows. The first variant has dosages \(0,0,2,2\), and the second has dosages \(0,1,0,1\), in the displayed individual order.

IndividualVariant 1 dosageVariant 2 dosage
A00
B01
C20
D21

The variant means are \(1\) and \(0.5\). Therefore,

$$ X= \begin{bmatrix} -1&-0.5\\ -1&0.5\\ 1&-0.5\\ 1&0.5 \end{bmatrix}. $$

The columns have squared lengths \(4\) and \(1\), and their inner product is \(0\). Thus \(X^\mathsf{T}X=\begin{bmatrix}4&0\\0&1\end{bmatrix}\), so the right singular vectors are the two coordinate vectors and the singular values are \(d_1=2\) and \(d_2=1\). The score vectors are the columns of \(X\). With \(n-1=3\), the component variances are \(4/3\) and \(1/3\). The first component explains \(4/(4+1)=0.80\), or 80%, of the total centered variation; the second explains 20%.

This result is a statement about these two dosage patterns in this sample: the first column has four times the squared length of the second and is orthogonal to it. It does not say that the first variant is biologically four times as important. The PCA calculation summarizes covariance in the matrix supplied to it.

Worked Example: What a One-Component Approximation Retains

Use the preceding centered matrix and retain only its first component. The rank-one approximation is \(X_1=d_1u_1v_1^\mathsf{T}\). Here \(v_1=(1,0)^\mathsf{T}\), \(d_1=2\), and \(u_1=(-1/2,-1/2,1/2,1/2)^\mathsf{T}\). Hence

$$ X_1= \begin{bmatrix} -1&0\\ -1&0\\ 1&0\\ 1&0 \end{bmatrix}, \qquad X-X_1= \begin{bmatrix} 0&-0.5\\ 0&0.5\\ 0&-0.5\\ 0&0.5 \end{bmatrix}. $$

The sum of squared entries of \(X\) is \(4+1=5\), while the sum of squared entries of the residual \(X-X_1\) is \(1\). Thus retaining the first component preserves \(4/5=80\%\) of the squared variation and leaves \(1/5=20\%\) unrepresented. This matches the explained-variance calculation. A low-rank approximation is a compact representation of the matrix, not a claim that the omitted variation is measurement error or biologically irrelevant.

What Leading Components Summarize

The leading components are the directions that account for the largest amounts of sample variation in the centered genotype matrix. When genotype frequencies differ across groups or vary along a gradient, many variants can contribute to a shared pattern across individuals. A component can summarize that broad pattern with one score per individual and one loading per variant. The covariance-based derivation explains why this works: a direction with large score variance corresponds to a large eigenvalue of the variant covariance matrix.

A component is always relative to the individuals, variants, and matrix preparation used in the analysis. Changing the sampled individuals or the included variants can change the estimated axes. Also, a component captures variation, not its cause. Population structure is one possible source of a pattern; relatedness, technical effects, and other sources of variation can also contribute. Accordingly, a leading component should be described as an axis of variation in the analyzed genotypes unless additional evidence supports a more specific interpretation.

The signs of a component are arbitrary: replacing \(v_k\) and \(u_k\) by \(-v_k\) and \(-u_k\) leaves \(d_ku_kv_k^\mathsf{T}\), the reconstruction, and the explained variance unchanged. If two singular values are equal, their component directions are not individually unique: different orthonormal directions within the tied subspace represent the same covariance information. These properties matter when comparing component coordinates across calculations.

Common Mistakes

  • Confusing a singular value with a score. The singular value \(d_k\) is a nonnegative scalar; the score vector is \(d_ku_k=Xv_k\), containing one score for each individual.
  • Using \(d_k\) rather than \(d_k^2\) for variance. The covariance eigenvalue is \(d_k^2/(n-1)\), not \(d_k/(n-1)\). The explained-variance proportion uses squared singular values.
  • Interpreting a component as a cause. A component is a mathematical summary of variation in the analyzed matrix. It does not, by itself, establish ancestry, selection, or any other causal explanation.
  • Treating the component sign as meaningful by itself. Reversing all scores and loadings for a component gives an equivalent solution; comparisons must account for this sign ambiguity.
Key takeaway: For centered genotype data \(X=UDV^\mathsf{T}\), scores are \(XV=UD\), covariance eigenvalues are \(d_k^2/(n-1)\), and explained-variance proportions are \(d_k^2/\sum_{\ell=1}^{r}d_\ell^2\). Leading components compactly summarize the largest axes of variation represented in the data.

Check Your Understanding

Try these questions using the definitions and results above.

  1. For a centered genotype matrix with \(n\) individuals, what is the sample covariance eigenvalue associated with singular value \(d_k\)?
  2. Why does a centered matrix with \(n\) rows have rank at most \(n-1\)?
  3. If the squared singular values are 9, 4, and 3, what proportion of total variation does the first component explain?
  4. What is unchanged if the signs of both \(u_k\) and \(v_k\) are reversed?
  5. Why does a component that explains a large share of genotype variation not, on its own, prove a particular biological cause?
Clinical Biostats