Expand description
gls.series (lmfit.R): gene-wise generalized least squares allowing for a
known correlation between duplicate spots (ndups) or between samples that
share a block. This is the fitting engine lmFit dispatches to whenever
ndups > 1 or block is supplied together with a correlation (typically
the consensus.correlation from crate::duplicate_correlation).
Two cormatrix constructions are reproduced:
- duplicates —
cormatrix = diag(correlation, narrays) ⊗ J(ndups)with unit diagonal, afterunwrapdupsfolds thendupsspots of each gene into extra columns and the design is replicated row-wise; - blocks —
cormatrix[i,j] = correlationwhenblock[i] == block[j], unit diagonal.
And both of limma’s code paths:
- the fast multi-response
lm.fitwhen every value is finite and no probe weights are supplied (one sharedchol(V)and design QR); - the slow per-gene iteration when probe weights or missing values are
present (each gene re-derives
Vover its observed arrays).
cov.coefficients is always the unweighted (Xᵀ V⁻¹ X)⁻¹ of the full
design (limma computes it from chol(cormatrix) even on the weighted path).
Not reproduced (rare, documented): the array-weight fast path that scales V
by 1/sqrt(arrayweights) — array weights are uncommon with gls.series, and
a full probe-weight matrix flows correctly through the slow path instead; and
per-gene rank deficiency (an observed-array subset smaller than the number of
coefficients), which limma resolves by pivoted column dropping.
Functions§
- gls_
series - Fit gene-wise linear models by generalized least squares. Port of limma’s
gls.series.correlationmust be supplied (limma would otherwise callduplicateCorrelation); passcrate::duplicate_correlation’s consensus.