Tutorials › High-Dimensional Genomic Data Analysis › Testing Differential Co-Expression Between Conditions

Co-Expression Networks · Tutorial 507 of 795

Testing Differential Co-Expression Between Conditions

Learn how to test whether a gene pair’s association differs between conditions, choose an appropriate comparison, and interpret its uncertainty and limitations.

Advanced 13 min read

What You'll Learn

  • Define differential co-expression as a difference between condition-specific gene-pair correlations.
  • Apply Fisher’s transformation to compare independent correlations.
  • Account for unequal group sizes in the standard error.
  • Distinguish correlation differences from regression-slope interactions.
  • Check assumptions and diagnose unstable or misleading comparisons.
  • Recognize the need for multiplicity control in genome-wide testing.

What Does It Mean for Co-Expression to Differ?

A gene pair may be positively correlated in one condition and weakly correlated in another. Testing this difference asks whether the two population correlations differ, not whether either correlation is individually different from zero. That distinction matters: one group’s correlation can be “significant” and the other’s not, even when the estimated correlations are not significantly different from each other.

For two genes \(X\) and \(Y\), let \(\rho_1\) and \(\rho_2\) denote their population correlations in conditions 1 and 2. The edge-level null hypothesis is \(H_0:\rho_1=\rho_2\); a two-sided alternative is \(H_a:\rho_1\ne\rho_2\). The correlations summarize linear association on the measured expression scale. A difference does not by itself identify a biological mechanism or establish causation.

Definition: Differential co-expression for a gene pair means that its population association, commonly measured by the Pearson correlation, differs between conditions. For independent groups, the direct target is \(\rho_1-\rho_2\), or equivalently whether that difference is zero.

The earlier material on batch, cell mixture, and spurious co-expression is relevant before interpreting a difference: condition-specific technical effects or changes in cell composition can alter correlations. The comparison below is a statistical test of the observed group populations, conditional on the sampling and measurement assumptions; it does not remove such confounding.

Fisher-Transformed Correlation Test

Suppose \(n_1\) and \(n_2\) independent biological samples are observed in the two conditions, with sample correlations \(r_1\) and \(r_2\). The standard Fisher comparison assumes independent groups, independent observations within each group, and an approximately bivariate-normal distribution of the two gene-expression measurements within each condition. The approximation is most useful when each sample size is not very small and the correlations are not dominated by extreme observations. Samples must be biological replicates, not technical replicates treated as independent subjects.

Definition: Fisher’s transformation of a sample correlation \(r\) is \(z_r=\frac{1}{2}\ln\left(\frac{1+r}{1-r}\right)=\operatorname{atanh}(r)\). Under the bivariate-normal model, \(z_r\) is approximately normal with standard error \(1/\sqrt{n-3}\). For two independent groups, the estimated difference \(z_{r_1}-z_{r_2}\) has standard error \(\sqrt{1/(n_1-3)+1/(n_2-3)}\).

The test statistic is the difference in transformed correlations divided by that standard error. Under \(H_0\), it is approximately standard normal. The transformation is important because the sampling distribution of \(r\) is skewed, especially when the population correlation is far from zero; the transformed scale is closer to normal and has a variance that is approximately independent of the correlation.

$$ Z=\frac{\operatorname{atanh}(r_1)-\operatorname{atanh}(r_2)} {\sqrt{\frac{1}{n_1-3}+\frac{1}{n_2-3}}} $$

For a two-sided test, the approximate p-value is \(2P(N(0,1)\ge |Z|)\). A confidence interval for the transformed difference can be formed as \((z_{r_1}-z_{r_2})\pm z_{1-\alpha/2}SE\), then interpreted on the transformed scale. Because subtracting transformed correlations is not the same as subtracting raw correlations, it is often clearer to report \(r_1\) and \(r_2\), their raw difference, and the test result together. The test is about equality of population correlations; it does not provide a confidence interval for the raw difference merely by back-transforming the endpoints of the transformed-difference interval.

Worked Example: Comparing Two Independent Correlations

In a hypothetical study, a gene pair has sample correlation \(r_1=0.60\) among \(n_1=40\) samples in condition 1 and \(r_2=0.20\) among \(n_2=40\) independent samples in condition 2. Assume the observations within each condition are independent and the gene-expression pairs are reasonably consistent with bivariate normal sampling, without influential outliers.

The transformed correlations are \(\operatorname{atanh}(0.60)=0.6931\) and \(\operatorname{atanh}(0.20)=0.2027\). The estimated transformed difference is \(0.6931-0.2027=0.4904\). The standard error is

