Skip to content

Simplify sv_dependence2D code #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions R/sv_dependence2D.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ sv_dependence2D.shapviz <- function(
add_vars = NULL,
seed = 1L,
...) {
nplots <- max(length(x), length(y))

if (nplots == 1L) {
if (max(length(x), length(y)) == 1L) {
p <- .one_dependence2D_plot(
object = object,
x = x,
Expand All @@ -86,16 +84,18 @@ sv_dependence2D.shapviz <- function(
jitter_height = jitter_height,
interactions = interactions,
add_vars = add_vars,
title = NULL,
seed = seed,
...
)
return(p)
}
# mapply requires varying arguments with length > 0 -> NULL packed into list
if (is.null(jitter_width)) {
jitter_width <- replicate(nplots, NULL)
jitter_width <- list(NULL)
}
if (is.null(jitter_height)) {
jitter_height <- replicate(nplots, NULL)
jitter_height <- list(NULL)
}
plot_list <- mapply(
FUN = .one_dependence2D_plot,
Expand All @@ -109,6 +109,7 @@ sv_dependence2D.shapviz <- function(
interactions = interactions,
add_vars = add_vars,
seed = seed,
title = NULL, # not needed
...
),
SIMPLIFY = FALSE
Expand Down Expand Up @@ -142,21 +143,26 @@ sv_dependence2D.mshapviz <- function(
length(x) == 1L,
length(y) == 1L
)
plot_list <- lapply(
object,
# mapply() does not allow varying arguments of length 0, thus we enclose NULL
titles <- if (!is.null(names(object))) names(object) else list(NULL)

plot_list <- mapply(
FUN = .one_dependence2D_plot,
# Argument list (simplify via match.call() or some rlang magic?)
x = x,
y = y,
viridis_args = viridis_args,
jitter_width = jitter_width,
jitter_height = jitter_height,
interactions = interactions,
add_vars = add_vars,
seed = seed,
...
object,
title = titles,
MoreArgs = list(
x = x,
y = y,
viridis_args = viridis_args,
jitter_width = jitter_width,
jitter_height = jitter_height,
interactions = interactions,
add_vars = add_vars,
seed = seed,
...
),
SIMPLIFY = FALSE
)
plot_list <- add_titles(plot_list, nms = names(object)) # see sv_waterfall()

# Collect axis titles, axes and guides
coll <- .collect(plot_list)
Expand All @@ -178,6 +184,7 @@ sv_dependence2D.mshapviz <- function(
jitter_height,
interactions,
add_vars,
title,
seed,
...) {
S <- get_shap_values(object)
Expand Down Expand Up @@ -227,6 +234,8 @@ sv_dependence2D.mshapviz <- function(
legend.box.spacing = grid::unit(0, "pt"),
legend.key.width = grid::unit(12, "pt")
)

if (!is.null(title)) {
p <- p + ggplot2::ggtitle(title)
}
return(p)
}
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Slight adaptions to comply with upcoming XGBoost version.

Status: OK

## Reverse dependencies (2)
## Reverse dependencies (3)

OK: 2
OK: 3
BROKEN: 0
114 changes: 56 additions & 58 deletions revdep/README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,64 @@
# Platform

|field |value |
|:--------|:-------------------------------------|
|version |R version 4.4.1 (2024-06-14 ucrt) |
|os |Windows 11 x64 (build 22631) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_Switzerland.utf8 |
|ctype |English_Switzerland.utf8 |
|tz |Europe/Zurich |
|date |2025-01-19 |
|rstudio |2024.12.0+467 Kousa Dogwood (desktop) |
|pandoc |NA |
|field |value |
|:--------|:---------------------------------------|
|version |R version 4.4.1 (2024-06-14 ucrt) |
|os |Windows 11 x64 (build 22631) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_Switzerland.utf8 |
|ctype |English_Switzerland.utf8 |
|tz |Europe/Zurich |
|date |2025-06-22 |
|rstudio |2025.05.0+496 Mariposa Orchid (desktop) |
|pandoc |NA |

# Dependencies

|package |old |new |Δ |
|:------------|:-------|:-------|:--|
|shapviz |0.9.6 |0.9.7 |* |
|cli |3.6.3 |3.6.3 | |
|colorspace |2.1-1 |2.1-1 | |
|commonmark |1.9.2 |1.9.2 | |
|curl |6.1.0 |6.1.0 | |
|data.table |1.16.4 |1.16.4 | |
|fansi |1.0.6 |1.0.6 | |
|farver |2.1.2 |2.1.2 | |
|ggfittext |0.10.2 |0.10.2 | |
|gggenes |0.5.1 |0.5.1 | |
|ggplot2 |3.5.1 |3.5.1 | |
|ggrepel |0.9.6 |0.9.6 | |
|glue |1.8.0 |1.8.0 | |
|gridtext |0.1.5 |0.1.5 | |
|gtable |0.3.6 |0.3.6 | |
|isoband |0.2.7 |0.2.7 | |
|jpeg |0.1-10 |0.1-10 | |
|jsonlite |1.8.9 |1.8.9 | |
|labeling |0.4.3 |0.4.3 | |
|lifecycle |1.0.4 |1.0.4 | |
|magrittr |2.0.3 |2.0.3 | |
|markdown |1.13 |1.13 | |
|munsell |0.5.1 |0.5.1 | |
|patchwork |1.3.0 |1.3.0 | |
|pillar |1.10.1 |1.10.1 | |
|pkgconfig |2.0.3 |2.0.3 | |
|png |0.1-8 |0.1-8 | |
|R6 |2.5.1 |2.5.1 | |
|RColorBrewer |1.1-3 |1.1-3 | |
|Rcpp |1.0.14 |1.0.14 | |
|rlang |1.1.4 |1.1.4 | |
|scales |1.3.0 |1.3.0 | |
|shades |1.4.0 |1.4.0 | |
|stringi |1.8.4 |1.8.4 | |
|stringr |1.5.1 |1.5.1 | |
|tibble |3.2.1 |3.2.1 | |
|utf8 |1.2.4 |1.2.4 | |
|vctrs |0.6.5 |0.6.5 | |
|viridisLite |0.4.2 |0.4.2 | |
|withr |3.0.2 |3.0.2 | |
|xfun |0.50 |0.50 | |
|xgboost |1.7.8.1 |1.7.8.1 | |
|xml2 |1.3.6 |1.3.6 | |
|package |old |new |Δ |
|:------------|:--------|:--------|:--|
|shapviz |0.9.7 |0.10.0 |* |
|cli |3.6.5 |3.6.5 | |
|commonmark |1.9.5 |1.9.5 | |
|curl |6.3.0 |6.3.0 | |
|data.table |1.17.6 |1.17.6 | |
|farver |2.1.2 |2.1.2 | |
|ggfittext |0.10.2 |0.10.2 | |
|gggenes |0.5.1 |0.5.1 | |
|ggplot2 |3.5.2 |3.5.2 | |
|ggrepel |0.9.6 |0.9.6 | |
|glue |1.8.0 |1.8.0 | |
|gridtext |0.1.5 |0.1.5 | |
|gtable |0.3.6 |0.3.6 | |
|isoband |0.2.7 |0.2.7 | |
|jpeg |0.1-11 |0.1-11 | |
|jsonlite |2.0.0 |2.0.0 | |
|labeling |0.4.3 |0.4.3 | |
|lifecycle |1.0.4 |1.0.4 | |
|litedown |0.7 |0.7 | |
|magrittr |2.0.3 |2.0.3 | |
|markdown |2.0 |2.0 | |
|patchwork |1.3.1 |1.3.1 | |
|pillar |1.10.2 |1.10.2 | |
|pkgconfig |2.0.3 |2.0.3 | |
|png |0.1-8 |0.1-8 | |
|R6 |2.6.1 |2.6.1 | |
|RColorBrewer |1.1-3 |1.1-3 | |
|Rcpp |1.0.14 |1.0.14 | |
|rlang |1.1.6 |1.1.6 | |
|scales |1.4.0 |1.4.0 | |
|shades |1.4.0 |1.4.0 | |
|stringi |1.8.7 |1.8.7 | |
|stringr |1.5.1 |1.5.1 | |
|tibble |3.3.0 |3.3.0 | |
|utf8 |1.2.6 |1.2.6 | |
|vctrs |0.6.5 |0.6.5 | |
|viridisLite |0.4.2 |0.4.2 | |
|withr |3.0.2 |3.0.2 | |
|xfun |0.52 |0.52 | |
|xgboost |1.7.11.1 |1.7.11.1 | |
|xml2 |1.3.8 |1.3.8 | |

# Revdeps

2 changes: 1 addition & 1 deletion revdep/cran.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## revdepcheck results

We checked 2 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
We checked 3 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
Expand Down