Skip to contents

Visualizes the relationship between SHAP values and corresponding feature values across samples, stratified by selected features.

Usage

SpaPheno_SHAP_dependence_plot(shap_df, feature_names, title = NULL)

Arguments

shap_df

A data.frame with SHAP output. Must contain columns:

  • feature: Name of the feature.

  • feature.value: The actual value of the feature in a sample.

  • phi: The SHAP value associated with that feature/sample.

feature_names

Character vector of feature names to include in the plot.

title

Optional character string for the plot title. Default is "SHAP Dependence Plot".

Value

A ggplot2 object showing SHAP dependence plots for selected features.

Details

This function generates a scatter plot of SHAP values versus feature values, overlaid with a LOESS smoothed curve. Each feature specified in feature_names is plotted in a separate facet panel. Useful for interpreting the directionality and interaction effects of SHAP-based model explanations.

Author

Bin Duan

Examples

if (FALSE) { # \dontrun{
shap_df <- data.frame(
  feature = rep(c("GeneA", "GeneB"), each = 50),
  feature.value = rnorm(100),
  phi = rnorm(100)
)
SpaPheno_SHAP_dependence_plot(shap_df, c("GeneA", "GeneB"), title = "Example SHAP Plot")
} # }