Skip to contents

This function visualizes the SHAP values against the feature values for each variable.

Usage

plot_shap_dependence(shap_se, feature, shap_feature, interaction_index)

Arguments

shap_se

A SummarizedExperiment object with results computed by ml_shap.

feature

Character. The feature name (from the "variable" column of shap_result) whose raw abundance value is plotted on the x-axis.

shap_feature

Character. The feature name (from the "variable" column of shap_result) whose SHAP value is plotted on the y-axis.

interaction_index

Character. The feature name (from the "variable" column of shap_result) whose raw abundance value is used to color the points, for visualizing interaction effects with shap_feature.

Value

Return 1 interactive plot, 1 static plot, 1 table.

  1. interactive_dependence_plot & static_dependence_plot: SHAP dependence plot.

  2. table_dependence_plot: table for plotting SHAP dependence plot

Examples

data("ml_se_sub")
shap_se <- ml_shap(ml_se_sub, feature_num=10, nsim=5)
selected_feature <- as.character(unique(S4Vectors::metadata(shap_se)$shap_result$variable))
res <- plot_shap_dependence(
    shap_se, feature=selected_feature[1], shap_feature=selected_feature[2],
    interaction_index=selected_feature[2])