Skip to main content

Module splines

Module splines 

Source
Expand description

Natural cubic spline basis, a port of splines::ns(x, df, intercept=TRUE) (R’s splines package) and the B-spline machinery (splineDesign / de Boor) it needs. Used by the trended variance moderation in eBayes (fitFDist with a covariate).

The downstream consumer only uses the basis through a least-squares fit, so the exact basis vectors do not matter — only the column space does. We therefore reproduce R’s knot placement exactly (boundary knots at the data range, interior knots at type-7 quantiles) and span the same natural-cubic- spline subspace, but parameterise it with our own orthonormal null-space basis rather than R’s. Projection onto a subspace is basis-independent, so the fitted values and residual sum of squares match R to floating-point precision regardless.

[NsBasis] keeps that null-space transform so the fitted spline can be re-evaluated at new covariate points (R’s predict.ns). A natural spline is a unique function — linear beyond the boundary knots — so its value at a new point is likewise basis-independent: evaluating our basis there and contracting with our fit coefficients reproduces R’s prediction exactly. This drives the notallok branch of trended fitFDist, which extrapolates the trend to genes excluded from the fit.