diff --git a/DESCRIPTION b/DESCRIPTION index 5c98dfcad..ebd6c8f5e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9187 +Version: 2.1.1.9188 Date: 2025-03-07 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 46a72496a..5382df1de 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9187 +# AMR 2.1.1.9188 *(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 6ffb36834..a6cae88a7 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.9187 +Version: 2.1.1.9188 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.9187.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9187.tar.gz deleted file mode 100644 index c99d56927..000000000 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9187.tar.gz and /dev/null differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9187-py3-none-any.whl b/PythonPackage/AMR/dist/amr-2.1.1.9188-py3-none-any.whl similarity index 52% rename from PythonPackage/AMR/dist/amr-2.1.1.9187-py3-none-any.whl rename to PythonPackage/AMR/dist/amr-2.1.1.9188-py3-none-any.whl index 6f4dae0c1..741e00e8e 100644 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9187-py3-none-any.whl and b/PythonPackage/AMR/dist/amr-2.1.1.9188-py3-none-any.whl differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9188.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9188.tar.gz new file mode 100644 index 000000000..d1d6caf3d Binary files /dev/null and b/PythonPackage/AMR/dist/amr-2.1.1.9188.tar.gz differ diff --git a/PythonPackage/AMR/setup.py b/PythonPackage/AMR/setup.py index 1a69aff62..a5d7f8e4a 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.9187', + version='2.1.1.9188', packages=find_packages(), install_requires=[ 'rpy2', diff --git a/R/antibiogram.R b/R/antibiogram.R index 410534326..f9307d9bd 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -769,6 +769,32 @@ antibiogram.default <- function(x, # prepare for definitive output out <- out_wisca wisca_parameters <- wisca_parameters[, colnames(wisca_parameters)[!colnames(wisca_parameters) %in% c(levels(NA_sir_), "lower_ci", "upper_ci", "group")], drop = FALSE] + if (isTRUE(has_syndromic_group)) { + long_numeric <- out_wisca %pm>% + pm_ungroup() %pm>% + pm_select( + syndromic_group = syndromic_group, + ab = ab, + coverage = coverage, + lower_ci = lower_ci, + upper_ci = upper_ci, + n_total = n_total, + n_tested = n_tested, + n_susceptible = n_susceptible + ) + } else { + long_numeric <- out_wisca %pm>% + pm_ungroup() %pm>% + pm_select( + ab = ab, + coverage = coverage, + lower_ci = lower_ci, + upper_ci = upper_ci, + n_total = n_total, + n_tested = n_tested, + n_susceptible = n_susceptible + ) + } } out$digits <- digits # since pm_sumarise() cannot work with an object outside the current frame @@ -1170,9 +1196,7 @@ tbl_format_footer.antibiogram <- function(x, ...) { plot.antibiogram <- function(x, ...) { df <- attributes(x)$long_numeric if (!"mo" %in% colnames(df)) { - stop_("Plotting antibiograms using `plot()` is only possible if they were not created using dplyr groups. See `?antibiogram` for how to retrieve numeric values in a long format for advanced plotting.", - call = FALSE - ) + df$mo <- "" } if ("syndromic_group" %in% colnames(df)) { # barplot in base R does not support facets - paste columns together @@ -1226,9 +1250,7 @@ barplot.antibiogram <- function(height, ...) { autoplot.antibiogram <- function(object, ...) { df <- attributes(object)$long_numeric if (!"mo" %in% colnames(df)) { - stop_("Plotting antibiograms using `autoplot()` is only possible if they were not created using dplyr groups. See `?antibiogram` for how to retrieve numeric values in a long format for advanced plotting.", - call = FALSE - ) + df$mo <- "" } out <- ggplot2::ggplot(df, mapping = ggplot2::aes( @@ -1243,6 +1265,10 @@ autoplot.antibiogram <- function(object, ...) { ) + ggplot2::geom_col(position = ggplot2::position_dodge2(preserve = "single")) + ggplot2::facet_wrap("mo") + + ggplot2::geom_errorbar( + mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100), + position = ggplot2::position_dodge2(preserve = "single", width = 1) + ) + ggplot2::labs( y = ifelse(isTRUE(attributes(object)$combine_SI), "%SI", "%S"), x = NULL, @@ -1252,14 +1278,6 @@ autoplot.antibiogram <- function(object, ...) { NULL } ) - if (isTRUE(attributes(object)$wisca)) { - out <- out + - ggplot2::geom_errorbar( - mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100), - position = ggplot2::position_dodge2(preserve = "single"), - width = 0.5 - ) - } out } diff --git a/data-raw/gpt_training_text_v2.1.1.9187.txt b/data-raw/gpt_training_text_v2.1.1.9188.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9187.txt rename to data-raw/gpt_training_text_v2.1.1.9188.txt index e7b496041..70300339f 100644 --- a/data-raw/gpt_training_text_v2.1.1.9187.txt +++ b/data-raw/gpt_training_text_v2.1.1.9188.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.9187. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9188. 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. ---------------------------------------------------------------------------------------------------- diff --git a/tests/testthat/test-antibiogram.R b/tests/testthat/test-antibiogram.R index 09adef1f0..16a828992 100644 --- a/tests/testthat/test-antibiogram.R +++ b/tests/testthat/test-antibiogram.R @@ -113,6 +113,8 @@ test_that("antibiogram works", { )) expect_inherits(ab8, "antibiogram") + expect_inherits(retrieve_wisca_parameters(ab8), "data.frame") + expect_inherits(attributes(ab8)$long_numeric, "data.frame") expect_equal(colnames(ab8), c("Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin")) # grouped tibbles