$$ SE=\sqrt{\frac{1}{40-3}+\frac{1}{40-3}} =\sqrt{\frac{2}{37}}=0.2325. $$

Thus \(Z=0.4904/0.2325=2.109\), giving a two-sided normal-approximation p-value of approximately \(0.0349\). At \(\alpha=0.05\), this is evidence against equal population correlations under the stated assumptions. The observed correlations differ by \(0.60-0.20=0.40\), but the test evaluates equality on the Fisher-transformed scale.

Worked Example: Unequal Group Sizes

For a second hypothetical gene pair, condition 1 has \(n_1=30\) samples and \(r_1=0.55\); condition 2 has \(n_2=60\) samples and \(r_2=0.10\). Assume independent groups and observations, and no substantial departure from the approximate bivariate-normal model.

The transformed values are \(\operatorname{atanh}(0.55)=0.6184\) and \(\operatorname{atanh}(0.10)=0.1003\), so their difference is \(0.5180\). The group sizes enter separately in the standard error:

$$ SE=\sqrt{\frac{1}{30-3}+\frac{1}{60-3}} =\sqrt{\frac{1}{27}+\frac{1}{57}}=0.2336. $$

The statistic is \(Z=0.5180/0.2336=2.218\), with a two-sided p-value of approximately \(0.0266\). This provides evidence against equal correlations at the 0.05 level, subject to the assumptions. The larger second group contributes more precision, but does not make the two groups equally precise: replacing the standard error with a formula that assumes both sample sizes are 30 would be incorrect.

Why the Approximation Works, and What It Requires

A brief justification explains both the transformation and its limits. For bivariate-normal observations, the sample correlation is approximately normal around the population correlation, with variance close to \((1-\rho^2)^2/(n-1)\) for moderately large \(n\). Apply the delta method to \(g(r)=\operatorname{atanh}(r)\). Since \(g'(r)=1/(1-r^2)\), the approximate variance of \(g(r)\) is the variance of \(r\) multiplied by \(g'(\rho)^2\):

$$ \operatorname{Var}(g(r)) \approx \frac{(1-\rho^2)^2}{n-1} \left(\frac{1}{1-\rho^2}\right)^2 =\frac{1}{n-1}. $$

The commonly used \(1/(n-3)\) standard-error formula is a refined approximation for Fisher’s transformation. For independent groups, the variance of a difference is the sum of the two variances, producing the unequal-size standard error above. These are approximations, not exact finite-sample guarantees. With small groups, extreme correlations, or substantial non-normality, the nominal p-value can be poorly calibrated.

The independent-groups formula is not appropriate when the same individuals contribute measurements in both conditions, or when observations are otherwise paired or dependent. In that case the two sample correlations are dependent, and their covariance must be accounted for using a method designed for dependent correlations or a suitable resampling procedure. Treating repeated measurements as independent generally understates uncertainty.

Interaction Models: A Related, Different Question

Regression can test whether a gene’s linear association with another gene varies by condition, while also allowing covariates to be included. Let \(G=0\) for condition 1 and \(G=1\) for condition 2. A model with separate intercepts and slopes is

$$ Y_i=\beta_0+\beta_1X_i+\beta_2G_i+\beta_3(X_iG_i)+\varepsilon_i. $$

The slope for condition 1 is \(\beta_1\); the slope for condition 2 is \(\beta_1+\beta_3\). Testing \(H_0:\beta_3=0\) tests equality of those conditional linear slopes. The model requires an appropriate mean specification and independent errors; conventional standard errors additionally rely on constant residual variance and, for exact small-sample t inference, normally distributed errors. Heteroskedasticity-robust standard errors or an appropriate bootstrap may be needed when residual variances differ.

A slope interaction is not automatically a correlation-difference test. A raw regression slope depends on the scales and variances of \(X\) and \(Y\), whereas correlation is standardized. If the scientific target is correlation, Fisher’s method is the direct two-group comparison under its assumptions. An interaction model can target standardized within-condition associations if variables are standardized separately within each condition, but the analysis must explicitly define that target and use valid uncertainty estimates. Adding covariates also changes the target: an adjusted slope comparison is not generally the same as comparing marginal correlations.

Worked Example: Testing an Interaction Contrast

In a hypothetical covariate-adjusted regression analysis, the estimated condition-specific slopes for a gene pair are \(0.70\) and \(0.20\) expression units of \(Y\) per expression unit of \(X\). A fitted interaction model estimates their contrast as \(\hat{\beta}_3=0.20-0.70=-0.50\), with \(SE(\hat{\beta}_3)=0.20\) and \(df=76\). Suppose residual diagnostics support the model’s linear mean structure and independent sampling; the reported standard error and degrees of freedom are taken from that fitted model.

