Single-sample matched-null benchmark for within-sample miRNA panel scoring
Source:R/singlesample-matched-null.R
singlesample_matched_null_benchmark.RdFor an observed scoring method scoring_fn applied to a panel of
size k, generates K random panels of the same size drawn from
the cohort feature pool, jointly stratified on per-feature detection-rate and
log-mean-abundance quartile bins (16 strata total). The empirical p-value
measures whether the observed panel AUC exceeds the matched-null distribution.
Name note: the simpler (non-stratified) package predecessor is
os_panel_null_benchmark (panel-gates.R). This function
uses the name singlesample_matched_null_benchmark to avoid collision.
Arguments
- X
Matrix (samples \(\times\) features). Must have column names. Should be the full feature pool, not just the observed panel.
- y
Binary outcome (0/1 or factor with 2 levels).
- panel
Character vector of feature names in the observed panel.
- scoring_fn
Function
function(X_subset)returning a per-sample numeric score.- K
Integer — number of null panels. Default 10,000 (per plan v0.3.3).
- feature_pool
Character vector — full feature pool. Defaults to
colnames(X).- exclude_features
Character — feature names to exclude from the candidate pool (e.g., hemolysis markers). Default
character(0).- post_hemolysis_corrected
Logical. If
TRUE, prepends the canonical hemolysis-marker list toexclude_features. DefaultFALSE.- seed
Integer — RNG seed. Default 42.
- auc_ci_method
Character; one of
"hanley_mcneil"(default; closed-form Hanley-McNeil 1982 standard error),"delong"(pROC::ci.auc(method="delong"); requirespROC>= 1.16), or"none"(skip CI). The 95% CI is reported alongside the observed AUC asauc_obs_ci_lo/auc_obs_ci_hi.
Value
A list with components:
auc_obsObserved panel AUC.
auc_obs_ci_lo,auc_obs_ci_hi95% confidence interval for the observed AUC; NA when
auc_ci_method = "none"or computation fails.auc_nullLength-
Knumeric vector of null AUCs (NA for degenerate draws).p_empEmpirical p-value, or
NA_real_if not eligible.panel_sizeNumber of features in the observed panel.
K,seedParameters as supplied.
null_panelsList of length
Kof random feature name sets.excluded_featuresFinal exclusion list applied.
eligibleLogical: whether matched-null p-value is valid.
fallback_tier1, 2, or 3 (3 = not eligible).
fallback_countNumber of draws that fell back to tier 3.
Examples
if (FALSE) { # \dontrun{
set.seed(42)
X <- matrix(rlnorm(100 * 50, meanlog = 5, sdlog = 1), nrow = 100,
dimnames = list(NULL, paste0("mir-", seq_len(50))))
y <- rbinom(100, 1, 0.5)
panel <- paste0("mir-", 1:10)
res <- singlesample_matched_null_benchmark(X, y, panel,
scoring_fn = function(M) rowSums(log(M + 1)),
K = 200L)
res$p_emp
} # }