Compute per-cohort performance metrics for a fitted panel on validation data. Unlike evaluate_panel() which returns aggregate metrics, this function returns a data frame with one row per cohort, enabling comparison of panel transferability across independent datasets.

evaluate_panel_by_cohort(
  panel,
  x,
  y,
  metrics = c("sensitivity", "specificity", "auc"),
  cutoff_prob = 0.5,
  positive = NULL,
  feature_transform = NULL,
  assay = NULL
)

Arguments

panel

A BiomarkerPanelResult.

x

Validation feature matrix, or a list of matrices for multi-cohort evaluation. Names of the list become cohort identifiers.

y

Validation binary response factor, or a list of factors when x is a list.

metrics

Character vector of registered metric names to compute (any name in metric_registry(), e.g. "pauc" or "specificity_at_sensitivity"). Defaults to c("sensitivity", "specificity", "auc").

cutoff_prob

Classification probability threshold. Defaults to 0.5.

positive

Label treated as the positive class. Defaults to the value stored in the panel, or "Yes".

feature_transform

Optional feature transform name. Defaults to the transform stored in the fitted panel.

assay

For SummarizedExperiment inputs, assay name or index.

Value

A data.frame with columns:

cohort

Character; cohort identifier

n_samples

Integer; number of samples in cohort

n_positive

Integer; number of positive samples

n_negative

Integer; number of negative samples

...

One column per metric in metrics argument

Attributes: cutoff_prob, positive, features.

See also

evaluate_panel() for aggregate evaluation, plot_cohort_comparison() for visualization.

Examples

# With a fitted panel and multi-cohort validation data:
# cohort_metrics <- evaluate_panel_by_cohort(panel, x_list, y_list)
# plot_cohort_comparison(cohort_metrics)