Tutorials › Statistical Genetics › Testing Differences Between Cell-Type Genetic Effects

Single-Cell and Cell-Type Genetics · Tutorial 957 of 989

Testing Differences Between Cell-Type Genetic Effects

Derive and interpret a cell-type effect contrast, calculate its uncertainty from the joint covariance, and distinguish a direct comparison from two separate significance tests.

Advanced 10 min read

What You'll Learn

  • Define a difference between two cell-type genetic-effect coefficients as a contrast.
  • Derive the contrast’s variance from both coefficient variances and their covariance.
  • Calculate a Wald test and confidence interval for a cell-type effect difference.
  • Interpret covariance when estimates come from overlapping or jointly modeled data.
  • Explain why significance in one cell type but not another does not establish different effects.
  • Extend the contrast calculation to a weighted comparison of multiple cell types.

Why Test the Difference Directly?

A genetic association can have different estimated magnitudes in different cell types. The relevant question is whether the effects themselves differ, not whether separate analyses happen to give different significance labels. Those are distinct questions: the uncertainty in a difference depends on the uncertainty of each estimate and on how the estimates covary.

For example, suppose a genotype is associated with expression in one cell type at a conventional significance level but not in another. That alone does not establish cell-type specificity. The second estimate might be nearly as large but less precise, or the two estimates might be strongly correlated. A direct contrast addresses the scientific target: the difference between the cell-type genetic effects.

Definition: Let \(\beta_A\) and \(\beta_B\) denote the genetic-effect coefficients for cell types A and B, defined on the same outcome and genotype scale. The contrast \(\Delta_{A-B}=\beta_A-\beta_B\) is the difference in genetic effects, with positive values indicating a larger coefficient in cell type A. Its estimate is \(\hat{\Delta}_{A-B}=\hat{\beta}_A-\hat{\beta}_B\).

Uncertainty in a Difference

The estimates \(\hat{\beta}_A\) and \(\hat{\beta}_B\) may not be independent. They can be correlated because the estimates come from a joint model or because observations, such as donors, contribute to both cell-type analyses. Write their standard errors as \(SE_A\) and \(SE_B\), and their estimated covariance as \(\widehat{\operatorname{Cov}}(\hat{\beta}_A,\hat{\beta}_B)\). Then the estimated variance of the difference is

$$ \widehat{\operatorname{Var}}(\hat{\Delta}_{A-B}) = SE_A^2+SE_B^2 - 2\widehat{\operatorname{Cov}}(\hat{\beta}_A,\hat{\beta}_B). $$

The standard error of the contrast is the square root of this estimated variance. The covariance has the same squared-coefficient units as the variances. It is not generally valid to omit the covariance term or to assume it is zero merely because two coefficients refer to different cell types.

Wald test and interval: To test \(H_0:\Delta_{A-B}=0\) against \(H_a:\Delta_{A-B}\ne 0\), calculate \(z=\hat{\Delta}_{A-B}/SE(\hat{\Delta}_{A-B})\). When the estimator is approximately normal under the model, the two-sided p-value is \(2P(Z\geq |z|)\), where \(Z\sim N(0,1)\). A 95% Wald confidence interval is \(\hat{\Delta}_{A-B}\pm1.96SE(\hat{\Delta}_{A-B})\). For an analysis using a finite-sample \(t\) reference distribution, use its specified degrees of freedom and corresponding critical value instead.

These calculations assume that the two coefficients describe comparable effects: the same outcome scale, genotype coding, and compatible adjustment for covariates. Inference also relies on an adequate fitted model and a valid estimate of the joint coefficient covariance. For a large-sample Wald test, the estimated contrast must be approximately normal. The null concerns equality of the modeled genetic-effect coefficients; rejecting it is evidence of a difference in association on that model’s scale, not proof that genotype causes a cell-type-specific biological mechanism.

Deriving the Contrast Variance

The variance formula follows from the variance of a linear combination. For any random variables \(U\) and \(V\), \(\operatorname{Var}(U-V)=\operatorname{Var}(U)+\operatorname{Var}(V)-2\operatorname{Cov}(U,V)\). Taking \(U=\hat{\beta}_A\) and \(V=\hat{\beta}_B\) gives the result directly. The covariance term is essential: positive covariance reduces the variance of a difference, while negative covariance increases it.

$$ \begin{aligned} \operatorname{Var}(\hat{\beta}_A-\hat{\beta}_B) &=\operatorname{Var}(\hat{\beta}_A)+\operatorname{Var}(-\hat{\beta}_B) +2\operatorname{Cov}(\hat{\beta}_A,-\hat{\beta}_B)\\ &=\operatorname{Var}(\hat{\beta}_A)+\operatorname{Var}(\hat{\beta}_B) -2\operatorname{Cov}(\hat{\beta}_A,\hat{\beta}_B). \end{aligned} $$

