Why Planned Contrasts Matter
With three conditions, a fitted model can answer several different questions. A comparison of each treatment with control asks whether either treatment differs from the reference condition; a pairwise comparison of the two treatments asks whether their effects differ from each other. These are not interchangeable claims. A contrast states exactly which difference is being estimated, while a multiplicity plan states which collection of tests is being controlled.
Here the conditions are independent groups: each biological donor contributes pseudobulk data to one condition, not repeated measurements across conditions. Pseudobulk counts are sums of cell counts within a donor and a prespecified cell type. The donor, rather than each cell, is the independent biological unit. The earlier material on pseudobulk inference and independent-group analysis motivates this unit of analysis; the focus here is constructing and interpreting multiple contrasts from one three-condition model.
Model and Assumptions
This model is appropriate when donors are independent across conditions, the condition labels and offsets are correctly recorded, and the negative-binomial mean–variance relationship is an adequate description of the counts. It also assumes that the condition effect is represented by the specified model and is not inseparably confounded with a batch or other design variable. If an adjustment variable is required and estimable, it belongs in the model; an omitted confounder is not repaired by changing the contrast afterward.
The examples use a fitted model with a log link and normal-based Wald tests. Those tests rely on standard errors and their sampling approximation being adequate. With few donors, unstable dispersion estimates, or poor calibration, nominal Wald p-values may be unreliable; the material on few-donor inference, robust standard errors, diagnostics, and calibration gives relevant checks. A repeated-measures design requires a model that represents within-donor dependence, rather than treating repeated pseudobulks as independent.
From Coefficients to Contrasts
A contrast is a linear combination of estimated coefficients. For a particular gene, write the coefficient vector as \(\hat{\boldsymbol{\beta}}=(\hat{\beta}_0,\hat{\beta}_A,\hat{\beta}_B)^\mathsf{T}\), and let \(\widehat{V}\) be its estimated covariance matrix. For a contrast vector \(\boldsymbol{c}\), the estimated contrast, standard error, and Wald statistic are
The two-sided normal-based p-value is \(2P(Z\geq |z|)\), where \(Z\sim N(0,1)\) under the null hypothesis. The three useful contrasts under reference coding are:
- A versus C: \(\beta_A\), with contrast vector \((0,1,0)\).
- B versus C: \(\beta_B\), with contrast vector \((0,0,1)\).
- B versus A: \(\beta_B-\beta_A\), with contrast vector \((0,-1,1)\).
The first two are control-versus-treatment comparisons; the third is the treatment-versus-treatment comparison. The sign convention matters: B minus A is positive when the fitted expression in B is higher than in A. Because coefficients are on the natural-log scale, \(\exp(\hat{\theta})\) is the estimated expression ratio, and \(\hat{\theta}/\log(2)\) is the log-fold change on a base-2 scale.
Worked Example: Setting Up the Three-Condition Fit
Suppose a hypothetical experiment has 12 independent donors in each of conditions C, A, and B. For one cell type, counts are summed within each donor to form pseudobulk samples. The following are the first three donor counts for gene G2; library sizes differ across donors, and the model uses the corresponding offsets.
| Condition | Displayed pseudobulk counts for G2 | Number of donors in fitted model |
|---|---|---|
| C (control) | 40, 44, 36 | 12 |
| A | 49, 53, 45 | 12 |
| B | 81, 89, 74 | 12 |
The displayed counts are a concrete excerpt, not the complete input to the fit: all 36 donor pseudobulks contribute to the hypothetical model output. Assume the design has no condition–batch confounding and that diagnostic checks support the count and dispersion model. A hypothetical fit gives \(\hat{\beta}_{A}=0.20\) and \(\hat{\beta}_{B}=0.75\) for G2. Thus the planned B-versus-A estimate is
This is a natural-log expression ratio of 0.55, or \(\exp(0.55)=1.733\): the fitted expression in B is about 1.73 times that in A, conditional on the model and offset. The coefficients are hypothetical fitted results, not arithmetic averages of the displayed raw counts; the count model uses all donor counts, offsets, and estimated dispersion.
Worked Example: Calculating the Planned Contrasts for G2
For G2, suppose the fitted covariance matrix for \((\hat{\beta}_0,\hat{\beta}_A,\hat{\beta}_B)\) has \(\operatorname{Var}(\hat{\beta}_A)=0.0400\), \(\operatorname{Var}(\hat{\beta}_B)=0.0625\), and \(\operatorname{Cov}(\hat{\beta}_A,\hat{\beta}_B)=0.0200\). The fitted estimates are \(\hat{\beta}_A=0.20\) and \(\hat{\beta}_B=0.75\). Use two-sided normal-based Wald tests.
For A versus C, the estimate is \(0.20\), its standard error is \(\sqrt{0.0400}=0.200\), and \(z=0.20/0.200=1.00\). The two-sided p-value is approximately \(0.3173\).
For B versus C, the estimate is \(0.75\), its standard error is \(\sqrt{0.0625}=0.250\), and \(z=0.75/0.250=3.00\). The two-sided p-value is approximately \(0.00270\).
For B versus A, the covariance is essential. The variance of a difference is the variance of each term minus twice their covariance:
Therefore \(SE=\sqrt{0.0625}=0.250\), \(z=(0.75-0.20)/0.250=2.20\), and the two-sided p-value is approximately \(0.0278\). A 95% Wald interval on the natural-log scale is \(0.55\pm1.96(0.250)=(0.060,1.040)\). Exponentiating its endpoints gives an approximate expression-ratio interval of \((1.062,2.829)\). Under the model and its approximation, the unadjusted evidence is inconsistent with a zero B-versus-A log difference at the 0.05 level. This p-value is not yet adjusted for testing multiple genes.
Multiplicity: Define the Family Before Interpreting Results
A gene-level p-value describes evidence for one gene and one specified contrast. Testing many genes creates a multiplicity problem: if the goal is to report discoveries across all tested genes, adjusting only a selected subset after seeing the results does not control the intended error rate. A common choice for exploratory differential-expression analysis is the Benjamini–Hochberg (BH) procedure, which controls the false discovery rate under its standard dependence conditions. Its adjusted p-values are often called q-values in software reports, although terminology can vary.
For \(m\) p-values in one prespecified family, sort them as \(p_{(1)}\leq\cdots\leq p_{(m)}\). The BH adjusted p-value at rank \(r\) is the monotone version of \(mp_{(r)}/r\):
The minimum over ranks at or above \(r\) ensures that adjusted values do not decrease as the ordered p-values increase. Rejecting tests with \(q\leq\alpha\) controls the expected proportion of false discoveries among rejected tests at level \(\alpha\), under the procedure’s assumptions. It does not mean each reported gene has probability \(q\) of being false.
Worked Example: Adjusting Nine Gene-Level Tests
Suppose the planned B-versus-A contrast is tested for nine genes. Their hypothetical p-values, sorted from smallest to largest, are shown below. Gene G2 has the p-value calculated above, \(0.0278\), at rank 4. For this example, the family is explicitly the nine tests for this one contrast.
| Rank \(r\) | Gene | Raw p-value | \(9p_{(r)}/r\) | BH adjusted p-value |
|---|---|---|---|---|
| 1 | G5 | 0.0040 | 0.0360 | 0.0360 |
| 2 | G8 | 0.0100 | 0.0450 | 0.0450 |
| 3 | G1 | 0.0180 | 0.0540 | 0.0540 |
| 4 | G2 | 0.0278 | 0.06255 | 0.06255 |
| 5 | G4 | 0.0400 | 0.0720 | 0.0720 |
| 6 | G7 | 0.0800 | 0.120 | 0.120 |
| 7 | G3 | 0.210 | 0.270 | 0.270 |
| 8 | G6 | 0.550 | 0.61875 | 0.61875 |
| 9 | G9 | 0.880 | 0.880 | 0.880 |
For G2, \(m=9\), \(r=4\), and \(p_{(4)}=0.0278\), so \(9(0.0278)/4=0.06255\). The raw BH values in this table already increase with rank, so the monotonicity step leaves them unchanged. At \(\alpha=0.05\), G2 is not a BH discovery for this nine-gene family, despite its raw p-value being below 0.05. This conclusion is specific to the stated family and does not determine the result under a different multiplicity plan.
Choosing the Contrast and the Testing Family
If the scientific questions are “Does A differ from control?” and “Does B differ from control?”, the two control contrasts should be reported directly. If the question also asks whether the treatments differ from each other, B-versus-A is a third planned comparison. Contrasts should be specified from the scientific question, not selected because they produce the smallest p-values.
There are two distinct dimensions of multiplicity: the number of genes and the number of contrasts. One defensible exploratory plan is to adjust across all genes separately for each prespecified contrast and report each contrast’s family clearly. If the claim is instead that a gene is differentially expressed in at least one of the three comparisons, the family must include the relevant tests across genes and contrasts, or use a prespecified procedure that controls the desired error rate for that combined claim. Separate per-contrast BH adjustment does not automatically control the error rate for a pooled list of discoveries across contrasts.
BH is often suitable for discovery-oriented analyses where controlling the expected false-discovery proportion is the goal. Holm adjustment is a common alternative when strong family-wise error control is required: it is generally more conservative but controls the probability of at least one false rejection in the family. The choice depends on the inferential goal; neither method repairs invalid gene-level p-values from a misspecified model.
Derivation and Interpretation of a Contrast Standard Error
The contrast standard error follows directly from the variance of a linear combination. If \(\hat{\boldsymbol{\beta}}\) has covariance matrix \(V\), then the contrast is the scalar \(\boldsymbol{c}^{\mathsf T}\hat{\boldsymbol{\beta}}\). Applying the covariance rule for a linear transformation gives
For B minus A, the coefficient entries for the intercept are zero and the remaining entries are \((-1,1)\). Expanding the quadratic form gives \(\operatorname{Var}(\hat{\beta}_B)+\operatorname{Var}(\hat{\beta}_A)-2\operatorname{Cov}(\hat{\beta}_A,\hat{\beta}_B)\). The covariance term is why subtracting the two coefficient standard errors, or combining them without regard to covariance, is not a valid general calculation. Contrasts are estimated jointly from the same fit, so their estimates may be correlated.
A confidence interval for a contrast is an interval procedure with its stated repeated-sampling coverage under the model and approximation. It is not a probability statement that a fixed parameter lies in the particular observed interval. Likewise, a p-value is calculated assuming the null hypothesis and model; it is not the probability that the null is true. Effect size and uncertainty should be reported together: a small p-value alone does not describe the magnitude or biological importance of a change.
Diagnostics, Limitations, and Common Errors
Confirm that each pseudobulk represents an independent donor-condition sample for the cell type. Repeated samples from one donor require dependence to be represented in the model.
Verify condition labels, donor counts, library-size offsets, and whether a batch or covariate is confounded with condition. A coefficient cannot separate effects that the design does not identify.
Inspect residual and influence diagnostics, dispersion and mean–variance fit, fitted means, and convergence. Strong outliers, excess zeros, or instability can make standard errors and p-values unreliable.
Confirm the subtraction order and state which genes and contrasts form each adjustment family. Report effect estimates and adjusted results together.
- Wrong: “B-versus-A is \(\hat{\beta}_B\).” Correction: with C as reference, \(\hat{\beta}_B\) is B versus C; B versus A is \(\hat{\beta}_B-\hat{\beta}_A\).
- Wrong: “The variance of B minus A is the sum of the two variances.” Correction: include the covariance term, subtracting twice the covariance for a difference.
- Wrong: “The raw p-value is below 0.05, so the gene is significant.” Correction: for a gene-level discovery claim, interpret the p-value after adjustment over the prespecified testing family.
- Wrong: “A significant B-versus-A result proves that B differs from control.” Correction: each contrast tests its own null; evidence for one comparison does not establish another.
These methods have limits. Small numbers of donors can weaken both dispersion estimation and test calibration; an appropriate correction or alternative small-sample method may be needed. A contrast can be estimated precisely but still be biologically unimportant, and the count model does not establish causation. Finally, BH adjustment addresses multiplicity, not confounding, poor pseudobulk construction, or model misspecification.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- With C as reference, which coefficient combination estimates A versus B?
- Suppose \(\operatorname{Var}(\hat{\beta}_A)=0.09\), \(\operatorname{Var}(\hat{\beta}_B)=0.16\), and their covariance is \(0.03\). Find the standard error of B minus A.
- For a family of 12 genes, a p-value of \(0.020\) is ranked sixth. What is its unmonotonized BH value?
- Why is a separate pseudobulk from the same donor in each condition not an independent-groups design?
Solutions. 1. A versus B is \(\hat{\beta}_A-\hat{\beta}_B\); reversing the order changes only the sign. 2. The variance is \(0.09+0.16-2(0.03)=0.19\), so the standard error is \(\sqrt{0.19}=0.4359\). 3. The value is \(12(0.020)/6=0.0400\); the final adjusted value may be smaller after the monotonicity step. 4. Measurements from the same donor can be correlated, so donor-level dependence must be represented rather than treating the two pseudobulks as independent biological units.