diff --git a/DESCRIPTION b/DESCRIPTION index 19211786..e762f865 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.7.1.9015 -Date: 2021-07-07 +Version: 1.7.1.9016 +Date: 2021-07-08 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 44d78f26..b736983d 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,11 +1,12 @@ -# `AMR` 1.7.1.9015 -## Last updated: 7 July 2021 +# `AMR` 1.7.1.9016 +## Last updated: 8 July 2021 ### Changed * Antibiotic class selectors (see `ab_class()`) - * They now finally also work in R-3.0 and R-3.1, supporting every version of R since 2013 + * They now also work in R-3.0 and R-3.1, supporting every version of R since 2013 * Added more selectors: `aminopenicillins()`, `lincosamides()`, `lipoglycopeptides()`, `polymyxins()`, `quinolones()`, `streptogramins()` and `ureidopenicillins()` * Fix for using selectors multiple times in one call (e.g., using them in `dplyr::filter()` and immediately after in `dplyr::select()`) + * Added argument `only_treatable`, which defaults to `TRUE` and will exclude drugs that are only for laboratory tests and not for treating patients (such as imipenem/EDTA and gentamicin-high) * Fix for duplicate ATC codes in the `antibiotics` data set * Added `ggplot2::autoplot()` generic for classes ``, ``, `` and `` * Fix to prevent introducing `NA`s for old MO codes when running `as.mo()` on them diff --git a/R/ab_class_selectors.R b/R/ab_class_selectors.R index a7c3bc40..d8a9ecf2 100644 --- a/R/ab_class_selectors.R +++ b/R/ab_class_selectors.R @@ -29,6 +29,7 @@ #' @inheritSection lifecycle Stable Lifecycle #' @param ab_class an antimicrobial class, such as `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value. #' @param only_rsi_columns a [logical] to indicate whether only columns of class `` must be selected (defaults to `FALSE`), see [as.rsi()] +#' @param only_treatable a [logical] to indicate whether agents that are only for laboratory tests should be excluded (defaults to `TRUE`), such as gentamicin-high (`GEH`) and imipenem/EDTA (`IPE`) #' @details #' These functions can be used in data set calls for selecting columns and filtering rows. They are heavily inspired by the [Tidyverse selection helpers][tidyselect::language] such as [`everything()`][tidyselect::everything()], but also work in base \R and not only in `dplyr` verbs. Nonetheless, they are very convenient to use with `dplyr` functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()], see *Examples*. #' @@ -123,17 +124,20 @@ #' } #' } ab_class <- function(ab_class, - only_rsi_columns = FALSE) { + only_rsi_columns = FALSE, + only_treatable = TRUE) { meet_criteria(ab_class, allow_class = "character", has_length = 1, allow_NULL = TRUE) meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1) - ab_selector(NULL, only_rsi_columns = only_rsi_columns, ab_class = ab_class) + meet_criteria(only_treatable, allow_class = "logical", has_length = 1) + ab_selector(NULL, only_rsi_columns = only_rsi_columns, ab_class = ab_class, only_treatable = only_treatable) } #' @rdname antibiotic_class_selectors #' @export -aminoglycosides <- function(only_rsi_columns = FALSE) { +aminoglycosides <- function(only_rsi_columns = FALSE, only_treatable = TRUE) { meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1) - ab_selector("aminoglycosides", only_rsi_columns = only_rsi_columns) + meet_criteria(only_treatable, allow_class = "logical", has_length = 1) + ab_selector("aminoglycosides", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable) } #' @rdname antibiotic_class_selectors @@ -145,16 +149,18 @@ aminopenicillins <- function(only_rsi_columns = FALSE) { #' @rdname antibiotic_class_selectors #' @export -betalactams <- function(only_rsi_columns = FALSE) { +betalactams <- function(only_rsi_columns = FALSE, only_treatable = TRUE) { meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1) - ab_selector("betalactams", only_rsi_columns = only_rsi_columns) + meet_criteria(only_treatable, allow_class = "logical", has_length = 1) + ab_selector("betalactams", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable) } #' @rdname antibiotic_class_selectors #' @export -carbapenems <- function(only_rsi_columns = FALSE) { +carbapenems <- function(only_rsi_columns = FALSE, only_treatable = TRUE) { meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1) - ab_selector("carbapenems", only_rsi_columns = only_rsi_columns) + meet_criteria(only_treatable, allow_class = "logical", has_length = 1) + ab_selector("carbapenems", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable) } #' @rdname antibiotic_class_selectors @@ -250,9 +256,10 @@ penicillins <- function(only_rsi_columns = FALSE) { #' @rdname antibiotic_class_selectors #' @export -polymyxins <- function(only_rsi_columns = FALSE) { +polymyxins <- function(only_rsi_columns = FALSE, only_treatable = TRUE) { meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1) - ab_selector("polymyxins", only_rsi_columns = only_rsi_columns) + meet_criteria(only_treatable, allow_class = "logical", has_length = 1) + ab_selector("polymyxins", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable) } #' @rdname antibiotic_class_selectors @@ -285,6 +292,7 @@ ureidopenicillins <- function(only_rsi_columns = FALSE) { ab_selector <- function(function_name, only_rsi_columns, + only_treatable, ab_class = NULL) { # get_current_data() has to run each time, for cases where e.g., filter() and select() are used in same call # but it only takes a couple of milliseconds @@ -292,6 +300,23 @@ ab_selector <- function(function_name, # to improve speed, get_column_abx() will only run once when e.g. in a select or group call ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE) + # untreatable drugs + untreatable <- antibiotics[which(antibiotics$name %like% "-high|EDTA|polysorbate"), "ab", drop = TRUE] + if (only_treatable == TRUE & any(untreatable %in% names(ab_in_data))) { + if (message_not_thrown_before(paste0("ab_class.untreatable.", function_name), entire_session = TRUE)) { + warning_("Some agents in `", function_name, "()` were ignored since they cannot be used for treating patients: ", + vector_and(ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable], + language = NULL, + tolower = TRUE), + quotes = FALSE, + sort = TRUE), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ", + "This warning will be shown once per session.", + call = FALSE) + remember_thrown_message(paste0("ab_class.untreatable.", function_name), entire_session = TRUE) + } + ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable] + } + if (length(ab_in_data) == 0) { message_("No antimicrobial agents found in the data.") return(NULL) diff --git a/R/bug_drug_combinations.R b/R/bug_drug_combinations.R index 05c24384..0bea3ff0 100644 --- a/R/bug_drug_combinations.R +++ b/R/bug_drug_combinations.R @@ -81,7 +81,7 @@ bug_drug_combinations <- function(x, unique_mo <- sort(unique(x[, col_mo, drop = TRUE])) # select only groups and antibiotics - if (inherits(x.bak, "grouped_df")) { + if (is_null_or_grouped_tbl(x.bak)) { data_has_groups <- TRUE groups <- setdiff(names(attributes(x.bak)$groups), ".rows") x <- x[, c(groups, col_mo, colnames(x)[vapply(FUN.VALUE = logical(1), x, is.rsi)]), drop = FALSE] diff --git a/R/mo.R b/R/mo.R index ffac04b6..916550d3 100755 --- a/R/mo.R +++ b/R/mo.R @@ -469,11 +469,11 @@ exec_as.mo <- function(x, x <- strip_whitespace(x, dyslexia_mode) # translate 'unknown' names back to English if (any(x %like% "unbekannt|onbekend|desconocid|sconosciut|iconnu|desconhecid", na.rm = TRUE)) { - trns <- subset(TRANSLATIONS, pattern %like% "unknown" | affect_mo_name == TRUE) + trns <- subset(TRANSLATIONS, pattern %like% "unknown") langs <- LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED != "en"] for (l in langs) { for (i in seq_len(nrow(trns))) { - if (!is.na(trns[i, l, drop = TRUE]) && trns[i, l, drop = TRUE] %unlike% "\\\\1") { + if (!is.na(trns[i, l, drop = TRUE])) { x <- gsub(pattern = trns[i, l, drop = TRUE], replacement = trns$pattern[i], x = x, diff --git a/R/rsi_calc.R b/R/rsi_calc.R index 8ee539df..214991a2 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -228,7 +228,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both" translate_ab <- get_translate_ab(translate_ab) # select only groups and antibiotics - if (inherits(data, "grouped_df")) { + if (is_null_or_grouped_tbl(data)) { data_has_groups <- TRUE groups <- setdiff(names(attributes(data)$groups), ".rows") data <- data[, c(groups, colnames(data)[vapply(FUN.VALUE = logical(1), data, is.rsi)]), drop = FALSE] diff --git a/R/sysdata.rda b/R/sysdata.rda index 56276449..841000a5 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/zzz.R b/R/zzz.R index da6e8ce0..b3241bcd 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -38,7 +38,7 @@ if (utf8_supported && !is_latex) { pkg_env$info_icon <- "i" } -.onLoad <- function(libname, pkgname) { +.onLoad <- function(...) { # Support for tibble headers (type_sum) and tibble columns content (pillar_shaft) # without the need to depend on other packages. This was suggested by the # developers of the vctrs package: @@ -86,7 +86,6 @@ if (utf8_supported && !is_latex) { assign(x = "INTRINSIC_R", value = create_intr_resistance(), envir = asNamespace("AMR")) } - # Helper functions -------------------------------------------------------- create_AB_lookup <- function() { diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 4978707f..32e22a1b 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/data-raw/_internals.R b/data-raw/_internals.R index 52f215a9..9460b80b 100644 --- a/data-raw/_internals.R +++ b/data-raw/_internals.R @@ -70,6 +70,8 @@ TRANSLATIONS <- utils::read.delim(file = "data-raw/translations.tsv", # for checking input in `language` argument in e.g. mo_*() and ab_*() functions LANGUAGES_SUPPORTED <- sort(c("en", colnames(TRANSLATIONS)[nchar(colnames(TRANSLATIONS)) == 2])) +# EXAMPLE_ISOLATES <- readRDS("data-raw/example_isolates.rds") + # vectors of CoNS and CoPS, improves speed in as.mo() create_species_cons_cops <- function(type = c("CoNS", "CoPS")) { # Determination of which staphylococcal species are CoNS/CoPS according to: @@ -147,6 +149,7 @@ DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_ usethis::use_data(EUCAST_RULES_DF, TRANSLATIONS, LANGUAGES_SUPPORTED, + # EXAMPLE_ISOLATES, MO_CONS, MO_COPS, AMINOGLYCOSIDES, diff --git a/data-raw/example_isolates.rds b/data-raw/example_isolates.rds new file mode 100644 index 00000000..46eac9ba Binary files /dev/null and b/data-raw/example_isolates.rds differ diff --git a/data-raw/translations.tsv b/data-raw/translations.tsv index 29e65e96..440dd639 100644 --- a/data-raw/translations.tsv +++ b/data-raw/translations.tsv @@ -16,19 +16,20 @@ unknown genus TRUE TRUE FALSE TRUE unbekannte Gattung onbekend geslacht género unknown species TRUE TRUE FALSE TRUE unbekannte Art onbekende soort especie desconocida specie sconosciute espèce inconnue espécies desconhecida unknown subspecies TRUE TRUE FALSE TRUE unbekannte Unterart onbekende ondersoort subespecie desconocida sottospecie sconosciute sous-espèce inconnue subespécies desconhecida unknown rank TRUE TRUE FALSE TRUE unbekannter Rang onbekende rang rango desconocido grado sconosciuto rang inconnu classificação desconhecido -CoNS FALSE TRUE FALSE TRUE KNS CNS SCN -CoPS FALSE TRUE FALSE TRUE KPS CPS SCP -Gram-negative TRUE TRUE FALSE TRUE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo -Gram-positive TRUE TRUE FALSE TRUE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo -^Bacteria$ TRUE TRUE FALSE TRUE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias -^Fungi$ TRUE TRUE FALSE TRUE Pilze Schimmels Hongos Funghi Champignons Fungos -^Yeasts$ TRUE TRUE FALSE TRUE Hefen Gisten Levaduras Lieviti Levures Leveduras -^Protozoa$ TRUE TRUE FALSE TRUE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários -biogroup TRUE TRUE FALSE TRUE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo -biotype TRUE TRUE FALSE TRUE Biotyp biotipo biotipo biótipo -vegetative TRUE TRUE FALSE TRUE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo -([([ ]*?)group TRUE TRUE FALSE TRUE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo -([([ ]*?)Group TRUE TRUE FALSE TRUE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo + group TRUE TRUE FALSE TRUE Gruppe groep grupo gruppo groupe grupo +CoNS FALSE TRUE FALSE FALSE KNS CNS SCN +CoPS FALSE TRUE FALSE FALSE KPS CPS SCP +Gram-negative TRUE TRUE FALSE FALSE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo +Gram-positive TRUE TRUE FALSE FALSE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo +^Bacteria$ TRUE TRUE FALSE FALSE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias +^Fungi$ TRUE TRUE FALSE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos +^Yeasts$ TRUE TRUE FALSE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras +^Protozoa$ TRUE TRUE FALSE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários +biogroup TRUE TRUE FALSE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo +biotype TRUE TRUE FALSE FALSE Biotyp biotipo biotipo biótipo +vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo +([([ ]*?)group TRUE TRUE FALSE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo +([([ ]*?)Group TRUE TRUE FALSE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo no .*growth TRUE FALSE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible diff --git a/docs/404.html b/docs/404.html index e1537850..033a552a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 8c4a16ea..1e6e6123 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 567fbd03..935525c9 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 @@ -192,7 +192,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 4d3fe390..31070c03 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 diff --git a/docs/index.html b/docs/index.html index e9136774..0f352a61 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 diff --git a/docs/news/index.html b/docs/news/index.html index 8ba97cde..6b6cb02e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016 @@ -236,12 +236,12 @@ Source: NEWS.md -
-

