1
0
mirror of https://github.com/msberends/AMR.git synced 2025-10-09 05:16:19 +02:00

(v3.0.1.9001) fix antibiogram

This commit is contained in:
2025-09-30 10:54:07 +02:00
parent adee419f1c
commit 0b24967b23
8 changed files with 28 additions and 15 deletions

View File

@@ -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")),

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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")) {

View File

@@ -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]

View File

@@ -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")) {

View File

@@ -32,6 +32,9 @@ test_that("test-antibiogram.R", {
# Traditional antibiogram ----------------------------------------------
ab0 <- antibiogram(example_isolates)
ab1 <- antibiogram(example_isolates,
antimicrobials = c(aminoglycosides(), carbapenems())
)