In a joint regression, the covariance is obtained from the estimated covariance matrix of the model coefficients. If cell-type effects are represented by a reference-cell coefficient and genotype-by-cell-type interaction coefficients, first express each cell-type effect as the appropriate linear combination of model coefficients. Then express their difference as a linear combination and use the same covariance matrix. This is the contrast view of testing an interaction: the answer depends on the contrast and its uncertainty, not just on the interaction coefficient’s label.

$$ \widehat{\operatorname{Var}}(\mathbf{c}^{T}\hat{\boldsymbol{\beta}}) = \mathbf{c}^{T}\widehat{\Sigma}\mathbf{c}, $$

where \(\hat{\boldsymbol{\beta}}\) is the vector of estimated coefficients, \(\mathbf{c}\) contains the contrast weights, and \(\widehat{\Sigma}\) is their estimated covariance matrix. For a two-coefficient difference, the weights are \(1\) and \(-1\), yielding the variance formula above. This form also handles comparisons involving more cell types.

Worked Example: Comparing Two Cell-Type Effects

Hypothetical data. A joint pseudobulk analysis estimates the per-allele effects of a genotype on expression in two cell types, on a log2-expression scale. The estimates are \(\hat{\beta}_A=0.42\) and \(\hat{\beta}_B=0.10\), with standard errors \(0.12\) and \(0.14\). The joint model reports covariance \(0.006\). Assume the model uses the same genotype coding and outcome scale for both effects and that a normal Wald approximation is appropriate.

The estimated difference, oriented as A minus B, is \(\hat{\Delta}_{A-B}=0.42-0.10=0.32\) log2-expression units per allele. Its estimated variance and standard error are

$$ \widehat{\operatorname{Var}}(\hat{\Delta}_{A-B}) =0.12^2+0.14^2-2(0.006) =0.0144+0.0196-0.012 =0.0220, \qquad SE(\hat{\Delta}_{A-B})=\sqrt{0.0220}=0.1483. $$

The covariance is feasible for these standard errors: its implied correlation is \(0.006/(0.12\times0.14)=0.357\), which lies between \(-1\) and \(1\). The test statistic is \(z=0.32/0.1483=2.158\), giving a two-sided normal p-value of approximately \(0.0310\). The 95% interval is \(0.32\pm1.96(0.1483)=(0.0293,0.6107)\).

Under the stated model and approximation, the data provide evidence that the per-allele association is larger in cell type A than in cell type B. The interval describes uncertainty in that difference, in log2-expression units per allele; it is not a probability statement about where the fixed true difference lies.

Why Separate Significance Tests Do Not Test a Difference

A test in cell type A evaluates \(H_0:\beta_A=0\); a separate test in cell type B evaluates \(H_0:\beta_B=0\). Neither test directly evaluates \(H_0:\beta_A-\beta_B=0\). A significant result in A and a nonsignificant result in B may occur even when the two estimated effects are similar. Conversely, two significant estimates do not imply that the effects are equal.

The distinction is especially important when standard errors differ or estimates covary. Comparing p-values, or treating “significant” and “not significant” as two different effect categories, discards the magnitude and uncertainty of the actual contrast. The direct procedure is to calculate the difference, its covariance-aware standard error, and a test or interval for that difference.

Worked Example: One Significant Result Is Not a Significant Difference

Hypothetical data. Suppose two cell-type analyses estimate per-allele effects of \(0.30\) and \(0.18\) log2-expression units, each with standard error \(0.12\). Their covariance from the joint analysis is \(0.010\). Assume comparable model scales and a normal Wald approximation.

For cell type A alone, \(z_A=0.30/0.12=2.50\), with a two-sided p-value of approximately \(0.0124\). For cell type B alone, \(z_B=0.18/0.12=1.50\), with a two-sided p-value of approximately \(0.134\). Thus, the first coefficient is statistically distinguishable from zero at the 0.05 level and the second is not.

But the estimated difference is only \(0.30-0.18=0.12\). Its variance, standard error, and test statistic are

$$ \widehat{\operatorname{Var}}(\hat{\Delta}_{A-B}) =0.12^2+0.12^2-2(0.010) =0.0088, \qquad SE(\hat{\Delta}_{A-B})=\sqrt{0.0088}=0.09381, \qquad z=\frac{0.12}{0.09381}=1.279. $$

The two-sided p-value for the difference is approximately \(0.201\), and its 95% interval is \(0.12\pm1.96(0.09381)=(-0.0639,0.3039)\). The interval includes zero, so this analysis does not provide evidence of a difference at the 0.05 level. The result does not show that the effects are equal; it shows that the estimated difference is too uncertain here to distinguish it from zero using this test.