The test statistic is \(t=-0.50/0.20=-2.50\). The two-sided p-value from a \(t\) distribution with 76 degrees of freedom is \(0.01457\). At \(\alpha=0.05\), the interaction provides evidence that the conditional slopes differ. The estimated contrast is \(-0.50\) \(Y\)-expression units per \(X\)-expression unit: the condition 2 slope is lower. This conclusion concerns the model’s slopes, not necessarily the raw gene-pair correlations.

Genome-Wide Testing, Diagnostics, and Limitations

Testing one pair is different from testing many pairs. With \(p\) genes there are \(p(p-1)/2\) distinct unordered pairs, so thousands or millions of tests may be conducted. A nominal p-value of 0.05 does not control the proportion of false discoveries across that collection. Apply a multiple-testing procedure appropriate to the analysis plan, commonly false-discovery-rate control, and report the adjustment method and adjusted results. Dependence among tests is expected because gene pairs share genes; the chosen procedure’s assumptions should be considered.

Useful diagnostics are focused on whether the correlation estimates and their standard errors are trustworthy. Examine scatterplots for selected pairs in each condition, check for nonlinearity, outliers, restricted ranges, and influential samples, and verify that group labels and sample counts are correct. Compare distributions and missingness patterns across conditions. If an apparent correlation is driven by one sample or by a batch that aligns with condition, the Fisher test does not repair the problem. Consider robust association measures or resampling when assumptions are doubtful, while recognizing that changing the association measure changes the scientific target.

ApproachPrimary targetKey consideration
Fisher-transformed testEquality of two independent Pearson correlationsUses group-specific sample sizes; relies on an approximate bivariate-normal sampling result
Interaction regressionEquality of condition-specific linear slopesCan include covariates, but raw slopes and correlations are different quantities
Resampling or permutationDepends on the statistic and resampling designMust preserve the study’s independent, paired, or blocked structure and a valid null scheme

Neither method makes a correlation causal, establishes why an association changed, nor guarantees that a network edge is biologically meaningful. A difference may reflect altered expression range, residual confounding, measurement quality, or sampling variability. Results are especially uncertain when one group is small, correlations are near \(1\) or \(-1\), or the relevant expression range differs sharply by condition. Report group sizes, correlations, the test statistic, p-value or adjusted p-value, and the assumptions that support interpretation.

Common Mistakes

  • Comparing separate significance labels. “Significant in condition 1 but not condition 2” does not establish a significant difference. Test the difference directly.
  • Ignoring group imbalance. The standard error uses \(n_1\) and \(n_2\) separately; a pooled sample size is not a substitute.
  • Calling a slope interaction a correlation test. A raw slope depends on measurement scales. State the estimand and standardization explicitly.
  • Using the independent-groups formula for paired samples. Dependence between estimates changes the variance of their difference.
  • Interpreting a small p-value as a large biological effect. Statistical evidence against equality does not quantify practical importance; report the observed correlations and their context.
Key takeaway: For two independent conditions, compare Fisher-transformed correlations using the standard error \(\sqrt{1/(n_1-3)+1/(n_2-3)}\). Use an interaction model when the target is a regression-slope difference, and do not conflate that target with correlation without explicitly defining the model and scale.

Check Your Understanding

Try the questions, then check the solutions below. For numerical answers, small differences from rounding are acceptable.

  1. Why is “the correlation is significant in one condition but not the other” insufficient evidence that the conditions differ?
  2. For independent groups with \(n_1=25\) and \(n_2=45\), what standard error is used for the difference in Fisher-transformed correlations?
  3. A fitted interaction is \(\hat{\beta}_3=0.30\) with standard error \(0.15\). What is the test statistic, and what null hypothesis does it test?
  4. Name two reasons the independent Fisher comparison may be unreliable or inappropriate.

Solutions. (1) The two separate tests address whether each correlation differs from zero, not whether the correlations differ from each other; test \(H_0:\rho_1=\rho_2\) directly. (2) \(SE=\sqrt{1/(25-3)+1/(45-3)}=\sqrt{1/22+1/42}=\sqrt{0.06926}=0.2632\). (3) \(t=0.30/0.15=2.00\); it tests equality of the model’s condition-specific slopes, \(H_0:\beta_3=0\). (4) Examples include paired or repeated samples, very small groups, influential outliers, substantial non-normality, or dependence among observations within a group. In paired data, the independent-group variance formula is not suitable.

Clinical Biostats