Tutorials › Multi-Omics Data Integration › Worked Example Of Nested Multi-Omics Evaluation

Prediction Models and Data Leakage · Tutorial 426 of 597

Worked Example Of Nested Multi-Omics Evaluation

Follow a two-block classifier from fold-specific preprocessing and inner tuning to a one-time outer-fold performance estimate.

Advanced 12 min read

What You'll Learn

  • Separate inner tuning data from the untouched outer test fold.
  • Fit preprocessing steps using only the training portion of each fold.
  • Tune a joint two-omics classifier using inner-fold performance.
  • Refit the selected pipeline on all outer-training subjects.
  • Calculate and interpret an outer-fold AUC from held-out predictions.
  • Recognize common leakage routes and limits of a single held-out score.

Why Nested Evaluation Is Needed

A multi-omics classifier can appear to predict well for two very different reasons: it may capture a reproducible relationship between the omics measurements and the outcome, or the analysis may have reused information from the subjects on whom it is evaluated. Reuse can happen indirectly. For example, scaling features using all subjects, selecting features before splitting, or choosing a tuning value after looking at test performance can all make an evaluation optimistic.

This tutorial works through one binary prediction task with two omics blocks. The target is an honest estimate of the performance of the complete fitted procedure, including its preprocessing and tuning—not just of a classifier considered in isolation. The outer test fold is kept untouched while all choices are made using the outer training data.

Definition: In nested evaluation, an outer split separates data used to develop a model from data used for its final evaluation. Within the outer training data, inner cross-validation compares candidate modelling procedures or hyperparameter values. After selecting a candidate, the complete pipeline is refit using all outer training data and evaluated once on the outer test fold. Every data-dependent operation, including preprocessing and feature selection, must be fitted using only the training portion of the split where it is applied.

For the worked task, let \(Y_i\in\{0,1\}\) denote the binary outcome for subject \(i\), and let \(X_i^{(1)}\) and \(X_i^{(2)}\) denote that subject’s measurements in two omics blocks. The planned classifier concatenates the retained features from both blocks and fits a ridge-penalized logistic regression. For a feature vector \(x_i\), the model assigns probability \( \hat{p}_i = 1/(1+\exp[-(\hat{\beta}_0+x_i^\mathsf{T}\hat{\beta})]) \). The penalty parameter \(\lambda\) controls the amount of coefficient shrinkage. A larger \(\lambda\) applies stronger shrinkage. The candidates and evaluation metric are specified before inspecting outer-test results.

The assumptions behind interpreting the outer score are important. Subjects in the outer test fold must not have contributed to development decisions, directly or indirectly. The split should reflect the intended prediction setting: for a new-subject prediction task, all records from one subject must stay in the same fold. The held-out subjects should also represent the target population reasonably well. A random split does not measure performance in a different population or a future period if those differ from the sampled data.

Fold-Local Preprocessing and Inner Tuning

Suppose there are 54 hypothetical subjects, with two omics blocks measured on each subject. We reserve 6 subjects—3 with \(Y=1\) and 3 with \(Y=0\)—as the outer test fold. The remaining 48 subjects form the outer training set, with 24 in each outcome class. We use four stratified inner folds, each containing 6 positive and 6 negative subjects. Stratification helps keep both outcome classes represented in these particular folds; it does not remove the need to check that the split design suits the application.

For each inner split, the 36 inner-training subjects alone determine the preprocessing. A planned sequence might remove features failing a prespecified measurement-quality rule, impute missing values using feature-wise training medians, remove features with zero training variance, and standardize each retained feature using the inner-training mean and sample standard deviation. The resulting transformation is then applied to the 12 inner-validation subjects without refitting it. Any supervised feature screen must also be fitted anew using only the 36 inner-training subjects.

The same discipline applies to the outer evaluation. Once tuning is complete, preprocessing is refitted on all 48 outer-training subjects, and the selected model is fitted on those transformed data. Those fitted transformations and coefficients are then applied to the 6 outer-test subjects. The test measurements are inputs to prediction, but they do not determine imputation values, scaling constants, selected features, tuning choices, or model coefficients.

Worked Example: Standardizing a Feature Within One Fold

