Why Adjust the Network for Covariates?
Age, treatment, batch, smoking status, and other measured variables can affect many omics features at once. If two features both vary with age, for example, they may be correlated in the observed data even when their remaining variation is unrelated. A network based on unadjusted measurements can therefore mix two different patterns: variation associated with measured covariates and dependence among features after accounting for those covariates.
A covariate-adjusted network targets the second pattern. Its edges describe conditional dependencies among omics features after conditioning on the measured covariates and the other features in the network. This is a statistical description of conditional association, not a causal graph: adjustment alone does not establish that one feature causes another or that all relevant confounders have been measured.
Model and Meaning of an Edge
For continuous features, a common starting model is a multivariate linear regression with Gaussian residuals. Write \(Z_i=(1,C_i^T)^T\), so the intercept is included, and let \(B\) contain a separate covariate coefficient for each feature. The model is
Here \(\Sigma\) is the covariance matrix of the residual feature vector \(\varepsilon_i\), and \(\Theta\) is its precision matrix. The model assumes that the conditional mean is correctly represented by the chosen covariate functions, the residual covariance is the same across covariate values, and subjects are independent. Gaussian residuals give the precise zero-entry interpretation below; with non-Gaussian residuals, a zero precision entry need not imply conditional independence.
For a multivariate Gaussian distribution, the conditional distribution of feature \(j\), given the covariates and all other features, has a linear mean. Its coefficient for feature \(k\) is \(-\theta_{jk}/\theta_{jj}\). Consequently, when \(\theta_{jk}=0\), feature \(k\) contributes no term to that conditional mean, and features \(j\) and \(k\) are conditionally independent given the remaining features and covariates. When \(\theta_{jk}\ne0\), they are conditionally dependent under this model.
The corresponding residual partial correlation is \( -\theta_{jk}/\sqrt{\theta_{jj}\theta_{kk}}\). It measures the residual association between the two features after linear adjustment for the covariates and accounting for the other features. Its sign and size describe conditional association, not a causal effect.
Worked Example: Residualizing Two Features
Suppose six hypothetical subjects have a centered covariate \(C=(-1,0,1,-1,0,1)\). Two measured features are \(X_1=10+2C+u\) and \(X_2=5-C+v\), where \(u=(1,-1,0,-1,1,0)\) and \(v=(1,0,-1,-1,0,1)\). Each residual vector sums to zero and has zero inner product with \(C\), so regressing each feature on an intercept and \(C\) recovers the stated residuals.
The residual sums of squares are \(u^Tu=4\) and \(v^Tv=4\); their cross-product is \(u^Tv=2\). There are \(6-2=4\) residual degrees of freedom after estimating the intercept and covariate slope. Thus the residual covariance estimates are
With just these two features, the residual correlation is \(0.5/\sqrt{1\cdot1}=0.5\). In a two-feature Gaussian network, this indicates a positive conditional association after adjustment for \(C\). It is not evidence that either feature causes the other.
Why the Residual Precision Matrix Defines the Network
The edge rule follows from the conditional Gaussian density. For a residual vector \(e\), its log density, up to constants, is \(-\tfrac12 e^T\Theta e\). To find the conditional distribution of component \(e_j\), hold the other components fixed and collect the terms involving \(e_j\):
This is a Gaussian conditional density with conditional mean \(-\sum_{k\ne j}\theta_{jk}e_k/\theta_{jj}\). The coefficient of \(e_k\) is zero exactly when \(\theta_{jk}=0\). In a Gaussian distribution, conditional independence is equivalent to this absence of a term, which justifies using nonzero off-diagonal precision entries as network edges. Applying the result to residuals means the covariates have already been conditioned on through the mean model.
Estimation in Practice
A basic workflow first estimates each feature’s conditional mean from the same covariate design, then estimates the network from the resulting residual matrix. With \(n\) subjects, collect the covariate rows in a design matrix \(Z\) and the feature measurements in an \(n\times p\) matrix \(X\). If ordinary least squares is appropriate, the fitted residual matrix is \(E=(I-P_Z)X\), where \(P_Z=Z(Z^TZ)^{-1}Z^T\) when \(Z\) has full column rank. The residual covariance estimate is based on \(E^TE\); dividing by \(n-\operatorname{rank}(Z)\) gives the usual degrees-of-freedom-adjusted covariance estimate under the linear model.
When there are many features relative to the number of subjects, the residual covariance can be singular or unstable. A sparse precision estimate can then be obtained using a graphical-lasso-type objective:
where \(S_E\) is a residual covariance input and \(\lambda\) controls the penalty on off-diagonal entries. Larger penalties generally produce fewer selected edges. A selected edge is a model-based estimate, not proof that a population dependency exists. The penalty and covariance scaling must be reported consistently, since their conventions affect the numerical value of \(\lambda\).
Worked Example: A Marginal Association Removed by Adjustment
Consider six hypothetical subjects with the same \(C=(-1,0,1,-1,0,1)\), and two features \(X_1=10+2C+u\) and \(X_2=5+3C+v\), where \(u=(1,-1,0,-1,1,0)\) and \(v=(1,1,1,-1,-1,-1)\). Both residual vectors sum to zero and are orthogonal to \(C\), so they are the residuals from regressions on an intercept and \(C\). Also, \(u^Tv=0\).
The centered covariate has \(C^TC=4\). The cross-product of the centered raw features is therefore \((2)(3)(4)+u^Tv=24\): the cross-terms involving residuals and \(C\) are zero by orthogonality. The raw sample covariance, using \(n-1=5\), is \(24/5=4.8\). The centered raw sums of squares are \(4(4)+4=20\) for \(X_1\), and \(9(4)+4=40\) for \(X_2\). Thus the raw sample variances are \(4\) and \(8\), and the raw correlation is
After adjustment, the residual cross-product is \(u^Tv=0\), so the estimated residual covariance is \(0/4=0\), and the residual correlation is zero. The large raw correlation here is generated by the shared linear association with \(C\); it does not remain as a residual association after the specified adjustment. This example demonstrates why a marginal correlation network and a covariate-adjusted network answer different questions.
Three-Feature Conditional Associations
A pairwise residual correlation is not generally the same as a network edge. A feature pair can be correlated marginally but conditionally independent after accounting for a third feature; its precision entry, rather than its covariance entry, determines the edge.
Worked Example: A Partial Correlation from a Residual Covariance Matrix
Suppose a hypothetical adjusted analysis gives the following standardized residual covariance matrix for three features:
Its determinant is \(1+2(0.6)(0.3)(0.6)-0.6^2-0.3^2-0.6^2=0.406\), which is positive; the leading principal minors are \(1\) and \(1-0.6^2=0.64\), also positive. Thus this matrix is positive definite and can be inverted. The inverse is
For features 1 and 3, the precision entry is \(0.06/0.406\), and the diagonal entries for both features are \(0.64/0.406\). Their estimated partial correlation, controlling for feature 2 as well as the covariates, is
Although the residual covariance between features 1 and 3 is \(0.3\), their estimated conditional association given feature 2 is small and negative. Whether an edge is selected depends on the estimation and sparsity procedure; the partial correlation by itself does not impose a threshold.
Choosing What to Condition On
A residual network and a joint graph containing covariates are not interchangeable. The residual network treats the covariates as given and asks about dependencies among features conditional on them. A joint graph instead includes covariates as nodes and models their dependence with the omics features. Marginalizing over covariates in a joint model can induce associations among features, even when those features are conditionally independent given the covariates.
Adjustment also depends on choosing an adequate covariate model. A straight-line effect of age may be insufficient if the feature changes nonlinearly with age. Interactions may be needed if a covariate’s association differs across treatment groups. In these cases, the conditional mean can be expanded to include justified transformations or interaction terms before residual network estimation. Covariate terms should be selected based on the scientific design and model checks, not solely to make a desired network appear sparse.
The usual alternatives answer different questions. An unadjusted network estimates dependencies without conditioning on the measured covariates. Stratifying estimates separate networks within covariate groups, which can be inefficient when groups are small and does not automatically estimate a common adjusted network. A joint covariate-feature graph explicitly represents covariate-feature relationships but has a different target. Feature-wise regression followed by residual network estimation is computationally simple, but uncertainty in the estimated mean functions and the covariance structure should be considered when interpreting edges.
Diagnostics, Failure Modes, and Limits
- Misspecified covariate effects. Residuals that still vary systematically with age, treatment, or batch suggest the mean model has not adequately adjusted for those variables. Residual plots and summaries across covariate ranges can reveal this problem.
- Changing residual variance or covariance. If residual spread or dependence changes across covariate values, a single \(\Sigma\) does not describe the data well. A single adjusted network may conceal that heterogeneity.
- Outliers and non-Gaussian residuals. A few extreme measurements can strongly affect covariance and precision estimates. Gaussian precision zeros have their conditional-independence interpretation only under the Gaussian model; with non-Gaussian residuals, they describe a linear conditional association structure rather than necessarily conditional independence.
- Too many covariate terms for the sample size. Estimating many coefficients consumes information and can leave little stable residual variation. Check design rank, residual degrees of freedom, and whether estimates change substantially under reasonable model choices.
- Unequal samples across feature pairs. Missing data handled with different subject sets can make pairwise covariance estimates inconsistent with one common joint covariance matrix. Use a coherent missing-data strategy before interpreting a network as one joint model.
- Unmeasured variables. Adjustment only conditions on measured and modeled covariates. Remaining shared variation may still create residual associations, and an edge does not identify its mechanism.
A common mistake is to regress out a measured covariate and then describe every remaining edge as a direct causal interaction. The correction is to say that the edge represents conditional dependence under the fitted model, given the included covariates and other features. Residualization can remove modeled covariate-associated mean variation, but it neither guarantees that all confounding is removed nor establishes a causal direction.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- In a Gaussian covariate-adjusted model, what does a zero residual precision entry for features \(j\) and \(k\) mean?
- Why can two features have a strong marginal correlation but zero residual correlation after adjustment?
- For a residual precision matrix with \(\theta_{12}=-0.4\), \(\theta_{11}=2\), and \(\theta_{22}=2\), calculate the partial correlation for features 1 and 2.
- Give one reason why a residual edge should not automatically be interpreted causally.
Solutions. (1) Under the Gaussian model, the features are conditionally independent given the measured covariates and all other omics features. (2) A shared covariate effect can induce marginal correlation; removing that modeled effect can leave uncorrelated residuals. (3) The partial correlation is \(-(-0.4)/\sqrt{2\cdot2}=0.4/2=0.2\), a positive conditional association. (4) For example, an unmeasured variable or misspecified covariate model may produce residual dependence; conditional association alone does not establish causal direction.