Why Factorial Design Matters
A microarray experiment may vary two biological factors at once, such as treatment and genotype. Studying each factor separately can miss an important pattern: treatment may change expression by a different amount in different genotypes. A factorial model represents that possibility directly. Its interaction terms describe how the effect of one factor varies across levels of the other.
For each gene \(g\), let \(y_{gi}\) denote the normalized log-expression measurement from sample \(i\). The design matrix records the factor levels for each sample; the gene-wise model relates those measurements to coefficients. The design and contrast specify the biological question, while the gene-wise variance and its moderation determine the uncertainty used for inference.
Reference-Level Coding and Its Interpretation
First consider two factors, A and B, each with two levels. Label their reference levels \(A=0\) and \(B=0\), and their other levels \(A=1\) and \(B=1\). For each gene, use the model
Here \(A_i\) and \(B_i\) are indicator variables equal to 1 when sample \(i\) is at the corresponding non-reference level, and 0 otherwise. The four expected cell means are
Thus, \(\beta_{Ag}=\mu_{10,g}-\mu_{00,g}\) is the A effect when B is at its reference level. The A effect when \(B=1\) is \(\beta_{Ag}+\beta_{ABg}\). The interaction coefficient is
It is not generally correct to describe \(\beta_{Ag}\) as an overall A effect when an interaction is present: under this coding it is specifically the A effect at \(B=0\). Changing the reference level changes the interpretation of individual coefficients, but not the cell means or the scientific question of whether effects vary across levels.
Worked Example: Reading the Coefficients in a Two-by-Two Model
Suppose a hypothetical experiment measures one gene’s log-expression in control and treated samples from two genotypes. Let genotype 0 and control be the reference levels. Suppose the four fitted cell means, in log-expression units, are 6, 8, 9, and 13 for cells \((A=0,B=0)\), \((1,0)\), \((0,1)\), and \((1,1)\), respectively.
The reference-cell mean is \(\beta_0=6\). The A effect at \(B=0\) is \(8-6=2\), so \(\beta_A=2\). The B effect at \(A=0\) is \(9-6=3\), so \(\beta_B=3\). The interaction is
Thus the A effect is 2 log-expression units at \(B=0\), and \(2+2=4\) units at \(B=1\). This example describes fitted means; a test of the interaction also requires uncertainty estimates and an appropriate gene-wise error model.
Contrasts: Turning a Question into a Test
In a linear model, a contrast is a linear combination of coefficients. If the coefficient vector for a gene is \(\boldsymbol{\beta}_g\), a contrast has the form \(c^\mathsf{T}\boldsymbol{\beta}_g\), where \(c\) is a specified vector. The estimated contrast is \(c^\mathsf{T}\hat{\boldsymbol{\beta}}_g\). For the two-by-two interaction above, the contrast selects \(\beta_{ABg}\); equivalently, it combines cell means with signs \(+,-,-,+\) for \(\mu_{00,g},\mu_{10,g},\mu_{01,g},\mu_{11,g}\). The null hypothesis of no interaction is \(H_0:\beta_{ABg}=0\).
More generally, under the gene-wise linear model \(y_g=X\boldsymbol{\beta}_g+\boldsymbol{\varepsilon}_g\), a contrast \(c^\mathsf{T}\boldsymbol{\beta}_g\) has estimated variance \(s_g^2c^\mathsf{T}(X^\mathsf{T}X)^{-1}c\) when the design is full rank and the ordinary least-squares variance estimate is \(s_g^2\). Moderated linear-model analyses use a moderated variance estimate and moderated degrees of freedom for inference, but the contrast still represents the same expression question.
The design should include the relevant combinations of factor levels, and its columns must be linearly independent for all specified coefficients to be separately estimable. Replication within cells permits estimation of residual variation. A missing cell or a confounded design can make a desired interaction non-estimable; a test cannot repair that lack of information.
Worked Example: Estimating and Testing a Difference-in-Differences
Consider hypothetical log-expression measurements for one gene, with three independent samples in each cell: \((A=0,B=0)\): 5, 6, 7; \((1,0)\): 7, 8, 9; \((0,1)\): 8, 9, 10; and \((1,1)\): 12, 13, 14. The cell means are 6, 8, 9, and 13. Each cell’s observations differ from its mean by \(-1,0,1\), so the residual sum of squares in each cell is \(1+0+1=2\), and the total residual sum of squares is \(8\).
There are 12 observations and 4 fitted cell means, hence \(df=12-4=8\). The ordinary residual variance estimate is \(s_g^2=8/8=1\) log-expression units squared. The estimated interaction is
With three independent observations per cell and equal cell variances, the variance of this contrast estimate is \(s_g^2(1/3+1/3+1/3+1/3)=4/3\). Therefore \(SE=\sqrt{4/3}=1.155\) log-expression units, and the ordinary statistic is \(t=2/1.155=1.732\), with \(df=8\). Its two-sided \(p\)-value is approximately 0.122. At \(\alpha=0.05\), this ordinary test does not provide sufficient evidence to reject a zero interaction for this gene. This conclusion concerns the test and its uncertainty, not proof that the interaction is absent. An empirical Bayes moderated test would use the same contrast estimate but its moderated variance and degrees of freedom.
The calculation assumes independent biological samples, a correctly specified four-cell model, and a common residual variance for this gene. The constructed observations have balanced residual variation across cells, and there are replicates to estimate that variation. If samples were paired or otherwise dependent, independence would not be appropriate without a design that accounts for the dependence.
More Than Two Levels and Joint Interaction Tests
When one factor has more than two levels, “no interaction” is a joint statement: the effect differences must agree across all levels. For example, let A have levels 0, 1, and 2 and B have levels 0 and 1. With level 0 as the A reference, a treatment-coded model includes an A indicator for levels 1 and 2, a B indicator, and two A-by-B product terms. The B effect at A level 0 is \(\beta_B\); at A levels 1 and 2 it is \(\beta_B+\beta_{A1:B}\) and \(\beta_B+\beta_{A2:B}\). The no-interaction null is \(H_0:\beta_{A1:B}=\beta_{A2:B}=0\), a two-coefficient test.
A joint test can be written \(H_0:C\boldsymbol{\beta}_g=\boldsymbol{0}\), where the rows of \(C\) specify the interaction contrasts. In the ordinary linear model, the corresponding F test uses the estimated contrast vector and its covariance; in a moderated linear-model workflow, the multi-coefficient effect can be assessed with a moderated F test. Testing just one interaction coefficient answers only one particular comparison, not the general no-interaction question.
Worked Example: Building a Joint Interaction Contrast
Suppose hypothetical fitted means for a gene are as follows, in log-expression units. At B level 0, the means at A levels 0, 1, and 2 are 4, 5, and 7. At B level 1, they are 5, 9, and 10. The B effects at the three A levels are \(5-4=1\), \(9-5=4\), and \(10-7=3\) log-expression units.
Using A level 0 as the reference, compare each non-reference B effect with the effect at A level 0. The two interaction contrasts are \(4-1=3\) and \(3-1=2\) log-expression units. Thus the joint no-interaction null sets both contrasts to zero. The data give the contrast estimates \((3,2)^\mathsf{T}\), so they do not exhibit equal B effects across the three A levels. A valid joint significance test still needs the covariance of these estimates, which depends on the design and residual variance; the fitted means alone do not determine its p-value.
This contrast construction is estimable only if the relevant cells and model terms are supported by the design. The model’s error assumptions apply to the samples within the full design, not merely to these six displayed means.
Assumptions, Diagnostics, and Alternatives
For exact small-sample t and F reference distributions, conditional on the design, gene-wise errors must be independent, normally distributed with mean zero, and have a common variance across design cells. Approximate normality may justify using those reference distributions as approximations, but does not make them exact. In practice, inspect residuals for unusual observations, changing spread across fitted values or cells, and patterns suggesting omitted structure. Check that the design matrix has full rank for the coefficients or contrasts of interest, and confirm that each factor combination has enough independent samples to support the intended model.
A factorial linear model is preferable to separate within-level tests when the scientific question concerns whether effects differ across levels: the interaction contrast states that question directly and uses a common model for its uncertainty. An alternative is to estimate cell means and combine them into differences, which is algebraically equivalent when the same model and covariance are used. A model omitting interaction is more parsimonious, but it imposes equal factor effects across the other factor’s levels; it should not be chosen simply because the interaction test is not significant. With interaction, report the conditional effects or planned contrasts rather than presenting a single main-effect coefficient as though it applied universally.
The model’s conclusions depend on the chosen expression scale and design. A contrast of log-expression means is not automatically a difference in raw expression. In addition, a gene-wise test is not a claim of causation, and tests across many genes require appropriate attention to multiplicity. These considerations do not change the interaction contrast, but they limit how its results should be interpreted.
Common Mistakes
- Reading a main-effect coefficient as universal. With reference coding and an interaction, \(\beta_A\) is the A effect at \(B=0\), not necessarily an average effect.
- Testing only one interaction term in a multi-level design. No interaction generally requires a joint test of all relevant interaction coefficients.
- Assuming a balanced design is required. Balance simplifies calculations but is not necessary; estimability and correct variance modeling are essential.
- Treating technical replicates as independent biological samples. Replicate measurements from the same biological unit do not by themselves provide independent biological replication.
Check Your Understanding
Answer the questions, then compare with the solutions below.
- In a two-by-two model, the fitted cell means are 3, 5, 8, and 11 for cells \((0,0),(1,0),(0,1),(1,1)\). What is the interaction contrast?
- Under reference coding, what does the coefficient for factor A represent when the model includes an A-by-B interaction?
- A has four levels and B has two levels. How many interaction coefficients are needed under treatment coding, and what is the null of no interaction?
- Why can a design with a missing factor-level combination prevent estimation of an interaction?
Solutions. (1) The contrast is \((11-8)-(5-3)=3-2=1\) log-expression unit. (2) It is the A effect at the reference level of B. (3) There are \((4-1)(2-1)=3\) interaction coefficients; the no-interaction null sets all three to zero jointly. (4) The missing cell may make design columns linearly dependent or leave the needed cell-mean combination unidentified, so the desired contrast is not estimable from the observed samples.