bgreenwell / fastshap

Fast approximate Shapley values in R
https://bgreenwell.github.io/fastshap/
112 stars 18 forks source link

Feature: ggplot2-based beeswarm plot #39

Closed kapsner closed 1 year ago

kapsner commented 2 years ago

This PR adds a ggplot2-based beeswarm plot to fastshap and closes #17.

The example plot from the unittest (https://github.com/kapsner/fastshap/blob/feat_beeswarm_plot/inst/tinytest/test_fastshap.R#L197) is as follows: fastshap_beeswarm

kapsner commented 2 years ago

The latest commit enhances the beeswarm plot by making use of the awesome R package ggbeeswarm https://github.com/eclarke/ggbeeswarm, resulting in beeswarm_plot

kapsner commented 2 years ago

The latest commit normalizes feature values between 0 and 1, resulting in beeswarm_plot n

kapsner commented 2 years ago

Hi @bgreenwell , when you take a closer look, there are some "challenges" to be considered:

All in all 6 new dependencies have been added for performing the data wrangling and visualizations:

magrittr dplyr utils tidyr viridis ggbeeswarm

Whereas ggbeeswarm is also imported via the DESCRIPTION file's "Remotes" section, since the argument corral from geom_beeswarm is not yet available the version that is released on CRAN.

This would currently disallow a fast CRAN release of fastshap, if one wants to make use of this argument. Alternatively, I have commented out the part without ggbeeswarm that uses plain ggplot2 and geom_jitter (https://github.com/kapsner/fastshap/blob/feat_beeswarm_plot/R/beeswarm.R#L110), which, however, does not look as nice.

To clarify the progress of ggbeeswarm's next CRAN release, I have opened this issue https://github.com/eclarke/ggbeeswarm/issues/74.

kapsner commented 2 years ago

Unfortunatelly, ggbeeswarm seems not to be actively maintained anymore (last CRAN upload in 2017). To get rid of this dependency, I've found geom_sina from the ggforce package, which results in a very similar depiction: beeswarm_plot

kapsner commented 2 years ago

Hi @bgreenwell , have you had already some time to take a closer look to this PR?

bgreenwell commented 2 years ago

Thanks @kapsner, I have not had a chance, but I will try to take a close look this week!

bgreenwell commented 1 year ago

Closing this in favor of reliance on the shapviz package.