diff --git a/DESCRIPTION b/DESCRIPTION index e454aa3e7..51e6f27e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 3.0.1 -Date: 2025-09-20 +Version: 3.0.1.9001 +Date: 2025-09-30 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by @@ -27,10 +27,10 @@ Authors@R: c( person(given = c("Judith", "M."), family = "Fonville", role = "ctb"), person(given = c("Kathryn"), family = "Holt", role = "ctb", comment = c(ORCID = "0000-0003-3949-2471")), person(given = c("Larisse"), family = "Bolton", role = "ctb", comment = c(ORCID = "0000-0001-7879-2173")), - person(given = c("Matthew"), family = "Saab", role = "ctb"), + person(given = c("Matthew"), family = "Saab", role = "ctb", comment = c(ORCID = "0009-0008-6626-7919")), person(given = c("Natacha"), family = "Couto", role = "ctb", comment = c(ORCID = "0000-0002-9152-5464")), person(given = c("Peter"), family = "Dutey-Magni", role = "ctb", comment = c(ORCID = "0000-0002-8942-9836")), - person(given = c("Rogier", "P."), family = "Schade", role = "ctb"), + person(given = c("Rogier", "P."), family = "Schade", role = "ctb", comment = c(ORCID = "0000-0002-9487-4467")), person(given = c("Sofia"), family = "Ny", role = "ctb", comment = c(ORCID = "0000-0002-2017-1363")), person(given = c("Alex", "W."), family = "Friedrich", role = "ths", comment = c(ORCID = "0000-0003-4881-038X")), person(given = c("Bhanu", "N.", "M."), family = "Sinha", role = "ths", comment = c(ORCID = "0000-0003-1634-0010")), diff --git a/NEWS.md b/NEWS.md index 135cc2a0a..c56588afb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# AMR 3.0.1.9001 + +### Changed +* Fixed a bug in `antibiogram()` for when no antimicrobials are set + + # AMR 3.0.1 This is a bugfix release following the release of v3.0.0 in June 2025. diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index f72b0527f..ad96299c2 100644 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -1620,8 +1620,8 @@ get_n_cores <- function(max_cores = Inf) { # Support `where()` if tidyselect not installed ---- if (!is.null(import_fn("where", "tidyselect", error_on_fail = FALSE))) { - # tidyselect::where() exists, load the namespace to make `where()`s work across the package in default arguments - loadNamespace("tidyselect") + # tidyselect::where() exists, retrieve from their namespace to make `where()`s work across the package in default arguments + where <- tidyselect::where } else { where <- function(fn) { # based on https://github.com/nathaneastwood/poorman/blob/52eb6947e0b4430cd588976ed8820013eddf955f/R/where.R#L17-L32 diff --git a/R/antibiogram.R b/R/antibiogram.R index fa099bb00..17c2f9135 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -453,7 +453,7 @@ antibiogram.default <- function(x, deprecation_warning("antibiotics", "antimicrobials", fn = "antibiogram", is_argument = TRUE) antimicrobials <- list(...)$antibiotics } - meet_criteria(antimicrobials, allow_class = c("character", "numeric", "integer"), allow_NA = FALSE, allow_NULL = FALSE) + meet_criteria(antimicrobials, allow_class = c("character", "numeric", "integer", "function"), allow_NA = FALSE, allow_NULL = FALSE) if (!is.function(mo_transform)) { meet_criteria(mo_transform, allow_class = "character", has_length = 1, is_in = c("name", "shortname", "gramstain", colnames(AMR::microorganisms)), allow_NULL = TRUE, allow_NA = TRUE) } @@ -518,6 +518,10 @@ antibiogram.default <- function(x, # get antimicrobials ab_trycatch <- tryCatch(colnames(suppressWarnings(x[, antimicrobials, drop = FALSE])), error = function(e) NULL) + if (is.null(ab_trycatch)) { + # try with tidyverse + ab_trycatch <- tryCatch(colnames(dplyr::select(x, {{ antimicrobials }})), error = function(e) NULL) + } if (is.null(ab_trycatch)) { stop_ifnot(is.character(suppressMessages(antimicrobials)), "`antimicrobials` must be an antimicrobial selector, or a character vector.") antimicrobials.bak <- antimicrobials diff --git a/R/plotting.R b/R/plotting.R index 0fc2760a2..72b842860 100755 --- a/R/plotting.R +++ b/R/plotting.R @@ -53,17 +53,17 @@ #' ### The `scale_*_mic()` Functions #' #' The functions [scale_x_mic()], [scale_y_mic()], [scale_colour_mic()], and [scale_fill_mic()] functions allow to plot the [mic][as.mic()] class (MIC values) on a continuous, logarithmic scale. -#' +#' #' There is normally no need to add these scale functions to your plot, as they are applied automatically when plotting values of class [mic][as.mic()]. -#' +#' #' When manually added though, they allow to rescale the MIC range with an 'inside' or 'outside' range if required, and provide the option to retain the operators in MIC values (such as `>=`). Missing intermediate log2 levels will always be plotted too. #' #' ### The `scale_*_sir()` Functions #' #' The functions [scale_x_sir()], [scale_colour_sir()], and [scale_fill_sir()] functions allow to plot the [sir][as.sir()] class in the right order (`r paste(levels(NA_sir_), collapse = " < ")`). -#' +#' #' There is normally no need to add these scale functions to your plot, as they are applied automatically when plotting values of class [sir][as.sir()]. -#' +#' #' At default, they translate the S/I/R values to an interpretative text ("Susceptible", "Resistant", etc.) in any of the `r length(AMR:::LANGUAGES_SUPPORTED)` supported languages (use `language = NULL` to keep S/I/R). Also, except for [scale_x_sir()], they set colour-blind friendly colours to the `colour` and `fill` aesthetics. #' #' ### Additional `ggplot2` Functions @@ -201,7 +201,7 @@ #' geom_boxplot(fill = NA, colour = "grey30") + #' geom_jitter(width = 0.25) #' labs(title = "scale_y_mic()/scale_colour_sir() automatically applied") -#' +#' #' mic_sir_plot #' } #' if (require("ggplot2")) { diff --git a/man/AMR.Rd b/man/AMR.Rd index 8ee9cc724..9bcb6d5a9 100644 --- a/man/AMR.Rd +++ b/man/AMR.Rd @@ -83,10 +83,10 @@ Other contributors: \item Judith M. Fonville [contributor] \item Kathryn Holt (\href{https://orcid.org/0000-0003-3949-2471}{ORCID}) [contributor] \item Larisse Bolton (\href{https://orcid.org/0000-0001-7879-2173}{ORCID}) [contributor] - \item Matthew Saab [contributor] + \item Matthew Saab (\href{https://orcid.org/0009-0008-6626-7919}{ORCID}) [contributor] \item Natacha Couto (\href{https://orcid.org/0000-0002-9152-5464}{ORCID}) [contributor] \item Peter Dutey-Magni (\href{https://orcid.org/0000-0002-8942-9836}{ORCID}) [contributor] - \item Rogier P. Schade [contributor] + \item Rogier P. Schade (\href{https://orcid.org/0000-0002-9487-4467}{ORCID}) [contributor] \item Sofia Ny (\href{https://orcid.org/0000-0002-2017-1363}{ORCID}) [contributor] \item Alex W. Friedrich (\href{https://orcid.org/0000-0003-4881-038X}{ORCID}) [thesis advisor] \item Bhanu N. M. Sinha (\href{https://orcid.org/0000-0003-1634-0010}{ORCID}) [thesis advisor] diff --git a/man/plot.Rd b/man/plot.Rd index 3729cad49..78dd00aba 100644 --- a/man/plot.Rd +++ b/man/plot.Rd @@ -322,7 +322,7 @@ if (require("ggplot2")) { geom_boxplot(fill = NA, colour = "grey30") + geom_jitter(width = 0.25) labs(title = "scale_y_mic()/scale_colour_sir() automatically applied") - + mic_sir_plot } if (require("ggplot2")) { diff --git a/tests/testthat/test-antibiogram.R b/tests/testthat/test-antibiogram.R index 03cf0b6dd..6f1a765a7 100644 --- a/tests/testthat/test-antibiogram.R +++ b/tests/testthat/test-antibiogram.R @@ -32,6 +32,9 @@ test_that("test-antibiogram.R", { # Traditional antibiogram ---------------------------------------------- + + ab0 <- antibiogram(example_isolates) + ab1 <- antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems()) )