Suppose one RNA feature has values \(2,4,6,8\) in a small hypothetical training fold. A held-out subject has value \(10\). Show how the feature is standardized without allowing the held-out value to affect the transformation.

The training mean is \( \bar{x}=(2+4+6+8)/4=5 \). The training sample standard deviation is \( s=\sqrt{[(2-5)^2+(4-5)^2+(6-5)^2+(8-5)^2]/(4-1)}=\sqrt{20/3}\approx2.582 \). The held-out value is transformed using these training quantities: \( z=(10-5)/2.582\approx1.936 \).

The held-out value is not included in either the mean or standard deviation. If it were included, the transformation would depend on the held-out fold and would no longer represent a procedure fitted only on training data. In a real pipeline, the same rule is applied separately within each block and feature, after the training-only imputation and feature checks.

For a candidate \(\lambda\), fit the same two-block pipeline in each inner split and calculate its AUC on that split’s validation subjects. AUC is the proportion of positive-negative pairs in which the positive subject receives a higher predicted score, with tied pairs counted as one half. The inner selection rule here is to choose the \(\lambda\) with the highest mean of the four fold-specific AUCs. A prespecified tie rule—for example, choose the larger \(\lambda\) in an exact tie—prevents an unplanned choice after seeing results.

Worked Example: Selecting the Penalty From Inner Folds

For illustration, suppose the fold-specific validation AUCs from the four inner splits are as follows. Each value comes from predictions made by a pipeline whose preprocessing and model fitting used only that split’s inner-training subjects.

\(\lambda\)Fold 1 AUCFold 2 AUCFold 3 AUCFold 4 AUCMean AUC
0.10.780.720.750.710.740
10.810.770.790.750.780
100.740.700.720.680.710

For \(\lambda=1\), the mean is \( (0.81+0.77+0.79+0.75)/4=3.12/4=0.780 \). The corresponding means for \(0.1\) and \(10\) are \(2.96/4=0.740\) and \(2.84/4=0.710\). The selection rule therefore chooses \(\lambda=1\). These inner scores are used to choose the candidate; they are not reported as the final outer-test performance.

Refit and Evaluate Once on the Outer Fold

After choosing \(\lambda=1\), the selected pipeline is fitted again from the beginning using all 48 outer-training subjects. That means the training-only quality checks, imputation, variance checks, and scaling are recalculated on these 48 subjects, and the ridge logistic regression is refitted with \(\lambda=1\). The resulting model produces one predicted probability for each of the 6 outer-test subjects. No change to the pipeline is made in response to these predictions or the observed outer outcomes.

A short justification explains why this separation matters. Conditional on the outer-training data, the fitted pipeline and its predictions for future subjects are fixed. If the outer test subjects are independent of that training data and are sampled from the target population, the expected held-out AUC evaluates that particular fitted pipeline rather than a procedure selected to look good on those test outcomes. In contrast, choosing the best-looking candidate using the test AUC makes the evaluation data part of model selection. For candidate scores \(A_1,\ldots,A_K\), selecting \(\max_k A_k\) tends to give a value at least as large as the best candidate’s underlying expected score:

$$ E\!\left[\max_k A_k\right]\ \geq\ \max_k E[A_k]. $$

The inequality follows because \(\max_k A_k\geq A_j\) for every candidate \(j\); taking expectations and then choosing the candidate with the largest expectation gives the result. The outer fold protects against this selection effect only if it remains untouched through all choices.

Worked Example: Calculating the Outer-Test AUC

Suppose the six held-out subjects have the following hypothetical outcomes and predicted probabilities from the refitted pipeline. These values are illustrative, and the prediction model was fixed before the test outcomes were examined.

SubjectOutcome \(Y\)Predicted probability
A10.90
B10.70
C10.55
D00.80
E00.40
F00.20

There are \(3\times3=9\) positive-negative pairs. Subject A’s score exceeds all three negative scores, contributing 3 correctly ordered pairs. Subject B’s score exceeds 0.40 and 0.20 but not 0.80, contributing 2. Subject C’s score also exceeds 0.40 and 0.20 but not 0.80, contributing 2. Thus \( \mathrm{AUC}= (3+2+2)/9=7/9\approx0.778 \).

