Skip to content

Commit adee419

Browse files
committed
v3.0.1
1 parent 33fb184 commit adee419

File tree

9 files changed

+62
-55
lines changed

9 files changed

+62
-55
lines changed

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 3.0.0
2-
Date: 2025-06-01 16:52:53 UTC
3-
SHA: 79038fed2169a25a7fc067c80bb25d9d78be21d9
1+
Version: 3.0.1
2+
Date: 2025-09-20 10:56:46 UTC
3+
SHA: 33fb1849eb5aa6d33828e643c8f5047dd93447e3

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: AMR
2-
Version: 3.0.0.9036
3-
Date: 2025-09-19
2+
Version: 3.0.1
3+
Date: 2025-09-20
44
Title: Antimicrobial Resistance Data Analysis
55
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
66
data analysis and to work with microbial and antimicrobial properties by

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ if(getRversion() >= "3.0.0") S3method(ggplot2::fortify, disk)
373373
if(getRversion() >= "3.0.0") S3method(ggplot2::fortify, mic)
374374
if(getRversion() >= "3.0.0") S3method(ggplot2::fortify, resistance_predict)
375375
if(getRversion() >= "3.0.0") S3method(ggplot2::fortify, sir)
376+
if(getRversion() >= "3.0.0") S3method(ggplot2::scale_type, mic)
377+
if(getRversion() >= "3.0.0") S3method(ggplot2::scale_type, sir)
376378
if(getRversion() >= "3.0.0") S3method(knitr::knit_print, antibiogram)
377379
if(getRversion() >= "3.0.0") S3method(knitr::knit_print, formatted_bug_drug_combinations)
378380
if(getRversion() >= "3.0.0") S3method(pillar::pillar_shaft, ab)

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# AMR 3.0.0.9036
1+
# AMR 3.0.1
22

33
This is a bugfix release following the release of v3.0.0 in June 2025.
44

