Tutorials › Multi-Omics Data Integration › CCA with Singular Covariance Matrices

Canonical Correlation and Partial Least Squares · Tutorial 134 of 597

CCA with Singular Covariance Matrices

You will learn why singular covariance matrices disrupt classical CCA, how to diagnose deficient rank, and what pseudoinverse and dimension-reduction remedies do—and do not—resolve.

Intermediate 11 min read

What You'll Learn

  • Identify exact and near rank deficiency in the within-block covariance matrices used by CCA.
  • Explain why singularity makes inverse-based CCA equations undefined and can make weights nonunique.
  • Formulate CCA on the nonzero-variance subspaces using Moore–Penrose pseudoinverses.
  • Distinguish exact rank reduction from truncating principal components.
  • Diagnose unstable weights, misleadingly high correlations, and information lost through truncation.

Why Singular Covariance Matrices Matter

Canonical correlation analysis (CCA) seeks linear combinations of two data blocks whose scores have high correlation. Its classical calculations rely on the within-block covariance matrices being invertible. In multi-omics data, however, a block may contain more features than samples, exact duplicate measurements, or features determined by other features. The resulting covariance matrix is singular: at least one nonzero direction in feature space has zero variance. In that case, the inverse-based equations cannot be used as written, and the canonical weights may not be uniquely determined.

Singularity is not just a numerical inconvenience. It can signal redundant measurements, an insufficient sample size for the number of features, or a structural constraint in the data. A numerical routine may still return weights or correlations, but those outputs require interpretation: the correlations can be determined on the observed subspaces while the weights in the original feature coordinates are not uniquely identified.

Rank, Null Spaces, and the Classical CCA Problem

Let \(X\) and \(Y\) be centered data matrices for two blocks measured on the same \(n\) samples, with \(p\) and \(q\) features. Write their sample covariance matrices and cross-covariance matrix as

$$ S_{xx}=\frac{X^\top X}{n-1},\qquad S_{yy}=\frac{Y^\top Y}{n-1},\qquad S_{xy}=\frac{X^\top Y}{n-1}. $$

For coefficient vectors \(a\) and \(b\), the corresponding scores are \(Xa\) and \(Yb\). Their sample variances are \(a^\top S_{xx}a\) and \(b^\top S_{yy}b\), and their sample covariance is \(a^\top S_{xy}b\). Classical CCA maximizes their correlation, equivalently maximizing covariance subject to both score variances being one. This formulation requires \(a^\top S_{xx}a>0\) and \(b^\top S_{yy}b>0\); a zero-variance score has no defined correlation.

$$ \max_{a,b}\ a^\top S_{xy}b \quad\text{subject to}\quad a^\top S_{xx}a=1,\qquad b^\top S_{yy}b=1. $$

A covariance matrix is singular when its rank is smaller than its dimension. Equivalently, it has at least one zero eigenvalue, and its null space contains a nonzero vector. For example, if \(S_{xx}a_0=0\), then \(Xa_0=0\): the data produce a score identically equal to zero in that direction. For centered data, \(\operatorname{rank}(X)\leq \min(n-1,p)\), so \(S_{xx}\) must be singular if \(p>n-1\). Exact linear dependencies among columns can make it singular even when \(p\leq n-1\).

Definition: A block covariance matrix is rank deficient if its rank is smaller than the number of features in that block. Its null space consists of coefficient vectors that produce a zero-variance score. The effective subspace is the span of its eigenvectors with positive eigenvalues; only directions in that subspace have nonzero variance.

When \(S_{xx}\) is singular, \(S_{xx}^{-1}\) does not exist, so the inverse-based generalized eigenvalue equations for classical CCA are undefined. The constrained optimization can still be considered over nonzero-variance scores, but its coefficients may not be identifiable. If \(a\) is a solution and \(a_0\) lies in the null space of \(S_{xx}\), then \(X(a+a_0)=Xa\). Thus these two coefficient vectors give exactly the same score. The reported weights are not unique even though the score can be.

What the Pseudoinverse Does

A standard way to describe CCA on the effective subspaces uses the Moore–Penrose pseudoinverse. For a symmetric positive semidefinite matrix \(S\), let \(S=U\Lambda U^\top\) be an eigenvalue decomposition. The matrix \(S^{+1/2}\) replaces each positive eigenvalue \(\lambda\) by \(\lambda^{-1/2}\), and leaves each zero eigenvalue at zero. It whitens the directions with positive variance while excluding the null space. The canonical correlations on the effective subspaces are the singular values of

$$ S_{xx}^{+1/2}S_{xy}S_{yy}^{+1/2}. $$

