Tutorials › High-Dimensional Genomic Data Analysis › Gene-Wise Linear Models for Microarray Expression

Linear Models for Expression Microarrays · Tutorial 386 of 795

Gene-Wise Linear Models for Microarray Expression

Learn how a shared sample-level design matrix relates log-scale expression to gene-specific coefficients, and what assumptions the model makes about errors.

Intermediate 10 min read

What You'll Learn

  • Define the expression matrix and the sample-level design matrix, including their dimensions.
  • Write the linear model for one gene and for all genes together.
  • Interpret gene-specific coefficients on the log-expression scale.
  • Derive the least-squares coefficient estimate and state when it is unique.
  • Distinguish equal-variance, zero-covariance, independence, and normality assumptions.
  • Recognize how sample dependence and gene-to-gene correlation affect the model.

Why Model Expression One Gene at a Time?

A microarray experiment measures expression for many genes across a set of biological samples. After appropriate preprocessing, the measured values are commonly analyzed on a logarithmic scale. The central modeling question is how expression for a given gene varies with sample characteristics recorded in the experiment, such as treatment, batch, or a clinical covariate. A gene-wise linear model gives a separate set of coefficients for each gene while using the same sample-level information to describe them.

The term gene-wise is important: the response values and coefficients belong to one gene at a time, but the design matrix records the same samples and predictors for all genes. This separates the expression measurements from the experimental structure. The model is a framework; the design matrix specifies which sample characteristics are represented, while the coefficient vector describes their relationship with a particular gene’s expected expression.

Definition: Let \(G\) genes be measured on \(n\) samples. The expression matrix \(Y\) is an \(n \times G\) matrix whose entry \(y_{ig}\) is the log-scale expression measurement for sample \(i\) and gene \(g\). The sample-level design matrix \(X\) is an \(n \times p\) matrix, with one row per sample and one column per modeled predictor, including any intercept. For gene \(g\), the coefficient vector \(\boldsymbol{\beta}_g\) has \(p\) entries and the error vector \(\boldsymbol{\varepsilon}_g\) has \(n\) entries. The gene-wise linear model is \(\mathbf{y}_g=X\boldsymbol{\beta}_g+\boldsymbol{\varepsilon}_g\), where \(\mathbf{y}_g\) is column \(g\) of \(Y\).

What the Model Says

For sample \(i\) and gene \(g\), the model can be written as

$$ y_{ig}=\sum_{j=1}^{p}x_{ij}\beta_{jg}+\varepsilon_{ig}. $$

Here \(x_{ij}\) is the value of design-matrix column \(j\) for sample \(i\), and \(\beta_{jg}\) is the coefficient for that column and gene \(g\). The expected expression, conditional on the design, is the linear predictor \(\sum_j x_{ij}\beta_{jg}\), provided the errors have conditional mean zero. Each gene has its own coefficient vector; the model does not require the coefficients to be equal across genes. In contrast, \(X\) is shared because the samples and their recorded predictors are the same when each gene is analyzed.

For example, if expression is recorded as \(\log_2\) intensity, a coefficient of 1 on a predictor that changes by one unit corresponds to a one-unit difference in expected log-base-2 expression. On the original intensity scale, a one-unit log-base-2 difference corresponds to a factor of \(2\). This describes the model’s scale relationship; it does not establish that a predictor causes a change in expression.

Worked Example: Reading the Expression and Design Matrices

Suppose a hypothetical experiment measures 120 genes on 8 samples. For each sample, the recorded predictors are an intercept, a treatment indicator, and a centered age value. What are the dimensions of \(Y\) and \(X\), and what does one column of \(Y\) represent?

There are \(n=8\) sample rows and \(G=120\) gene columns in the expression matrix, so \(Y\) is \(8 \times 120\). There are \(p=3\) predictors, so \(X\) is \(8 \times 3\). Each gene-specific coefficient vector has 3 entries, and each gene-specific error vector has 8 entries.

The column \(\mathbf{y}_{g}\) for any chosen gene \(g\) contains that gene’s eight log-scale expression measurements, in the same sample order as the rows of \(X\). The corresponding model is \(\mathbf{y}_{g}=X\boldsymbol{\beta}_{g}+\boldsymbol{\varepsilon}_{g}\). Thus, a mismatch in sample ordering between \(Y\) and \(X\) would assign predictors to the wrong expression measurements, even if both matrices had the correct dimensions.

Error Assumptions and Coefficient Estimation

