Why Pairing Changes the Model
In a paired microarray design, each biological subject contributes a sample under each of two conditions—for example, before and after treatment. Expression levels can differ substantially between subjects even when the condition has little effect. The analysis should therefore compare conditions within the same subject, rather than treating all samples in the two conditions as unrelated.
For each gene, assume expression has been measured on a scale where a linear model is appropriate, commonly normalized log-expression. The condition coefficient then describes a difference on that scale. For log base 2 expression, a difference of 1 corresponds to a two-fold expression ratio, although the coefficient itself is not a causal effect unless the study design and assumptions justify a causal interpretation.
The subject effects are nuisance parameters: they absorb stable differences among subjects, while \(\beta_g\) is estimated from the change within each subject. With \(n\) complete pairs, there are \(2n\) observations and \(n+1\) fitted coefficients (one intercept for each subject and one condition coefficient). The design matrix must have full column rank; each subject must have observations in both conditions for that subject to contribute a within-subject comparison.
Within-Subject Contrast and Its Sampling Variance
Subtract the condition-0 observation from the condition-1 observation for each subject. The subject effect cancels:
Thus, the fitted condition coefficient is the mean of the paired differences. Under the standard fixed-subject model, residual errors are independent across observations, have mean zero, and for a given gene have a common variance \(\sigma_g^2\). Subjects are independent. Then the difference error has variance \(2\sigma_g^2\), so the variance of the mean difference is \(2\sigma_g^2/n\).
The residual degrees of freedom are \(2n-(n+1)=n-1\). This also follows from the differences: one mean is estimated from \(n\) paired differences, leaving \(n-1\) degrees of freedom. In the full subject-effect model, the residual sum of squares is half the sum of squared deviations of the paired differences. Consequently, its residual variance estimate is half the sample variance of the differences.
where \(\bar D_g\) is the mean paired difference and \(\hat\beta_g=\bar D_g\). Equivalently, if \(s_{D,g}^2\) is the sample variance of the paired differences, then \(s_g^2=s_{D,g}^2/2\) and \(SE(\hat\beta_g)=s_{D,g}/\sqrt n\). This equivalence connects the subject-effect linear model to the ordinary paired t-test. The linear-model formulation is useful because it gives a contrast and variance estimate that can be moderated across genes.
Worked Example: Encoding Three Complete Pairs
Suppose three hypothetical subjects each have a control and a treated sample. Code control as 0 and treated as 1. With columns for subjects 1, 2, 3, and condition, the design matrix has rows
The first three columns represent the subject effects; the final column indicates the treated condition. The treatment coefficient is therefore the treated-minus-control difference after accounting for subject. The matrix has rank 4, so there are \(6-4=2\) residual degrees of freedom, equal to \(n-1=3-1\). A different reference coding for subjects would change the individual subject coefficients, but not the estimated condition contrast.
Worked Example: Computing the Paired Estimate and Standard Error
For one hypothetical gene, suppose the treated-minus-control log-expression differences for four subjects are \(0.8,\ 1.0,\ 0.6,\ 1.2\). The paired estimate is
The deviations from \(0.9\) are \(-0.1,\ 0.1,\ -0.3,\ 0.3\); their squared sum is \(0.01+0.01+0.09+0.09=0.20\). The residual variance estimate in the subject-effect model is
It follows that \(df_g=3\) and
This agrees with the paired-difference calculation: the sample variance of the differences is \(0.20/3=0.06667\), and \(\sqrt{0.06667/4}=0.1291\). The positive estimate is a mean increase of 0.9 log-expression units in treated samples for these hypothetical subjects; it is not by itself evidence that the increase is statistically distinguishable from zero.
Moderating the Gene-Wise Variance
With few pairs, each gene's residual variance is estimated with very few degrees of freedom and can be unstable. Empirical-Bayes moderation combines that gene-wise estimate with information across genes, as established in the earlier material on empirical-Bayes shrinkage and cross-gene assumptions. The paired design determines the contrast, its unscaled variance, and the residual degrees of freedom; moderation changes the variance estimate used for inference.
Let \(d_0\) and \(s_0^2\) denote the estimated prior degrees of freedom and prior variance, and let \(d_g\) and \(s_g^2\) denote the residual degrees of freedom and residual variance for gene \(g\). Under the scaled inverse-chi-squared prior model, the moderated variance and degrees of freedom are
For a contrast with unscaled variance \(v_g\), the moderated standard error is \(\sqrt{s_{g,\mathrm{post}}^2v_g}\). In a complete balanced paired design, \(v_g=2/n\); the gene-wise moderated t-statistic for testing zero difference is
The two-sided gene-wise p-value is the probability, under a \(t\) distribution with \(df_{g,\mathrm{mod}}\) degrees of freedom, of a value at least as extreme in absolute value as the observed statistic. Moderation does not alter \(\hat\beta_g\), the pairing, or the condition contrast. It stabilizes the estimated variance, particularly when the gene-wise residual degrees of freedom are small.
Worked Example: A Moderated Paired Test
For a hypothetical gene measured in six complete pairs, suppose \(\hat\beta_g=0.75\), the residual variance estimate is \(s_g^2=0.060\), and \(d_g=5\). Suppose the empirical-Bayes fit gives \(s_0^2=0.040\) and \(d_0=8\). These prior values are illustrative, not estimates from a real experiment. The moderated variance is
The moderated degrees of freedom are \(8+5=13\). For six pairs, the unscaled variance is \(2/6=1/3\), giving
A two-sided \(t_{13}\) reference distribution gives a p-value of approximately \(0.00005\). This is strong gene-wise evidence against a zero mean paired difference under the model. It is not the probability that the null hypothesis is true, and it does not account for any separate adjustment for testing many genes. The estimated difference remains \(0.75\) log-expression units; moderation affects the standard error and reference degrees of freedom, not the estimated effect.
Assumptions, Diagnostics, and Alternatives
A paired moderated test is appropriate when the pairing is genuine and the measurements are on a scale for which the linear model is reasonable. The key assumptions are: the condition coding matches the scientific comparison; subjects are independent of one another; residuals have mean zero and a common variance within a gene under the specified model; and the residual errors for the two observations within a subject are independent after the fixed subject effect. With small \(n\), the usual t reference inference also relies on a reasonably adequate normal-error approximation. The empirical-Bayes step additionally relies on the variance-prior model and its cross-gene estimation being suitable.
For each gene, inspect paired values or paired differences, not just the two condition distributions separately. A large outlying difference can dominate the mean and variance. Check sample labels and subject matching carefully; a swapped label can reverse or distort a within-subject contrast. Residual-versus-fitted plots can reveal nonconstant variance or systematic patterns. If condition is confounded with an unmodeled processing change, the estimated condition contrast may include that change. If a subject is missing one condition, that subject cannot provide a within-subject contrast in the fixed-subject model; the complete-pair formula above does not apply unchanged to an incomplete design.
The principal alternatives answer the question differently or make different assumptions. An unpaired two-group test ignores the matching and treats observations as independent groups; it discards the control supplied by subject and is generally inefficient when within-subject measurements are correlated. The ordinary paired t-test works directly with the paired differences and is equivalent to the unmoderated fixed-subject test in a complete balanced design. It does not borrow variance information across genes. A subject-effect linear model expresses the comparison as a contrast and fits naturally into moderated linear-model inference. The paired analysis is not a substitute for a design that separates condition from batch or other systematic changes: if those factors are inseparable, the data do not identify their separate effects.
Common Pitfalls
- Ignoring the pair. Treating the two conditions as independent loses the within-subject comparison and uses the wrong variance calculation for paired data.
- Using the wrong contrast direction. If condition 1 is treated, \(Y_{gi1}-Y_{gi0}\) means treated minus control. Reversing the subtraction reverses the sign of the estimate and t-statistic.
- Counting the wrong degrees of freedom. With \(n\) complete pairs and fixed subject effects, residual \(df=n-1\), not \(2n-2\). Moderation then adds \(d_0\) to the residual degrees of freedom for the moderated reference distribution.
- Thinking moderation changes the effect estimate. It changes the variance estimate and degrees of freedom, while the fitted contrast \(\hat\beta_g\) remains the same.
- Assuming pairing cures confounding. Pairing controls stable subject differences; it does not separate condition from a batch or time effect that changes in lockstep with condition.
Check Your Understanding
Answer each question, then compare with the solutions.
- With seven complete pairs, how many residual degrees of freedom does the fixed-subject model have?
- For one gene, the paired differences are \(1,\ 2,\ 0\). Find the estimated condition difference and the residual variance estimate \(s_g^2\) in the subject-effect model.
- If the condition indicator is coded 1 for control and 0 for treated, what direction does its coefficient represent?
- Why can an unpaired test be inefficient for a strongly paired design?
- Does variance moderation change the estimated paired difference? State what it changes instead.
Solutions. (1) The model has \(n-1=7-1=6\) residual degrees of freedom. (2) The mean difference is \((1+2+0)/3=1\). The deviations are \(0,1,-1\), whose squared sum is 2, so \(s_g^2=2/[2(3-1)]=0.5\). (3) The coefficient represents control minus treated, so its sign is the reverse of a treated-minus-control contrast. (4) An unpaired test ignores within-subject information; when measurements from the same subject are similar, differencing can reduce variability, while treating them as unrelated fails to use that reduction. (5) No. The fitted paired difference is unchanged; moderation stabilizes the variance estimate and changes the standard error and reference degrees of freedom used for inference.