The outer-fold AUC is therefore about 0.778: in this held-out set, 77.8% of positive-negative pairs were ranked in the correct direction. This is a small test fold, so the score is imprecise; it is not evidence that performance is exactly 0.778 in the target population. The calculation describes discrimination, not calibration, and it does not establish that either omics block causes the outcome.

Diagnostics, Alternatives, and Limitations

Before interpreting a score, audit the data flow at every split. Check that sample identifiers align across the two blocks and outcome labels, that no subject or repeated specimen crosses folds, and that each inner validation subject receives a prediction from a model that did not train on that subject. Confirm that every learned transformation is trained within the relevant training fold. A preprocessing object fitted once on all 54 subjects and then reused in cross-validation is a warning sign, even if the classifier itself was refitted correctly.

Also inspect whether each fold contains both outcome classes, whether missingness or failed assays cause exclusions that differ by outcome, and whether the chosen metric matches the prediction goal. AUC cannot be calculated in a validation fold with only one outcome class. If that occurs, revise the split plan or use a metric and design appropriate to the data; do not silently omit problematic folds. Large variation in inner-fold scores can indicate small-sample instability, influential subjects, or a split that is poorly matched to the study structure.

Nested evaluation differs from several common alternatives. A single development/test split with tuning performed entirely inside the development set can also protect the test set, but its result may be sensitive to which subjects happen to be held out. Ordinary cross-validation that uses the same folds both to select the best candidate and to report its best score is generally optimistic for the selected candidate. Nested cross-validation repeats the outer split-and-evaluate process across outer folds, giving multiple held-out predictions and a broader summary, but it is computationally more demanding and requires careful aggregation. It is not the same as evaluating on an independent external cohort, which tests transport to a separately sampled population.

A single outer fold has important limitations. It provides only one estimate, and with few held-out subjects its uncertainty can be substantial. The particular split can affect the result. If the intended use is prediction in a new hospital, future time period, or different population, a random subject-level split may not represent that use; the split strategy must instead mirror the intended deployment setting. Finally, honest evaluation does not guarantee a useful model: a fully leakage-free pipeline can still perform poorly or be unstable.

Common Pitfall

Common mistake: “The feature filter does not use the outcome, so I can run it once on all subjects before cross-validation.” This reasoning is wrong because the filter still learns from validation and test feature distributions. The held-out observations can influence which features survive, even without their labels. Fit every data-dependent filter within each training fold, then apply its result unchanged to that fold’s validation data. The same rule applies to imputation and scaling.
1
Reserve the outer test fold.
Define the split to match the target prediction setting, and keep its outcomes out of all model-development decisions.
2
Tune within outer training data.
For every inner split and candidate, fit preprocessing and the classifier on inner-training subjects, then score inner-validation predictions.
3
Refit the selected pipeline.
Recalculate preprocessing on all outer-training subjects and fit the chosen model using the selected hyperparameter.
4
Evaluate once.
Apply the fixed pipeline to the outer test fold and calculate the prespecified performance metric without further tuning.

Check Your Understanding

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

  1. In an inner split, should the validation subjects contribute to the feature-wise means and standard deviations used for scaling?
  2. If mean inner AUC is highest for \(\lambda=1\), may the outer-test AUC be used to decide between \(\lambda=1\) and \(\lambda=10\)?
  3. A held-out set has 4 positive and 5 negative subjects. How many positive-negative pairs contribute to its AUC?
  4. Why might a subject-level random split be unsuitable when the intended use is prediction at a new hospital?

Solutions. (1) No. Fit the means and standard deviations on inner-training subjects only, then apply them to validation subjects. (2) No. That would reuse the test set for selection; use the inner results to select \(\lambda\), then evaluate the selected pipeline once on the outer fold. (3) \(4\times5=20\) pairs. AUC is the proportion of these pairs correctly ranked, with ties counted as one half. (4) Subjects from the same hospital can share population and measurement characteristics, so a random subject split may place closely related observations in both training and test sets. A hospital-level split better reflects prediction at a previously unseen hospital.

Clinical Biostats