The model’s error assumptions describe variation around the expected expression, conditional on the design matrix. The most basic mean assumption is \(E(\boldsymbol{\varepsilon}_g\mid X)=\mathbf{0}\). It says that the model’s linear predictor is the conditional mean, so systematic shifts left out of the predictor are not being placed in the errors. A common classical assumption for a gene is equal error variance across samples and zero covariance between different samples:

$$ \operatorname{Var}(\boldsymbol{\varepsilon}_g\mid X)=\sigma_g^2 I_n. $$

This covariance condition means that each sample error has variance \(\sigma_g^2\), and that errors for distinct samples have zero covariance. It does not, by itself, imply independence. Independence is a separate assumption when it is required. If errors are jointly normal conditional on \(X\), then zero covariance between components does imply their independence; without joint normality, zero covariance alone is not enough. In the standard normal-error version of the model, \(\boldsymbol{\varepsilon}_g\mid X\sim N_n(\mathbf{0},\sigma_g^2 I_n)\). Normality is an additional distributional assumption, not a consequence of the covariance equation.

The variance \(\sigma_g^2\) is gene-specific: different genes may have different error variances. The model does not require errors from different genes to be independent. Their expression measurements may be correlated across genes, even when the model is fit gene by gene. Treating each gene’s coefficients separately is therefore distinct from asserting that genes are biologically or statistically unrelated.

For the ordinary least-squares coefficient estimate to be uniquely defined, \(X\) must have full column rank: its \(p\) columns cannot be exact linear combinations of one another. Under that condition, the estimate for gene \(g\) is

$$ \widehat{\boldsymbol{\beta}}_g=(X^\mathsf{T}X)^{-1}X^\mathsf{T}\mathbf{y}_g. $$

This formula follows by minimizing the residual sum of squares. Write \(Q(\boldsymbol{\beta}_g)=(\mathbf{y}_g-X\boldsymbol{\beta}_g)^\mathsf{T}(\mathbf{y}_g-X\boldsymbol{\beta}_g)\). Differentiating with respect to the coefficient vector and setting the derivative to zero gives the normal equations:

$$ \frac{\partial Q}{\partial \boldsymbol{\beta}_g} =-2X^\mathsf{T}\mathbf{y}_g+2X^\mathsf{T}X\boldsymbol{\beta}_g=\mathbf{0}, \qquad X^\mathsf{T}X\boldsymbol{\beta}_g=X^\mathsf{T}\mathbf{y}_g. $$

When \(X\) has full column rank, \(X^\mathsf{T}X\) is invertible, so solving the normal equations yields the stated estimate. If the columns are not full rank, the data do not uniquely determine all \(p\) coefficients; a different parameterization or additional constraints are needed. Full rank does not guarantee that every coefficient is scientifically meaningful, but it is the algebraic condition for this unique least-squares solution.

Worked Example: Fitting a Two-Coefficient Model

Consider hypothetical \(\log_2\)-scale expression values for one gene in three samples. Let the centered predictor \(x\) be \(-1,0,1\), and let the expression values be \(5.2,5.0,6.1\), respectively. Use an intercept and \(x\), so the model is \(y_i=\beta_{0g}+\beta_{1g}x_i+\varepsilon_{ig}\).

The design matrix and response vector are

$$ X= \begin{pmatrix} 1&-1\\ 1&0\\ 1&1 \end{pmatrix}, \qquad \mathbf{y}_g= \begin{pmatrix} 5.2\\ 5.0\\ 6.1 \end{pmatrix}. $$

The columns of \(X\) are linearly independent. Because the predictor values sum to zero, the least-squares intercept is the mean response: \(\widehat{\beta}_{0g}=(5.2+5.0+6.1)/3=16.3/3\approx5.433\). The slope is \(\widehat{\beta}_{1g}=\sum_i x_i y_{ig}/\sum_i x_i^2=[(-1)(5.2)+(0)(5.0)+(1)(6.1)]/[(-1)^2+0^2+1^2]=0.9/2=0.4500\).

The fitted values are \(5.433+0.4500(-1)=4.983\), \(5.433+0.4500(0)=5.433\), and \(5.433+0.4500(1)=5.883\). The observed-minus-fitted residuals are approximately \(0.217,-0.433,0.217\). The fitted slope describes an estimated increase of 0.4500 \(\log_2\)-expression units per one-unit increase in the centered predictor. These calculations illustrate coefficient estimation; three observations are not enough to assess the error assumptions reliably.

Checking the Model’s Fit and Scope

