diff --git a/DESCRIPTION b/DESCRIPTION index dfa3c71b7..2c35b4b43 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9153 +Version: 2.1.1.9154 Date: 2025-02-22 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 4485f3c8c..ee37d9fab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9153 +# AMR 2.1.1.9154 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/PythonPackage/AMR/AMR.egg-info/PKG-INFO b/PythonPackage/AMR/AMR.egg-info/PKG-INFO index bc1c0e2c2..4583ab3ba 100644 --- a/PythonPackage/AMR/AMR.egg-info/PKG-INFO +++ b/PythonPackage/AMR/AMR.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.2 Name: AMR -Version: 2.1.1.9153 +Version: 2.1.1.9154 Summary: A Python wrapper for the AMR R package Home-page: https://github.com/msberends/AMR Author: Matthijs Berends diff --git a/PythonPackage/AMR/dist/AMR-2.1.1.9153-py3-none-any.whl b/PythonPackage/AMR/dist/AMR-2.1.1.9154-py3-none-any.whl similarity index 84% rename from PythonPackage/AMR/dist/AMR-2.1.1.9153-py3-none-any.whl rename to PythonPackage/AMR/dist/AMR-2.1.1.9154-py3-none-any.whl index 1481339c5..bd4abbb05 100644 Binary files a/PythonPackage/AMR/dist/AMR-2.1.1.9153-py3-none-any.whl and b/PythonPackage/AMR/dist/AMR-2.1.1.9154-py3-none-any.whl differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9153.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9153.tar.gz deleted file mode 100644 index e8aca67a7..000000000 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9153.tar.gz and /dev/null differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9154.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9154.tar.gz new file mode 100644 index 000000000..a168b57e9 Binary files /dev/null and b/PythonPackage/AMR/dist/amr-2.1.1.9154.tar.gz differ diff --git a/PythonPackage/AMR/setup.py b/PythonPackage/AMR/setup.py index e6fa9073e..f7fc7dc48 100644 --- a/PythonPackage/AMR/setup.py +++ b/PythonPackage/AMR/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='AMR', - version='2.1.1.9153', + version='2.1.1.9154', packages=find_packages(), install_requires=[ 'rpy2', diff --git a/R/plotting.R b/R/plotting.R index d65b7a246..1787cf54f 100755 --- a/R/plotting.R +++ b/R/plotting.R @@ -81,20 +81,24 @@ #' some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30)) #' #' -#' # Plotting using base R's plot() --------------------------------------- -#' -#' plot(some_mic_values) -#' plot(some_disk_values) -#' plot(some_sir_values) -#' -#' # when providing the microorganism and antibiotic, colours will show interpretations: -#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin") -#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl") +#' \donttest{ +#' # Plotting using ggplot2's autoplot() for MIC, disk, and SIR ----------- +#' if (require("ggplot2")) { +#' autoplot(some_mic_values) +#' } +#' if (require("ggplot2")) { +#' # when providing the microorganism and antibiotic, colours will show interpretations: +#' autoplot(some_mic_values, mo = "Escherichia coli", ab = "cipro") +#' } +#' if (require("ggplot2")) { +#' # support for 20 languages, various guidelines, and many options +#' autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro", +#' guideline = "CLSI 2024", language = "no", +#' title = "Disk diffusion from the North") +#' } #' #' #' # Plotting using scale_x_mic() ----------------------------------------- -#' \donttest{ #' if (require("ggplot2")) { #' mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), #' counts = c(1, 1, 2, 2, 3, 3)), @@ -142,22 +146,10 @@ #' aes(group, mic)) + #' geom_boxplot() + #' geom_violin(linetype = 2, colour = "grey", fill = NA) + -#' scale_y_mic(mic_range = c(NA, 2)) +#' scale_y_mic(mic_range = c(NA, 0.25)) #' } #' #' -#' # Plotting using scale_fill_mic() ----------------------------------------- -#' some_counts <- as.integer(runif(20, 5, 50)) -#' -#' if (require("ggplot2")) { -#' ggplot(data.frame(mic = some_mic_values, -#' group = some_groups, -#' counts = some_counts), -#' aes(group, counts, fill = mic)) + -#' geom_col() + -#' scale_fill_mic(mic_range = c(0.5, 16)) -#' } -#' #' # Plotting using scale_x_sir() ----------------------------------------- #' if (require("ggplot2")) { #' ggplot(data.frame(x = c("I", "R", "S"), @@ -191,42 +183,22 @@ #' if (require("ggplot2")) { #' plain + #' scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") + -#' scale_colour_sir(language = "nl", eucast_I = FALSE, -#' name = "In Dutch!") +#' scale_colour_sir(language = "pt", +#' name = "Support in 20 languages") #' } #' #' -#' # Plotting using ggplot2's autoplot() ---------------------------------- -#' if (require("ggplot2")) { -#' autoplot(some_mic_values) -#' } -#' if (require("ggplot2")) { -#' autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -#' } -#' if (require("ggplot2")) { -#' autoplot(some_sir_values) -#' } +#' # Plotting using base R's plot() --------------------------------------- +#' +#' plot(some_mic_values) +#' # when providing the microorganism and antibiotic, colours will show interpretations: +#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin") #' +#' plot(some_disk_values) +#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro") +#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl") #' -#' # Plotting using scale_y_percent() ------------------------------------- -#' if (require("ggplot2")) { -#' p <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), -#' counts = c(1, 1, 2, 2, 3, 3)), -#' aes(mics, counts / sum(counts))) + -#' geom_col() -#' print(p) -#' -#' p2 <- p + -#' scale_y_percent() + -#' theme_sir() -#' print(p2) -#' -#' p + -#' scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1), -#' limits = c(0, 1)) + -#' theme_sir() -#' } -#' } +#' plot(some_sir_values) NULL create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { @@ -243,12 +215,12 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) { scale$mic_limits_set <- limits_set scale$transform <- function(x) { - as.double(rescale_mic(x = as.double(x), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)) + as.double(rescale_mic(x = as.double(as.mic(x)), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)) } scale$transform_df <- function(self, df) { stop_if(all(is.na(df[[aest]])), "`scale_", aest, "_mic()`: All MIC values are `NA`. Check your input data.", call = FALSE) - self$mic_values_rescaled <- rescale_mic(x = as.double(df[[aest]]), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE) + self$mic_values_rescaled <- rescale_mic(x = as.double(as.mic(df[[aest]])), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE) # create new breaks and labels here lims <- range(self$mic_values_rescaled, na.rm = TRUE) # support inner and outer mic_range settings (e.g., data ranges 0.5-8 and mic_range is set to 0.025-64) diff --git a/data-raw/gpt_training_text_v2.1.1.9153.txt b/data-raw/gpt_training_text_v2.1.1.9154.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9153.txt rename to data-raw/gpt_training_text_v2.1.1.9154.txt index d7a283974..6d9990a71 100644 --- a/data-raw/gpt_training_text_v2.1.1.9153.txt +++ b/data-raw/gpt_training_text_v2.1.1.9154.txt @@ -1,6 +1,6 @@ This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. -First and foremost, you are trained on version 2.1.1.9153. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9154. Remember this whenever someone asks which AMR package version you’re at. Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens. ---------------------------------------------------------------------------------------------------- @@ -7540,159 +7540,6 @@ The interpretation of "I" will be named "Increased exposure" for all EUCAST guid For interpreting MIC values as well as disk diffusion diameters, the default guideline is EUCAST 2024, unless the package option \code{\link[=AMR-options]{AMR_guideline}} is set. See \code{\link[=as.sir]{as.sir()}} for more information. } } -\examples{ -some_mic_values <- random_mic(size = 100) -some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro") -some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30)) - - -# Plotting using base R's plot() --------------------------------------- - -plot(some_mic_values) -plot(some_disk_values) -plot(some_sir_values) - -# when providing the microorganism and antibiotic, colours will show interpretations: -plot(some_mic_values, mo = "S. aureus", ab = "ampicillin") -plot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl") - - -# Plotting using scale_x_mic() ----------------------------------------- -\donttest{ -if (require("ggplot2")) { - mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), - counts = c(1, 1, 2, 2, 3, 3)), - aes(mics, counts)) + - geom_col() - mic_plot + - labs(title = "without scale_x_mic()") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic() + - labs(title = "with scale_x_mic()") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(keep_operators = "all") + - labs(title = "with scale_x_mic() keeping all operators") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(mic_range = c(1, 16)) + - labs(title = "with scale_x_mic() using a manual 'within' range") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(mic_range = c(0.032, 256)) + - labs(title = "with scale_x_mic() using a manual 'outside' range") -} - - -# Plotting using scale_y_mic() ----------------------------------------- -some_groups <- sample(LETTERS[1:5], 20, replace = TRUE) - -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups), - aes(group, mic)) + - geom_boxplot() + - geom_violin(linetype = 2, colour = "grey", fill = NA) + - scale_y_mic() -} -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups), - aes(group, mic)) + - geom_boxplot() + - geom_violin(linetype = 2, colour = "grey", fill = NA) + - scale_y_mic(mic_range = c(NA, 2)) -} - - -# Plotting using scale_fill_mic() ----------------------------------------- -some_counts <- as.integer(runif(20, 5, 50)) - -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups, - counts = some_counts), - aes(group, counts, fill = mic)) + - geom_col() + - scale_fill_mic(mic_range = c(0.5, 16)) -} - -# Plotting using scale_x_sir() ----------------------------------------- -if (require("ggplot2")) { - ggplot(data.frame(x = c("I", "R", "S"), - y = c(45,323, 573)), - aes(x, y)) + - geom_col() + - scale_x_sir() -} - - -# Plotting using scale_y_mic() and scale_colour_sir() ------------------ -if (require("ggplot2")) { - plain <- ggplot(data.frame(mic = some_mic_values, - group = some_groups, - sir = as.sir(some_mic_values, - mo = "E. coli", - ab = "cipro")), - aes(x = group, y = mic, colour = sir)) + - theme_minimal() + - geom_boxplot(fill = NA, colour = "grey") + - geom_jitter(width = 0.25) - - plain -} -if (require("ggplot2")) { - # and now with our MIC and SIR scale functions: - plain + - scale_y_mic() + - scale_colour_sir() -} -if (require("ggplot2")) { - plain + - scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") + - scale_colour_sir(language = "nl", eucast_I = FALSE, - name = "In Dutch!") -} - - -# Plotting using ggplot2's autoplot() ---------------------------------- -if (require("ggplot2")) { - autoplot(some_mic_values) -} -if (require("ggplot2")) { - autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -} -if (require("ggplot2")) { - autoplot(some_sir_values) -} - - -# Plotting using scale_y_percent() ------------------------------------- -if (require("ggplot2")) { - p <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), - counts = c(1, 1, 2, 2, 3, 3)), - aes(mics, counts / sum(counts))) + - geom_col() - print(p) - - p2 <- p + - scale_y_percent() + - theme_sir() - print(p2) - - p + - scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1), - limits = c(0, 1)) + - theme_sir() -} -} -} diff --git a/man/plot.Rd b/man/plot.Rd index bdeac271d..c3e175cd2 100644 --- a/man/plot.Rd +++ b/man/plot.Rd @@ -196,156 +196,3 @@ The interpretation of "I" will be named "Increased exposure" for all EUCAST guid For interpreting MIC values as well as disk diffusion diameters, the default guideline is EUCAST 2024, unless the package option \code{\link[=AMR-options]{AMR_guideline}} is set. See \code{\link[=as.sir]{as.sir()}} for more information. } } -\examples{ -some_mic_values <- random_mic(size = 100) -some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro") -some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30)) - - -# Plotting using base R's plot() --------------------------------------- - -plot(some_mic_values) -plot(some_disk_values) -plot(some_sir_values) - -# when providing the microorganism and antibiotic, colours will show interpretations: -plot(some_mic_values, mo = "S. aureus", ab = "ampicillin") -plot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl") - - -# Plotting using scale_x_mic() ----------------------------------------- -\donttest{ -if (require("ggplot2")) { - mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), - counts = c(1, 1, 2, 2, 3, 3)), - aes(mics, counts)) + - geom_col() - mic_plot + - labs(title = "without scale_x_mic()") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic() + - labs(title = "with scale_x_mic()") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(keep_operators = "all") + - labs(title = "with scale_x_mic() keeping all operators") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(mic_range = c(1, 16)) + - labs(title = "with scale_x_mic() using a manual 'within' range") -} -if (require("ggplot2")) { - mic_plot + - scale_x_mic(mic_range = c(0.032, 256)) + - labs(title = "with scale_x_mic() using a manual 'outside' range") -} - - -# Plotting using scale_y_mic() ----------------------------------------- -some_groups <- sample(LETTERS[1:5], 20, replace = TRUE) - -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups), - aes(group, mic)) + - geom_boxplot() + - geom_violin(linetype = 2, colour = "grey", fill = NA) + - scale_y_mic() -} -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups), - aes(group, mic)) + - geom_boxplot() + - geom_violin(linetype = 2, colour = "grey", fill = NA) + - scale_y_mic(mic_range = c(NA, 2)) -} - - -# Plotting using scale_fill_mic() ----------------------------------------- -some_counts <- as.integer(runif(20, 5, 50)) - -if (require("ggplot2")) { - ggplot(data.frame(mic = some_mic_values, - group = some_groups, - counts = some_counts), - aes(group, counts, fill = mic)) + - geom_col() + - scale_fill_mic(mic_range = c(0.5, 16)) -} - -# Plotting using scale_x_sir() ----------------------------------------- -if (require("ggplot2")) { - ggplot(data.frame(x = c("I", "R", "S"), - y = c(45,323, 573)), - aes(x, y)) + - geom_col() + - scale_x_sir() -} - - -# Plotting using scale_y_mic() and scale_colour_sir() ------------------ -if (require("ggplot2")) { - plain <- ggplot(data.frame(mic = some_mic_values, - group = some_groups, - sir = as.sir(some_mic_values, - mo = "E. coli", - ab = "cipro")), - aes(x = group, y = mic, colour = sir)) + - theme_minimal() + - geom_boxplot(fill = NA, colour = "grey") + - geom_jitter(width = 0.25) - - plain -} -if (require("ggplot2")) { - # and now with our MIC and SIR scale functions: - plain + - scale_y_mic() + - scale_colour_sir() -} -if (require("ggplot2")) { - plain + - scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") + - scale_colour_sir(language = "nl", eucast_I = FALSE, - name = "In Dutch!") -} - - -# Plotting using ggplot2's autoplot() ---------------------------------- -if (require("ggplot2")) { - autoplot(some_mic_values) -} -if (require("ggplot2")) { - autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -} -if (require("ggplot2")) { - autoplot(some_sir_values) -} - - -# Plotting using scale_y_percent() ------------------------------------- -if (require("ggplot2")) { - p <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")), - counts = c(1, 1, 2, 2, 3, 3)), - aes(mics, counts / sum(counts))) + - geom_col() - print(p) - - p2 <- p + - scale_y_percent() + - theme_sir() - print(p2) - - p + - scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1), - limits = c(0, 1)) + - theme_sir() -} -} -}