Skip to content

Commit 472cec6

Browse files
committed
Avoid use of deprecated aes_string
1 parent a080af0 commit 472cec6

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: ExploreModelMatrix
22
Type: Package
33
Title: Graphical Exploration of Design Matrices
4-
Version: 1.21.0
5-
Date: 2024-12-31
4+
Version: 1.21.1
5+
Date: 2025-09-30
66
Authors@R: c(person("Charlotte", "Soneson", role = c("aut", "cre"),
77
email = "[email protected]",
88
comment = c(ORCID = "0000-0003-3833-2169")),
@@ -44,8 +44,9 @@ Imports:
4444
MASS,
4545
limma,
4646
S4Vectors,
47-
shinyjs
48-
RoxygenNote: 7.3.2
47+
shinyjs,
48+
rlang
49+
RoxygenNote: 7.3.3
4950
Suggests:
5051
testthat (>= 2.1.0),
5152
knitr,

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ importFrom(dplyr,mutate_if)
2020
importFrom(dplyr,n)
2121
importFrom(dplyr,select)
2222
importFrom(ggplot2,aes)
23-
importFrom(ggplot2,aes_string)
2423
importFrom(ggplot2,annotate)
2524
importFrom(ggplot2,coord_flip)
2625
importFrom(ggplot2,element_blank)
@@ -48,6 +47,7 @@ importFrom(methods,as)
4847
importFrom(methods,is)
4948
importFrom(rintrojs,introjs)
5049
importFrom(rintrojs,introjsUI)
50+
importFrom(rlang,.data)
5151
importFrom(scales,hue_pal)
5252
importFrom(shiny,HTML)
5353
importFrom(shiny,actionButton)

R/VisualizeDesign.R

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@
7070
#' across everything
7171
#' @importFrom tidyr unite separate_rows
7272
#' @importFrom ggplot2 ggplot ggtitle annotate geom_vline theme geom_hline
73-
#' theme_bw geom_text aes_string element_blank coord_flip aes element_text
73+
#' theme_bw geom_text element_blank coord_flip aes element_text
7474
#' scale_color_manual scale_x_discrete scale_y_discrete expansion
7575
#' @importFrom stats model.matrix as.formula cor var
7676
#' @importFrom methods is as
7777
#' @importFrom MASS ginv
7878
#' @importFrom magrittr %>%
7979
#' @importFrom S4Vectors DataFrame
80+
#' @importFrom rlang .data
8081
#'
8182
VisualizeDesign <- function(sampleData, designFormula = NULL,
8283
flipCoordFitted = FALSE, flipCoordCoocc = FALSE,
@@ -304,12 +305,24 @@ VisualizeDesign <- function(sampleData, designFormula = NULL,
304305
ggp <- lapply(split(
305306
plot_data, f = plot_data$groupby),
306307
function(w) {
307-
gg <- ggplot2::ggplot(
308-
w,
309-
ggplot2::aes_string(
310-
x = ifelse(length(plot_terms) == 1, 1, plot_terms[2]),
311-
y = plot_terms[1],
312-
label = "value")) +
308+
if (length(plot_terms) == 1) {
309+
gg <- ggplot2::ggplot(
310+
w,
311+
ggplot2::aes(
312+
x = 1,
313+
y = .data[[plot_terms[1]]],
314+
label = .data$value)
315+
)
316+
} else {
317+
gg <- ggplot2::ggplot(
318+
w,
319+
ggplot2::aes(
320+
x = .data[[plot_terms[2]]],
321+
y = .data[[plot_terms[1]]],
322+
label = .data$value)
323+
)
324+
}
325+
gg <- gg +
313326
ggplot2::scale_x_discrete(
314327
expand = ggplot2::expansion(mult = 0, add = 0.5)
315328
) +
@@ -371,14 +384,26 @@ VisualizeDesign <- function(sampleData, designFormula = NULL,
371384
plot_data, f = plot_data$groupby),
372385
function(w) {
373386
w <- w %>% dplyr::select(dplyr::all_of(keepcols)) %>% dplyr::distinct()
374-
gp <- ggplot2::ggplot(
375-
w,
376-
ggplot2::aes_string(
377-
x = ifelse(length(plot_terms) == 1, 1, plot_terms[2]),
378-
y = plot_terms[1],
379-
fill = "nSamples",
380-
label = "nSamples"
381-
)) +
387+
if (length(plot_terms) == 1) {
388+
gp <- ggplot2::ggplot(
389+
w,
390+
ggplot2::aes(
391+
x = 1,
392+
y = .data[[plot_terms[1]]],
393+
fill = .data$nSamples,
394+
label = .data$nSamples
395+
))
396+
} else {
397+
gp <- ggplot2::ggplot(
398+
w,
399+
ggplot2::aes(
400+
x = .data[[plot_terms[2]]],
401+
y = .data[[plot_terms[1]]],
402+
fill = .data$nSamples,
403+
label = .data$nSamples
404+
))
405+
}
406+
gp <- gp +
382407
ggplot2::geom_tile(color = "black") +
383408
ggplot2::scale_x_discrete(
384409
expand = ggplot2::expansion(mult = 0, add = 0)

0 commit comments

Comments
 (0)