- Unreleased AMR 1.7.1.9015

-
+
+

+ Unreleased AMR 1.7.1.9016

+

-Last updated: 7 July 2021 +Last updated: 8 July 2021

@@ -249,10 +249,11 @@
  • Antibiotic class selectors (see ab_class())
  • Fix for duplicate ATC codes in the antibiotics data set
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index ad18d624..0aa62aab 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-07-07T18:31Z +last_built: 2021-07-08T20:22Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index de09d0d6..f55b0f3b 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -82,7 +82,7 @@ AMR (for R) - 1.7.1.9014 + 1.7.1.9016

@@ -242,15 +242,15 @@

These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.

-
ab_class(ab_class, only_rsi_columns = FALSE)
+    
ab_class(ab_class, only_rsi_columns = FALSE, only_treatable = TRUE)
 
-aminoglycosides(only_rsi_columns = FALSE)
+aminoglycosides(only_rsi_columns = FALSE, only_treatable = TRUE)
 
 aminopenicillins(only_rsi_columns = FALSE)
 
-betalactams(only_rsi_columns = FALSE)
+betalactams(only_rsi_columns = FALSE, only_treatable = TRUE)
 
-carbapenems(only_rsi_columns = FALSE)
+carbapenems(only_rsi_columns = FALSE, only_treatable = TRUE)
 
 cephalosporins(only_rsi_columns = FALSE)
 