The error assumptions are about the pattern of unexplained variation, not just whether the coefficient formula can be computed. Residuals are the observed values minus their fitted values. For a given gene, residuals plotted against fitted values or against sample order can reveal patterns such as changing spread or a trend across samples. Such patterns can indicate that the assumed equal variance or lack of sample structure is not credible. They are diagnostics rather than definitive tests: a small sample may not reveal a real problem, and a pattern may have several possible causes.

Sample dependence deserves particular attention. For example, repeated measurements from the same person may have correlated errors. If the model is fit as though those errors had covariance \(\sigma_g^2 I_n\), the coefficient estimate may still be calculable, but conventional uncertainty calculations based on the independent, equal-variance model can be misleading. A covariance matrix with nonzero off-diagonal entries represents a different error structure and calls for a model that accounts for that dependence.

The gene-wise model is related to, but more general in setup than, fitting a separate two-group test for every gene. A two-group comparison can be expressed as a linear model with a suitable design matrix; other predictors or multiple modeled terms can also be represented in that framework. This common representation helps keep the expression response, sample structure, and gene-specific coefficients explicit. It does not mean that every possible design is appropriate or that a linear model automatically handles repeated measures, unequal variances, or nonlinear relationships.

Worked Example: Covariance Is Not the Same as Independence

Suppose the hypothetical errors for one gene in three samples are asserted to have covariance matrix

$$ \operatorname{Var}(\boldsymbol{\varepsilon}_g\mid X)= \begin{pmatrix} 0.04&0.01&0\\ 0.01&0.04&0\\ 0&0&0.04 \end{pmatrix}. $$

Each diagonal entry is \(0.04\), so each sample error has standard deviation \(\sqrt{0.04}=0.20\) log-expression units. The covariance between errors in samples 1 and 2 is \(0.01\), not zero. Therefore this covariance matrix does not satisfy the model condition \(\sigma_g^2 I_n\): the samples have equal marginal variances, but their errors are not uncorrelated.

This matrix alone does not establish the full dependence structure. In general, a covariance matrix with zero off-diagonal entries says errors are uncorrelated, not necessarily independent. If, in addition, the error vector is jointly normal, then the zero off-diagonal entries imply independence. The distinction matters because independence is a stronger statement than zero covariance unless joint normality is assumed.

Common Pitfalls and Limitations

  • Inferring independence from the covariance condition. A diagonal covariance matrix establishes zero covariance, not general independence. State independence separately, or invoke joint normality when using the result that uncorrelated normal components are independent.
  • Confusing the dimensions of \(Y\) and \(X\). Rows refer to samples in both matrices. Columns of \(Y\) refer to genes, whereas columns of \(X\) refer to modeled sample-level predictors.
  • Assuming the errors must be independent across genes. The gene-wise model specifies an error structure for each gene. It does not require the errors for different genes to be unrelated.
  • Using a design matrix with redundant columns. If \(X\) is not full column rank, the formula using \((X^\mathsf{T}X)^{-1}\) is not available and the full coefficient vector is not uniquely estimable.
  • Reading coefficients as causal effects. A coefficient describes the modeled association on the chosen expression scale, conditional on the predictors in the model. Causal interpretation requires additional design and identification assumptions.

The model is also limited by its chosen scale and linear predictor. A log transformation can make multiplicative differences additive, but it does not guarantee that the conditional mean is correctly represented or that the error variance is constant. Model assumptions must be considered for the particular samples and genes being analyzed, rather than treated as automatic consequences of using a linear model.

Check Your Understanding

Answer each question, then compare your reasoning with the brief solutions.

  1. An experiment has 10 samples, 500 genes, and 4 columns in its design matrix. Give the dimensions of \(Y\) and \(X\), and the length of one gene’s coefficient vector.
  2. Does \(\operatorname{Var}(\boldsymbol{\varepsilon}_g\mid X)=\sigma_g^2 I_n\) imply independent errors without any distributional assumption?
  3. What condition on \(X\) makes the ordinary least-squares coefficient vector unique?
  4. For log-base-2 expression, how should a coefficient of 0.5 per unit of a predictor be described on the original intensity scale?

Solutions. (1) \(Y\) is \(10 \times 500\), \(X\) is \(10 \times 4\), and each coefficient vector has length 4. (2) No. It gives equal variances and zero covariance between distinct sample errors; independence is separate unless joint normality is assumed. (3) \(X\) must have full column rank, so \(X^\mathsf{T}X\) is invertible. (4) A one-unit predictor increase corresponds to an estimated \(0.5\) \(\log_2\)-expression-unit difference, or a factor of \(2^{0.5}\approx1.414\) in intensity under the log-scale relationship.

Clinical Biostats