This expression presumes that the covariance blocks are compatible parts of a joint covariance matrix, as they are when calculated from the same paired observations. In particular, a zero-variance direction in one block cannot have nonzero covariance with a direction in the other block. For example, if \(Xa_0=0\), then \(a_0^\top S_{xy}=0\) follows directly from \(S_{xy}=X^\top Y/(n-1)\). Therefore the cross-block covariance acts only between directions with nonzero variance. Whitening those directions gives a matrix whose singular values are correlations and hence cannot exceed one.

The pseudoinverse gives a well-defined calculation on the nonzero-variance subspaces; it does not make every original-coordinate weight uniquely meaningful. Any component added in a within-block null space leaves the score unchanged. A Moore–Penrose calculation selects a minimum-norm representative among equivalent choices, but that convention is not evidence that the selected weights are uniquely identified by the data.

Worked Example: Duplicate Features and Nonunique Weights

Suppose a hypothetical centered block \(X\) has two features, with the second exactly twice the first. Let the first feature have sample variance \(1\), and let a one-feature block \(Y\) have sample variance \(1\) and sample covariance \(0.6\) with the first \(X\) feature. The implied covariance matrices are

$$ S_{xx}= \begin{pmatrix}1&2\\2&4\end{pmatrix},\qquad S_{yy}=(1),\qquad S_{xy}= \begin{pmatrix}0.6\\1.2\end{pmatrix}. $$

The determinant of \(S_{xx}\) is \(1(4)-2(2)=0\), so its inverse does not exist. For \(a=(a_1,a_2)^\top\), the \(X\) score is \(a_1X_1+a_2X_2=(a_1+2a_2)X_1\). Its variance is \((a_1+2a_2)^2\). A unit-variance score therefore requires \(a_1+2a_2=1\) or \(-1\). There are infinitely many such weights: \((1,0)^\top\) and \((-1,1)^\top\) both give the same positive score \(X_1\).

That score has variance \(1\), and its covariance with \(Y\) is \(0.6\), so the canonical correlation is \(0.6/\sqrt{1\cdot1}=0.6\). The correlation is well-defined even though the original two-feature weight vector is not unique. The Moore–Penrose minimum-norm representative for the positive score satisfies \(a_1+2a_2=1\): it is \((0.2,0.4)^\top\), since \(0.2+2(0.4)=1\). It yields the same score and correlation.

Diagnosing Rank Deficiency

Diagnosis should use both the data and the covariance spectrum. Start by checking the number of samples and features, then compute numerical ranks or inspect eigenvalues or singular values. Exact rank is a mathematical property; numerical rank depends on a tolerance because floating-point calculations rarely produce exact zeros. A very small eigenvalue relative to the largest can indicate near rank deficiency: inversion is technically possible, but small perturbations can cause large changes in the estimated weights.

  • Compare the number of features with the maximum possible centered-data rank, \(n-1\).
  • Inspect eigenvalues or singular values for zeros and for a large gap between retained and discarded values.
  • Check for constant features, duplicated measurements, and exact linear combinations of features.
  • Assess weight and score stability under reasonable changes in preprocessing or resampling. Large weight changes with similar score correlations indicate weak identification or near-collinearity.

A condition number—the ratio of the largest to the smallest positive eigenvalue—can summarize the spread of scales on the effective subspace. It does not by itself identify a universal cutoff: the choice of numerical tolerance should reflect scaling, precision, and the analysis. Standardization changes feature scales and can help make spectral comparisons interpretable, but it cannot restore information to an exact linear dependency.

Worked Example: Rank Diagnosis in a Small Block

Suppose a hypothetical centered \(X\) block has five features measured on four samples. Its singular values are \(3.0,\ 1.0,\ 0.2,\ 0.0\). Because there are four centered samples, the rank cannot exceed \(4-1=3\); the observed zero singular value means the rank is \(3\), not \(5\). The covariance matrix \(S_{xx}=X^\top X/3\) has eigenvalues equal to the squared singular values divided by \(3\):

$$ \frac{3.0^2}{3}=3.0,\qquad \frac{1.0^2}{3}=0.3333,\qquad \frac{0.2^2}{3}=0.01333,\qquad \frac{0.0^2}{3}=0. $$

Thus two feature-space directions lie in the covariance null space. The smallest positive eigenvalue is \(0.01333\), giving a positive-subspace condition number of \(3.0/0.01333\approx225\). This indicates that even after excluding the exact zero direction, inversion may be sensitive to perturbations. A defensible diagnosis is therefore both exact rank deficiency and a substantial difference in scale among the positive-variance directions—not simply “five features and four samples.”

Two Remedies: Pseudoinverse and Dimension Reduction

A pseudoinverse retains all positive-variance directions and sets null directions aside. It is appropriate when the aim is to compute CCA on the observed subspaces without declaring any nonzero-variance direction irrelevant. Exact dimension reduction does the same thing in another coordinate system: represent each block in a basis for its full effective subspace, then run ordinary CCA on those reduced coordinates. If no positive-variance directions are discarded, these approaches preserve the same attainable canonical correlations.

