diff --git a/DESCRIPTION b/DESCRIPTION index 7529e106..81441dc0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.5.0.9039 +Version: 1.5.0.9040 Date: 2021-03-08 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NAMESPACE b/NAMESPACE index dc044128..4cdb85b0 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,23 +16,19 @@ S3method(">",mic) S3method(">=",mic) S3method("[",ab) S3method("[",disk) -S3method("[",isolate_identifier) S3method("[",mic) S3method("[",mo) S3method("[<-",ab) S3method("[<-",disk) -S3method("[<-",isolate_identifier) S3method("[<-",mic) S3method("[<-",mo) S3method("[<-",rsi) S3method("[[",ab) S3method("[[",disk) -S3method("[[",isolate_identifier) S3method("[[",mic) S3method("[[",mo) S3method("[[<-",ab) S3method("[[<-",disk) -S3method("[[<-",isolate_identifier) S3method("[[<-",mic) S3method("[[<-",mo) S3method("[[<-",rsi) @@ -42,7 +38,6 @@ S3method(abs,mic) S3method(acos,mic) S3method(acosh,mic) S3method(all,mic) -S3method(all.equal,isolate_identifier) S3method(any,mic) S3method(as.data.frame,ab) S3method(as.data.frame,mo) @@ -63,7 +58,6 @@ S3method(barplot,mic) S3method(barplot,rsi) S3method(c,ab) S3method(c,disk) -S3method(c,isolate_identifier) S3method(c,mic) S3method(c,mo) S3method(c,rsi) @@ -105,7 +99,6 @@ S3method(print,bug_drug_combinations) S3method(print,catalogue_of_life_version) S3method(print,custom_mdro_guideline) S3method(print,disk) -S3method(print,isolate_identifier) S3method(print,mic) S3method(print,mo) S3method(print,mo_renamed) @@ -139,7 +132,6 @@ S3method(trigamma,mic) S3method(trunc,mic) S3method(unique,ab) S3method(unique,disk) -S3method(unique,isolate_identifier) S3method(unique,mic) S3method(unique,mo) S3method(unique,rsi) @@ -235,7 +227,6 @@ export(is.mo) export(is.rsi) export(is.rsi.eligible) export(is_new_episode) -export(isolate_identifier) export(key_antibiotics) export(key_antibiotics_equal) export(kurtosis) diff --git a/NEWS.md b/NEWS.md index c187df2d..5b8df560 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.5.0.9039 +# AMR 1.5.0.9040 ## Last updated: 8 March 2021 ### New @@ -22,7 +22,6 @@ #> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I" ``` * Support for custom MDRO guidelines, using the new `custom_mdro_guideline()` function, please see `mdro()` for additional info -* Function `isolate_identifier()`, which will paste a microorganism code with all antimicrobial results of a data set into one string for each row. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available. * `ggplot()` generics for classes `` and `` * Function `mo_is_yeast()`, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales: ```r @@ -57,7 +56,16 @@ * `is.rsi()` and `is.rsi.eligible()` now return a vector of `TRUE`/`FALSE` when the input is a data set, by iterating over all columns * Using functions without setting a data set (e.g., `mo_is_gram_negative()`, `mo_is_gram_positive()`, `mo_is_intrinsic_resistant()`, `first_isolate()`, `mdro()`) now work with `dplyr`s `group_by()` again * `first_isolate()` can be used with `group_by()` (also when using a dot `.` as input for the data) and now returns the names of the groups -* MIC values now allow for any mathematical processing, such as usage inside functions `min()`, `max()`, `range()`, and with binary operators (+, -, etc.). This also enables other functions, such as `fivenum()`. +* MIC values (see `as.mic()`) can now be used in any mathematical processing, such as usage inside functions `min()`, `max()`, `range()`, and with binary operators (+, -, etc.). This allows easy distribution analysis and fast filtering on MIC values: + ```r + x <- random_mic(10) + x + #> Class + #> [1] 0.5 64 64 128 0.125 4 0.5 0.0625 0.0625 0.125 + x[x > 4] + #> Class + #> [1] 64 64 128 + ``` * Updated the data set `microorganisms.codes` (which contains popular LIS and WHONET codes for microorganisms) for some species of *Mycobacterium* that previously incorrectly returned *M. africanum* * WHONET code `"PNV"` will now correctly be interpreted as `PHN`, the antibiotic code for phenoxymethylpenicillin ('peni V') * Fix for verbose output of `mdro(..., verbose = TRUE)` for German guideline (3MGRN and 4MGRN) and Dutch guideline (BRMO, only *P. aeruginosa*) diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 3f87e2a6..6907a185 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -507,12 +507,12 @@ format_class <- function(class, plural) { if ("isolate_identifier" %in% class) { class <- "created with isolate_identifier()" } - if (any(c("mo", "ab", "rsi", "disk", "mic") %in% class)) { + if (any(c("mo", "ab", "rsi") %in% class)) { class <- paste0("of class <", class[1L], ">") } class[class == class.bak] <- paste0("of class <", class[class == class.bak], ">") # output - vector_or(class, quotes = FALSE) + vector_or(class, quotes = FALSE, sort = FALSE) } # a check for every single argument in all functions diff --git a/R/isolate_identifier.R b/R/isolate_identifier.R deleted file mode 100644 index 1b9afe80..00000000 --- a/R/isolate_identifier.R +++ /dev/null @@ -1,203 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Data Analysis for R # -# # -# SOURCE # -# https://github.com/msberends/AMR # -# # -# LICENCE # -# (c) 2018-2021 Berends MS, Luz CF et al. # -# Developed at the University of Groningen, the Netherlands, in # -# collaboration with non-profit organisations Certe Medical # -# Diagnostics & Advice, and University Medical Center Groningen. # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# We created this package for both routine data analysis and academic # -# research and it was publicly released in the hope that it will be # -# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # -# # -# Visit our website for the full manual and a complete tutorial about # -# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # -# ==================================================================== # - -#' Create Identifier of an Isolate -#' -#' This function will paste the microorganism code with all antimicrobial results into one string for each row in a data set. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available. -#' @inheritSection lifecycle Experimental Lifecycle -#' @inheritParams eucast_rules -#' @param cols_ab a character vector of column names of `x`, or (a combination with) an [antibiotic selector function]([ab_class()]), such as [carbapenems()] and [aminoglycosides()] -#' @rdname isolate_identifier -#' @export -#' @inheritSection AMR Read more on Our Website! -#' @examples -#' # automatic selection of microorganism and antibiotics (i.e., all columns, see ?as.rsi) -#' x <- isolate_identifier(example_isolates) -#' -#' # ignore microorganism codes, only use antimicrobial results -#' x <- isolate_identifier(example_isolates, col_mo = FALSE, cols_ab = c("AMX", "TZP", "GEN", "TOB")) -#' -#' # select antibiotics from certain antibiotic classes -#' x <- isolate_identifier(example_isolates, cols_ab = c(carbapenems(), aminoglycosides())) -isolate_identifier <- function(x, col_mo = NULL, cols_ab = NULL) { - if (is.null(col_mo)) { - col_mo <- search_type_in_df(x, "mo") - if (is.null(col_mo)) { - # no column found, then ignore the argument - col_mo <- FALSE - } - } - - if (isFALSE(col_mo)) { - # is FALSE then ignore mo column - x$col_mo <- "" - col_mo <- "col_mo" - } else if (!is.null(col_mo)) { - x[, col_mo] <- paste0(as.mo(x[, col_mo, drop = TRUE]), "|") - } - - cols_ab <- deparse(substitute(cols_ab)) # support ab class selectors: isolate_identifier(x, cols_ab = carbapenems()) - if (identical(cols_ab, "NULL")) { - cols_ab <- colnames(x)[vapply(FUN.VALUE = logical(1), x, is.rsi)] - } else { - cols_ab <- tryCatch(colnames(x[, eval(parse(text = cols_ab), envir = parent.frame())]), - # tryCatch adds 4 calls, so total is -5 - error = function(e) stop_(e$message, call = -5)) - } - - # cope with empty values - if (length(cols_ab) == 0 && all(x[, col_mo, drop = TRUE] == "", na.rm = TRUE)) { - warning_("in isolate_identifier(): no column with microorganisms and no columns with antimicrobial agents found", call = FALSE) - } else if (length(cols_ab) == 0) { - warning_("in isolate_identifier(): no columns with antimicrobial agents found", call = FALSE) - } - - out <- x[, c(col_mo, cols_ab), drop = FALSE] - out <- do.call(paste, c(out, sep = "")) - out <- gsub("NA", ".", out, fixed = TRUE) - out <- set_clean_class(out, new_class = c("isolate_identifier", "character")) - attr(out, "ab") <- cols_ab - out -} - -#' @method all.equal isolate_identifier -#' @inheritParams base::all.equal -#' @param ignore_empty_results a logical to indicate whether empty results must be ignored, so that only values R, S and I will be compared -#' @rdname isolate_identifier -#' @export -all.equal.isolate_identifier <- function(target, current, ignore_empty_results = TRUE, ...) { - meet_criteria(target, allow_class = "isolate_identifier") - meet_criteria(current, allow_class = "isolate_identifier") - meet_criteria(ignore_empty_results, allow_class = "logical", has_length = 1) - - if (isTRUE(all.equal.character(target, current))) { - return(TRUE) - } - # vectorise over both target and current - if (length(target) > 1 && length(current) == 1) { - current <- rep(current, length(target)) - } else if (length(current) > 1 && length(target) == 1) { - target <- rep(target, length(current)) - } - stop_if(length(target) != length(current), - "length of `target` and `current` must be the same, or one must be 1") - - get_vector <- function(x) { - if (grepl("|", x, fixed = TRUE)) { - mo <- gsub("(.*)\\|.*", "\\1", x) - } else { - mo <- NULL - } - if (grepl("|", x, fixed = TRUE)) { - ab <- gsub(".*\\|(.*)", "\\1", x) - } else { - ab <- x - } - ab <- strsplit(ab, "")[[1L]] - if (is.null(mo)) { - out <- as.character(ab) - names(out) <- attributes(x)$ab - } else { - out <- as.character(c(mo, ab)) - names(out) <- c("mo", attributes(x)$ab) - } - out - } - - # run it - for (i in seq_len(length(target))) { - if (i == 1) { - df <- data.frame(object = paste0(c("target[", "current["), i, "]")) - } - trgt <- get_vector(target[i]) - crnt <- get_vector(current[i]) - if (ignore_empty_results == TRUE) { - diff <- names(trgt[trgt != crnt & trgt != "." & crnt != "."]) - } else { - diff <- names(trgt[trgt != crnt]) - } - - } - - stop("THIS FUNCTION IS WORK IN PROGRESS AND NOT AVAILABLE IN THIS BETA VERSION") - -} - -#' @method print isolate_identifier -#' @export -#' @noRd -print.isolate_identifier <- function(x, ...) { - print(as.character(x), ...) -} - -#' @method [ isolate_identifier -#' @export -#' @noRd -"[.isolate_identifier" <- function(x, ...) { - y <- NextMethod() - attributes(y) <- attributes(x) - y -} -#' @method [[ isolate_identifier -#' @export -#' @noRd -"[[.isolate_identifier" <- function(x, ...) { - y <- NextMethod() - attributes(y) <- attributes(x) - y -} -#' @method [<- isolate_identifier -#' @export -#' @noRd -"[<-.isolate_identifier" <- function(i, j, ..., value) { - y <- NextMethod() - attributes(y) <- attributes(i) - y -} -#' @method [[<- isolate_identifier -#' @export -#' @noRd -"[[<-.isolate_identifier" <- function(i, j, ..., value) { - y <- NextMethod() - attributes(y) <- attributes(i) - y -} -#' @method c isolate_identifier -#' @export -#' @noRd -c.isolate_identifier <- function(x, ...) { - y <- NextMethod() - attributes(y) <- attributes(x) - y -} - -#' @method unique isolate_identifier -#' @export -#' @noRd -unique.isolate_identifier <- function(x, incomparables = FALSE, ...) { - y <- NextMethod() - attributes(y) <- attributes(x) - y -} diff --git a/R/mic.R b/R/mic.R index 73a1c6d0..cca503bf 100755 --- a/R/mic.R +++ b/R/mic.R @@ -100,13 +100,13 @@ #' plot(mic_data) #' plot(mic_data, mo = "E. coli", ab = "cipro") as.mic <- function(x, na.rm = FALSE) { - meet_criteria(x, allow_class = c("mic", "character", "numeric", "integer"), allow_NA = TRUE) + meet_criteria(x, allow_class = c("mic", "character", "numeric", "integer", "factor"), allow_NA = TRUE) meet_criteria(na.rm, allow_class = "logical", has_length = 1) if (is.mic(x)) { x } else { - x <- unlist(x) + x <- as.character(unlist(x)) if (na.rm == TRUE) { x <- x[!is.na(x)] } diff --git a/_pkgdown.yml b/_pkgdown.yml index 98c88cd5..463c130a 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -143,7 +143,6 @@ reference: - "`as.mic`" - "`as.disk`" - "`eucast_rules`" - - "`isolate_identifier`" - title: "Analysing data: antimicrobial resistance" desc: > diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index f2776f33..72bb9869 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index e0d9d6fe..e7050fe6 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index c63bcf33..3a89eece 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 diff --git a/docs/articles/index.html b/docs/articles/index.html index f88e1db7..5f169739 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 diff --git a/docs/authors.html b/docs/authors.html index b11f9da1..bb0ae004 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 diff --git a/docs/index.html b/docs/index.html index 3cbf6616..62544869 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 diff --git a/docs/news/index.html b/docs/news/index.html index e0b542fb..6e66431e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.5.0.9039 Unreleased +
+

