diff --git a/.Rbuildignore b/.Rbuildignore index 45a4d842..0496b081 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,7 +21,7 @@ ^pkgdown$ ^public$ ^data-raw$ -R/aa_test.R$ ^\.lintr$ ^vignettes/benchmark.* ^vignettes/SPSS.* +^tests/appveyor$ diff --git a/DESCRIPTION b/DESCRIPTION index d4dbd964..7de38f74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.8.0.9016 -Date: 2019-11-05 +Version: 0.8.0.9017 +Date: 2019-11-06 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index cfca1ca2..8c1bcb95 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 0.8.0.9016 -Last updated: 05-Nov-2019 +# AMR 0.8.0.9017 +Last updated: 06-Nov-2019 ### New * Support for a new MDRO guideline: Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012). diff --git a/R/ab.R b/R/ab.R index e682e242..ec6bf1de 100755 --- a/R/ab.R +++ b/R/ab.R @@ -25,7 +25,6 @@ #' @param x character vector to determine to antibiotic ID #' @param ... arguments passed on to internal functions #' @rdname as.ab -#' @keywords atc #' @inheritSection WHOCC WHOCC #' @export #' @importFrom dplyr %>% filter slice pull diff --git a/R/ab_property.R b/R/ab_property.R index 50cbaf50..5f6cf662 100644 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -83,6 +83,7 @@ ab_name <- function(x, language = get_locale(), tolower = FALSE, ...) { } #' @rdname ab_property +#' @aliases ATC #' @export ab_atc <- function(x, ...) { ab_validate(x = x, property = "atc", ...) diff --git a/R/age.R b/R/age.R index 55b00135..c6b301bd 100755 --- a/R/age.R +++ b/R/age.R @@ -106,7 +106,6 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE) { #' \item{\code{"tens"}, equivalent of: \code{1:10 * 10}. This will split on 0-9, 10-19, 20-29, ... 80-89, 90-99, 100+.} #' } #' } -#' @keywords age_group age #' @return Ordered \code{\link{factor}} #' @seealso To determine ages, based on one or more reference dates, use the \code{\link{age}} function. #' @export diff --git a/R/count.R b/R/count.R index 00c794ac..8d6b0ff1 100755 --- a/R/count.R +++ b/R/count.R @@ -37,7 +37,6 @@ #' @inheritSection portion Combination therapy #' @source Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html} #' @seealso \code{\link{portion}_*} to calculate microbial resistance and susceptibility. -#' @keywords resistance susceptibility rsi antibiotics isolate isolates #' @return Integer #' @rdname count #' @name count diff --git a/R/disk.R b/R/disk.R index 42689644..264dfba1 100644 --- a/R/disk.R +++ b/R/disk.R @@ -27,7 +27,7 @@ #' @param na.rm a logical indicating whether missing values should be removed #' @details Interpret disk values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. #' @return Ordered integer factor with new class \code{disk} -#' @keywords disk +#' @aliases disk #' @export #' @seealso \code{\link{as.rsi}} #' @inheritSection AMR Read more on our website! diff --git a/R/eucast_rules.R b/R/eucast_rules.R index e1daabc6..472209e3 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -122,7 +122,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' \strong{TMP}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), #' \strong{SXT}: trimethoprim/sulfamethoxazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), #' \strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). -#' @keywords interpretive eucast reading resistance +#' @aliases EUCAST #' @rdname eucast_rules #' @export #' @importFrom dplyr %>% select pull mutate_at vars group_by summarise n diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R index 6b3bfd88..1ab7f9a1 100644 --- a/R/filter_ab_class.R +++ b/R/filter_ab_class.R @@ -29,7 +29,6 @@ #' @param ... parameters passed on to \code{filter_at} from the \code{dplyr} package #' @details The \code{group} column in \code{\link{antibiotics}} data set will be searched for \code{ab_class} (case-insensitive). If no results are found, the \code{atc_group1} and \code{atc_group2} columns will be searched. Next, \code{x} will be checked for column names with a value in any abbreviations, codes or official names found in the \code{antibiotics} data set. #' @rdname filter_ab_class -#' @keywords filter fillter_class #' @importFrom dplyr filter_at %>% select vars any_vars all_vars #' @importFrom crayon bold blue #' @export diff --git a/R/first_isolate.R b/R/first_isolate.R index fc9c24af..95dafc14 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -70,7 +70,6 @@ #' \strong{2. Using} \code{type = "points"} \strong{and parameter} \code{points_threshold} \cr #' A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds \code{points_threshold}, which default to \code{2}, an isolate will be (re)selected as a first weighted isolate. #' @rdname first_isolate -#' @keywords isolate isolates first #' @seealso \code{\link{key_antibiotics}} #' @export #' @importFrom dplyr arrange_at lag between row_number filter mutate arrange pull ungroup diff --git a/R/g.test.R b/R/g.test.R index adf6db01..5ccad116 100755 --- a/R/g.test.R +++ b/R/g.test.R @@ -61,7 +61,6 @@ #' where \code{df} are the degrees of freedom. #' #' If there are more than two categories and you want to find out which ones are significantly different from their null expectation, you can use the same method of testing each category vs. the sum of all categories, with the Bonferroni correction. You use \emph{G}-tests for each category, of course. -#' @keywords chi #' @seealso \code{\link{chisq.test}} #' @references [1] McDonald, J.H. 2014. \strong{Handbook of Biological Statistics (3rd ed.)}. Sparky House Publishing, Baltimore, Maryland. \url{http://www.biostathandbook.com/gtestgof.html}. #' @source This code is almost identical to \code{\link{chisq.test}}, except that: diff --git a/R/like.R b/R/like.R index 6b388e12..9ba97a2e 100755 --- a/R/like.R +++ b/R/like.R @@ -49,9 +49,8 @@ #' # get frequencies of bacteria whose name start with 'Ent' or 'ent' #' library(dplyr) #' example_isolates %>% -#' left_join_microorganisms() %>% -#' filter(genus %like% '^ent') %>% -#' freq(genus, species) +#' filter(mo_genus(mo) %like% '^ent') %>% +#' freq(mo_fullname(mo)) like <- function(x, pattern, ignore.case = TRUE) { if (length(pattern) > 1) { if (length(x) != length(pattern)) { diff --git a/R/mdro.R b/R/mdro.R index 3ae7752d..20028752 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -26,6 +26,7 @@ #' @param info print progress #' @inheritParams eucast_rules #' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for \emph{S. aureus}. Setting this \code{pct_required_classes} argument to \code{0.5} (default) means that for every \emph{S. aureus} isolate at least 8 different classes must be available. Any lower number of available classes will return \code{NA} for that isolate. +#' @param combine_SI a logical to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the \code{mdro()} function, it follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using \code{combine_SI = FALSE}, resistance is considered when isolates are R or I. #' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not. #' @inheritSection eucast_rules Antibiotics #' @details @@ -43,7 +44,7 @@ #' Please suggest your own (country-specific) guidelines by letting us know: \url{https://gitlab.com/msberends/AMR/issues/new}. #' #' \strong{Note:} Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named order Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu \emph{et al.} in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this \code{mdro()} function makes sure that results from before 2016 and after 2016 are identical. -#' +#' @inheritSection as.rsi Interpretation of S, I and R #' @return \itemize{ #' \item{CMI 2012 paper - function \code{mdr_cmi2012()} or \code{mdro()}:\cr Ordered factor with levels \code{Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant (XDR) < Pandrug-resistant (PDR)}} #' \item{TB guideline - function \code{mdr_tb()} or \code{mdro(..., guideline = "TB")}:\cr Ordered factor with levels \code{Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant < Extensively drug-resistant}} @@ -51,6 +52,7 @@ #' \item{Everything else:\cr Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests} #' } #' @rdname mdro +#' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN #' @importFrom dplyr %>% filter_at vars all_vars pull mutate_at #' @importFrom crayon blue bold italic #' @importFrom cleaner percentage @@ -80,8 +82,9 @@ mdro <- function(x, guideline = NULL, col_mo = NULL, info = TRUE, - verbose = FALSE, pct_required_classes = 0.5, + combine_SI = TRUE, + verbose = FALSE, ...) { if (verbose == TRUE & interactive()) { @@ -109,7 +112,7 @@ mdro <- function(x, # allow pct_required_classes = 75 -> pct_required_classes = 0.75 pct_required_classes <- pct_required_classes / 100 } - + if (!is.null(list(...)$country)) { warning("Using `country` is deprecated, use `guideline` instead. Please see ?mdro.", call. = FALSE) guideline <- list(...)$country @@ -410,8 +413,19 @@ mdro <- function(x, if (guideline$code == "tb" & length(abx_tb) == 0) { stop("No antimycobacterials found in data set.", call. = FALSE) } + + if (combine_SI == TRUE) { + search_result <- "R" + } else { + search_result <- c("R", "I") + } if (info == TRUE) { + if (combine_SI == TRUE) { + cat("\nOnly results with 'R' are considered as resistance. Use `combine_SI = FALSE` to also consider 'I' as resistance.\n") + } else { + cat("\nResults with 'R' or 'I' are considered as resistance. Use `combine_SI = TRUE` to only consider 'R' as resistance.\n") + } cat("\nDetermining multidrug-resistant organisms (MDRO), according to:\n", bold("Guideline: "), italic(guideline$name), "\n", bold("Version: "), guideline$version, "\n", @@ -444,19 +458,21 @@ mdro <- function(x, x <<- x %>% mutate_at(vars(cols), as.rsi) x[rows, "columns_nonsusceptible"] <<- sapply(rows, function(row, group_vct = cols) { - cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y == "R") + cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], + function(y) y %in% search_result) paste(sort(c(unlist(strsplit(x[row, "columns_nonsusceptible", drop = TRUE], ", ")), names(cols_nonsus)[cols_nonsus])), collapse = ", ") }) + if (any_all == "any") { - row_filter <- which(x[, cols] == "R") + search_function <- dplyr::any_vars } else if (any_all == "all") { - row_filter <- x %>% - mutate(index = seq_len(nrow(.))) %>% - filter_at(vars(cols), all_vars(. == "R")) %>% - pull((index)) + search_function <- dplyr::all_vars } + row_filter <- x %>% + filter_at(vars(cols), search_function(. %in% search_result)) %>% + pull("row_number") rows <- rows[rows %in% row_filter] x[rows, "MDRO"] <<- to x[rows, "reason"] <<- paste0(any_all, " of the required antibiotics ", ifelse(any_all == "any", "is", "are"), " R") @@ -479,7 +495,7 @@ mdro <- function(x, if (verbose == TRUE) { x[rows, "columns_nonsusceptible"] <<- sapply(rows, function(row, group_vct = lst_vector) { - cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y %in% c("I", "R")) + cols_nonsus <- sapply(x[row, group_vct, drop = FALSE], function(y) y %in% search_result) paste(sort(names(cols_nonsus)[cols_nonsus]), collapse = ", ") }) } @@ -487,14 +503,14 @@ mdro <- function(x, function(row, group_tbl = lst) { sum(sapply(group_tbl, function(group) { - any(x[row, group[!is.na(group)]] == "R", na.rm = TRUE) | - any(x[row, group[!is.na(group)]] == "I", na.rm = TRUE) + any(unlist(x[row, group[!is.na(group)], drop = TRUE]) %in% search_result, na.rm = TRUE) }), na.rm = TRUE) }) + # for PDR; all agents are R (or I if combine_SI = FALSE) x[filter_at(x[rows, ], vars(lst_vector), - all_vars(. %in% c("R", "I")))$row_number, "classes_affected"] <<- 999 + all_vars(. %in% search_result))$row_number, "classes_affected"] <<- 999 } if (info == TRUE) { diff --git a/R/mic.R b/R/mic.R index 25211016..dcdd17bc 100755 --- a/R/mic.R +++ b/R/mic.R @@ -27,7 +27,7 @@ #' @param na.rm a logical indicating whether missing values should be removed #' @details Interpret MIC values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. #' @return Ordered factor with new class \code{mic} -#' @keywords mic +#' @aliases MIC #' @export #' @importFrom dplyr %>% #' @seealso \code{\link{as.rsi}} diff --git a/R/portion.R b/R/portion.R index 7357eb32..5c52a26c 100755 --- a/R/portion.R +++ b/R/portion.R @@ -79,7 +79,6 @@ #' #' Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html} #' @seealso \code{\link[AMR]{count}_*} to count resistant and susceptible isolates. -#' @keywords resistance susceptibility rsi_df rsi antibiotics isolate isolates #' @return Double or, when \code{as_percent = TRUE}, a character. #' @rdname portion #' @name portion diff --git a/R/rsi.R b/R/rsi.R index a076a45d..1cd4286e 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -36,7 +36,7 @@ #' #' The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains at most 5\% invalid antimicrobial interpretations (not S and/or I and/or R), and \code{FALSE} otherwise. The threshold of 5\% can be set with the \code{threshold} parameter. #' @section Interpretation of S, I and R: -#' In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations". +#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations". #' #' \itemize{ #' \item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.} @@ -48,7 +48,7 @@ #' #' This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates. #' @return Ordered factor with new class \code{rsi} -#' @keywords rsi +#' @aliases RSI #' @export #' @importFrom dplyr %>% desc arrange filter #' @seealso \code{\link{as.mic}} diff --git a/appveyor.yml b/appveyor.yml index 509b4db9..bdc06413 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,7 +23,7 @@ init: ps: | $ErrorActionPreference = "Stop" - Invoke-WebRequest https://raw.githubusercontent.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" + Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/appveyor_tool.ps1 -OutFile "..\appveyor-tool.ps1" Import-Module '..\appveyor-tool.ps1' install: diff --git a/docs/404.html b/docs/404.html index e261a7c3..ed984d46 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 8e7621ad..783ceac4 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 diff --git a/docs/articles/index.html b/docs/articles/index.html index 8a908532..90367097 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 diff --git a/docs/authors.html b/docs/authors.html index a63e8fc5..dd7f8996 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 diff --git a/docs/index.html b/docs/index.html index 3012afaf..00399fb6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -45,7 +45,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 diff --git a/docs/news/index.html b/docs/news/index.html index ba49411c..b35615e7 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.8.0.9016 + 0.8.0.9017 @@ -231,11 +231,11 @@ -
+

