diff --git a/DESCRIPTION b/DESCRIPTION index 325bd5761..447740bce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 2.1.1.9190 -Date: 2025-03-09 +Version: 2.1.1.9191 +Date: 2025-03-10 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 diff --git a/NEWS.md b/NEWS.md index b1c800194..8744f4fc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9190 +# AMR 2.1.1.9191 *(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 4ed58b8b5..c4630b60b 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.9190 +Version: 2.1.1.9191 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.9190.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9190.tar.gz deleted file mode 100644 index c99e2f4a5..000000000 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9190.tar.gz and /dev/null differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9190-py3-none-any.whl b/PythonPackage/AMR/dist/amr-2.1.1.9191-py3-none-any.whl similarity index 86% rename from PythonPackage/AMR/dist/amr-2.1.1.9190-py3-none-any.whl rename to PythonPackage/AMR/dist/amr-2.1.1.9191-py3-none-any.whl index 1c331b181..b953412f0 100644 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9190-py3-none-any.whl and b/PythonPackage/AMR/dist/amr-2.1.1.9191-py3-none-any.whl differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9191.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9191.tar.gz new file mode 100644 index 000000000..3c78ad49a Binary files /dev/null and b/PythonPackage/AMR/dist/amr-2.1.1.9191.tar.gz differ diff --git a/PythonPackage/AMR/setup.py b/PythonPackage/AMR/setup.py index 32d4a3300..2f142ed28 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.9190', + version='2.1.1.9191', packages=find_packages(), install_requires=[ 'rpy2', diff --git a/R/antibiogram.R b/R/antibiogram.R index 4d4015829..f348dca07 100755 --- a/R/antibiogram.R +++ b/R/antibiogram.R @@ -870,7 +870,9 @@ antibiogram.default <- function(x, if (formatting_type == 20) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,", n_susceptible, "/", n_tested, ")")) if (formatting_type == 21) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), " (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), ",N=", n_susceptible, "/", n_tested, ")")) if (formatting_type == 22) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,N=", n_susceptible, "/", n_tested, ")")) - out$out_value[out$out_value %like% "^NA"] <- NA_character_ + if (formatting_type >= 4) { + out$out_value[out$out_value %like% "^NA"] <- NA_character_ + } # transform names of antimicrobials ab_naming_function <- function(x, t, l, s) { @@ -1260,6 +1262,15 @@ autoplot.antibiogram <- function(object, ...) { if (!"mo" %in% colnames(df)) { df$mo <- "" } + groups <- colnames(df)[seq_len(which(colnames(df) %in% c("mo", "ab"))[1] - 1)] + group_name <- paste(groups, collapse = "/") + if (length(groups) > 1) { + df$syndromic_group <- apply(df[groups], 1, function(x) { + paste(stats::na.omit(x), collapse = "/") + }) + } else if ("syndromic_group" %in% colnames(df)) { + group_name <- colnames(object)[1] + } out <- ggplot2::ggplot(df, mapping = ggplot2::aes( x = ab, @@ -1272,7 +1283,6 @@ 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) @@ -1281,11 +1291,15 @@ autoplot.antibiogram <- function(object, ...) { y = ifelse(isTRUE(attributes(object)$combine_SI), "%SI", "%S"), x = NULL, fill = if ("syndromic_group" %in% colnames(df)) { - colnames(object)[1] + group_name } else { NULL } ) + if (!all(df$mo == "", na.rm = TRUE)) { + out <- out + + ggplot2::facet_wrap("mo") + } out } diff --git a/data-raw/gpt_training_text_v2.1.1.9190.txt b/data-raw/gpt_training_text_v2.1.1.9191.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9190.txt rename to data-raw/gpt_training_text_v2.1.1.9191.txt index 5175c93ed..710ec980e 100644 --- a/data-raw/gpt_training_text_v2.1.1.9190.txt +++ b/data-raw/gpt_training_text_v2.1.1.9191.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.9190. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9191. 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 16a828992..ab0af208f 100644 --- a/tests/testthat/test-antibiogram.R +++ b/tests/testthat/test-antibiogram.R @@ -31,18 +31,18 @@ test_that("antibiogram works", { # Traditional antibiogram ---------------------------------------------- ab1 <- antibiogram(example_isolates, - antibiotics = c(aminoglycosides(), carbapenems()) + antimicrobials = c(aminoglycosides(), carbapenems()) ) ab2 <- antibiogram(example_isolates, - antibiotics = aminoglycosides(), + antimicrobials = aminoglycosides(), ab_transform = "atc", mo_transform = "gramstain", add_total_n = TRUE ) ab3 <- antibiogram(example_isolates, - antibiotics = carbapenems(), + antimicrobials = carbapenems(), ab_transform = "ab", mo_transform = "name", formatting_type = 1 @@ -58,14 +58,14 @@ test_that("antibiogram works", { # Combined antibiogram ------------------------------------------------- - # combined antibiotics yield higher empiric coverage + # combined antibiogram yield higher empiric coverage ab4 <- antibiogram(example_isolates, - antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"), + antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), mo_transform = "gramstain" ) ab5 <- antibiogram(example_isolates, - antibiotics = c("TZP", "TZP+TOB"), + antimicrobials = c("TZP", "TZP+TOB"), mo_transform = "gramstain", ab_transform = "name", sep = " & ", @@ -81,7 +81,7 @@ test_that("antibiogram works", { # the data set could contain a filter for e.g. respiratory specimens ab6 <- antibiogram(example_isolates, - antibiotics = c(aminoglycosides(), carbapenems()), + antimicrobials = c(aminoglycosides(), carbapenems()), syndromic_group = "ward", ab_transform = NULL ) @@ -90,7 +90,7 @@ test_that("antibiogram works", { # (i.e., this table will be in Dutch on Dutch systems) ex1 <- example_isolates[which(mo_genus() == "Escherichia"), ] ab7 <- antibiogram(ex1, - antibiotics = aminoglycosides(), + antimicrobials = aminoglycosides(), ab_transform = "name", syndromic_group = ifelse(ex1$ward == "ICU", "IC", "Geen IC" @@ -108,7 +108,7 @@ test_that("antibiogram works", { # the data set could contain a filter for e.g. respiratory specimens ab8 <- suppressWarnings(antibiogram(example_isolates, - antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"), + antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), wisca = TRUE )) @@ -118,11 +118,12 @@ test_that("antibiogram works", { expect_equal(colnames(ab8), c("Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin")) # grouped tibbles - if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) { - ab9 <- example_isolates %>% - group_by(ward, gender) %>% - wisca(antibiotics = c("TZP", "TZP+TOB", "TZP+GEN")) + expect_warning( + ab9 <- example_isolates %>% + group_by(ward, gender) %>% + wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN")) + ) expect_equal(colnames(ab9), c("ward", "gender", "Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin")) }