From SNP Associations to a Gene-Level Test
A transcriptome-wide association study (TWAS) combines GWAS evidence across variants using weights from a genetic expression predictor. The weights determine how SNP-level evidence is combined; they do not make the SNP tests independent. Because nearby variants can be correlated through linkage disequilibrium (LD), that dependence must be included when calculating the variability of the weighted sum.
This tutorial derives the standard summary-statistic form of the test. Its central result is that, when SNP z-scores have null covariance given by the LD matrix \(R\), the variance of their weighted sum is \(w^\mathsf{T}Rw\). Thus the gene-level statistic is not generally the weighted sum alone: it is that sum divided by its LD-aware standard deviation.
The numerator \(w^\mathsf{T}Z=\sum_{j=1}^{m}w_j Z_j\) is the weighted aggregate of the SNP z-scores. The denominator is its null standard deviation. A two-sided p-value is calculated as \(2\{1-\Phi(|Z_{\mathrm{TWAS}}|)\}\), where \(\Phi\) is the standard normal cumulative distribution function. The test assesses whether the weighted genetic evidence is inconsistent with a null of no association for this gene-level score. A small p-value is evidence of association, not by itself evidence that altered expression causes the outcome.
Why the LD Matrix Appears
The derivation uses a standard large-sample approximation for GWAS score statistics. Suppose the genotypes at the \(m\) SNPs have been standardized, and the GWAS SNP tests use the same individuals and phenotype analysis. Under the global null of no SNP association, the vector of SNP z-scores is approximately multivariate normal with mean zero and covariance \(R\), the SNP correlation matrix in the GWAS sample. In notation,
This approximation requires that the LD matrix represent the correlations relevant to the GWAS SNP scores. In practice, a reference panel may be used to estimate those correlations, so ancestry and allele alignment matter. The weights and \(Z\) must refer to the same variants in the same order, and the alleles used to define the weights must agree with the alleles used for the GWAS statistics. The weights are treated as fixed for this derivation, as is usual when they have been estimated in an independent expression-prediction sample.
For any fixed vector \(w\), the mean of a weighted random vector is the corresponding weighted mean, and its variance is obtained by multiplying its covariance matrix on the left and right by the weight vector. Applying these identities to \(w^\mathsf{T}Z\) gives the result directly.
Consequently, standardizing the weighted sum by \(\sqrt{w^\mathsf{T}Rw}\) gives a statistic with approximate mean zero and variance one under the null. If \(R\) is positive semidefinite, \(w^\mathsf{T}Rw\geq 0\), as a variance must be. If this quantity is zero, the weighted score has no null variability and the displayed statistic is undefined; it is not a usable test in that case.
Worked Calculations
Worked Example: Two SNPs With Opposite-Signed Weights
Suppose two hypothetical SNPs have GWAS z-scores \(Z=(2.10,1.20)^\mathsf{T}\), prediction weights \(w=(0.80,-0.50)^\mathsf{T}\), and estimated LD correlation \(r=0.30\). The LD matrix is
First calculate the weighted numerator: $$ w^\mathsf{T}Z=(0.80)(2.10)+(-0.50)(1.20)=1.68-0.60=1.08. $$ The variance includes the covariance term: $$ w^\mathsf{T}Rw=(0.80)^2+(-0.50)^2+2(0.80)(-0.50)(0.30) =0.64+0.25-0.24=0.65. $$ Therefore, $$ Z_{\mathrm{TWAS}}=\frac{1.08}{\sqrt{0.65}}=\frac{1.08}{0.8062}=1.340. $$ The approximate two-sided p-value is \(2\{1-\Phi(1.340)\}\approx 0.180\). At a 0.05 threshold, this hypothetical result is not statistically significant. The negative covariance contribution follows from the opposite-signed weights: with positively correlated SNP scores, their weighted contributions tend to offset one another under the null.
Worked Example: Same-Signed Weights and Positive LD
Now suppose the hypothetical weights are \(w=(0.60,0.40)^\mathsf{T}\), the GWAS z-scores are \(Z=(2.00,1.00)^\mathsf{T}\), and the SNP correlation remains \(r=0.50\). Then $$ R= \begin{pmatrix} 1&0.50\\ 0.50&1 \end{pmatrix}. $$ The weighted score is $$ w^\mathsf{T}Z=(0.60)(2.00)+(0.40)(1.00)=1.20+0.40=1.60. $$ Its null variance and standard deviation are $$ w^\mathsf{T}Rw=(0.60)^2+(0.40)^2+2(0.60)(0.40)(0.50) =0.36+0.16+0.24=0.76, \qquad \sqrt{0.76}=0.8718. $$ Thus \(Z_{\mathrm{TWAS}}=1.60/0.8718=1.835\), with two-sided p-value approximately \(0.0665\). This result is not significant at 0.05. Here the cross-product is positive, so positive LD increases the variance of the weighted sum. Ignoring LD would give a denominator of \(\sqrt{0.36+0.16}=0.7211\), and an incorrectly larger statistic of about \(2.219\).
Using SNP Effect Estimates Instead of Z-Scores
Some analyses start with marginal effect estimates and their standard errors rather than z-scores. The same variance principle applies, but the covariance must be on the effect-estimate scale. If \(\hat{\beta}\) is the vector of marginal SNP effect estimates and \(V=\operatorname{Cov}(\hat{\beta})\), then the weighted estimate \(w^\mathsf{T}\hat{\beta}\) has variance \(w^\mathsf{T}Vw\). The corresponding standardized statistic is $$ \frac{w^\mathsf{T}\hat{\beta}}{\sqrt{w^\mathsf{T}Vw}}. $$ The matrix \(V\) is not automatically the correlation matrix \(R\): its diagonal entries are the squared standard errors, and its off-diagonal entries must be on the same effect scale. Applying the z-score formula directly to effect estimates, or using \(R\) as though it were an effect-estimate covariance matrix, generally gives the wrong standard error.
Worked Example: Weighted Effect Estimates With Their Covariance
Consider hypothetical marginal estimates \(\hat{\beta}=(0.10,0.04)^\mathsf{T}\), with standard errors \(0.05\) and \(0.04\), respectively. Let their correlation be \(0.25\), and let the weights be \(w=(0.70,0.30)^\mathsf{T}\). For this example, assume the covariance between the two estimates is their standard errors multiplied by their correlation: $$ \operatorname{Cov}(\hat{\beta}_1,\hat{\beta}_2)=(0.05)(0.04)(0.25)=0.0005. $$ Therefore, $$ V= \begin{pmatrix} 0.05^2&0.0005\\ 0.0005&0.04^2 \end{pmatrix} = \begin{pmatrix} 0.0025&0.0005\\ 0.0005&0.0016 \end{pmatrix}. $$ The weighted estimate is $$ w^\mathsf{T}\hat{\beta}=(0.70)(0.10)+(0.30)(0.04)=0.070+0.012=0.082. $$ Its variance and standard error are $$ w^\mathsf{T}Vw=(0.70)^2(0.0025)+(0.30)^2(0.0016)+2(0.70)(0.30)(0.0005) =0.001225+0.000144+0.000210=0.001579, $$ $$ SE=\sqrt{0.001579}=0.03974. $$ The standardized statistic is \(0.082/0.03974=2.064\), corresponding to an approximate two-sided p-value of \(0.0391\). Under the stated covariance model, the weighted estimate is statistically distinguishable from zero at the 0.05 level. The estimate’s units are determined by the units of the SNP effects and weights; they must be stated in an applied analysis.
The effect-estimate and z-score versions are related, but their weights and scaling must be handled consistently. When standard errors differ across SNPs, weighting a vector of z-scores by \(w\) is not generally identical to weighting raw effect estimates by the same \(w\). The formula used must match the quantity being combined and its covariance matrix.
Practical Checks and a Common Pitfall
Before interpreting a computed statistic, verify that the entries of \(Z\), \(w\), and \(R\) refer to precisely the same SNPs, in the same order. Check effect-allele orientation as well: reversing an allele changes the sign of a SNP effect and its z-score, so inconsistent orientation changes the weighted numerator. The LD matrix should have ones on its diagonal, be symmetric, and be a plausible correlation matrix. These checks address the inputs to the calculation; they do not change the meaning of the test.
- Pitfall: treating SNP tests as independent. The incorrect reasoning is that the variance of the weighted sum is always \(\sum_j w_j^2\), because each SNP z-score has variance one. That omits covariance between distinct SNP scores. The correction is to use \(w^\mathsf{T}Rw=\sum_j w_j^2+2\sum_{j<k}w_jw_kR_{jk}\).
- Pitfall: interpreting a significant TWAS statistic as proof of a causal expression effect. The statistic tests a weighted association under its model and assumptions. Statistical significance alone does not establish the causal interpretation.
- Pitfall: mixing effect estimates and z-scores. These have different scales and covariance matrices. Use the appropriate weighted numerator and its corresponding covariance-based standard error.
Check Your Understanding
Try these questions without looking back.
- For a vector of GWAS z-scores with null covariance \(R\), what is the null variance of \(w^\mathsf{T}Z\)?
- With two positively correlated SNPs and two positive weights, will the LD cross-product increase or decrease the weighted-score variance? Explain using its sign.
- Why is \(\sum_j w_j^2\) generally not the correct variance for a weighted sum of correlated SNP z-scores?
- What information must align across the GWAS z-scores, weights, and LD matrix before calculating the statistic?
- For weighted effect estimates, which covariance matrix belongs in the variance calculation, and why is it not generally just \(R\)?