Tutorials › High-Dimensional Genomic Data Analysis › Sparse Relationship Matrices for Large Cohorts

Mixed-Model GWAS, Relatedness and Inflation Diagnostics · Tutorial 263 of 795

Sparse Relationship Matrices for Large Cohorts

You will learn to threshold relationship matrices, quantify the resulting covariance approximation, and check when sparsity gains may come at the cost of unreliable covariance information.

Advanced 12 min read

What You'll Learn

  • Define symmetric hard thresholding of off-diagonal relationship entries.
  • Count retained relationships and estimate sparse storage requirements.
  • Bound the change in a mixed-model covariance matrix after thresholding.
  • Check positive semidefiniteness and recognize when thresholding can invalidate a covariance model.
  • Diagnose information loss using row sums, eigenvalues, and sensitivity to the threshold.
  • Distinguish sparse storage and matrix operations from the cost of sparse factorization.

Why Sparsify a Relationship Matrix?

A relationship matrix for \(n\) individuals records genetic similarity across pairs. In a large cohort, storing every entry requires memory proportional to \(n^2\), even when most pairs have only weak estimated relationships. Setting sufficiently small off-diagonal entries to zero can reduce storage and speed some matrix operations. But a weak relationship is not necessarily irrelevant: many small entries can collectively affect covariance calculations.

The goal is therefore not simply to create as many zeros as possible. It is to make a controlled approximation, state what has been discarded, and check whether the approximation is acceptable for the intended mixed-model analysis. This tutorial focuses on that trade-off.

Definition and Mixed-Model Context

Definition: Let \(K\) be a symmetric \(n\times n\) relationship matrix and let \(\tau>0\) be a threshold. Symmetric hard thresholding sets an off-diagonal entry to zero when its absolute value is less than \(\tau\), while retaining entries whose absolute value is at least \(\tau\). The diagonal is retained. The result is a symmetric matrix \(K_\tau\).

Using the absolute value matters when a relationship matrix can contain negative entries: thresholding by \(K_{ij}<\tau\), rather than by \(|K_{ij}|<\tau\), would treat negative and positive relationships asymmetrically. The threshold should be applied symmetrically to the pair \(i,j\) and \(j,i\); otherwise the result may not even be symmetric.

For context, consider the linear mixed model

$$ y=X\beta+g+\varepsilon,\qquad g\sim N(0,\sigma_g^2K),\qquad \varepsilon\sim N(0,\sigma_e^2 I), $$

where \(y\) is the phenotype vector, \(X\) is the fixed-effect design matrix, and \(g\) and \(\varepsilon\) are independent random vectors. Assume \(\sigma_g^2\geq 0\), \(\sigma_e^2>0\), and that \(K\) is positive semidefinite, as a valid covariance relationship matrix should be. Then the phenotype covariance is \(V=\sigma_g^2K+\sigma_e^2 I\). Replacing \(K\) with \(K_\tau\) gives \(V_\tau=\sigma_g^2K_\tau+\sigma_e^2 I\). This replacement approximates the covariance model; it does not merely compress the same matrix without changing its values.

Worked Example: Applying a Threshold to a Small Matrix

Suppose a hypothetical five-individual relationship matrix has diagonal entries equal to 1 and the following nonzero off-diagonal entries, with symmetric counterparts:

$$ K= \begin{pmatrix} 1&0.20&0.04&0&0\\ 0.20&1&0.07&0.15&0\\ 0.04&0.07&1&0.12&0.03\\ 0&0.15&0.12&1&0.08\\ 0&0&0.03&0.08&1 \end{pmatrix}. $$

Use \(\tau=0.10\). The absolute values \(0.04\), \(0.07\), \(0.03\), and \(0.08\) are below the threshold, so the four corresponding pairs are removed. The entries \(0.20\), \(0.15\), and \(0.12\) are retained. Thus \(K_\tau\) has three retained off-diagonal pairs out of the ten possible pairs. The retained proportion is \(3/10=0.30\), or 30%.

There are five diagonal entries and six retained off-diagonal entries when both symmetric halves are stored, for 11 nonzero entries out of 25 matrix positions. This small example illustrates the operation, but the computational benefit becomes substantial only at large \(n\).

How Much Covariance Information Can Be Lost?