55
### Changed
66
* Fixed bugs introduced by `ggplot2` v4.0.0 (#236)
7+
* MIC scale functions (such as `scale_y_mic()`) will now be applied automatically when plotting values of class `mic`
8+
* SIR scale functions (such as `scale_x_sir()`) will now be applied automatically when plotting values of class `sir`
79
* Fixed a bug in `antibiogram()` for when no antimicrobials are set
810
* Fixed a bug in `antibiogram()` to allow column names containing the `+` character (#222)
911
* Fixed a bug in `as.ab()` for antimicrobial codes with a number in it if they are preceded by a space

R/ab.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pillar_shaft.ab <- function(x, ...) {
514514
out[is.na(x)] <- font_na(NA)
515515

516516
# add the names to the drugs as mouse-over!
517-
if (tryCatch(isTRUE(getExportedValue("ansi_has_hyperlink_support", ns = asNamespace("cli"))()), error = function(e) FALSE)) {
517+
if (in_rstudio()) {
518518
out[!is.na(x)] <- font_url(
519519
url = paste0(x[!is.na(x)], ": ", ab_name(x[!is.na(x)])),
520520
txt = out[!is.na(x)]

R/mdro.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,12 +1499,13 @@ mdro <- function(x = NULL,
14991499
any_all = "any",
15001500
reason = "Enterobacterales: carbapenemase"
15011501
)
1502+
c.freundii_complex <- AMR::microorganisms.groups$mo_name[AMR::microorganisms.groups$mo_group_name == "Citrobacter freundii complex"]
15021503
trans_tbl(
15031504
3,
15041505
rows = which(col_values(x, SXT) == "R" &
15051506
(col_values(x, GEN) == "R" | col_values(x, TOB) == "R" | col_values(x, AMK) == "R") &
15061507
(col_values(x, CIP) == "R" | col_values(x, NOR) == "R" | col_values(x, LVX) == "R") &
1507-
(x$genus %in% c("Enterobacter", "Providencia") | paste(x$genus, x$species) %in% c("Citrobacter freundii", "Klebsiella aerogenes", "Hafnia alvei", "Morganella morganii"))),
1508+
(x$genus %in% c("Enterobacter", "Providencia") | paste(x$genus, x$species) %in% c(c.freundii_complex, "Klebsiella aerogenes", "Hafnia alvei", "Morganella morganii"))),
15081509
cols = c(SXT, aminoglycosides, fluoroquinolones),
15091510
any_all = "any",
15101511
reason = "Enterobacterales group II: aminoglycoside + fluoroquinolone + cotrimoxazol"

R/mo.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ pillar_shaft.mo <- function(x, ...) {
675675
}
676676

677677
# add the names to the bugs as mouse-over!
678-
if (tryCatch(isTRUE(getExportedValue("ansi_has_hyperlink_support", ns = asNamespace("cli"))()), error = function(e) FALSE)) {
678+
if (in_rstudio()) {
679679
out[!x %in% c("UNKNOWN", NA)] <- font_url(
680680
url = paste0(
681681
x[!x %in% c("UNKNOWN", NA)], ": ",

R/plotting.R

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@
5252
#' @details
5353
#' ### The `scale_*_mic()` Functions
5454
#'
55-
#' 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. They also allow to rescale the MIC range with an 'inside' or 'outside' range if required, and retain the operators in MIC values (such as `>=`) if desired. Missing intermediate log2 levels will be plotted too.
55+
#' 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.
56+
#'
57+
#' 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()].
58+
#'
59+
#' 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.
5660
#'
5761
#' ### The `scale_*_sir()` Functions
5862
#'
59-
#' 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 = " < ")`). 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.
63+
#' 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 = " < ")`).
64+
#'
65+
#' 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()].
66+
#'
67+
#' 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.
6068
#'
6169
#' ### Additional `ggplot2` Functions
6270
#'
@@ -114,17 +122,12 @@
114122
#' ) +
115123
#' geom_col()
116124
#' mic_plot +
117-
#' labs(title = "without scale_x_mic()")
125+
#' labs(title = "scale_x_mic() automatically applied")
118126
#' }
119127
#' if (require("ggplot2")) {
120128
#' mic_plot +
121-
#' scale_x_mic() +
122-
#' labs(title = "with scale_x_mic()")
123-
#' }
124-
#' if (require("ggplot2")) {
125-
#' mic_plot +
126-
#' scale_x_mic(keep_operators = "all") +
127-
#' labs(title = "with scale_x_mic() keeping all operators")
129+
#' scale_x_mic(keep_operators = "none") +
130+
#' labs(title = "with scale_x_mic() keeping no operators")
128131
#' }
129132
#' if (require("ggplot2")) {
130133
#' mic_plot +
@@ -151,7 +154,7 @@
151154
#' ) +
152155
#' geom_boxplot() +
153156
#' geom_violin(linetype = 2, colour = "grey30", fill = NA) +
154-
#' scale_y_mic()
157+
#' labs(title = "scale_y_mic() automatically applied")
155158
#' }
156159
#' if (require("ggplot2")) {
157160
#' ggplot(
@@ -183,7 +186,7 @@
183186
#'
184187
#' # Plotting using scale_y_mic() and scale_colour_sir() ------------------
185188
#' if (require("ggplot2")) {
186-
#' plain <- ggplot(
189+
#' mic_sir_plot <- ggplot(
187190
#' data.frame(
188191
#' mic = some_mic_values,
189192
#' group = some_groups,
@@ -197,21 +200,16 @@
197200
#' theme_minimal() +
198201
#' geom_boxplot(fill = NA, colour = "grey30") +
199202
#' geom_jitter(width = 0.25)
200-
#'
201-
#' plain
203+
#' labs(title = "scale_y_mic()/scale_colour_sir() automatically applied")
204+
#'
205+
#' mic_sir_plot
202206
#' }
203207
#' if (require("ggplot2")) {
204-
#' # and now with our MIC and SIR scale functions:
205-
#' plain +
206-
#' scale_y_mic() +
207-
#' scale_colour_sir()
208-
#' }
209-
#' if (require("ggplot2")) {
210-
#' plain +
208+
#' mic_sir_plot +
211209
#' scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") +
212210
#' scale_colour_sir(
213-
#' language = "pt",
214-
#' name = "Support in 27 languages"
211+
#' language = "pt", # Portuguese
212+
#' name = "Support in 28 languages"
215213
#' )
216214
#' }
217215
#' }
@@ -229,6 +227,9 @@
229227
#' plot(some_sir_values)
230228
NULL
231229

230+
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(ggplot2::scale_type, mic)
231+
scale_type.mic <- function(x) c("mic", "discrete")
232+
232233
create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) {
233234
ggplot_fn <- getExportedValue(paste0("scale_", aest, "_continuous"),
234235
ns = asNamespace("ggplot2")
@@ -381,6 +382,9 @@ scale_fill_mic <- function(keep_operators = "edges", mic_range = NULL, ...) {
381382
create_scale_mic("fill", keep_operators = keep_operators, mic_range = mic_range, ...)
382383
}
383384

385+
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(ggplot2::scale_type, sir)
386+
scale_type.sir <- function(x) c("sir", "discrete")
387+
384388
create_scale_sir <- function(aesthetics, colours_SIR, language, eucast_I, ...) {
385389
args <- list(...)
386390
args[c("value", "labels", "limits")] <- NULL

man/plot.Rd

Lines changed: 21 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)