Contrasts Across Several Cell Types

A contrast need not compare only two cell types. Suppose a study has three cell-type effects, \(\beta_1,\beta_2,\beta_3\), and the prespecified target is the effect in type 1 minus the average effect in types 2 and 3. The contrast is \(\Delta=\beta_1-(\beta_2+\beta_3)/2\), with weights \(\mathbf{c}=(1,-0.5,-0.5)^T\). Its variance is \(\mathbf{c}^{T}\widehat{\Sigma}\mathbf{c}\), so all relevant variances and covariances contribute. State the contrast and its direction before interpreting the result; reversing the order changes the sign of the estimate and interval, but not a two-sided p-value.

Worked Example: Comparing One Cell Type With Two Others

Hypothetical data. Three estimated per-allele effects, in log2-expression units, are \(\hat{\boldsymbol{\beta}}=(0.24,0.08,0.02)^T\). Their estimated covariance matrix is

$$ \widehat{\Sigma}= \begin{pmatrix} 0.0100 & 0.0020 & 0.0010\\ 0.0020 & 0.0144 & 0.0030\\ 0.0010 & 0.0030 & 0.0196 \end{pmatrix}. $$

The target is cell type 1 minus the average of cell types 2 and 3, so \(\hat{\Delta}=0.24-(0.08+0.02)/2=0.19\). Using weights \((1,-0.5,-0.5)^T\), expand the variance to include the diagonal and covariance terms:

$$ \begin{aligned} \widehat{\operatorname{Var}}(\hat{\Delta}) &=0.0100+0.25(0.0144)+0.25(0.0196)\\ &\quad+2(1)(-0.5)(0.0020)+2(1)(-0.5)(0.0010) +2(-0.5)(-0.5)(0.0030)\\ &=0.0170, \qquad SE(\hat{\Delta})=\sqrt{0.0170}=0.1304. \end{aligned} $$

The Wald statistic is \(z=0.19/0.1304=1.457\), with a two-sided p-value of approximately \(0.145\). The 95% interval is \(0.19\pm1.96(0.1304)=(-0.0656,0.4456)\). Under this model, the comparison does not establish that the effect in cell type 1 differs from the average effect in cell types 2 and 3.

Common Mistakes and Practical Checks

  • Wrong reasoning: “The effect is significant in A but not B, so the effects differ.” These tests compare each effect with zero, not with each other. Calculate and test \(\beta_A-\beta_B\) directly.
  • Wrong reasoning: “The variance of the difference is just the sum of the two variances.” That is justified only when the covariance is zero. Use the covariance from the joint model or another valid procedure for estimating the joint uncertainty.
  • Wrong reasoning: “A positive covariance makes a difference less precise.” For a difference, positive covariance subtracts twice from the variance and therefore reduces its standard error; negative covariance increases it. The sign depends on the contrast.
  • Wrong reasoning: “A nonsignificant contrast proves identical effects.” Failure to reject equality is not proof of equality. Report the estimate and interval so readers can assess which differences remain compatible with the data.
  • Wrong reasoning: “Any two reported coefficients can be subtracted.” A meaningful contrast requires comparable estimands, including compatible outcome scales, genotype coding, and model adjustments.

When multiple contrasts are examined, their multiplicity and the analysis plan also matter for interpreting evidence. Whatever testing strategy is used, the basic contrast and its uncertainty should remain explicit. In single-cell genetic analyses, it is particularly important to use the coefficient covariance appropriate to the fitted analysis rather than assume estimates from different cell types are independent.

Key takeaway: A cell-type difference is a contrast of genetic-effect coefficients. Estimate that contrast, calculate its variance with the coefficient covariance, and test or report an interval for the difference itself. Separate significance results do not answer this question.

Check Your Understanding

Use the contrast and its covariance-aware uncertainty to reason through each question.

  1. For cell-type effects \(\hat{\beta}_A=0.25\) and \(\hat{\beta}_B=0.10\), what is the estimated A-minus-B contrast, and what does its sign mean?
  2. Why does the variance formula for \(\hat{\beta}_A-\hat{\beta}_B\) include minus twice the covariance?
  3. If each cell-type estimate has standard error \(0.10\) and their covariance is \(0.004\), calculate the standard error of their difference.
  4. In your own words, why does significance for one effect and nonsignificance for another fail to establish a significant difference?
  5. For the contrast \(\beta_1-(\beta_2+\beta_3)/2\), state the three contrast weights and explain why off-diagonal entries of the covariance matrix can affect its standard error.
Clinical Biostats