From 8907e8e4afaef60c07e5ff44beb4da1e2ab618d9 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Mon, 30 Sep 2024 19:13:53 +0200 Subject: [PATCH] (v2.1.1.9083) update for `first_isolate()` --- DESCRIPTION | 2 +- NEWS.md | 11 +++++++---- R/first_isolate.R | 3 +-- inst/tinytest/test-first_isolate.R | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5fc174b2..f3cbf1a2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9082 +Version: 2.1.1.9083 Date: 2024-09-30 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 99fecb1d..7dffcb4f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9082 +# AMR 2.1.1.9083 *(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).)* @@ -51,19 +51,22 @@ This package now supports not only tools for AMR data analysis in clinical setti * Added new argument `keep_operators` to `as.mic()`. This can be `"all"` (default), `"none"`, or `"edges"`. This argument is also available in the new `rescale_mic()` and `scale_*_mic()` functions. * Comparisons of MIC values are now more strict. For example, `>32` is higher than (and never equal to) `32`. Thus, `as.mic(">32") == as.mic(32)` now returns `FALSE`, and `as.mic(">32") > as.mic(32)` now returns `TRUE`. * Sorting of MIC values (using `sort()`) was fixed in the same manner; `<0.001` now gets sorted before `0.001`, and `>0.001` gets sorted after `0.001`. + * Intermediate log2 levels used for MIC plotting are now more common values instead of following a strict dilution range * Updated `italicise_taxonomy()` to support HTML output * `custom_eucast_rules()` now supports multiple antibiotics and antibiotic groups to be affected by a single rule -* `mo_info()` now contains an extra element `group_members`, with the contents of the new `mo_group_members()` function +* `mo_info()` now contains an extra element `rank` and `group_members` (with the contents of the new `mo_group_members()` function) * Greatly improved `vctrs` integration, a Tidyverse package working in the background for many Tidyverse functions. For users, this means that functions such as `dplyr`'s `bind_rows()`, `rowwise()` and `c_across()` are now supported for e.g. columns of class `mic`. Despite this, this `AMR` package is still zero-dependent on any other package, including `dplyr` and `vctrs`. * Updated all ATC codes from WHOCC * Updated all antibiotic DDDs from WHOCC * Fix for using a manual value for `mo_transform` in `antibiogram()` * Fix for mapping 'high level' antibiotics in `as.ab()` (amphotericin B-high, gentamicin-high, kanamycin-high, streptomycin-high, tobramycin-high) * Improved overall algorithm of `as.ab()` for better performance and accuracy -* Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically, more weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species. -* Intermediate log2 levels used for MIC plotting are now more common values instead of following a strict dilution range +* Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically: + * More weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species + * Genera from the World Health Organization's (WHO) Priority Pathogen List now have the highest prevalence * Fixed a bug for when `antibiogram()` returns an empty data set * Updated the prevalence calculation to include genera from the World Health Organization's (WHO) Priority Pathogen List +* Improved algorithm of `first_isolate()` when using the phenotype-based method, to prioritise records with the highest availability of SIR values ## Other * Greatly updated and expanded documentation diff --git a/R/first_isolate.R b/R/first_isolate.R index 7647c1f4..41df81d5 100644 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -670,8 +670,7 @@ duplicated_antibiogram <- function(antibiogram, points_threshold, ignore_I, type # fast return, only 1 isolate return(FALSE) } - stop("Check R/first_isolate.R -> duplicated_antibiogram()") - # first sort on data availability - count the dots and order that ascending + # first sort on data availability - count the dots and order that ascending so that highest availability of SIR is on top number_dots <- vapply(FUN.VALUE = integer(1), antibiogram, function(x) sum(strsplit(x, "", fixed = TRUE)[[1]] == "."), diff --git a/inst/tinytest/test-first_isolate.R b/inst/tinytest/test-first_isolate.R index 9806eafe..5a735902 100755 --- a/inst/tinytest/test-first_isolate.R +++ b/inst/tinytest/test-first_isolate.R @@ -42,7 +42,7 @@ expect_equal( ) expect_equal( sum(first_isolate(x = example_isolates, method = "phenotype-based", info = TRUE), na.rm = TRUE), - 1373 + 1387 ) # for phenotype determination @@ -66,7 +66,7 @@ expect_equal( type = "keyantimicrobials", antifungal = NULL, info = TRUE ), na.rm = TRUE), - 1376 + 1383 ) expect_equal( sum(first_isolate( @@ -75,7 +75,7 @@ expect_equal( type = "keyantimicrobials", antifungal = NULL, info = TRUE, ignore_I = FALSE ), na.rm = TRUE), - 1396 + 1397 )