+AMR 1.5.0.9040 Unreleased

@@ -279,7 +279,6 @@ #> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"

  • Support for custom MDRO guidelines, using the new custom_mdro_guideline() function, please see mdro() for additional info

  • -
  • Function isolate_identifier(), which will paste a microorganism code with all antimicrobial results of a data set into one string for each row. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available.

  • ggplot() generics for classes <mic> and <disk>

  • Function mo_is_yeast(), which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:

    @@ -309,14 +308,16 @@

    Changed

      -
    • Updated the bacterial taxonomy to 3 March 2021 (using LSPN) +
    • +

      Updated the bacterial taxonomy to 3 March 2021 (using LSPN)

      • Added 3,372 new species and 1,523 existing species became synomyms
      • The URL of a bacterial species (mo_url()) will now lead to https://lpsn.dsmz.de
    • -
    • Big update for plotting classes rsi, <mic>, and <disk>: +
    • +

      Big update for plotting classes rsi, <mic>, and <disk>:

      • Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent
      • All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)
      • @@ -324,34 +325,37 @@
      • Plotting is now possible with base R using plot() and with ggplot2 using ggplot() on any vector of MIC and disk diffusion values
    • +
    • is.rsi() and is.rsi.eligible() now return a vector of TRUE/FALSE when the input is a data set, by iterating over all columns

    • +
    • Using functions without setting a data set (e.g., mo_is_gram_negative(), mo_is_gram_positive(), mo_is_intrinsic_resistant(), first_isolate(), mdro()) now work with dplyrs group_by() again

    • +
    • first_isolate() can be used with group_by() (also when using a dot . as input for the data) and now returns the names of the groups

    • -is.rsi() and is.rsi.eligible() now return a vector of TRUE/FALSE when the input is a data set, by iterating over all columns
    • -
    • Using functions without setting a data set (e.g., mo_is_gram_negative(), mo_is_gram_positive(), mo_is_intrinsic_resistant(), first_isolate(), mdro()) now work with dplyrs group_by() again
    • -
    • -first_isolate() can be used with group_by() (also when using a dot . as input for the data) and now returns the names of the groups
    • -
    • MIC values now allow for any mathematical processing, such as usage inside functions min(), max(), range(), and with binary operators (+, -, etc.). This also enables other functions, such as fivenum().
    • -
    • Updated the data set microorganisms.codes (which contains popular LIS and WHONET codes for microorganisms) for some species of Mycobacterium that previously incorrectly returned M. africanum +

      MIC values (see as.mic()) can now be used in any mathematical processing, such as usage inside functions min(), max(), range(), and with binary operators (+, -, etc.). This allows easy distribution analysis and fast filtering on MIC values:

      +
      +
      +x <- random_mic(10)
      +x
      +#> Class <mic>
      +#>  [1] 0.5    64     64     128    0.125  4      0.5    0.0625 0.0625 0.125 
      +x[x > 4]
      +#> Class <mic>
      +#> [1] 64  64  128
    • -
    • WHONET code "PNV" will now correctly be interpreted as PHN, the antibiotic code for phenoxymethylpenicillin (‘peni V’)
    • -
    • Fix for verbose output of mdro(..., verbose = TRUE) for German guideline (3MGRN and 4MGRN) and Dutch guideline (BRMO, only P. aeruginosa)
    • -
    • -is.rsi.eligible() now detects if the column name resembles an antibiotic name or code and now returns TRUE immediately if the input contains any of the values “R”, “S” or “I”. This drastically improves speed, also for a lot of other functions that rely on automatic determination of antibiotic columns.
    • -
    • Functions get_episode() and is_new_episode() now support less than a day as value for argument episode_days (e.g., to include one patient/test per hour)
    • -
    • Argument ampc_cephalosporin_resistance in eucast_rules() now also applies to value “I” (not only “S”)
    • -
    • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by() -
    • -
    • Improved speed and reliability of guess_ab_col(). As this also internally improves the reliability of first_isolate() and mdro(), this might have a slight impact on the results of those functions.
    • -
    • Fix for mo_name() when used in other languages than English
    • -
    • The like() function (and its fast alias %like%) now always use Perl compatibility, improving speed for many functions in this package (e.g., as.mo() is now up to 4 times faster)
    • -
    • -Staphylococcus cornubiensis is now correctly categorised as coagulase-positive
    • -
    • -random_disk() and random_mic() now have an expanded range in their randomisation
    • -
    • Support for GISA (glycopeptide-intermediate S. aureus), so e.g. mo_genus("GISA") will return "Staphylococcus" -
    • -
    • Added translations of German and Spanish for more than 200 antimicrobial drugs
    • -
    • Speed improvement for as.ab() when the input is an official name or ATC code
    • -
    • Added argument include_untested_rsi to the first_isolate() functions (defaults to TRUE to keep existing behaviour), to be able to exclude rows where all R/SI values (class <rsi>, see as.rsi()) are empty
    • +
    • Updated the data set microorganisms.codes (which contains popular LIS and WHONET codes for microorganisms) for some species of Mycobacterium that previously incorrectly returned M. africanum

    • +
    • WHONET code "PNV" will now correctly be interpreted as PHN, the antibiotic code for phenoxymethylpenicillin (‘peni V’)

    • +
    • Fix for verbose output of mdro(..., verbose = TRUE) for German guideline (3MGRN and 4MGRN) and Dutch guideline (BRMO, only P. aeruginosa)

    • +
    • is.rsi.eligible() now detects if the column name resembles an antibiotic name or code and now returns TRUE immediately if the input contains any of the values “R”, “S” or “I”. This drastically improves speed, also for a lot of other functions that rely on automatic determination of antibiotic columns.

    • +
    • Functions get_episode() and is_new_episode() now support less than a day as value for argument episode_days (e.g., to include one patient/test per hour)

    • +
    • Argument ampc_cephalosporin_resistance in eucast_rules() now also applies to value “I” (not only “S”)

    • +
    • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by()

    • +
    • Improved speed and reliability of guess_ab_col(). As this also internally improves the reliability of first_isolate() and mdro(), this might have a slight impact on the results of those functions.

    • +
    • Fix for mo_name() when used in other languages than English

    • +
    • The like() function (and its fast alias %like%) now always use Perl compatibility, improving speed for many functions in this package (e.g., as.mo() is now up to 4 times faster)

    • +
    • Staphylococcus cornubiensis is now correctly categorised as coagulase-positive

    • +
    • random_disk() and random_mic() now have an expanded range in their randomisation

    • +
    • Support for GISA (glycopeptide-intermediate S. aureus), so e.g. mo_genus("GISA") will return "Staphylococcus"

    • +
    • Added translations of German and Spanish for more than 200 antimicrobial drugs

    • +
    • Speed improvement for as.ab() when the input is an official name or ATC code

    • +
    • Added argument include_untested_rsi to the first_isolate() functions (defaults to TRUE to keep existing behaviour), to be able to exclude rows where all R/SI values (class <rsi>, see as.rsi()) are empty

  • @@ -374,7 +378,7 @@ -
    +
     
     # to select first isolates that are Gram-negative 
     # and view results of cephalosporins and aminoglycosides:
    @@ -440,7 +444,7 @@
     
     
  • For antibiotic selection functions (such as cephalosporins(), aminoglycosides()) to select columns based on a certain antibiotic group, the dependency on the tidyselect package was removed, meaning that they can now also be used without the need to have this package installed and now also work in base R function calls (they rely on R 3.2 or later):

    -
    +
     
     # above example in base R:
     example_isolates[which(first_isolate() & mo_is_gram_negative()),
    @@ -491,7 +495,7 @@
     
  • Data set intrinsic_resistant. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: microorganism and antibiotic.

    Curious about which enterococci are actually intrinsic resistant to vancomycin?

    -
    +
     
     library(AMR)
     library(dplyr)
    @@ -514,7 +518,7 @@
     
    • Support for using dplyr’s across() to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.

      -
      +
       
       # until dplyr 1.0.0
       your_data %>% mutate_if(is.mic, as.rsi)
      @@ -532,7 +536,7 @@
       
    • Added intelligent data cleaning to as.disk(), so numbers can also be extracted from text and decimal numbers will always be rounded up:

      -
      +
       
       as.disk(c("disk zone: 23.4 mm", 23.4))
       #> Class <disk>
      @@ -593,7 +597,7 @@
       
    • Function ab_from_text() to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses as.ab() internally

    • Tidyverse selection helpers for antibiotic classes, that help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations. They can be used in any function that allows selection helpers, like dplyr::select() and tidyr::pivot_longer():

      -
      +
       
       library(dplyr)
       
      @@ -782,7 +786,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
       
    • Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline

    • Interpretation from MIC values (and disk zones) to R/SI can now be used with mutate_at() of the dplyr package:

      -
      +
       
       yourdata %>% 
         mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli")
      @@ -811,7 +815,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
       
      • Support for LOINC codes in the antibiotics data set. Use ab_loinc() to retrieve LOINC codes, or use a LOINC code for input in any ab_* function:

        -
        +
         
         ab_loinc("ampicillin")
         #> [1] "21066-6" "3355-5"  "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"
        @@ -822,7 +826,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
         
      • Support for SNOMED CT codes in the microorganisms data set. Use mo_snomed() to retrieve SNOMED codes, or use a SNOMED code for input in any mo_* function:

        -
        +
         
         mo_snomed("S. aureus")
         #> [1] 115329001   3092008 113961008
        @@ -887,11 +891,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
         
        • If you were dependent on the old Enterobacteriaceae family e.g. by using in your code:

          -
          +
           
           if (mo_family(somebugs) == "Enterobacteriaceae") ...

          then please adjust this to:

          -
          +
           
           if (mo_order(somebugs) == "Enterobacterales") ...
        • @@ -905,7 +909,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
          • Functions susceptibility() and resistance() as aliases of proportion_SI() and proportion_R(), respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.

            -
            +
             
             library(dplyr)
             example_isolates %>%
            @@ -934,7 +938,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
             
          • More intelligent way of coping with some consonants like “l” and “r”

          • Added a score (a certainty percentage) to mo_uncertainties(), that is calculated using the Levenshtein distance:

            -
            +
             
             as.mo(c("Stafylococcus aureus",
                     "staphylokok aureuz"))
            @@ -993,14 +997,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
             
            • Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code "UNKNOWN". They can be included with the new argument include_unknown:

              -
              +
               
               first_isolate(..., include_unknown = TRUE)

              For WHONET users, this means that all records/isolates with organism code "con" (contamination) will be excluded at default, since as.mo("con") = "UNKNOWN". The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.

            • For code consistency, classes ab and mo will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in NA:

              -
              +
               
               # how it works in base R:
               x <- factor("A")
              @@ -1025,7 +1029,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
               
              • Function bug_drug_combinations() to quickly get a data.frame with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with mo_shortname() at default:

                -
                +
                 
                 x <- bug_drug_combinations(example_isolates)
                 #> NOTE: Using column `mo` as input for `col_mo`.
                @@ -1048,13 +1052,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 #> 4 Gram-negative AMX 227  0 405   632
                 #> NOTE: Use 'format()' on this result to get a publicable/printable format.

                You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R format() function:

                -
                +
                 
                 format(x, combine_IR = FALSE)
              • Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for portion_* functions or count_* functions. This can be used to determine the empiric susceptibility of a combination therapy. A new argument only_all_tested (which defaults to FALSE) replaces the old also_single_tested and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the portion and count help pages), where the %SI is being determined:

                -
                +
                 
                 # --------------------------------------------------------------------
                 #                     only_all_tested = FALSE  only_all_tested = TRUE
                @@ -1076,7 +1080,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • tibble printing support for classes rsi, mic, disk, ab mo. When using tibbles containing antimicrobial columns, values S will print in green, values I will print in yellow and values R will print in red. Microbial IDs (class mo) will emphasise on the genus and species, not on the kingdom.

                -
                +
                 
                 # (run this on your own console, as this page does not support colour printing)
                 library(dplyr)
                @@ -1159,7 +1163,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
                • Function rsi_df() to transform a data.frame to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions count_df() and portion_df() to immediately show resistance percentages and number of available isolates:

                  -
                  +
                   
                   septic_patients %>%
                     select(AMX, CIP) %>%
                  @@ -1186,7 +1190,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • UPEC (Uropathogenic E. coli)

                All these lead to the microbial ID of E. coli:

                -
                +
                 
                 as.mo("UPEC")
                 # B_ESCHR_COL
                @@ -1291,7 +1295,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • when all values are unique it now shows a message instead of a warning

              • support for boxplots:

                -
                +
                 
                 septic_patients %>% 
                   freq(age) %>% 
                @@ -1386,7 +1390,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • New filters for antimicrobial classes. Use these functions to filter isolates on results in one of more antibiotics from a specific class:

                -
                +
                 
                 filter_aminoglycosides()
                 filter_carbapenems()
                @@ -1400,7 +1404,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 filter_macrolides()
                 filter_tetracyclines()

                The antibiotics data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics data set. For example:

                -
                +
                 
                 septic_patients %>% filter_glycopeptides(result = "R")
                 # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R
                @@ -1409,7 +1413,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • All ab_* functions are deprecated and replaced by atc_* functions:

                -
                +
                 
                 ab_property -> atc_property()
                 ab_name -> atc_name()
                @@ -1430,7 +1434,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • New function age_groups() to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic AMR data analysis per age group.

              • New function ggplot_rsi_predict() as well as the base R plot() function can now be used for resistance prediction calculated with resistance_predict():

                -
                +
                 
                 x <- resistance_predict(septic_patients, col_ab = "amox")
                 plot(x)
                @@ -1438,13 +1442,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
              • Functions filter_first_isolate() and filter_first_weighted_isolate() to shorten and fasten filtering on data sets with antimicrobial results, e.g.:

                -
                +
                 
                 septic_patients %>% filter_first_isolate(...)
                 # or
                 filter_first_isolate(septic_patients, ...)

                is equal to:

                -
                +
                 
                 septic_patients %>%
                   mutate(only_firsts = first_isolate(septic_patients, ...)) %>%
                @@ -1477,7 +1481,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                 
                • Now handles incorrect spelling, like i instead of y and f instead of ph:

                  -
                  +
                   
                   # mo_fullname() uses as.mo() internally
                   
                  @@ -1489,7 +1493,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default allow_uncertain = TRUE is equal to uncertainty level 2. Run ?as.mo for more info about these levels.

                  -
                  +
                   
                   # equal:
                   as.mo(..., allow_uncertain = TRUE)
                  @@ -1504,7 +1508,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                • All microbial IDs that found are now saved to a local file ~/.Rhistory_mo. Use the new function clean_mo_history() to delete this file, which resets the algorithms.

                • Incoercible results will now be considered ‘unknown’, MO code UNKNOWN. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:

                  -
                  +
                   
                   mo_genus("qwerty", language = "es")
                   # Warning: 
                  @@ -1554,7 +1558,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                   
                  • Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:

                    -
                    +
                     
                     # Determine genus of microorganisms (mo) in `septic_patients` data set:
                     # OLD WAY
                    @@ -1638,7 +1642,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Fewer than 3 characters as input for as.mo will return NA

                  • Function as.mo (and all mo_* wrappers) now supports genus abbreviations with “species” attached

                    -
                    +
                     
                     as.mo("E. species")        # B_ESCHR
                     mo_fullname("E. spp.")     # "Escherichia species"
                    @@ -1655,7 +1659,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                    • Support for grouping variables, test with:

                      -
                      +
                       
                       septic_patients %>% 
                         group_by(hospital_id) %>% 
                      @@ -1663,7 +1667,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       
                    • Support for (un)selecting columns:

                      -
                      +
                       
                       septic_patients %>% 
                         freq(hospital_id) %>% 
                      @@ -1743,7 +1747,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                       

                    They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:

                    -
                    +
                     
                     mo_gramstain("E. coli")
                     # [1] "Gram negative"
                    @@ -1754,7 +1758,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     mo_fullname("S. group A", language = "pt") # Portuguese
                     # [1] "Streptococcus grupo A"

                    Furthermore, former taxonomic names will give a note about the current taxonomic name:

                    -
                    +
                     
                     mo_gramstain("Esc blattae")
                     # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)
                    @@ -1769,7 +1773,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Function is.rsi.eligible to check for columns that have valid antimicrobial results, but do not have the rsi class yet. Transform the columns of your raw data with: data %>% mutate_if(is.rsi.eligible, as.rsi)

                  • Functions as.mo and is.mo as replacements for as.bactid and is.bactid (since the microoganisms data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo function determines microbial IDs using intelligent rules:

                    -
                    +
                     
                     as.mo("E. coli")
                     # [1] B_ESCHR_COL
                    @@ -1778,7 +1782,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     as.mo("S group A")
                     # [1] B_STRPTC_GRA

                    And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:

                    -
                    +
                     
                     thousands_of_E_colis <- rep("E. coli", 25000)
                     microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
                    @@ -1812,7 +1816,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Added three antimicrobial agents to the antibiotics data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)

                  • Added 163 trade names to the antibiotics data set, it now contains 298 different trade names in total, e.g.:

                    -
                    +
                     
                     ab_official("Bactroban")
                     # [1] "Mupirocin"
                    @@ -1829,7 +1833,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Added arguments minimum and as_percent to portion_df

                  • Support for quasiquotation in the functions series count_* and portions_*, and n_rsi. This allows to check for more than 2 vectors or columns.

                    -
                    +
                     
                     septic_patients %>% select(amox, cipr) %>% count_IR()
                     # which is the same as:
                    @@ -1849,12 +1853,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
                     
                  • Added longest en shortest character length in the frequency table (freq) header of class character

                  • Support for types (classes) list and matrix for freq

                    -
                    +
                     
                     my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
                     freq(my_matrix)

                    For lists, subsetting is possible:

                    -
                    +
                     
                     my_list = list(age = septic_patients$age, gender = septic_patients$gender)
                     my_list %>% freq(age)
                    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
                    index 0b6afac6..b07e7bc4 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-03-08T01:35Z
                    +last_built: 2021-03-08T08:41Z
                     urls:
                       reference: https://msberends.github.io/AMR//reference
                       article: https://msberends.github.io/AMR//articles
                    diff --git a/docs/reference/ab_from_text.html b/docs/reference/ab_from_text.html
                    index 7acd3e4c..23af775b 100644
                    --- a/docs/reference/ab_from_text.html
                    +++ b/docs/reference/ab_from_text.html
                    @@ -82,7 +82,7 @@
                           
                           
                             AMR (for R)
                    -        1.5.0.9032
                    +        1.5.0.9040
                           
                         
                    diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index c380e679..313926d1 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9034 + 1.5.0.9040
                    diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index ab8427d3..07a4e1f2 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040
                    diff --git a/docs/reference/ggplot_pca.html b/docs/reference/ggplot_pca.html index c36a2318..d17b104b 100644 --- a/docs/reference/ggplot_pca.html +++ b/docs/reference/ggplot_pca.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9040
                  • @@ -410,7 +410,7 @@ The lifecycle of this function is stable# new ggplot_pca(pca_model) - if (require("ggplot2")) { + if (require("ggplot2")) { ggplot_pca(pca_model) + scale_colour_viridis_d() + labs(title = "Title here") diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index 1bde674d..05c0eca3 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9040
                    @@ -429,7 +429,7 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

                    Examples

                    -
                    if (require("ggplot2") & require("dplyr")) {
                    +    
                    if (require("ggplot2") & require("dplyr")) {
                      
                       # get antimicrobial results for drugs against a UTI:
                       ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +
                    diff --git a/docs/reference/index.html b/docs/reference/index.html
                    index fec64ebb..229a55ef 100644
                    --- a/docs/reference/index.html
                    +++ b/docs/reference/index.html
                    @@ -81,7 +81,7 @@
                           
                           
                             AMR (for R)
                    -        1.5.0.9039
                    +        1.5.0.9040
                           
                         
                  • @@ -450,12 +450,6 @@

                    eucast_rules() eucast_dosage()

                    Apply EUCAST Rules

                    - - - -

                    isolate_identifier() all.equal(<isolate_identifier>)

                    - -

                    Create Identifier of an Isolate

                    diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 7c433927..c9c4b9ae 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040
                    diff --git a/docs/reference/pca.html b/docs/reference/pca.html index 67b20677..3f220b16 100644 --- a/docs/reference/pca.html +++ b/docs/reference/pca.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9040
                  • diff --git a/docs/reference/random.html b/docs/reference/random.html index 5c21b3c6..d5f655e7 100644 --- a/docs/reference/random.html +++ b/docs/reference/random.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9040
                    diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index fc2c3852..f158bf3c 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9032 + 1.5.0.9040
                    @@ -401,7 +401,7 @@ A microorganism is categorised as Susceptible, Increased exposure when year_min = 2010, model = "binomial") plot(x) -if (require("ggplot2")) { +if (require("ggplot2")) { ggplot_rsi_predict(x) } @@ -419,7 +419,7 @@ A microorganism is categorised as Susceptible, Increased exposure when } # create nice plots with ggplot2 yourself -if (require("dplyr") & require("ggplot2")) { +if (require("dplyr") & require("ggplot2")) { data <- example_isolates %>% filter(mo == as.mo("E. coli")) %>% diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 899189f9..e2a0039f 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -102,9 +102,6 @@ https://msberends.github.io/AMR//reference/intrinsic_resistant.html - - https://msberends.github.io/AMR//reference/isolate_identifier.html - https://msberends.github.io/AMR//reference/join.html diff --git a/docs/survey.html b/docs/survey.html index 469024dd..1636d37d 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9039 + 1.5.0.9040
                  • diff --git a/man/isolate_identifier.Rd b/man/isolate_identifier.Rd deleted file mode 100644 index fee4fd48..00000000 --- a/man/isolate_identifier.Rd +++ /dev/null @@ -1,50 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/isolate_identifier.R -\name{isolate_identifier} -\alias{isolate_identifier} -\alias{all.equal.isolate_identifier} -\title{Create Identifier of an Isolate} -\usage{ -isolate_identifier(x, col_mo = NULL, cols_ab = NULL) - -\method{all.equal}{isolate_identifier}(target, current, ignore_empty_results = TRUE, ...) -} -\arguments{ -\item{x}{data with antibiotic columns, such as \code{amox}, \code{AMX} and \code{AMC}} - -\item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} - -\item{cols_ab}{a character vector of column names of \code{x}, or (a combination with) an \href{[ab_class()]}{antibiotic selector function}, such as \code{\link[=carbapenems]{carbapenems()}} and \code{\link[=aminoglycosides]{aminoglycosides()}}} - -\item{target}{\R object.} - -\item{current}{other \R object, to be compared with \code{target}.} - -\item{ignore_empty_results}{a logical to indicate whether empty results must be ignored, so that only values R, S and I will be compared} - -\item{...}{column name of an antibiotic, see section \emph{Antibiotics} below} -} -\description{ -This function will paste the microorganism code with all antimicrobial results into one string for each row in a data set. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available. -} -\section{Experimental Lifecycle}{ - -\if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{experimental}. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this \code{AMR} package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough. -} - -\section{Read more on Our Website!}{ - -On our website \url{https://msberends.github.io/AMR/} you can find \href{https://msberends.github.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR data analysis, the \href{https://msberends.github.io/AMR/reference/}{complete documentation of all functions} and \href{https://msberends.github.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. As we would like to better understand the backgrounds and needs of our users, please \href{https://msberends.github.io/AMR/survey.html}{participate in our survey}! -} - -\examples{ -# automatic selection of microorganism and antibiotics (i.e., all columns, see ?as.rsi) -x <- isolate_identifier(example_isolates) - -# ignore microorganism codes, only use antimicrobial results -x <- isolate_identifier(example_isolates, col_mo = FALSE, cols_ab = c("AMX", "TZP", "GEN", "TOB")) - -# select antibiotics from certain antibiotic classes -x <- isolate_identifier(example_isolates, cols_ab = c(carbapenems(), aminoglycosides())) -} diff --git a/tests/testthat/test-ggplot_rsi.R b/tests/testthat/test-ggplot_rsi.R index 79f8c977..c8dad2b5 100644 --- a/tests/testthat/test-ggplot_rsi.R +++ b/tests/testthat/test-ggplot_rsi.R @@ -71,5 +71,19 @@ test_that("ggplot_rsi works", { ggplot(aes(x = ab, y = n)) + geom_col())$data), "data.frame") - + + expect_equal(class((data.frame(ab = as.ab(c("amx", "amc")), + n = c(40, 100)) %>% + ggplot(aes(x = ab, y = n)) + + geom_col())$data), + "data.frame") + + # support for manual colours + expect_equal(class((ggplot(data.frame(x = c("Value1", "Value2", "Value3"), + y = c(1, 2, 3), + z = c("Value4", "Value5", "Value6"))) + + geom_col(aes(x = x, y = y, fill = z)) + + scale_rsi_colours(Value4 = "S", Value5 = "I", Value6 = "R"))$data), + "data.frame") + }) diff --git a/tests/testthat/test-isolate_identifier.R b/tests/testthat/test-isolate_identifier.R deleted file mode 100644 index 9bee9144..00000000 --- a/tests/testthat/test-isolate_identifier.R +++ /dev/null @@ -1,44 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Data Analysis for R # -# # -# SOURCE # -# https://github.com/msberends/AMR # -# # -# LICENCE # -# (c) 2018-2021 Berends MS, Luz CF et al. # -# Developed at the University of Groningen, the Netherlands, in # -# collaboration with non-profit organisations Certe Medical # -# Diagnostics & Advice, and University Medical Center Groningen. # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# We created this package for both routine data analysis and academic # -# research and it was publicly released in the hope that it will be # -# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # -# # -# Visit our website for the full manual and a complete tutorial about # -# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # -# ==================================================================== # - -context("isolate_identifier.R") - -test_that("isolate_identifier works", { - x <- suppressMessages(isolate_identifier(example_isolates)) - expect_s3_class(x, "isolate_identifier") - expect_s3_class(x, "character") - - expect_equal(suppressMessages( - unique(nchar(isolate_identifier(example_isolates, cols_ab = carbapenems(), col_mo = FALSE)))), - 2) - - expect_warning(isolate_identifier(example_isolates[, 1:3, drop = FALSE])) # without mo and without rsi - expect_warning(isolate_identifier(example_isolates[, 1:9, drop = FALSE])) # only without rsi - - - expect_output(print(x)) - expect_s3_class(unique(c(x, x)), "isolate_identifier") - -})