Define the discarded matrix \(\Delta=K-K_\tau\). For symmetric hard thresholding, \(\Delta\) is symmetric, has zero diagonal, and contains the removed off-diagonal entries. A useful summary is its maximum absolute row sum, the matrix infinity norm \(\|\Delta\|_\infty\). It accounts for the combined magnitude of all removed relationships involving each individual, rather than judging each entry in isolation.

The spectral norm \(\|\Delta\|_2\) controls the largest possible change in a covariance quadratic form. For any symmetric matrix, \(\|\Delta\|_2\leq\|\Delta\|_\infty\). Since \(V-V_\tau=\sigma_g^2\Delta\), this gives a bound for all directions in the phenotype space.

Justification: For any vector \(a\), the Cauchy–Schwarz inequality for the Euclidean norm and the definition of the spectral norm give \(|a^\mathsf{T}(V-V_\tau)a|\leq\|a\|_2\|(V-V_\tau)a\|_2\leq\|a\|_2^2\|V-V_\tau\|_2\). Also, \(\|V-V_\tau\|_2=\sigma_g^2\|\Delta\|_2\leq\sigma_g^2\|\Delta\|_\infty\). Together, these imply \(|a^\mathsf{T}(V-V_\tau)a|\leq\sigma_g^2\|\Delta\|_\infty\|a\|_2^2\). The bound is conservative, but it applies to every contrast \(a\).

Worked Example: Bounding the Covariance Change

For the matrix above, the discarded absolute row sums are as follows. Row 1 has \(0.04\); row 2 has \(0.07\); row 3 has \(0.04+0.07+0.03=0.14\); row 4 has \(0.08\); and row 5 has \(0.03+0.08=0.11\). Therefore \(\|\Delta\|_\infty=0.14\), with row 3 attaining the maximum.

Suppose the hypothetical variance component is \(\sigma_g^2=0.4\). The spectral norm bound is

$$ \|V-V_\tau\|_2 =0.4\|\Delta\|_2 \leq0.4(0.14)=0.056. $$

For the contrast \(a=(1,-1,0,0,0)^\mathsf{T}\), \(\|a\|_2^2=1^2+(-1)^2=2\). Its model variance change is bounded by \(0.056(2)=0.112\), in squared units of the phenotype. This upper bound is not the actual change: in this particular matrix, the removed entries do not connect individuals 1 and 2, and the diagonal entries are unchanged. Consequently \(a^\mathsf{T}(V-V_\tau)a=0\). The bound allows for the worst possible direction; it need not be tight for a specified contrast.

Positive Semidefiniteness Is Not Automatic

A relationship matrix used as a covariance matrix must be positive semidefinite: for every vector \(a\), \(a^\mathsf{T}Ka\geq0\). Symmetry and nonnegative diagonal entries alone do not guarantee this property. Hard thresholding does not, in general, preserve positive semidefiniteness. Thus a valid \(K\) can produce a \(K_\tau\) with a negative eigenvalue.

If \(K_\tau\) is positive semidefinite, then \(V_\tau\) is positive definite under the stated model assumptions. For any nonzero \(a\),

$$ a^\mathsf{T}V_\tau a =\sigma_g^2 a^\mathsf{T}K_\tau a+\sigma_e^2 a^\mathsf{T}a \geq \sigma_e^2\|a\|_2^2>0. $$

If \(K_\tau\) has a negative eigenvalue, the resulting \(V_\tau\) may or may not remain positive definite: the residual variance could outweigh the negative component, but this must be checked rather than assumed. A matrix that is not a valid covariance can cause a factorization to fail or yield an invalid fitted model. In the five-person example, \(K_\tau\) is strictly diagonally dominant with positive diagonal: each row’s off-diagonal absolute sum is less than 1. For a symmetric matrix, that condition here ensures its eigenvalues are positive, so \(K_\tau\) is positive definite. That convenient property of this example is not a general guarantee for thresholded matrices.

Worked Example: Checking Sparsity and Memory at Cohort Scale

Suppose a hypothetical cohort has \(n=100{,}000\) individuals and thresholding leaves an average of 40 nonzero off-diagonal relationships per individual. Including the diagonal, the full symmetric matrix has about \(100{,}000(40+1)=4{,}100{,}000\) nonzero entries. The dense matrix has \(100{,}000^2=10{,}000{,}000{,}000\) entries, so the sparse representation stores about \(4.1\times10^6/(10^{10})=0.00041\) as many entries, or about 0.041% as many.

