A Two-Group Analysis in Context
A two-group microarray analysis asks whether average expression differs between two conditions, such as control and treatment. Each sample contributes a normalized expression measurement for each gene. The analysis fits a linear model separately for each gene, then uses empirical Bayes moderation to stabilize the gene-wise variance estimates by sharing information across genes. The aim here is to follow that sequence with a small hypothetical data set, including the design matrix, effect estimates, moderated tests, and the limits of their interpretation.
The examples use normalized log base 2 expression values from six independent biological samples: three controls and three treated samples. The analysis assumes that normalization and quality checks have produced comparable measurements across arrays. It also assumes that samples are independent, the model is correctly specified, residuals are approximately normal within each gene, and each gene has a common residual variance across the two groups. Empirical Bayes moderation additionally relies on the idea that gene-wise variances can be usefully summarized by a cross-gene distribution. These assumptions should be considered before interpreting any result.
From Group Labels to a Design Matrix
With an intercept and one binary group indicator, the design matrix has one row per sample and two columns: an intercept column and the treatment indicator. In this coding, the intercept estimates the control mean, and the treatment coefficient estimates the difference between the treated and control means. The matrix must have full column rank; here that requires observations in both groups.
Worked Example: Coding the Two Groups
Suppose the six hypothetical samples are ordered as three controls followed by three treated samples. Their design matrix is
The first column is the intercept. The second column marks treated samples. It is not a separate intercept for the treated group: rather, the treated mean is \(\beta_{g0}+\beta_{g1}\). Thus, if the fitted coefficients for a gene are \(\hat{\beta}_{g0}=8.0\) and \(\hat{\beta}_{g1}=0.4\), the fitted control and treated means are 8.0 and \(8.0+0.4=8.4\) log2 units, respectively. The estimated treated-minus-control effect is 0.4 log2 units.
For this balanced design, the coefficient estimates equal the group sample means and their difference:
Here \(C\) denotes control and \(T\) denotes treatment. The residual sum of squares for gene \(g\), written \(SSE_g\), is the sum of squared differences between each observed expression value and its fitted group mean. There are six observations and two fitted coefficients, so the residual degrees of freedom are \(d=6-2=4\). The ordinary gene-wise residual variance estimate is \(s_g^2=SSE_g/d\).
Moderating the Gene-Wise Variances
With only three samples per group, the residual variance for any one gene is based on just four residual degrees of freedom and can be unstable. Empirical Bayes moderation combines that variance estimate with information about the variance distribution across genes. It does not pool the gene expression means: the effect estimate remains gene-specific. Instead, it stabilizes the variance estimate used to calculate uncertainty.
For the treatment-minus-control contrast in this balanced design, the variance factor is \(q=1/3+1/3=2/3\). The moderated statistic is compared with a t reference distribution having \(d_0+d\) degrees of freedom under the model and empirical Bayes assumptions. The prior quantities are estimated from the collection of genes; for a worked calculation, we will treat them as given. The earlier material on empirical Bayes shrinkage and moderated t-statistics develops the estimation and inferential rationale in more depth.
The weighted-variance expression has a direct justification: the observed gene-wise variance contributes with weight \(d\), while the cross-gene prior variance contributes with weight \(d_0\). Dividing their weighted sum by the total degrees of freedom gives the moderated variance. Consequently, genes with small \(d\) are more influenced by the cross-gene estimate, while genes with more residual information are more influenced by their own observed variance.
Worked Example: Moderated Test for a One-Log2-Unit Change
Consider a hypothetical gene with control expression values 7.8, 8.0, and 8.2, and treated values 8.8, 9.0, and 9.2, all in normalized log2 units. The group means are 8.0 and 9.0, so the estimated treatment effect is \(9.0-8.0=1.0\) log2 unit. Each group contributes \(0.2^2+0^2+(-0.2)^2=0.08\) to the residual sum of squares, so the combined residual sum of squares is \(0.08+0.08=0.16\).
There are \(d=4\) residual degrees of freedom, giving \(s_g^2=0.16/4=0.04\). Suppose the cross-gene estimates are \(s_0^2=0.04\) and \(d_0=4\). Then
The contrast variance factor is \(2/3\), so \(SE_{\mathrm{mod}}=\sqrt{0.04(2/3)}=0.1633\) log2 units. The statistic is \(t=1.0/0.1633=6.124\), with 8 degrees of freedom. Its two-sided p-value is approximately 0.000282. This is evidence against a zero mean difference for this gene under the stated model; it is not the probability that the null hypothesis is true.
A log2 fold change of 1 corresponds to a treated-to-control expression ratio of \(2^1=2\). Thus, the estimated group means differ by a factor of 2 on the original expression scale represented by the log2 values. This is an estimated relative difference, not evidence that treatment caused the difference.
Worked Example: A Smaller Effect with a Lower Moderated Variance
For a second hypothetical gene, suppose controls have values 7.9, 8.0, and 8.1, while treated samples have values 8.3, 8.4, and 8.5. The group means are 8.0 and 8.4, so the estimated effect is \(0.4\) log2 units. Each group contributes \(0.1^2+0^2+(-0.1)^2=0.02\) to the residual sum of squares, giving a combined \(SSE_g=0.04\) and \(s_g^2=0.04/4=0.01\).
Using the same \(s_0^2=0.04\), \(d_0=4\), and \(d=4\), the moderated variance is
Therefore, \(SE_{\mathrm{mod}}=\sqrt{0.025(2/3)}=0.1291\) log2 units, and \(t=0.4/0.1291=3.098\), with 8 degrees of freedom. The two-sided p-value is approximately 0.0147. The estimated ratio is \(2^{0.4}=1.320\), so the treated group’s estimated expression is about 1.32 times the control group’s on the original scale. The p-value is nominal and does not account for testing many genes.
Reading Results and Checking the Analysis
A two-group result should be read in layers. First, check the estimated log2 fold change and its direction. Then examine the uncertainty and test result, remembering that the moderated test addresses a zero contrast under the model. Finally, consider the size of the gene-wise effect in context and the fact that a microarray analysis tests many genes. A small p-value alone does not establish a large or biologically important change.
Before relying on the results, verify the design coding and sample labels, inspect array-level quality and normalization diagnostics, and examine residuals and fitted values for unusual patterns. Residuals that show strong outliers, group-specific spread, or systematic structure may indicate that normality, common within-gene variance, or the model specification is questionable. The variance distribution across genes should also be checked: a poor fit to the cross-gene variance model can make moderation misleading. A shared variance prior is not a remedy for mislabeled samples, unmodeled batch effects, or non-independent replicates.
The ordinary pooled two-sample t-test is the direct alternative for each gene: it estimates the variance using only that gene’s residuals. Moderation retains gene-specific effects but stabilizes variance estimates by borrowing information across genes, which can be valuable when each gene has few residual degrees of freedom. The trade-off is that the moderation depends on the cross-gene variance model being informative and reasonably well fitted. If the genes’ variance distribution is poorly represented by the fitted prior, moderation may not provide reliable calibration. A paired design is not interchangeable with this independent-groups setup; it requires a model that represents the pairing.
Another common error is to treat the reported nominal p-values as if they already answer the study-wide question. When many genes are tested, the chance of small p-values under null effects increases. Study-wide conclusions therefore require an appropriate multiple-testing procedure, as well as attention to effect sizes and diagnostics. In the examples above, the calculated p-values describe individual moderated tests only.
Define control and treatment, confirm which samples belong to each group, and state the treatment-minus-control direction.
Use the intercept and treatment indicator; obtain the group means, log2 fold change, residual sum of squares, and residual degrees of freedom.
Combine gene-wise and cross-gene variance information, compute the moderated standard error and test, then interpret effect size and evidence with the design and diagnostics in view.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- With control coded 0 and treatment coded 1, what does the treatment coefficient estimate?
- For three samples per group in an intercept-plus-indicator model, how many residual degrees of freedom are available?
- Suppose \(s_g^2=0.02\), \(d=4\), \(s_0^2=0.03\), and \(d_0=6\). Calculate the moderated variance.
- A gene has an estimated treatment coefficient of \(-1\) log2 unit. What is the estimated treated-to-control ratio?
Solutions. (1) It estimates the treated mean minus the control mean in log2 expression units. (2) There are \(6-2=4\) residual degrees of freedom because six observations are used to estimate two coefficients. (3) \(s_{g,\mathrm{mod}}^2=[6(0.03)+4(0.02)]/(6+4)=(0.18+0.08)/10=0.026\). (4) The ratio is \(2^{-1}=0.5\), so the treated group’s estimated expression is half the control group’s on the original scale.