From Genotypes to Individual Scores
Principal components give coordinates for individuals along directions that capture variation in a data matrix. In genotype analysis, the central computational object is a matrix with individuals in rows and genetic variants in columns. Singular value decomposition (SVD) provides one route from this matrix to individual coordinates; eigen-decomposition of a related matrix provides another. The two routes agree, with a specific scaling relationship between their outputs.
The distinction matters in practice: an eigenvector of the matrix of individual-by-individual inner products is not itself the usual vector of principal-component scores. The score also includes a singular-value factor. Keeping that factor straight makes calculations interpretable and helps detect implementation errors.
Here \(Z\) is the input to the decomposition; the algebra below applies to any real-valued \(Z\). For genotype analysis, its columns are typically centered across individuals, and their scaling follows the chosen genotype-standardization convention. These choices affect which variants contribute how much to the decomposition. A column that is constant across individuals has zero variance and cannot be divided by its standard deviation; it must be excluded or handled before standardizing. The calculations assume a finite matrix without unresolved missing entries.
The SVD and the Two Gram Matrices
The SVD of \(Z\) can be written as \(Z=UDV^{\mathsf T}\), where the columns of \(U\) and \(V\) are orthonormal, and \(D\) has nonnegative singular values \(d_1 \geq d_2 \geq \cdots \geq 0\) on its diagonal. For a matrix of rank \(r\), the \(r\) positive singular values correspond to nonzero components. The SVD directly gives the principal-component scores: \(ZV=UD\).
There are two relevant Gram matrices. \(ZZ^{\mathsf T}\) is \(n \times n\), with one row and column per individual; \(Z^{\mathsf T}Z\) is \(m \times m\), with one row and column per variant. Substitution of the SVD shows that the left singular vectors are eigenvectors of the first, while the right singular vectors are eigenvectors of the second.
The score relationship follows directly from the SVD:
where \(e_k\) is the \(k\)th coordinate vector and \(V^{\mathsf T}v_k=e_k\). The same result follows from the individual Gram matrix. If \(ZZ^{\mathsf T}u_k=d_k^2u_k\) with \(d_k>0\), define \(v_k=Z^{\mathsf T}u_k/d_k\). Then
So a positive-eigenvalue individual eigenvector recovers a unit-length variant direction and the corresponding individual scores. If \(d_k=0\), this division is not defined: the component has no variation in the data, and it has no nonzero score vector.
Worked Calculations
Worked Example: Decomposing a Small Genotype Matrix
Consider this hypothetical centered, transformed genotype matrix for three individuals and two variants:
The columns each sum to zero. First form the individual Gram matrix:
The unit vector \(u_1=(1,1,-2)^{\mathsf T}/\sqrt{6}\) is an eigenvector with eigenvalue 3: multiplying the matrix by \((1,1,-2)^{\mathsf T}\) gives \((3,3,-6)^{\mathsf T}\). The unit vector \(u_2=(1,-1,0)^{\mathsf T}/\sqrt{2}\) is an eigenvector with eigenvalue 1. The remaining eigenvalue is zero, since the matrix has rank at most two.
The positive singular values are therefore \(d_1=\sqrt{3}\) and \(d_2=1\). The score vectors are \(t_k=d_ku_k\):
For a direct check, the matching variant directions are \(v_1=(1,1)^{\mathsf T}/\sqrt{2}\) and \(v_2=(1,-1)^{\mathsf T}/\sqrt{2}\). Multiplying \(Z v_1\) and \(Z v_2\) gives exactly \(t_1\) and \(t_2\). The total squared matrix length is \(1+0+0+1+1+1=4\), also \(d_1^2+d_2^2=3+1=4\). The two components account for \(3/4\) and \(1/4\) of this total, respectively.
Worked Example: Recovering Scores From Variant Eigenvectors
Suppose a second hypothetical transformed matrix is
The variant Gram matrix is \(Z^{\mathsf T}Z=\begin{pmatrix}2&2\\2&2\end{pmatrix}\). Its leading unit eigenvector is \(v_1=(1,1)^{\mathsf T}/\sqrt{2}\), with eigenvalue 4. Thus \(d_1=\sqrt{4}=2\). The score vector is the matrix projection, not the variant eigenvector:
Equivalently, the individual eigenvector is \(u_1=t_1/2=(-1,0,1)^{\mathsf T}/\sqrt{2}\), and its eigenvalue in \(ZZ^{\mathsf T}\) is \(d_1^2=4\). The second eigenvalue of \(Z^{\mathsf T}Z\) is zero: the two columns are identical, so the data contain only one nonzero direction. This example shows why reporting \(v_1\) alone would describe a variant direction, not the three individuals’ coordinates.
Worked Example: Changing a Covariance Divisor
For four hypothetical individuals, take the centered matrix
Its columns are orthogonal, and \(Z^{\mathsf T}Z=\operatorname{diag}(4,2)\). The singular values are \(2\) and \(\sqrt{2}\), while the leading score vector is the first column of \(Z\), because the leading variant direction is \(v_1=(1,0)^{\mathsf T}\).
If a covariance-style matrix is defined as \(ZZ^{\mathsf T}/(n-1)\), here \(n-1=3\), its nonzero eigenvalues are \(4/3\) and \(2/3\). If instead the Gram matrix is divided by \(m=2\), its nonzero eigenvalues are \(2\) and \(1\). The eigenvalue scales differ, but the component directions and the proportion of total squared length are unchanged: \(4/(4+2)=2/3\) for the first component and \(2/(4+2)=1/3\) for the second. State the divisor when reporting eigenvalues; do not confuse a common scaling of eigenvalues with a change in the directions.
Why the Equivalence Is Useful
The two Gram matrices have the same positive eigenvalues, but their dimensions differ. The individual matrix \(ZZ^{\mathsf T}\) is \(n \times n\), and the variant matrix \(Z^{\mathsf T}Z\) is \(m \times m\). When one dimension is much smaller than the other, an eigen-decomposition on the smaller Gram matrix can reduce computation. The SVD, in contrast, gives the left and right singular vectors together and makes the score scaling explicit. Either route should return equivalent components, subject to numerical precision and choices about component signs.
For a nonzero component, its eigenvalue in either unscaled Gram matrix is \(d_k^2\). The total squared length of the matrix is
Consequently, the fraction of total squared length associated with component \(k\) is \(d_k^2/\sum_\ell d_\ell^2\), or the same ratio formed from Gram-matrix eigenvalues. When the columns of \(Z\) are centered, this corresponds to the fraction of total centered variation under the stated scaling. This description is algebraic: it does not by itself establish a biological cause for a component or a sampling-based uncertainty statement.
Checks, Failure Modes, and Conventions
A useful implementation check is to compare both the eigenvalues and the score scaling. If \(u_k\) is unit length, then the squared length of the score vector must be \(t_k^{\mathsf T}t_k=d_k^2\). Also, a score matrix formed from \(K\) right singular vectors should equal \(ZV_K\), and it should equal \(U_KD_K\) up to numerical precision. A substantial mismatch often indicates a transposed input, a missing singular-value multiplier, inconsistent scaling, or misaligned individual ordering.
Signs need not match between software outputs. If \(u_k\) and \(v_k\) are both multiplied by \(-1\), the SVD remains valid and the scores reverse sign. The coordinates have not changed in any substantive way; comparisons should allow for this sign flip. If singular values are repeated, the vectors within the corresponding subspace need not be uniquely determined: different valid orthonormal bases can represent the same subspace. In that case, compare the subspace or reconstructed matrix rather than expecting component vectors to match one by one.
The matrix identity also does not validate the input. Check that rows and columns are in the intended order, that the centering and scaling were applied consistently, and that no undefined values remain. If the chosen standardization gives one variant far greater weight than intended, the resulting components can reflect that weighting. Algebraically correct decomposition cannot repair an inappropriate or inconsistent preprocessing choice.
A frequent mistake is to call an eigenvector \(u_k\) from \(ZZ^{\mathsf T}\) the individual scores without qualification. It is a unit-length direction across individuals; the projection scores are \(d_ku_k\). Another mistake is to compare eigenvalues from matrices divided by different constants as if their magnitudes should agree. Check the matrix definition and divisor first. Finally, a zero eigenvalue is not a direction with a hidden nonzero score: it corresponds to no additional variation in the matrix.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- If a positive eigenvalue of \(ZZ^{\mathsf T}\) is 9, what is the corresponding singular value, and how are its unit eigenvector and score vector related?
- Why does \(Z^{\mathsf T}Z\) have the same positive eigenvalues as \(ZZ^{\mathsf T}\), even though the matrices can have different dimensions?
- If every eigenvalue is divided by 5 because the whole Gram matrix is divided by 5, what happens to its eigenvectors and to the proportions of total variation?
- A software output gives unit eigenvectors \(u_k\) and eigenvalues \(\lambda_k\) from \(ZZ^{\mathsf T}\). Write the corresponding score vector for a positive eigenvalue.
- Why can the sign of a component differ across two correct SVD implementations?
Solutions. (1) The singular value is \(d_k=\sqrt{9}=3\), and the score vector is \(t_k=3u_k\). (2) The SVD gives \(ZZ^{\mathsf T}=UD^2U^{\mathsf T}\) and \(Z^{\mathsf T}Z=VD^2V^{\mathsf T}\), so both have the same positive eigenvalues \(d_k^2\); their dimensions differ because one indexes individuals and the other variants. (3) Eigenvectors are unchanged by multiplication of the matrix by a positive scalar, and all eigenvalues are scaled equally, so their ratios to the total eigenvalue sum are unchanged. (4) \(t_k=\sqrt{\lambda_k}\,u_k\). (5) Reversing the signs of both matching singular vectors leaves the decomposition valid, so the corresponding scores may also have their signs reversed.