From 03294c79015f73dbebc3d5d5969fc5dad414fa8c Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Fri, 10 Feb 2023 16:47:25 +0100 Subject: [PATCH] fix for Salmonella group A, unit tests --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aa_globals.R | 14 ++++++++++---- R/bug_drug_combinations.R | 2 +- R/mo.R | 8 ++++---- R/mo_property.R | 3 +-- inst/tinytest/test-mo_property.R | 2 +- man/mo_property.Rd | 3 +-- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7d3e1c87..7bef1135 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9114 +Version: 1.8.2.9115 Date: 2023-02-10 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 27857330..c2bbe5af 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.8.2.9114 +# AMR 1.8.2.9115 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* diff --git a/R/aa_globals.R b/R/aa_globals.R index e87f094f..57bbb29c 100755 --- a/R/aa_globals.R +++ b/R/aa_globals.R @@ -94,7 +94,9 @@ TAXONOMY_VERSION <- list( ) globalVariables(c( + ".mo", ".rowid", + ".syndromic_group", "ab", "ab_txt", "affect_ab_name", @@ -105,8 +107,10 @@ globalVariables(c( "atc_group1", "atc_group2", "base_ab", - "ci_min", + "bind_rows", "ci_max", + "ci_min", + "clinical_breakpoints", "code", "cols", "count", @@ -130,14 +134,15 @@ globalVariables(c( "language", "lookup", "method", - "mic", "mic ", + "mic", "microorganism", "microorganisms", "microorganisms.codes", "mo", "name", "new", + "numerator", "observations", "old", "old_name", @@ -149,13 +154,14 @@ globalVariables(c( "reference.rule_group", "reference.version", "rowid", - "sir", - "clinical_breakpoints", "rule_group", "rule_name", "se_max", "se_min", + "SI", + "sir", "species", + "syndromic_group", "total", "txt", "type", diff --git a/R/bug_drug_combinations.R b/R/bug_drug_combinations.R index b53e693a..0b86e529 100755 --- a/R/bug_drug_combinations.R +++ b/R/bug_drug_combinations.R @@ -165,7 +165,7 @@ bug_drug_combinations <- function(x, out <- run_it(x) } rownames(out) <- NULL - out <- out %>% pm_arrange(mo, ab) + out <- out %pm>% pm_arrange(mo, ab) out <- as_original_data_class(out, class(x.bak)) # will remove tibble groups structure(out, class = c("bug_drug_combinations", ifelse(data_has_groups, "grouped", character(0)), class(out))) } diff --git a/R/mo.R b/R/mo.R index 36b4504d..4a9b3704 100755 --- a/R/mo.R +++ b/R/mo.R @@ -966,14 +966,14 @@ convert_colloquial_input <- function(x) { out[x %like_case% "(viridans.* (strepto|^s).*|^vgs[^a-z]*$)"] <- "B_STRPT_VIRI" # Salmonella in different languages, like "Salmonella grupo B" - out[x %like_case% "salmonella.* [bcd]$"] <- gsub(".*salmonella.* ([bcd])$", + out[x %like_case% "salmonella.* [abcd]$"] <- gsub(".*salmonella.* ([abcd])$", "B_SLMNL_GRP\\U\\1", - x[x %like_case% "salmonella.* [bcd]$"], + x[x %like_case% "salmonella.* [abcd]$"], perl = TRUE ) - out[x %like_case% "group [bcd] salmonella"] <- gsub(".*group ([bcd]) salmonella*", + out[x %like_case% "group [abcd] salmonella"] <- gsub(".*group ([abcd]) salmonella*", "B_SLMNL_GRP\\U\\1", - x[x %like_case% "group [bcd] salmonella"], + x[x %like_case% "group [abcd] salmonella"], perl = TRUE ) diff --git a/R/mo_property.R b/R/mo_property.R index 5733b137..2669263b 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -69,9 +69,8 @@ #' @return #' - An [integer] in case of [mo_year()] #' - An [ordered factor][factor] in case of [mo_pathogenicity()] -#' - A [list] in case of [mo_taxonomy()], [mo_synonyms()] and [mo_info()] +#' - A [list] in case of [mo_taxonomy()], [mo_synonyms()], [mo_snomed()] and [mo_info()] #' - A named [character] in case of [mo_url()] -#' - A [numeric] in case of [mo_snomed()] #' - A [character] in all other cases #' @export #' @seealso Data set [microorganisms] diff --git a/inst/tinytest/test-mo_property.R b/inst/tinytest/test-mo_property.R index 8fc14257..b0fb0d8a 100644 --- a/inst/tinytest/test-mo_property.R +++ b/inst/tinytest/test-mo_property.R @@ -163,7 +163,7 @@ expect_identical(mo_current(c("Escherichia blattae", "Escherichia coli")), expect_identical(mo_ref("Chlamydia psittaci"), "Garcia-Lopez et al., 2019") expect_identical(mo_ref("Chlamydophila psittaci", keep_synonyms = TRUE), "Everett et al., 1999") -expect_true(112283007 %in% mo_snomed("Escherichia coli")) +expect_true(112283007 %in% mo_snomed("Escherichia coli")[[1]]) # old codes must throw a warning in mo_* family expect_warning(mo_name(c("B_ESCHR_COL", "B_STPHY_AUR"))) # outcome of mo_fullname must always return the fullname from the data set diff --git a/man/mo_property.Rd b/man/mo_property.Rd index d93445e7..25ee05a7 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -284,9 +284,8 @@ mo_property( \itemize{ \item An \link{integer} in case of \code{\link[=mo_year]{mo_year()}} \item An \link[=factor]{ordered factor} in case of \code{\link[=mo_pathogenicity]{mo_pathogenicity()}} -\item A \link{list} in case of \code{\link[=mo_taxonomy]{mo_taxonomy()}}, \code{\link[=mo_synonyms]{mo_synonyms()}} and \code{\link[=mo_info]{mo_info()}} +\item A \link{list} in case of \code{\link[=mo_taxonomy]{mo_taxonomy()}}, \code{\link[=mo_synonyms]{mo_synonyms()}}, \code{\link[=mo_snomed]{mo_snomed()}} and \code{\link[=mo_info]{mo_info()}} \item A named \link{character} in case of \code{\link[=mo_url]{mo_url()}} -\item A \link{numeric} in case of \code{\link[=mo_snomed]{mo_snomed()}} \item A \link{character} in all other cases } }