diff --git a/DESCRIPTION b/DESCRIPTION index 93bb0c94..d55a835b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.7.1.9075 -Date: 2021-12-14 +Version: 1.7.1.9077 +Date: 2021-12-23 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 4cac5722..f8c0de6d 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.7.1.9075 -## Last updated: 14 December 2021 +# `AMR` 1.7.1.9077 +## Last updated: 23 December 2021 All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on. diff --git a/R/ab.R b/R/ab.R index a1f92708..27e696ba 100755 --- a/R/ab.R +++ b/R/ab.R @@ -133,8 +133,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { note_if_more_than_one_found <- function(found, index, from_text) { if (initial_search == TRUE & isTRUE(length(from_text) > 1)) { abnames <- ab_name(from_text, tolower = TRUE, initial_search = FALSE) - if (ab_name(found[1L], language = NULL) %like% "clavulanic acid") { - abnames <- abnames[!abnames == "clavulanic acid"] + if (ab_name(found[1L], language = NULL) %like% "(clavulanic acid|avibactam)") { + abnames <- abnames[!abnames %in% c("clavulanic acid", "avibactam")] } if (length(abnames) > 1) { message_("More than one result was found for item ", index, ": ", @@ -222,6 +222,16 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { next } + # length of input is quite long, and Levenshtein distance is only max 2 + if (nchar(x[i]) >= 10) { + levenshtein <- as.double(utils::adist(x[i], AB_lookup$generalised_name)) + if (any(levenshtein <= 2)) { + found <- AB_lookup$ab[which(levenshtein <= 2)] + x_new[i] <- note_if_more_than_one_found(found, i, from_text) + next + } + } + # allow characters that resemble others, but only continue when having more than 3 characters if (nchar(x[i]) <= 3) { x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) @@ -238,7 +248,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { x_spelling <- gsub("E+", "E+", x_spelling, perl = TRUE) x_spelling <- gsub("O+", "O+", x_spelling, perl = TRUE) # allow any ending of -in/-ine and -im/-ime - x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE) + x_spelling <- gsub("(\\[IY\\]\\+(N|M)|\\[IY\\]\\+(N|M)E\\+?)$", "[IY]+(N|M)E*", x_spelling, perl = TRUE) # allow any ending of -ol/-ole x_spelling <- gsub("(O\\+L|O\\+LE\\+)$", "O+LE*", x_spelling, perl = TRUE) # allow any ending of -on/-one diff --git a/R/zzz.R b/R/zzz.R index 4f5d1be7..461fc7bc 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -57,10 +57,12 @@ if (utf8_supported && !is_latex) { s3_register("cleaner::freq", "mo") s3_register("cleaner::freq", "rsi") # Support for skim() from the skimr package - s3_register("skimr::get_skimmers", "mo") - s3_register("skimr::get_skimmers", "rsi") - s3_register("skimr::get_skimmers", "mic") - s3_register("skimr::get_skimmers", "disk") + if (pkg_is_available("skimr", also_load = FALSE, min_version = "2.0.0")) { + s3_register("skimr::get_skimmers", "mo") + s3_register("skimr::get_skimmers", "rsi") + s3_register("skimr::get_skimmers", "mic") + s3_register("skimr::get_skimmers", "disk") + } # Support for autoplot() from the ggplot2 package s3_register("ggplot2::autoplot", "rsi") s3_register("ggplot2::autoplot", "mic") diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index b5fa4af6..fdb875e7 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 4cc1e5e5..7ed04594 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -44,7 +44,7 @@ AMR (for R) - 1.7.1.9075 + 1.7.1.9077 @@ -190,7 +190,7 @@ @@ -157,13 +157,13 @@
- +
-

Last updated: 14 December 2021

+

Last updated: 23 December 2021

All functions in this package are now all considered to be stable. Updates to the AMR interpretation rules (such as by EUCAST and CLSI), the microbial taxonomy, and the antibiotic dosages will all be updated every 6 to 12 months from now on.

-

Breaking changes

+

Breaking changes

  • Removed p_symbol() and all filter_*() functions (except for filter_first_isolate()), which were all deprecated in a previous package version
  • Removed the key_antibiotics() and key_antibiotics_equal() functions, which were deprecated and superseded by key_antimicrobials() and antimicrobials_equal()
  • @@ -171,7 +171,7 @@
  • Renamed function get_locale() to get_AMR_locale() to prevent conflicts with other packages
-

New

+

New

  • Support for the CLSI 2021 guideline for interpreting MIC/disk diffusion values, which are incorporated in the rsi_translation data set. This data set now more strictly follows the WHONET software as well.

  • Support for EUCAST Intrinsic Resistance and Unusual Phenotypes v3.3 (October 2021). This is now the default EUCAST guideline in the package (all older guidelines are still available) for eucast_rules(), mo_is_intrinsic_resistant() and mdro(). The intrinsic_resistant data set was also updated accordingly.

  • Support for all antimicrobial drug (group) names and colloquial microorganism names in Danish, Dutch, English, French, German, Italian, Portuguese, Russian, Spanish and Swedish

  • @@ -186,7 +186,7 @@
  • Function ab_ddd_units() to get units of DDDs (daily defined doses), deprecating the use of ab_ddd(..., units = TRUE) to be more consistent in data types of function output

-

Changed

+

Changed

  • Updated the bacterial taxonomy to 5 October 2021 (according to LPSN), including all 11 new staphylococcal species named since 1 January last year
  • The antibiotics data set now contains all ATC codes that are available through the WHOCC website, regardless of drugs being present in more than one ATC group. This means that:
    • Some drugs now contain multiple ATC codes (e.g., metronidazole contains 5)
    • @@ -258,7 +258,7 @@ get_episode() and is_new_episode() can now cope with NAs
-

Other

+

Other

  • This package is now being maintained by two epidemiologists and a data scientist from two different non-profit healthcare organisations.
diff --git a/inst/tinytest/test-ab.R b/inst/tinytest/test-ab.R index effe6b8d..1f6d619b 100755 --- a/inst/tinytest/test-ab.R +++ b/inst/tinytest/test-ab.R @@ -61,6 +61,9 @@ expect_equal(as.character(as.ab(c("mreopenem", "co-maoxiclav"))), expect_message(as.ab("cipro mero")) +# based on Levenshtein distance +expect_identical(ab_name("ceftazidim/avibactam", language = NULL), "Ceftazidime/avibactam") + # assigning and subsetting x <- antibiotics$ab expect_inherits(x[1], "ab") diff --git a/inst/tinytest/test-zzz.R b/inst/tinytest/test-zzz.R index b16ab06d..dfa24fb3 100644 --- a/inst/tinytest/test-zzz.R +++ b/inst/tinytest/test-zzz.R @@ -52,9 +52,6 @@ import_functions <- c( call_functions <- c( # cleaner "freq.default" = "cleaner", - # skimr - "inline_hist" = "skimr", - "sfl" = "skimr", # readxl "read_excel" = "readxl", # ggplot2 @@ -85,6 +82,12 @@ call_functions <- c( "xlab" = "ggplot2", "ylab" = "ggplot2" ) +if (pkg_is_available("skimr", also_load = FALSE, min_version = "2.0.0")) { + call_functions <- c(call_functions, + # skimr + "inline_hist" = "skimr", + "sfl" = "skimr") +} extended_functions <- c( "freq" = "cleaner",