From e4ea96cbf90470cda671dc4ac4cd13ac804c77c4 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Fri, 30 Dec 2022 12:57:27 +0100 Subject: [PATCH] fix for R < 3.4 --- DESCRIPTION | 4 ++-- NEWS.md | 8 ++++---- R/aa_helper_functions.R | 3 ++- R/add_custom_antimicrobials.R | 6 ++++-- R/add_custom_microorganisms.R | 9 ++++----- R/rsi.R | 2 +- R/translate.R | 2 +- _pkgdown.yml | 15 +++++++-------- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8c494af4..14bc13d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.8.2.9074 -Date: 2022-12-29 +Version: 1.8.2.9075 +Date: 2022-12-30 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 7f3d8c87..4f89e136 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9074 +# 1.8.2.9075 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* @@ -19,7 +19,7 @@ This is a new major release of the AMR package, with great new additions but als ### Interpretation of MIC and disk diffusion values -EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 (v12.0) is now the new default guideline for all MIC and disks diffusion interpretations, and for `eucast_rules()` to apply EUCAST Expert Rules. The default guideline (EUCAST) can now be changed with the new `AMR_guideline` option, such as: `options(AMR_guideline = "CLSI 2020")`. +The clinical breakpoints and intrinsic resistance of EUCAST 2022 and CLSI 2022 have been added for `as.rsi()`. EUCAST 2022 (v12.0) is now the new default guideline for all MIC and disks diffusion interpretations, and for `eucast_rules()` to apply EUCAST Expert Rules. The default guideline (EUCAST) can now be changed with the new `AMR_guideline` option, such as: `options(AMR_guideline = "CLSI 2020")`. Interpretation guidelines older than 10 years were removed, the oldest now included guidelines of EUCAST and CLSI are from 2013. @@ -31,7 +31,7 @@ We are very grateful for the valuable input by our colleagues from other countri ### Microbiological taxonomy -The `microorganisms` no longer relies on the Catalogue of Life, but on the List of Prokaryotic names with Standing in Nomenclature (LPSN) and is supplemented with the 'backbone taxonomy' from the Global Biodiversity Information Facility (GBIF). The structure of this data set has changed to include separate LPSN and GBIF identifiers. Almost all previous MO codes were retained. It contains over 1,400 taxonomic names from 2022. +The `microorganisms` data set no longer relies on the Catalogue of Life, but on the List of Prokaryotic names with Standing in Nomenclature (LPSN) and is supplemented with the 'backbone taxonomy' from the Global Biodiversity Information Facility (GBIF). The structure of this data set has changed to include separate LPSN and GBIF identifiers. Almost all previous MO codes were retained. It contains over 1,400 taxonomic names from 2022. We previously relied on our own experience to categorise species into pathogenic groups, but we were very happy to encounter the very recent work of Bartlett *et al.* (2022, DOI [10.1099/mic.0.001269](https://doi.org/10.1099/mic.0.001269)) who extensively studied medical-scientific literature to categorise all bacterial species into groups. See `mo_matching_score()` on how their work was incorporated into the `prevalence` column of the `microorganisms` data set. Using their results, the `as.mo()` and all `mo_*()` functions are now much better capable of converting user input to valid taxonomic records. @@ -40,7 +40,7 @@ The new function `add_custom_microorganisms()` allows users to add custom microo We also made the following changes regarding the included taxonomy or microorganisms functions: * Updated full microbiological taxonomy according to the latest daily LPSN data set (December 2022) and latest yearly GBIF taxonomy backbone (November 2022) -* Support for all 1,515 city-like serovars of *Salmonella*, such as *Salmonella* Goldcoast. Formally, these are serovars belonging to the *S. enterica* species, but they are reported with only the name of the genus and the city. For this reason, the serovars are in the `subspecies` column of the `microorganisms` data set and "enterica" is in the `species` column, but the full name does not contain the species name (*enterica*). +* Support for all 1,516 city-like serovars of *Salmonella*, such as *Salmonella* Goldcoast. Formally, these are serovars belonging to the *S. enterica* species, but they are reported with only the name of the genus and the city. For this reason, the serovars are in the `subspecies` column of the `microorganisms` data set and "enterica" is in the `species` column, but the full name does not contain the species name (*enterica*). * All new algorithm for `as.mo()` (and thus all `mo_*()` functions) while still following our original set-up as described in our recently published JSS paper (DOI [10.18637/jss.v104.i03](https://doi.org/10.18637/jss.v104.i03)). * A new argument `keep_synonyms` allows to *not* correct for updated taxonomy, in favour of the now deleted argument `allow_uncertain` * It has increased tremendously in speed and returns generally more consequent results diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 024927fa..9155b6bf 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -380,7 +380,7 @@ import_fn <- function(name, pkg, error_on_fail = TRUE) { error = function(e) { if (isTRUE(error_on_fail)) { stop_("function ", name, "() is not an exported object from package '", pkg, - "'. Please create an issue at https://github.com/msberends/AMR/issues. Many thanks!", + "'. Please create an issue at ", font_url("https://github.com/msberends/AMR/issues"), ". Many thanks!", call = FALSE ) } else { @@ -476,6 +476,7 @@ word_wrap <- function(..., # remove extra space that was introduced (e.g. "Smith et al., 2022") msg <- gsub(". ,", ".,", msg, fixed = TRUE) msg <- gsub("[ ,", "[,", msg, fixed = TRUE) + msg <- gsub("/ /", "//", msg, fixed = TRUE) msg } diff --git a/R/add_custom_antimicrobials.R b/R/add_custom_antimicrobials.R index 158f6911..51824211 100644 --- a/R/add_custom_antimicrobials.R +++ b/R/add_custom_antimicrobials.R @@ -135,7 +135,7 @@ add_custom_antimicrobials <- function(x) { x$generalised_name <- generalise_antibiotic_name(x$name) x$generalised_all <- as.list(x$generalised_name) for (col in colnames(x)) { - if (is.list(AMR_env$AB_lookup[, col, drop = TRUE])) { + if (is.list(AMR_env$AB_lookup[, col, drop = TRUE]) & !is.list(x[, col, drop = TRUE])) { x[, col] <- as.list(x[, col, drop = TRUE]) } } @@ -155,7 +155,8 @@ add_custom_antimicrobials <- function(x) { new_df[, col] <- x[, col, drop = TRUE] } AMR_env$AB_lookup <- unique(rbind(AMR_env$AB_lookup, new_df)) - AMR_env$ab_previously_coerced <- AMR_env$ab_previously_coerced[which(!AMR_env$ab_previously_coerced$ab %in% new_df$ab), , drop = FALSE] + + AMR_env$ab_previously_coerced <- AMR_env$ab_previously_coerced[which(!AMR_env$ab_previously_coerced$ab %in% x$ab), , drop = FALSE] class(AMR_env$AB_lookup$ab) <- c("ab", "character") message_("Added ", nr2char(nrow(x)), " record", ifelse(nrow(x) > 1, "s", ""), " to the internal `antibiotics` data set.") } @@ -167,5 +168,6 @@ clear_custom_antimicrobials <- function() { AMR_env$AB_lookup <- create_AB_lookup() n2 <- nrow(AMR_env$AB_lookup) AMR_env$custom_ab_codes <- character(0) + AMR_env$ab_previously_coerced <- AMR_env$ab_previously_coerced[which(AMR_env$ab_previously_coerced$ab %in% AMR_env$AB_lookup$ab), , drop = FALSE] message_("Cleared ", nr2char(n - n2), " custom record", ifelse(n - n2 > 1, "s", ""), " from the internal `antibiotics` data set.") } diff --git a/R/add_custom_microorganisms.R b/R/add_custom_microorganisms.R index 296011f5..dce06fd0 100644 --- a/R/add_custom_microorganisms.R +++ b/R/add_custom_microorganisms.R @@ -185,11 +185,10 @@ add_custom_microorganisms <- function(x) { x$mo <- trimws2(x$mo) x$mo[x$mo == ""] <- NA_character_ x$mo[is.na(x$mo)] <- paste0("CUSTOM_", - toupper(abbreviate(gsub(" +", " _ ", - gsub("[^A-Za-z0-9-]", " ", - trimws2(paste(x$genus, x$species, x$subspecies)))), - minlength = 10, - named = FALSE))) + toupper(unname(abbreviate(gsub(" +", " _ ", + gsub("[^A-Za-z0-9-]", " ", + trimws2(paste(x$genus, x$species, x$subspecies)))), + minlength = 10)))) # add to package ---- diff --git a/R/rsi.R b/R/rsi.R index 6f575b1a..54ad546f 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -804,7 +804,7 @@ as_rsi_method <- function(method_short, for (i in seq_len(length(messages))) { messages[i] <- word_wrap(extra_indent = 5, messages[i]) } - message(font_green(font_bold(" * NOTE *\n")), + message(font_green(font_bold(" Note:\n")), paste0(" ", font_black(AMR_env$bullet_icon)," ", font_black(messages, collapse = NULL) , collapse = "\n")) } diff --git a/R/translate.R b/R/translate.R index 9addac4a..d88349c0 100755 --- a/R/translate.R +++ b/R/translate.R @@ -230,7 +230,7 @@ translate_into_language <- function(from, any_form_in_patterns <- tryCatch( any(from_unique %like% paste0("(", paste(gsub(" +\\(.*", "", df_trans$pattern), collapse = "|"), ")")), error = function(e) { - warning_("Translation not possible. Please open an issue on GitHub (https://github.com/msberends/AMR/issues).") + warning_("Translation not possible. Please create an issue at ", font_url("https://github.com/msberends/AMR/issues"), ". Many thanks!") return(FALSE) } ) diff --git a/_pkgdown.yml b/_pkgdown.yml index 02a0c02d..18107f43 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -96,13 +96,13 @@ navbar: - text: "Apply EUCAST rules" icon: "fa-exchange-alt" href: "articles/EUCAST.html" - - text: "Get properties of a microorganism" + - text: "Get taxonomy of a microorganism" icon: "fa-bug" href: "reference/mo_property.html" # reference instead of an article - - text: "Get properties of an antibiotic" + - text: "Get properties of an antibiotic drug" icon: "fa-capsules" href: "reference/ab_property.html" # reference instead of an article - - text: "Get properties of an antiviral agent" + - text: "Get properties of an antiviral drug" icon: "fa-capsules" href: "reference/av_property.html" # reference instead of an article - text: "Manual" @@ -118,15 +118,14 @@ navbar: - text: "Source Code" icon: "fab fa-github" href: "https://github.com/msberends/AMR" - # - text: "Survey" - # icon: "fa-clipboard-list" - # href: "survey.html" reference: - title: "Preparing data: microorganisms" desc: > - These functions are meant to get taxonomically valid properties of microorganisms from any input. - Use `mo_source()` to teach this package how to translate your own codes to valid microorganism codes. + These functions are meant to get taxonomically valid properties of microorganisms from any input, but + also properties derived from taxonomy, such as the Gram stain (`mo_gramstain()`) , or `mo_is_yeast()`. + Use `mo_source()` to teach this package how to translate your own codes to valid microorganisms, and + use `add_custom_microorganisms() to add your own custom microorganisms to this package. contents: - "`as.mo`" - "`mo_property`"