diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index d6802c8d..94a609b1 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -120,7 +120,7 @@ jobs: sessioninfo::session_info(pkgs, include_base = TRUE) shell: Rscript {0} - - name: Run Check + - name: Run R CMD check env: _R_CHECK_CRAN_INCOMING_: false run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") diff --git a/DESCRIPTION b/DESCRIPTION index 2484b053..3b74194e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.4.0.9047 +Version: 1.4.0.9048 Date: 2020-12-27 Title: Antimicrobial Resistance Analysis Authors@R: c( @@ -29,6 +29,8 @@ Authors@R: c( family = "Meijer", given = c("Bart", "C."), email = "b.meijerg@certe.nl"), person(role = "ctb", family = "Ny", given = "Sofia", email = "sofia.ny@folkhalsomyndigheten.se"), + person(role = "ctb", + family = "Schade", given = c("Rogier", "P."), email = "r.schade@amsterdamumc.nl"), person(role = "ctb", family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl"), person(role = "ctb", diff --git a/NEWS.md b/NEWS.md index 4be16f2a..3f264538 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.4.0.9047 +# AMR 1.4.0.9048 ## Last updated: 27 December 2020 ### New @@ -14,6 +14,7 @@ * Functions `random_mic()`, `random_disk()` and `random_rsi()` for random number generation. They take microorganism names and antibiotic names as input to make generation more realistic. ### Changed +* New argument `ampc_cephalosporin_resistance` in `eucast_rules()` to correct for AmpC de-repressed cephalosporin-resistant mutants * Interpretation of antimicrobial resistance - `as.rsi()`: * Reference data used for `as.rsi()` can now be set by the user, using the `reference_data` argument. This allows for using own interpretation guidelines. The user-set data must have the same structure as `rsi_translation`. * Better determination of disk zones and MIC values when running `as.rsi()` on a data.frame @@ -50,7 +51,8 @@ ### Other * All messages and warnings thrown by this package now break sentences on whole words * More extensive unit tests -* Internal calls to `options()` were all removed in favour of a new internal environment `mo_env` +* Internal calls to `options()` were all removed in favour of a new internal environment `pkg_env` +* Added Dr. Rogier Schade as contributor # AMR 1.4.0 diff --git a/R/episode.R b/R/episode.R index dd09cc44..ac26d5e0 100644 --- a/R/episode.R +++ b/R/episode.R @@ -50,7 +50,7 @@ #' get_episode(example_isolates$date, episode_days = 60) #' is_new_episode(example_isolates$date, episode_days = 60) #' -#' # filter on results from the third 60-day episode using base R +#' # filter on results from the third 60-day episode only, using base R #' example_isolates[which(get_episode(example_isolates$date, 60) == 3), ] #' #' \donttest{ diff --git a/R/eucast_rules.R b/R/eucast_rules.R index a8fbd45f..6983cc47 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -64,6 +64,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) { #' @param verbose a [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time. #' @param version_breakpoints the version number to use for the EUCAST Clinical Breakpoints guideline. Currently supported: `r paste0(names(EUCAST_VERSION_BREAKPOINTS), collapse = ", ")`. #' @param version_expertrules the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: `r paste0(names(EUCAST_VERSION_EXPERT_RULES), collapse = ", ")`. +#' @param ampc_cephalosporin_resistance a character value that should be applied for AmpC de-repressed cephalosporin-resistant mutants, defaults to `NA`. Currently only works when `version_expertrules` is `3.2`; '*EUCAST Expert Rules v3.2 on Enterobacterales*' states that susceptible (S) results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these agents. A value of `NA` for this argument will remove results for these agents, while e.g. a value of `"R"` will make the results for these agents resistant. Use `NULL` to not alter the results for AmpC de-repressed cephalosporin-resistant mutants. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: *`r gsub("|", "*, *", gsub("[)(^)]", "", eucast_rules_file[which(eucast_rules_file$reference.version == 3.2 & eucast_rules_file$reference.rule %like% "ampc"), "this_value"][1]), fixed = TRUE)`*. #' @param ... column name of an antibiotic, please see section *Antibiotics* below #' @inheritParams first_isolate #' @details @@ -149,6 +150,7 @@ eucast_rules <- function(x, verbose = FALSE, version_breakpoints = 10.0, version_expertrules = 3.2, + ampc_cephalosporin_resistance = NA, ...) { meet_criteria(x, allow_class = "data.frame") meet_criteria(col_mo, allow_class = "character", has_length = 1, is_in = colnames(x), allow_NULL = TRUE) @@ -157,6 +159,7 @@ eucast_rules <- function(x, meet_criteria(verbose, allow_class = "logical", has_length = 1) meet_criteria(version_breakpoints, allow_class = "numeric", has_length = 1) meet_criteria(version_expertrules, allow_class = "numeric", has_length = 1) + meet_criteria(ampc_cephalosporin_resistance, allow_class = c("rsi", "character"), has_length = 1, allow_NA = TRUE, allow_NULL = TRUE, is_in = c("R", "S", "I")) x_deparsed <- deparse(substitute(x)) if (length(x_deparsed) > 1 || !all(x_deparsed %like% "[a-z]+")) { @@ -731,7 +734,7 @@ eucast_rules <- function(x, # Official EUCAST rules --------------------------------------------------- eucast_notification_shown <- FALSE if (!is.null(list(...)$eucast_rules_df)) { - # this allows: eucast_rules(x, eucast_rules_df = AMR:::eucast_rules_file %pm>% filter(is.na(have_these_values))) + # this allows: eucast_rules(x, eucast_rules_df = AMR:::eucast_rules_file %>% filter(is.na(have_these_values))) eucast_rules_df <- list(...)$eucast_rules_df } else { # otherwise internal data file, created in data-raw/internals.R @@ -749,6 +752,13 @@ eucast_rules <- function(x, !reference.rule_group %like% "expert" | (reference.rule_group %like% "expert" & reference.version == version_expertrules)) } + # filter out AmpC de-repressed cephalosporin-resistant mutants ---- + if (is.null(ampc_cephalosporin_resistance)) { + eucast_rules_df <- subset(eucast_rules_df, + !reference.rule %like% "ampc") + } else { + eucast_rules_df[which(eucast_rules_df$reference.rule %like% "ampc"), "to_value"] <- as.character(ampc_cephalosporin_resistance) + } for (i in seq_len(nrow(eucast_rules_df))) { @@ -946,7 +956,7 @@ eucast_rules <- function(x, by = c(".rowid" = "rowid")) %pm>% pm_select(-`.rowid`) %pm>% pm_select(row, pm_everything()) %pm>% - pm_filter(!is.na(new)) %pm>% + pm_filter(!is.na(new) | is.na(new) & !is.na(old)) %pm>% pm_arrange(row, rule_group, rule_name, col) rownames(verbose_info) <- NULL } @@ -1007,6 +1017,7 @@ eucast_rules <- function(x, if (total_n_changed > 0) { changed_summary <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% + pm_mutate(new = ifelse(is.na(new), "NA", new)) %pm>% pm_count(old, new, name = "n") cat(paste(" -", paste0(formatnr(changed_summary$n), " test result", ifelse(changed_summary$n > 1, "s", ""), " changed from ", @@ -1092,7 +1103,7 @@ edit_rsi <- function(x, if (w$message %like% "invalid factor level") { xyz <- sapply(cols, function(col) { new_edits[, col] <<- factor(x = as.character(pm_pull(new_edits, col)), - levels = unique(c(to, levels(pm_pull(new_edits, col))))) + levels = unique(c(to, levels(pm_pull(new_edits, col))))) invisible() }) suppressWarnings(new_edits[rows, cols] <<- to) @@ -1134,7 +1145,7 @@ edit_rsi <- function(x, stringsAsFactors = FALSE) colnames(verbose_new) <- c("rowid", "col", "mo_fullname", "old", "new", "rule", "rule_group", "rule_name", "rule_source") - verbose_new <- verbose_new %pm>% pm_filter(old != new | is.na(old)) + verbose_new <- verbose_new %pm>% pm_filter(old != new | is.na(old) | is.na(new) & !is.na(old)) # save changes to data set 'verbose_info' track_changes$verbose_info <- rbind(track_changes$verbose_info, verbose_new, diff --git a/R/sysdata.rda b/R/sysdata.rda index 736d43dc..88761872 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/cran-comments.md b/cran-comments.md index 8b1a2ce1..823a18bb 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1 @@ -* Edited the unit tests, so they will run under 10 minutes on CRAN (using testthat::skip_on_cran() on some tests). - * Since version 0.3.0 (2018-08-14), CHECK returns a NOTE for having a data directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package. diff --git a/data-raw/eucast_rules.tsv b/data-raw/eucast_rules.tsv index 4ffbb0cf..2e2a6b7c 100644 --- a/data-raw/eucast_rules.tsv +++ b/data-raw/eucast_rules.tsv @@ -300,3 +300,6 @@ genus_species is Moraxella catarrhalis NAL S fluoroquinolones S Expert Rules on genus_species is Moraxella catarrhalis NAL R fluoroquinolones R Expert Rules on Moraxella catarrhalis Expert Rules 3.2 genus is Campylobacter ERY S CLR, AZM S Expert Rules on Campylobacter Expert Rules 3.2 genus_species is Campylobacter ERY R CLR, AZM R Expert Rules on Campylobacter Expert Rules 3.2 +fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter freundii|Hafnia alvei|Serratia|Morganella morganii|Providencia) CTX S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument +fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter freundii|Hafnia alvei|Serratia|Morganella morganii|Providencia) CRO S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument +fullname like ^(Enterobacter|Klebsiella aerogenes|Citrobacter freundii|Hafnia alvei|Serratia|Morganella morganii|Providencia) CAZ S CTX, CRO, CAZ Expert Rules on Enterobacterales (AmpC de-repressed cephalosporins) Expert Rules 3.2 This is rule 3 and 4 of EUCAST Expert Rules v3.2 on Enterobacterales, result will be set with the 'ampc_derepressed_cephalosporins' argument diff --git a/docs/404.html b/docs/404.html index 882bb89d..4463130d 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 9685c24b..5062e46c 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 4d611988..476f5aa0 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 25fc26d4..b20f4ceb 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ @@ -303,6 +303,10 @@Sofia Ny. Contributor.
+Rogier P. Schade. Contributor. +
+Dennis Souverein. Contributor.
diff --git a/docs/extra.js b/docs/extra.js index 78f0d9dd..bc54c5de 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -90,6 +90,7 @@ $(document).ready(function() { x = x.replace("Judith", "Dr. Judith"); x = x.replace("Gwen", "Dr. Gwen"); x = x.replace("Anthony", "Dr. Anthony"); + x = x.replace("Rogier", "Dr. Rogier"); } return(x); } diff --git a/docs/index.html b/docs/index.html index 106a5fd4..8f53a05a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ diff --git a/docs/news/index.html b/docs/news/index.html index 145d0592..49165a29 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ @@ -236,9 +236,9 @@ Source:NEWS.md
- New argument ampc_cephalosporin_resistance
in eucast_rules()
to correct for AmpC de-repressed cephalosporin-resistant mutants
Interpretation of antimicrobial resistance - as.rsi()
:
options()
were all removed in favour of a new internal environment mo_env
+options()
were all removed in favour of a new internal environment pkg_env
the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Currently supported: 3.1, 3.2.
a character value that should be applied for AmpC de-repressed cephalosporin-resistant mutants, defaults to NA
. Currently only works when version_expertrules
is 3.2
; 'EUCAST Expert Rules v3.2 on Enterobacterales' states that susceptible (S) results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these agents. A value of NA
for this argument will remove results for these agents, while e.g. a value of "R"
will make the results for these agents resistant. Use NULL
to not alter the results for AmpC de-repressed cephalosporin-resistant mutants.
For EUCAST Expert Rules v3.2, this rule applies to: Enterobacter, Klebsiella aerogenes, Citrobacter freundii, Hafnia alvei, Serratia, Morganella morganii, Providencia.
column name of an antibiotic, please see section Antibiotics below
Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least episode_days
days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least episode_days
days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
The first_isolate()
function is a wrapper around the is_new_episode()
function, but is more efficient for data sets containing microorganism codes or names.
The dplyr
package is not required for these functions to work, but these functions support variable grouping and work conveniently inside dplyr
verbs such as filter()
, mutate()
and summarise()
.
The dplyr
package is not required for these functions to work, but these functions support variable grouping and work conveniently inside dplyr
verbs such as filter()
, mutate()
and summarise()
.