With 8-byte values, a dense matrix requires approximately \(10^{10}(8)=80\) billion bytes, about 80 GB in decimal units. In a simple compressed sparse row representation using 8-byte values, 4-byte column indices, and 4-byte row pointers, the approximate storage is \(4.1\) million \(\times12\) bytes plus \(100{,}001\times4\) bytes, or about 49.6 MB. These calculations assume the stated average degree and ignore software overhead and any extra workspace.

This is a storage comparison, not a guarantee of a corresponding speedup in fitting. A sparse matrix-vector multiplication can take work proportional to the number of stored entries, but sparse factorization may create fill-in: intermediate matrices can acquire many nonzero entries. If the retained relationships form a poorly structured pattern, factorization can be much less sparse than the original matrix. Runtime therefore depends on the algorithm and the pattern of nonzeros, not just on the fraction of entries removed.

Diagnostics and Failure Modes

A threshold should be evaluated against the structure of the matrix and the intended model, not chosen solely to reach a desired storage target. Useful checks include:

  • Inspect the retained degree distribution. Record the number of retained neighbors per individual. A small average can conceal individuals whose rows remain dense or others whose relationships have nearly all been removed.
  • Summarize discarded row sums. Examine \(\|\Delta\|_\infty\), as well as the distribution of absolute discarded row sums. Many individually small entries can add to a substantial row total.
  • Check symmetry and eigenvalues. Confirm that thresholding was symmetric and assess whether the resulting matrix is positive semidefinite. Failed Cholesky factorization can be a warning, though it is not by itself a complete diagnosis of the source of the problem.
  • Vary the threshold. Compare the resulting sparsity, covariance summaries, and relevant fitted quantities across plausible thresholds. Large changes under small threshold adjustments indicate that the approximation deserves caution.
  • Check computational behavior. Measure actual memory and runtime for the intended operations. Sparse storage alone does not establish that the mixed-model fit will be faster.

A particularly common mistake is to reason that “each deleted relationship is tiny, so their total effect must be tiny.” This ignores accumulation across a row and the direction of the phenotype contrast being considered. The correction is to examine aggregate discarded relationships and, where useful, a bound such as \(\sigma_g^2\|\Delta\|_\infty\), while remembering that it is a worst-direction bound rather than a complete description of every fitted association result.

What Thresholding Does—and Does Not—Replace

A dense relationship matrix retains all estimated pairwise information and avoids this particular thresholding approximation, but its storage scales quadratically with cohort size. A sparse thresholded matrix reduces storage and can accelerate operations that exploit sparsity, at the cost of removing covariance information and potentially creating a non-positive-semidefinite matrix. Low-rank approximation, introduced in the earlier material on low-rank approximations to relationship matrices, compresses the matrix by representing dominant components rather than by deleting selected weak entries. The two approximations discard information in different ways; neither should be assumed to preserve all covariance features.

Thresholding is most defensible when the retained pattern has a meaningful sparse structure, the removed aggregate contributions are acceptably small for the analysis, and the resulting covariance is valid. Its limitations are important: it can distort long-range or diffuse relatedness, is sensitive to the threshold, and does not guarantee faster factorization. The best evidence is a combination of matrix diagnostics and sensitivity analysis, not sparsity alone.

Check Your Understanding

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

  1. With \(\tau=0.05\), which of the entries \(0.03\), \(-0.05\), and \(0.08\) are set to zero under the stated hard-thresholding rule?
  2. If the maximum absolute discarded row sum is \(0.09\) and \(\sigma_g^2=0.6\), give the bound on \(\|V-V_\tau\|_2\).
  3. Explain why a thresholded relationship matrix might be unsuitable even when the original matrix was positive semidefinite.
  4. A sparse matrix has few stored entries. Does that alone establish that fitting the mixed model will be fast? Give one reason for your answer.

Solutions. (1) The rule removes entries with absolute value strictly less than \(0.05\). Thus \(0.03\) is set to zero, while \(-0.05\) is retained because its absolute value equals the threshold, and \(0.08\) is retained. (2) The bound is \(\sigma_g^2\|\Delta\|_\infty=0.6(0.09)=0.054\). (3) Hard thresholding need not preserve positive semidefiniteness; the resulting matrix can have a negative eigenvalue and may not define a valid covariance. (4) No. Sparse factorization can create fill-in, so actual runtime depends on the nonzero pattern and the operations used.

Clinical Biostats