Truncated dimension reduction is different. For example, retaining only the first few principal components discards positive-variance directions as well as null directions. That may stabilize or simplify an analysis, but it changes the space over which CCA is optimized. The resulting correlations describe the retained subspaces, and an association confined to a discarded direction can disappear. The choice of retained dimension should therefore be justified and assessed for stability rather than treated as a purely computational fix.

ApproachWhat it retainsMain benefitMain caution
Moore–Penrose pseudoinverseAll positive-variance directions; excludes exact null directionsDefines CCA on the effective subspacesOriginal-coordinate weights can remain nonunique; near-zero eigenvalues can still be unstable
Exact rank reductionA basis spanning the full positive-variance subspaceRemoves redundant coordinates while preserving attainable correlationsInterpretation must be mapped back carefully; nonunique original-coordinate weights remain equivalent
Truncated dimension reductionOnly selected components; may discard positive-variance directionsCan reduce noise and simplify a high-dimensional analysisChanges the target; associations in discarded directions may be lost

Worked Example: Truncation Can Remove an Association

Consider hypothetical covariance matrices in principal-component coordinates:

$$ S_{xx}=\begin{pmatrix}9&0\\0&1\end{pmatrix},\qquad S_{yy}=\begin{pmatrix}4&0\\0&1\end{pmatrix},\qquad S_{xy}=\begin{pmatrix}0&0\\0&0.8\end{pmatrix}. $$

Both within-block matrices are nonsingular. After whitening, the cross-covariance matrix is

$$ S_{xx}^{-1/2}S_{xy}S_{yy}^{-1/2} = \begin{pmatrix}1/3&0\\0&1\end{pmatrix} \begin{pmatrix}0&0\\0&0.8\end{pmatrix} \begin{pmatrix}1/2&0\\0&1\end{pmatrix} = \begin{pmatrix}0&0\\0&0.8\end{pmatrix}. $$

Its singular values are \(0.8\) and \(0\), so the first canonical correlation is \(0.8\). But suppose dimension reduction retains only the first principal component of each block. Their cross-covariance is zero, so the CCA correlation in those retained one-dimensional blocks is \(0\). The original association was in the second component, which has less variance in \(X\); retaining components solely because they explain the most within-block variance can therefore omit an important cross-block association.

Assumptions, Limitations, and Common Pitfalls

The matrix arguments above require paired observations and covariance matrices that represent the same centered sample or a compatible joint covariance model. A pseudoinverse calculation still requires positive-variance directions in both blocks; if an entire block has zero variance, no canonical correlation is defined. For inference, the assumptions and procedures of classical tests cannot automatically be carried over after rank selection or truncation. Selection affects the analysis, and a computed sample correlation alone does not establish population association.

A common mistake is to interpret a minimum-norm pseudoinverse weight vector as the uniquely correct biological signature. In the duplicate-feature example, many weight vectors generated the same score; the minimum-norm choice was a computational convention. Report which subspace was used, how numerical rank was determined, and whether dimension reduction discarded positive-variance directions. If original features are highly redundant, score patterns may be more stable and interpretable than individual weights.

Another pitfall is to assume that removing exact zeros resolves severe near-singularity. A tiny but positive eigenvalue is inverted to a large value by ordinary whitening, potentially magnifying sampling noise. Rank thresholds and retained dimensions should be examined for sensitivity. When a regularized CCA method is considered as an alternative, its estimates depend on additional choices; it is not the same operation as taking a pseudoinverse or selecting an exact-rank basis.

Key takeaway: Singular covariance matrices make inverse-based classical CCA equations undefined and can leave original-coordinate weights nonunique. Pseudoinverse CCA and exact rank reduction operate on the nonzero-variance subspaces; truncated reduction also changes which associations the analysis can detect.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. A centered block has \(n=8\) samples and \(p=10\) features. What is the maximum possible rank of its sample covariance matrix, and must it be singular?
  2. If \(a_0\) is in the null space of \(S_{xx}\), why do \(a\) and \(a+a_0\) produce the same \(X\)-block score?
  3. Does exact rank reduction that retains the entire positive-variance subspace necessarily change the attainable canonical correlations? Explain.
  4. In the truncation example, what happens to the first canonical correlation when only the first principal component of each block is retained?

Solutions. (1) The rank is at most \(\min(n-1,p)=\min(7,10)=7\), which is less than \(p=10\); the covariance matrix must be singular. (2) Since \(S_{xx}=X^\top X/(n-1)\), \(a_0^\top S_{xx}a_0=0\) implies \(Xa_0=0\); hence \(X(a+a_0)=Xa+Xa_0=Xa\). (3) No. A basis for the full positive-variance subspace changes coordinates but retains every nonzero-variance score direction, so it preserves the attainable canonical correlations. (4) It becomes \(0\), because the retained first components have zero cross-covariance in the stated example.

Clinical Biostats