@@ -278,7 +278,7 @@
 
 penicillins(only_rsi_columns = FALSE)
 
-polymyxins(only_rsi_columns = FALSE)
+polymyxins(only_rsi_columns = FALSE, only_treatable = TRUE)
 
 streptogramins(only_rsi_columns = FALSE)
 
@@ -299,6 +299,10 @@
       only_rsi_columns
       

a logical to indicate whether only columns of class <rsi> must be selected (defaults to FALSE), see as.rsi()

+ + only_treatable +

a logical to indicate whether agents that are only for laboratory tests should be excluded (defaults to TRUE), such as gentamicin-high (GEH) and imipenem/EDTA (IPE)

+

Details

diff --git a/docs/reference/index.html b/docs/reference/index.html index 9e3b0a96..63e92da0 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016
diff --git a/docs/survey.html b/docs/survey.html index a694a586..136835e7 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9015 + 1.7.1.9016
diff --git a/inst/tinytest/test-mo_property.R b/inst/tinytest/test-mo_property.R index ea6f94e2..62bd2934 100644 --- a/inst/tinytest/test-mo_property.R +++ b/inst/tinytest/test-mo_property.R @@ -28,20 +28,17 @@ expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli")) expect_equal(mo_phylum("Escherichia coli"), "Proteobacteria") expect_equal(mo_class("Escherichia coli"), "Gammaproteobacteria") expect_equal(mo_order("Escherichia coli"), "Enterobacterales") - -# S3 class for taxonomic names -expect_inherits(mo_family("Escherichia coli"), "taxonomic_name") -expect_equal(as.character(mo_family("Escherichia coli")), "Enterobacteriaceae") -expect_equal(as.character(mo_fullname("Escherichia coli")), "Escherichia coli") -expect_equal(as.character(mo_genus("Escherichia coli")), "Escherichia") -expect_equal(as.character(mo_name("Escherichia coli")), "Escherichia coli") -expect_equal(as.character(mo_shortname("Escherichia coli")), "E. coli") -expect_equal(as.character(mo_shortname("Escherichia")), "Escherichia") -expect_equal(as.character(mo_shortname("Staphylococcus aureus")), "S. aureus") -expect_equal(as.character(mo_shortname("Staphylococcus aureus", Becker = TRUE)), "S. aureus") -expect_equal(as.character(mo_shortname("Staphylococcus aureus", Becker = "all", language = "en")), "CoPS") -expect_equal(as.character(mo_shortname("Streptococcus agalactiae")), "S. agalactiae") -expect_equal(as.character(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE)), "GBS") +expect_equal(mo_family("Escherichia coli"), "Enterobacteriaceae") +expect_equal(mo_fullname("Escherichia coli"), "Escherichia coli") +expect_equal(mo_genus("Escherichia coli"), "Escherichia") +expect_equal(mo_name("Escherichia coli"), "Escherichia coli") +expect_equal(mo_shortname("Escherichia coli"), "E. coli") +expect_equal(mo_shortname("Escherichia"), "Escherichia") +expect_equal(mo_shortname("Staphylococcus aureus"), "S. aureus") +expect_equal(mo_shortname("Staphylococcus aureus", Becker = TRUE), "S. aureus") +expect_equal(mo_shortname("Staphylococcus aureus", Becker = "all", language = "en"), "CoPS") +expect_equal(mo_shortname("Streptococcus agalactiae"), "S. agalactiae") +expect_equal(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE), "GBS") expect_equal(mo_species("Escherichia coli"), "coli") expect_equal(mo_subspecies("Escherichia coli"), "") @@ -68,7 +65,7 @@ expect_true(mo_url("Escherichia coli") %like% "lpsn.dsmz.de") # test integrity MOs <- microorganisms -expect_identical(MOs$fullname, as.character(mo_fullname(MOs$fullname, language = "en"))) +expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en")) # check languages expect_equal(mo_type("Escherichia coli", language = "de"), "Bakterien") @@ -84,7 +81,7 @@ expect_stdout(print(mo_gramstain("Escherichia coli", language = "fr"))) expect_error(mo_gramstain("Escherichia coli", language = "UNKNOWN")) dutch <- mo_name(microorganisms$fullname, language = "nl") # should be transformable to English again -expect_identical(as.character(mo_name(dutch, language = NULL)), microorganisms$fullname) # gigantic test - will run ALL names +expect_identical(mo_name(dutch, language = NULL), microorganisms$fullname) # gigantic test - will run ALL names # manual property function expect_error(mo_property("Escherichia coli", property = c("tsn", "fullname"))) @@ -120,7 +117,7 @@ expect_equal(mo_is_intrinsic_resistant(c("Escherichia coli", "Staphylococcus aur "vanco"), c(TRUE, FALSE, FALSE)) # with reference data -expect_equal(as.character(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI"))), +expect_equal(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI")), "Escherichia coli") if (AMR:::pkg_is_available("dplyr")) { expect_equal(example_isolates %>% filter(mo_is_gram_negative()) %>% nrow(), diff --git a/man/antibiotic_class_selectors.Rd b/man/antibiotic_class_selectors.Rd index d793936a..4d809d95 100644 --- a/man/antibiotic_class_selectors.Rd +++ b/man/antibiotic_class_selectors.Rd @@ -27,15 +27,15 @@ \alias{ureidopenicillins} \title{Antibiotic Class Selectors} \usage{ -ab_class(ab_class, only_rsi_columns = FALSE) +ab_class(ab_class, only_rsi_columns = FALSE, only_treatable = TRUE) -aminoglycosides(only_rsi_columns = FALSE) +aminoglycosides(only_rsi_columns = FALSE, only_treatable = TRUE) aminopenicillins(only_rsi_columns = FALSE) -betalactams(only_rsi_columns = FALSE) +betalactams(only_rsi_columns = FALSE, only_treatable = TRUE) -carbapenems(only_rsi_columns = FALSE) +carbapenems(only_rsi_columns = FALSE, only_treatable = TRUE) cephalosporins(only_rsi_columns = FALSE) @@ -63,7 +63,7 @@ oxazolidinones(only_rsi_columns = FALSE) penicillins(only_rsi_columns = FALSE) -polymyxins(only_rsi_columns = FALSE) +polymyxins(only_rsi_columns = FALSE, only_treatable = TRUE) streptogramins(only_rsi_columns = FALSE) @@ -77,6 +77,8 @@ ureidopenicillins(only_rsi_columns = FALSE) \item{ab_class}{an antimicrobial class, such as \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.} \item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}} + +\item{only_treatable}{a \link{logical} to indicate whether agents that are only for laboratory tests should be excluded (defaults to \code{TRUE}), such as gentamicin-high (\code{GEH}) and imipenem/EDTA (\code{IPE})} } \description{ These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.