-AMR 0.8.0.9016 Unreleased +AMR 0.8.0.9017 Unreleased

-

Last updated: 05-Nov-2019

+

Last updated: 06-Nov-2019

New

@@ -1333,7 +1333,7 @@ Using as.mo(..., allow_uncertain = 3)

Contents

diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html index 2eb1ac55..6a51f1f1 100644 --- a/docs/reference/age_groups.html +++ b/docs/reference/age_groups.html @@ -85,7 +85,7 @@ AMR (for R) - 0.8.0.9009 + 0.8.0.9017
diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index 5e34395e..33af5584 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -85,7 +85,7 @@ AMR (for R) - 0.8.0 + 0.8.0.9017
diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 0e9e07e9..3c80a806 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -85,7 +85,7 @@ AMR (for R) - 0.8.0 + 0.8.0.9017 diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index e43f1657..a6cb3475 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -85,7 +85,7 @@ AMR (for R) - 0.8.0.9008 + 0.8.0.9017 diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 18ee25a0..67d19b4e 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -85,7 +85,7 @@ AMR (for R) - 0.8.0.9008 + 0.8.0.9017 @@ -298,7 +298,7 @@ -

In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (http://www.eucast.org/newsiandr/). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".

+

In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (http://www.eucast.org/newsiandr/). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".