Practical 20: Genomics, systems biology and multi-omics
Learning objectives
Implement training-only centering and scaling; compare a supplied ridge model with a baseline; explain tuning and deployment-population limitations.
Biological question and data
Do the hypothetical molecular measurements improve prediction for a held-out group of animals?
The response uses arbitrary units and depends on a shared latent factor by construction. Animals 1–32 train the model and 33–48 form a supplied holdout. This split also changes farm composition; its representativeness should be discussed. Lambda is supplied, not chosen using test outcomes.
No biological download is required. Numerical inputs are hypothetical, not observed animal data. The runnable examples use base R. Count and abundance units are specified where used.
1. Define the split and preprocess using training only
Combine available log2 protein and metabolite features, then estimate their means and scales in training.
One split shows the evaluation procedure. The generating model makes useful molecular association plausible, but the test score does not establish practical value in a real livestock population.
4. Tune only within the training animals
For demonstration, partition the original training group into fitting and internal validation subsets. Every candidate model re-estimates preprocessing from its fitting subset. The final test set remains outside this selection.
Show R code
source(file.path(helper_dir,'prediction_helpers.R'))# Inspect the helper interface before replacing the transparent calculation above.args(fit_teaching_ridge)
function (X, y, lambda = 4, weights = rep(1, ncol(X)))
NULL
The complete internal-selection exercise below is written transparently to preserve the penalty convention.
Choose the penalty from internal validation only, refit on all original training animals and apply the training transformation to the original test group.
This score evaluates the supplied selection procedure on this realization. Do not use it to reconsider the chosen penalty.
6. Distinguish selection from final evaluation
After choosing a penalty internally, refit preprocessing and coefficients using all original training animals, then evaluate the selected procedure once on the test group. The small contiguous internal split is only a supplied illustration; its farm composition and uncertainty still matter. More candidate penalties create more selection opportunity, not more independent evaluation evidence.
Interpretation challenge
Can the original held-out test score be used to override the internally selected penalty?
Suggested reasoning
Doing so uses the test set for selection. Its score would no longer assess an untouched selected procedure. Use a new evaluation set or an appropriate nested design.
Interpretation and limits
Feature selection, scaling, imputation and lambda tuning must occur inside training-only validation. If lambda is optimized on these test animals, they become a tuning set. For real prediction, use a grouping/time split matching deployment and quantify uncertainty across independent units.
Exercises
Why is the intercept not penalized here?
What happens if test outcomes select lambda?
Could an accurate predictor be a noncausal proxy?
Suggested answers
The model centers the response separately, leaving the mean outside the coefficient penalty.
The reported score is no longer an untouched test evaluation.
Yes; predictive usefulness does not establish intervention or mediation.