Skip to contents

Plot the training-sample hierarchy, prediction distributions, and SHAP features for one target from a previously calculated explanation-path object. Path assignments are never recalculated by this function.

Usage

plot_explanation_paths(
  paths,
  target,
  models = NULL,
  top_n = 10,
  feature_selection = c("path_markers", "mean_absolute_shap"),
  marker_max_adjusted_p_value = 0.05,
  marker_min_abs_mean_difference = 0.005,
  marker_min_nonzero_fraction = 0.5,
  marker_only_positive = TRUE,
  sensitive_color = "#f04546",
  resistant_color = "#3591d1"
)

Arguments

paths

An object returned by calculate_explanation_paths().

target

A single analyzed target name.

models

Optional original fitted model list. Required when feature_selection = "path_markers" so marker tests can use per-sample training SHAP values without storing full SHAP matrices in paths.

top_n

Number of features selected per supported path.

feature_selection

Feature-selection method for the lower panel. "path_markers" performs one-path-versus-rest Wilcoxon rank-sum tests with Benjamini-Hochberg correction. "mean_absolute_shap" uses the predominant features retained during path calculation.

marker_max_adjusted_p_value

Maximum adjusted p-value for path markers.

marker_min_abs_mean_difference

Minimum absolute path-versus-rest mean SHAP difference.

marker_min_nonzero_fraction

Minimum nonzero fraction in either comparison group.

marker_only_positive

If TRUE, retain only markers with higher mean SHAP in the focal path.

sensitive_color

Color used for Sensitive paths.

resistant_color

Color used for Resistant paths.

Value

A ggplot object assembled from the explanation hierarchy, path-level prediction boxplots, and SHAP heatmap. Path-marker statistics are available as the path_markers attribute when marker selection is used.

Examples

if (FALSE) { # \dontrun{
plot_explanation_paths(paths, target = "CTNNB1", models = my_models)
plot_explanation_paths(paths, target = "CTNNB1", feature_selection = "mean_absolute_shap")
} # }