From SNP Associations to a Gene-Level Score
A transcriptome-wide association study (TWAS) tests whether a gene’s genetically predicted expression is associated with a trait. The prediction is built from SNP genotypes and expression-prediction weights. If SNPs are correlated through linkage disequilibrium, their association statistics are correlated too. Therefore, a weighted sum of SNP-level statistics needs a variance calculation that accounts for their covariance.
This tutorial derives that score from a linear-model perspective and then expresses it using summary statistics. The target is the test statistic for one gene and one trait. The statistic measures evidence of association; by itself, it does not establish that changing the gene’s expression would cause a change in the trait.
Model and Assumptions
For the derivation, suppose each SNP genotype has been centered and scaled to variance one in the association sample. Write \(X\) for the \(n\times m\) genotype matrix, with \(n\) individuals and \(m\) SNPs, so that \(X^\mathsf{T}X/n\) estimates \(R\). Let \(y\) be a quantitative trait after centering and, if needed, adjusting for covariates. The expression predictor for each individual is the weighted genotype sum \(Xw\). The weights are treated as fixed for this test; for example, they may have been estimated in an independent expression reference sample.
For a simple derivation, take the null model to be \(y=\varepsilon\), where the residuals have mean zero, variance \(\sigma^2\), and are independent across individuals conditional on the genotypes. The linear-model score calculation also applies after suitable covariate adjustment, using genotypes and outcomes residualized against those covariates. The normal approximation requires enough information for the SNP association statistics to be approximately jointly normal. The association statistics and LD matrix must refer to harmonized SNPs, alleles, and a sufficiently compatible population. In practice, differences in sample composition or allele coding can violate that alignment.
Define the SNP-level score component \(z_j\) as \(X_j^\mathsf{T}y/(\sigma\sqrt{n})\), where \(X_j\) is column \(j\) of \(X\). In applied analyses, this component is represented by a SNP association \(z\)-statistic, typically an estimated effect divided by its standard error. Under the null, the components have variance approximately one, and their covariance is determined by the genotype correlations.
Why the Denominator Contains the SNP Covariance
The unstandardized gene-level score is \(w^\mathsf{T}z\): each SNP association is multiplied by its expression-prediction weight and the contributions are summed. To turn this into a test statistic, calculate the variance of that sum under the null.
The quadratic form expands to the sum of each SNP’s variance contribution and every pairwise covariance contribution:
Since the SNP statistics have unit variance under the stated null approximation, their covariance is approximately \(R_{jk}\). Dividing the weighted sum by its null standard deviation therefore gives \(Z_{\mathrm{TWAS}}\). This is a standardization, not a second weighting step: the numerator aggregates associations, and the denominator scales that aggregate according to its variability.
Calculate \(w^\mathsf{T}z\), preserving each SNP’s signed association and signed prediction weight.
Use \(w^\mathsf{T}Rw\), including the off-diagonal covariances between SNP statistics.
Divide by \(\sqrt{w^\mathsf{T}Rw}\). A two-sided test uses the standard normal tail probability \(2P(N(0,1)\geq |Z_{\mathrm{TWAS}}|)\).
The same result follows directly from the individual-level regression score. The score for testing association of \(y\) with \(Xw\) at a zero gene-level effect is \((Xw)^\mathsf{T}y\). Under the null, its variance is \(\sigma^2(Xw)^\mathsf{T}(Xw)\). Since \((Xw)^\mathsf{T}y=w^\mathsf{T}X^\mathsf{T}y\) and \((Xw)^\mathsf{T}(Xw)\approx n w^\mathsf{T}Rw\), dividing the score by its standard deviation yields the same expression as the summary-statistic formula.
Worked Example: A Two-SNP TWAS Score
Suppose a hypothetical gene has weights \(w=(0.6,0.8)^\mathsf{T}\), SNP-trait statistics \(z=(2.0,1.0)^\mathsf{T}\), and SNP correlation \(R_{12}=R_{21}=0.5\). The diagonal entries of a correlation matrix are one, so $$ R=\begin{pmatrix}1&0.5\\0.5&1\end{pmatrix}. $$
The weighted numerator is $$ w^\mathsf{T}z=(0.6)(2.0)+(0.8)(1.0)=1.2+0.8=2.0. $$
The variance factor is $$ w^\mathsf{T}Rw=(0.6)^2+(0.8)^2+2(0.6)(0.8)(0.5) =0.36+0.64+0.48=1.48. $$ Thus the standard deviation is \(\sqrt{1.48}=1.2166\), and $$ Z_{\mathrm{TWAS}}=\frac{2.0}{1.2166}=1.644. $$ The two-sided standard normal p-value is approximately \(0.100\). Under the model, the data provide limited evidence against the null of no association for this gene-level score at conventional significance levels. The result is not obtained by treating the two SNP statistics as independent: their positive correlation contributes \(0.48\) to the variance factor.
Using Effect Estimates and Standard Errors
The formula can also be written with SNP effect estimates, but the units and covariance need to be handled consistently. Let \(\hat b_j\) be the SNP-trait effect estimate and \(s_j\) its standard error. If \(z_j=\hat b_j/s_j\), collect the standard errors in the diagonal matrix \(D=\operatorname{diag}(s_1,\ldots,s_m)\), so that \(\hat b=Dz\). When the null covariance of \(z\) is \(R\), the covariance of the effect estimates is approximately \(DRD\). Consequently, the weighted effect sum has variance approximately \(w^\mathsf{T}DRDw\), and its standardized statistic is $$ \frac{w^\mathsf{T}\hat b}{\sqrt{w^\mathsf{T}DRDw}}. $$ When all standard errors are the same value \(s\), this reduces to \(w^\mathsf{T}\hat b/(s\sqrt{w^\mathsf{T}Rw})\). A formula that mixes effect estimates with a denominator intended for \(z\)-statistics will generally have the wrong scale.
Worked Example: Equal Standard Errors and Independent SNPs
Consider a hypothetical two-SNP example with independent genotypes, weights \(w=(1,1)^\mathsf{T}\), effect estimates \(\hat b=(0.4,-0.1)^\mathsf{T}\), and standard errors \(s_1=s_2=0.5\). Independence means \(R\) is the identity matrix. The weighted effect sum is $$ w^\mathsf{T}\hat b=(1)(0.4)+(1)(-0.1)=0.3. $$
The variance of this sum is $$ w^\mathsf{T}DRDw =(0.5)^2+(0.5)^2=0.25+0.25=0.50. $$ Its standard deviation is \(\sqrt{0.50}=0.7071\), not \(0.50\). Therefore, $$ Z_{\mathrm{TWAS}}=\frac{0.30}{\sqrt{0.50}} =\frac{0.30}{0.7071}=0.4243. $$ The two-sided standard normal p-value is approximately \(0.6715\). The weighted effect sum is \(0.30\) in the units of the SNP effects; the standardized statistic is unitless. Because the effects point in opposite directions, their weighted contributions partly cancel.
Covariance Can Increase or Decrease the Score’s Scale
The off-diagonal terms matter in relation to both the SNP correlations and the signs of the weights. Positively correlated SNPs with weights of the same sign add positive covariance terms, increasing the variance of the sum. If the weights have opposite signs, the same positive correlation can reduce that variance. The numerator alone does not reveal either effect.
Worked Example: Opposite-Signed Weights
For a hypothetical gene, let \(w=(1,-1)^\mathsf{T}\), \(z=(1.5,1.0)^\mathsf{T}\), and let the SNP correlation be \(0.8\). The weighted numerator is $$ w^\mathsf{T}z=(1)(1.5)+(-1)(1.0)=0.5. $$
The variance factor includes a negative covariance term: $$ w^\mathsf{T}Rw=1^2+(-1)^2+2(1)(-1)(0.8) =2-1.6=0.4. $$ Hence the standard deviation is \(\sqrt{0.4}=0.6325\), and $$ Z_{\mathrm{TWAS}}=\frac{0.5}{0.6325}=0.7906. $$ The two-sided p-value is approximately \(0.429\). If one incorrectly ignored correlation, the denominator would be \(\sqrt{2}=1.414\), giving \(Z=0.3536\). That is a different statistic, because it assumes zero covariance when the stated SNP correlation is \(0.8\).
Assumptions, Checks, and Alternatives
Before interpreting a calculated score, check that the weight and association vectors refer to the same variants and allele orientation. If an allele is reversed for a SNP, its effect estimate or \(z\)-statistic must be reoriented consistently; otherwise, a contribution can acquire the wrong sign. Also check that \(R\) is a correlation matrix for the relevant SNPs in a population compatible with the trait-association sample. A mismatched or poorly estimated covariance matrix can distort the denominator, even if the numerator is calculated correctly.
The quadratic form must be nonnegative because it is a variance. A negative computed value indicates a problem such as an invalid covariance matrix, inconsistent SNP ordering, or numerical error. If \(w^\mathsf{T}Rw=0\), the predicted genotype score has zero variance in the modeled data, so the standardized statistic is undefined. Very small values can also make the calculation sensitive to small errors in weights or covariance estimates. These are reasons to inspect the inputs, not to force a p-value from an invalid denominator.
This covariance-adjusted score differs from simply summing SNP \(z\)-statistics or applying an independence-based denominator. Those shortcuts are valid only when their covariance assumptions hold. An individual-level regression on predicted expression is a related alternative: when it uses the same individuals, genotypes, weights, and covariate adjustment, its score calculation gives the same standardized result. It may be unavailable when only summary statistics can be analyzed. With summary data, the matrix expression makes the required covariance explicit, but its quality depends on having appropriate LD information.
The null normal approximation is not a guarantee that every practical analysis is calibrated. It relies on suitable association statistics and covariance estimates, and can be affected by ancestry mismatch, sample structure, or dependence between the expression-weight training data and the trait sample. The score also tests the weighted predicted-expression component represented by the chosen \(w\); it is not a direct test of every possible expression effect at the gene. In particular, association from this test alone does not demonstrate a causal expression mechanism.
Check Your Understanding
Work through each question, then compare with the solutions below.
- For \(w=(1,2)^\mathsf{T}\), \(z=(1,-0.5)^\mathsf{T}\), and \(R_{12}=0\), calculate the numerator, variance factor, and TWAS statistic.
- For \(w=(1,1)^\mathsf{T}\) and SNP correlation \(R_{12}=0.5\), what is \(w^\mathsf{T}Rw\)? Explain why it differs from the independent-SNP value.
- If two SNPs have positive correlation but weights with opposite signs, is their covariance contribution to \(w^\mathsf{T}Rw\) positive or negative?
- In the equal-standard-error example, why is the denominator \(\sqrt{0.50}\) rather than \(0.50\)?
Solutions. (1) The numerator is \(1(1)+2(-0.5)=0\). The variance factor is \(1^2+2^2=5\), so \(Z_{\mathrm{TWAS}}=0/\sqrt{5}=0\). (2) The variance factor is \(1+1+2(1)(1)(0.5)=3\), larger than the independent value \(2\) because the positive covariance adds \(1\). (3) It is negative, since the term \(2w_1w_2R_{12}\) has opposite-signed weights and positive correlation. (4) The variance is \(0.50\), and a standardized statistic divides by the standard deviation, which is the square root of the variance: \(\sqrt{0.50}=0.7071\).