diff --git a/DESCRIPTION b/DESCRIPTION index f2512355..7b8bab26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.7.1.9019 +Version: 1.7.1.9020 Date: 2021-07-12 Title: Antimicrobial Resistance Data Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index c3380f91..5041d829 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,22 +1,21 @@ -# `AMR` 1.7.1.9019 +# `AMR` 1.7.1.9020 ## Last updated: 12 July 2021 ### Changed +* Previously implemented `ggplot2::gggplot()` generics for classes ``, ``, `` and `` did not follow the `ggplot2` logic, and were replaced with `autoplot()` generics. * Antibiotic class selectors (see `ab_class()`) * 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 * Added more informative error messages when any of the `proportion_*()` and `count_*()` functions fail * When printing a tibble with any old MO code, a warning will be thrown that old codes should be updated using `as.mo()` * Improved automatic column selector when `col_*` arguments are left blank, e.g. in `first_isolate()` * The right input types for `random_mic()`, `random_disk()` and `random_rsi()` are now enforced * `as.rsi()` can now correct for textual input (such as "Susceptible", "Resistant") in Dutch, English, French, German, Italian, Portuguese and Spanish -* When warnings are throws because of too few isolates in any `count_*()`, `proportion_*()` function (or `resistant()` or `susceptible()`), the `dplyr` group will be shown, if available -* Taxonomic names now print in italic in tibbles, if created with `mo_name()`, `mo_fullname()`, `mo_shortname()`, `mo_genus()` or `mo_family()` +* When warnings are thrown because of too few isolates in any `count_*()`, `proportion_*()` function (or `resistant()` or `susceptible()`), the `dplyr` group will be shown, if available * `ab_name()` gained argument `snake_case`, which is useful for column renaming * Fix for legends created with `scale_rsi_colours()` when using `ggplot2` v3.3.4 or higher (this is bug ggplot2#4511, soon to be fixed) * Fix for minor translation errors diff --git a/R/plot.R b/R/plot.R index b04dd991..3b68eb9f 100644 --- a/R/plot.R +++ b/R/plot.R @@ -26,15 +26,14 @@ #' Plotting for Classes `rsi`, `mic` and `disk` #' #' Functions to plot classes `rsi`, `mic` and `disk`, with support for base \R and `ggplot2`. -#' @inheritSection lifecycle Stable Lifecycle +#' @inheritSection lifecycle Maturing Lifecycle #' @inheritSection AMR Read more on Our Website! -#' @param x,data MIC values created with [as.mic()] or disk diffusion values created with [as.disk()] -#' @param mapping aesthetic mappings to use for [`ggplot()`][ggplot2::ggplot()] -#' @param main,title title of the plot -#' @param xlab,ylab axis title +#' @param x,object values created with [as.mic()], [as.disk()] or [as.rsi()] #' @param mo any (vector of) text that can be coerced to a valid microorganism code with [as.mo()] #' @param ab any (vector of) text that can be coerced to a valid antimicrobial code with [as.ab()] #' @param guideline interpretation guideline to use, defaults to the latest included EUCAST guideline, see *Details* +#' @param main,title title of the plot +#' @param xlab,ylab axis title #' @param colours_RSI colours to use for filling in the bars, must be a vector of three values (in the order R, S and I). The default colours are colour-blind friendly. #' @param language language to be used to translate 'Susceptible', 'Increased exposure'/'Intermediate' and 'Resistant', defaults to system language (see [get_locale()]) and can be overwritten by setting the option `AMR_locale`, e.g. `options(AMR_locale = "de")`, see [translate]. Use `language = NULL` or `language = ""` to prevent translation. #' @param expand a [logical] to indicate whether the range on the x axis should be expanded between the lowest and highest value. For MIC values, intermediate values will be factors of 2 starting from the highest MIC value. For disk diameters, the whole diameter range will be filled. @@ -46,7 +45,7 @@ #' Simply using `"CLSI"` or `"EUCAST"` as input will automatically select the latest version of that guideline. #' @name plot #' @rdname plot -#' @return The `ggplot` functions return a [`ggplot`][ggplot2::ggplot()] model that is extendible with any `ggplot2` function. +#' @return The `autoplot()` functions return a [`ggplot`][ggplot2::ggplot()] model that is extendible with any `ggplot2` function. #' @param ... arguments passed on to [as.rsi()] #' @examples #' some_mic_values <- random_mic(size = 100) @@ -63,9 +62,9 @@ #' #' \donttest{ #' if (require("ggplot2")) { -#' ggplot(some_mic_values) -#' ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") -#' ggplot(some_rsi_values) +#' autoplot(some_mic_values) +#' autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") +#' autoplot(some_rsi_values) #' } #' } NULL @@ -75,22 +74,22 @@ NULL #' @export #' @rdname plot plot.mic <- function(x, - main = paste("MIC values of", deparse(substitute(x))), - ylab = "Frequency", - xlab = "Minimum Inhibitory Concentration (mg/L)", mo = NULL, ab = NULL, guideline = "EUCAST", + main = paste("MIC values of", deparse(substitute(x))), + ylab = "Frequency", + xlab = "Minimum Inhibitory Concentration (mg/L)", colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), language = get_locale(), expand = TRUE, ...) { - meet_criteria(main, allow_class = "character", has_length = 1, allow_NULL = TRUE) - meet_criteria(ylab, allow_class = "character", has_length = 1) - meet_criteria(xlab, allow_class = "character", has_length = 1) meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE) meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE) meet_criteria(guideline, allow_class = "character", has_length = 1) + meet_criteria(main, allow_class = "character", has_length = 1, allow_NULL = TRUE) + meet_criteria(ylab, allow_class = "character", has_length = 1) + meet_criteria(xlab, allow_class = "character", has_length = 1) meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3)) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) meet_criteria(expand, allow_class = "logical", has_length = 1) @@ -161,12 +160,12 @@ plot.mic <- function(x, #' @export #' @noRd barplot.mic <- function(height, - main = paste("MIC values of", deparse(substitute(height))), - ylab = "Frequency", - xlab = "Minimum Inhibitory Concentration (mg/L)", mo = NULL, ab = NULL, guideline = "EUCAST", + main = paste("MIC values of", deparse(substitute(height))), + ylab = "Frequency", + xlab = "Minimum Inhibitory Concentration (mg/L)", colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), language = get_locale(), expand = TRUE, @@ -202,28 +201,27 @@ barplot.mic <- function(height, ...) } -#' @method ggplot mic +#' @method autplot mic #' @rdname plot # will be exported using s3_register() in R/zzz.R -ggplot.mic <- function(data, - mapping = NULL, - title = paste("MIC values of", deparse(substitute(data))), - ylab = "Frequency", - xlab = "Minimum Inhibitory Concentration (mg/L)", - mo = NULL, - ab = NULL, - guideline = "EUCAST", - colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), - language = get_locale(), - expand = TRUE, - ...) { +autoplot.mic <- function(object, + mo = NULL, + ab = NULL, + guideline = "EUCAST", + title = paste("MIC values of", deparse(substitute(object))), + ylab = "Frequency", + xlab = "Minimum Inhibitory Concentration (mg/L)", + colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), + language = get_locale(), + expand = TRUE, + ...) { stop_ifnot_installed("ggplot2") - meet_criteria(title, allow_class = "character", allow_NULL = TRUE) - meet_criteria(ylab, allow_class = "character", has_length = 1) - meet_criteria(xlab, allow_class = "character", has_length = 1) meet_criteria(mo, allow_class = c("mo", "character"), allow_NULL = TRUE) meet_criteria(ab, allow_class = c("ab", "character"), allow_NULL = TRUE) meet_criteria(guideline, allow_class = "character", has_length = 1) + meet_criteria(title, allow_class = "character", allow_NULL = TRUE) + meet_criteria(ylab, allow_class = "character", has_length = 1) + meet_criteria(xlab, allow_class = "character", has_length = 1) meet_criteria(colours_RSI, allow_class = "character", has_length = c(1, 3)) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) meet_criteria(expand, allow_class = "logical", has_length = 1) @@ -243,7 +241,7 @@ ggplot.mic <- function(data, title <- gsub(" +", " ", paste0(title, collapse = " ")) } - x <- plot_prepare_table(data, expand = expand) + x <- plot_prepare_table(object, expand = expand) cols_sub <- plot_colours_subtitle_guideline(x = x, mo = mo, ab = ab, @@ -262,11 +260,7 @@ ggplot.mic <- function(data, levels = translate_AMR(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"), language = language), ordered = TRUE) - if (!is.null(mapping)) { - p <- ggplot2::ggplot(df, mapping = mapping) - } else { - p <- ggplot2::ggplot(df) - } + p <- ggplot2::ggplot(df) if (any(colours_RSI %in% cols_sub$cols)) { vals <- c("Resistant" = colours_RSI[1], @@ -289,10 +283,6 @@ ggplot.mic <- function(data, ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub) } -#' @method autoplot mic -#' @rdname plot -# will be exported using s3_register() in R/zzz.R -autoplot.mic <- ggplot.mic #' @method plot disk #' @export @@ -427,21 +417,20 @@ barplot.disk <- function(height, ...) } -#' @method ggplot disk +#' @method autoplot disk #' @rdname plot # will be exported using s3_register() in R/zzz.R -ggplot.disk <- function(data, - mapping = NULL, - title = paste("Disk zones of", deparse(substitute(data))), - ylab = "Frequency", - xlab = "Disk diffusion diameter (mm)", - mo = NULL, - ab = NULL, - guideline = "EUCAST", - colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), - language = get_locale(), - expand = TRUE, - ...) { +autoplot.disk <- function(object, + mo = NULL, + ab = NULL, + title = paste("Disk zones of", deparse(substitute(object))), + ylab = "Frequency", + xlab = "Disk diffusion diameter (mm)", + guideline = "EUCAST", + colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), + language = get_locale(), + expand = TRUE, + ...) { stop_ifnot_installed("ggplot2") meet_criteria(title, allow_class = "character", allow_NULL = TRUE) meet_criteria(ylab, allow_class = "character", has_length = 1) @@ -468,7 +457,7 @@ ggplot.disk <- function(data, title <- gsub(" +", " ", paste0(title, collapse = " ")) } - x <- plot_prepare_table(data, expand = expand) + x <- plot_prepare_table(object, expand = expand) cols_sub <- plot_colours_subtitle_guideline(x = x, mo = mo, ab = ab, @@ -488,11 +477,7 @@ ggplot.disk <- function(data, levels = translate_AMR(c("Susceptible", plot_name_of_I(cols_sub$guideline), "Resistant"), language = language), ordered = TRUE) - if (!is.null(mapping)) { - p <- ggplot2::ggplot(df, mapping = mapping) - } else { - p <- ggplot2::ggplot(df) - } + p <- ggplot2::ggplot(df) if (any(colours_RSI %in% cols_sub$cols)) { vals <- c("Resistant" = colours_RSI[1], @@ -515,11 +500,6 @@ ggplot.disk <- function(data, ggplot2::labs(title = title, x = xlab, y = ylab, subtitle = cols_sub$sub) } -#' @method autoplot disk -#' @rdname plot -# will be exported using s3_register() in R/zzz.R -autoplot.disk <- ggplot.disk - #' @method plot rsi #' @export #' @importFrom graphics plot text axis @@ -618,17 +598,16 @@ barplot.rsi <- function(height, axis(2, seq(0, max(x))) } -#' @method ggplot rsi +#' @method autoplot rsi #' @rdname plot # will be exported using s3_register() in R/zzz.R -ggplot.rsi <- function(data, - mapping = NULL, - title = paste("Resistance Overview of", deparse(substitute(data))), - xlab = "Antimicrobial Interpretation", - ylab = "Frequency", - colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), - language = get_locale(), - ...) { +autoplot.rsi <- function(object, + title = paste("Resistance Overview of", deparse(substitute(object))), + xlab = "Antimicrobial Interpretation", + ylab = "Frequency", + colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"), + language = get_locale(), + ...) { stop_ifnot_installed("ggplot2") meet_criteria(title, allow_class = "character", allow_NULL = TRUE) meet_criteria(ylab, allow_class = "character", has_length = 1) @@ -654,15 +633,9 @@ ggplot.rsi <- function(data, colours_RSI <- rep(colours_RSI, 3) } - df <- as.data.frame(table(data), stringsAsFactors = TRUE) + df <- as.data.frame(table(object), stringsAsFactors = TRUE) colnames(df) <- c("rsi", "count") - if (!is.null(mapping)) { - p <- ggplot2::ggplot(df, mapping = mapping) - } else { - p <- ggplot2::ggplot(df) - } - - p + + ggplot2::ggplot(df) + ggplot2::geom_col(ggplot2::aes(x = rsi, y = count, fill = rsi)) + # limits = force is needed because of a ggplot2 >= 3.3.4 bug (#4511) ggplot2::scale_fill_manual(values = c("R" = colours_RSI[1], @@ -673,11 +646,6 @@ ggplot.rsi <- function(data, ggplot2::theme(legend.position = "none") } -#' @method autoplot rsi -#' @rdname plot -# will be exported using s3_register() in R/zzz.R -autoplot.rsi <- ggplot.rsi - plot_prepare_table <- function(x, expand) { x <- x[!is.na(x)] stop_if(length(x) == 0, "no observations to plot", call = FALSE) diff --git a/R/resistance_predict.R b/R/resistance_predict.R index 41295c37..fae7d544 100755 --- a/R/resistance_predict.R +++ b/R/resistance_predict.R @@ -23,7 +23,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -#' Predict antimicrobial resistance +#' Predict Antimicrobial Resistance #' #' Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns `se_min` and `se_max`. See *Examples* for a real live example. #' @inheritSection lifecycle Stable Lifecycle @@ -99,9 +99,9 @@ #' info = FALSE, #' minimum = 15) #' -#' ggplot(data) +#' autoplot(data) #' -#' ggplot(as.data.frame(data), +#' ggplot(data, #' aes(x = year)) + #' geom_col(aes(y = value), #' fill = "grey75") + @@ -394,20 +394,22 @@ ggplot_rsi_predict <- function(x, p } -#' @method ggplot resistance_predict -#' @rdname resistance_predict -# will be exported using s3_register() in R/zzz.R -ggplot.resistance_predict <- function(x, - main = paste("Resistance Prediction of", x_name), - ribbon = TRUE, - ...) { - x_name <- paste0(ab_name(attributes(x)$ab), " (", attributes(x)$ab, ")") - meet_criteria(main, allow_class = "character", has_length = 1) - meet_criteria(ribbon, allow_class = "logical", has_length = 1) - ggplot_rsi_predict(x = x, main = main, ribbon = ribbon, ...) -} - #' @method autoplot resistance_predict #' @rdname resistance_predict # will be exported using s3_register() in R/zzz.R -autoplot.resistance_predict <- ggplot.resistance_predict +autoplot.resistance_predict <- function(object, + main = paste("Resistance Prediction of", x_name), + ribbon = TRUE, + ...) { + x_name <- paste0(ab_name(attributes(object)$ab), " (", attributes(object)$ab, ")") + meet_criteria(main, allow_class = "character", has_length = 1) + meet_criteria(ribbon, allow_class = "logical", has_length = 1) + ggplot_rsi_predict(x = object, main = main, ribbon = ribbon, ...) +} + +#' @method fortify resistance_predict +#' @noRd +# will be exported using s3_register() in R/zzz.R +fortify.resistance_predict <- function(model, data, ...) { + as.data.frame(model) +} diff --git a/R/zzz.R b/R/zzz.R index b3241bcd..7acf1074 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -61,10 +61,6 @@ if (utf8_supported && !is_latex) { s3_register("skimr::get_skimmers", "rsi") s3_register("skimr::get_skimmers", "mic") s3_register("skimr::get_skimmers", "disk") - s3_register("ggplot2::ggplot", "rsi") - s3_register("ggplot2::ggplot", "mic") - s3_register("ggplot2::ggplot", "disk") - s3_register("ggplot2::ggplot", "resistance_predict") s3_register("ggplot2::autoplot", "rsi") s3_register("ggplot2::autoplot", "mic") s3_register("ggplot2::autoplot", "disk") diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 3d20283c..077fda62 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 0fb27c10..7f9294c7 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 933345c4..9decfecb 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 0d0c8bee..d9445c93 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 @@ -1007,7 +1007,7 @@ If you are reading this page from within R, please Interpretation from MIC values / disk diameters to R/SI

A data set with 22,000 rows and 10 columns, containing the following column names:
guideline, method, site, mo, ab, ref_tbl, disk_dose, breakpoint_S, breakpoint_R and uti.

This data set is in R available as rsi_translation, after you load the AMR package.

-

It was last updated on 12 July 2021 10:10:26 UTC. Find more info about the structure of this data set here.

+

It was last updated on 12 July 2021 10:54:20 UTC. Find more info about the structure of this data set here.

Direct download links:

  • Download as R file (37 kB)
    diff --git a/docs/articles/index.html b/docs/articles/index.html index bac05c9b..f5e0abd4 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/authors.html b/docs/authors.html index a626db04..5b844c8a 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/index.html b/docs/index.html index 1a495d95..0537dc67 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/news/index.html b/docs/news/index.html index a7768a03..136656c7 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 @@ -236,9 +236,9 @@ Source: NEWS.md -
    -

    - Unreleased AMR 1.7.1.9019

    +
    +

    + Unreleased AMR 1.7.1.9020

    Last updated: 12 July 2021 @@ -247,6 +247,7 @@

    Changed

      +
    • Previously implemented ggplot2::gggplot() generics for classes <mic>, <disk>, <rsi> and <resistance_predict> did not follow the ggplot2 logic, and were replaced with autoplot() generics.
    • Antibiotic class selectors (see ab_class())
      • They now also work in R-3.0 and R-3.1, supporting every version of R since 2013
      • @@ -257,8 +258,6 @@
    • Fix for duplicate ATC codes in the antibiotics data set
    • -
    • Added ggplot2::autoplot() generic for classes <mic>, <disk>, <rsi> and <resistance_predict> -
    • Fix to prevent introducing NAs for old MO codes when running as.mo() on them
    • Added more informative error messages when any of the proportion_*() and count_*() functions fail
    • When printing a tibble with any old MO code, a warning will be thrown that old codes should be updated using as.mo() @@ -268,9 +267,7 @@
    • The right input types for random_mic(), random_disk() and random_rsi() are now enforced
    • as.rsi() can now correct for textual input (such as “Susceptible”, “Resistant”) in Dutch, English, French, German, Italian, Portuguese and Spanish
    • -
    • When warnings are throws because of too few isolates in any count_*(), proportion_*() function (or resistant() or susceptible()), the dplyr group will be shown, if available
    • -
    • Taxonomic names now print in italic in tibbles, if created with mo_name(), mo_fullname(), mo_shortname(), mo_genus() or mo_family() -
    • +
    • When warnings are thrown because of too few isolates in any count_*(), proportion_*() function (or resistant() or susceptible()), the dplyr group will be shown, if available
    • ab_name() gained argument snake_case, which is useful for column renaming
    • Fix for legends created with scale_rsi_colours() when using ggplot2 v3.3.4 or higher (this is bug ggplot2#4511, soon to be fixed)
    • @@ -329,7 +326,7 @@
  • Function betalactams() as additional antbiotic column selector and function filter_betalactams() as additional antbiotic column filter. The group of betalactams consists of all carbapenems, cephalosporins and penicillins.
  • -
  • A ggplot() method for resistance_predict() +
  • A ggplot() method for resistance_predict()
@@ -430,7 +427,7 @@ #> 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

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

  • +
  • 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:

    @@ -487,7 +484,7 @@
     
  • 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)
  • Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see translate)
  • -
  • Plotting is now possible with base R using plot() and with ggplot2 using ggplot() on any vector of MIC and disk diffusion values
  • +
  • Plotting is now possible with base R using plot() and with ggplot2 using ggplot() on any vector of MIC and disk diffusion values
  • Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the microorganisms data set
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 0ae9b179..24053671 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-12T10:28Z +last_built: 2021-07-12T18:24Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index e5cde978..abeca8f7 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 diff --git a/docs/reference/index.html b/docs/reference/index.html index 838c378f..632ddf98 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.7.1.9019 + 1.7.1.9020 @@ -508,7 +508,7 @@ -

    plot(<mic>) ggplot(<mic>) autoplot(<mic>) plot(<disk>) ggplot(<disk>) autoplot(<disk>) plot(<rsi>) ggplot(<rsi>) autoplot(<rsi>)

    +

    plot(<mic>) autplot(<mic>) plot(<disk>) autoplot(<disk>) plot(<rsi>) autoplot(<rsi>)

    Plotting for Classes rsi, mic and disk

    @@ -532,9 +532,9 @@ -

    resistance_predict() rsi_predict() plot(<resistance_predict>) ggplot_rsi_predict() ggplot(<resistance_predict>) autoplot(<resistance_predict>)

    +

    resistance_predict() rsi_predict() plot(<resistance_predict>) ggplot_rsi_predict() autoplot(<resistance_predict>)

    -

    Predict antimicrobial resistance

    +

    Predict Antimicrobial Resistance

    diff --git a/docs/reference/plot.html b/docs/reference/plot.html index 9af46c49..974a080b 100644 --- a/docs/reference/plot.html +++ b/docs/reference/plot.html @@ -82,7 +82,7 @@ AMR (for R) - 1.7.1.9009 + 1.7.1.9020 @@ -245,12 +245,12 @@
    # S3 method for mic
     plot(
       x,
    +  mo = NULL,
    +  ab = NULL,
    +  guideline = "EUCAST",
       main = paste("MIC values of", deparse(substitute(x))),
       ylab = "Frequency",
       xlab = "Minimum Inhibitory Concentration (mg/L)",
    -  mo = NULL,
    -  ab = NULL,
    -  guideline = "EUCAST",
       colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
       language = get_locale(),
       expand = TRUE,
    @@ -258,31 +258,14 @@
     )
     
     # S3 method for mic
    -ggplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("MIC values of", deparse(substitute(data))),
    -  ylab = "Frequency",
    -  xlab = "Minimum Inhibitory Concentration (mg/L)",
    +autplot(
    +  object,
       mo = NULL,
       ab = NULL,
       guideline = "EUCAST",
    -  colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
    -  language = get_locale(),
    -  expand = TRUE,
    -  ...
    -)
    -
    -# S3 method for mic
    -autoplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("MIC values of", deparse(substitute(data))),
    +  title = paste("MIC values of", deparse(substitute(object))),
       ylab = "Frequency",
       xlab = "Minimum Inhibitory Concentration (mg/L)",
    -  mo = NULL,
    -  ab = NULL,
    -  guideline = "EUCAST",
       colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
       language = get_locale(),
       expand = TRUE,
    @@ -304,31 +287,14 @@
       ...
     )
     
    -# S3 method for disk
    -ggplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("Disk zones of", deparse(substitute(data))),
    -  ylab = "Frequency",
    -  xlab = "Disk diffusion diameter (mm)",
    -  mo = NULL,
    -  ab = NULL,
    -  guideline = "EUCAST",
    -  colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
    -  language = get_locale(),
    -  expand = TRUE,
    -  ...
    -)
    -
     # S3 method for disk
     autoplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("Disk zones of", deparse(substitute(data))),
    -  ylab = "Frequency",
    -  xlab = "Disk diffusion diameter (mm)",
    +  object,
       mo = NULL,
       ab = NULL,
    +  title = paste("Disk zones of", deparse(substitute(object))),
    +  ylab = "Frequency",
    +  xlab = "Disk diffusion diameter (mm)",
       guideline = "EUCAST",
       colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
       language = get_locale(),
    @@ -345,23 +311,10 @@
       ...
     )
     
    -# S3 method for rsi
    -ggplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("Resistance Overview of", deparse(substitute(data))),
    -  xlab = "Antimicrobial Interpretation",
    -  ylab = "Frequency",
    -  colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
    -  language = get_locale(),
    -  ...
    -)
    -
     # S3 method for rsi
     autoplot(
    -  data,
    -  mapping = NULL,
    -  title = paste("Resistance Overview of", deparse(substitute(data))),
    +  object,
    +  title = paste("Resistance Overview of", deparse(substitute(object))),
       xlab = "Antimicrobial Interpretation",
       ylab = "Frequency",
       colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
    @@ -373,16 +326,8 @@
         
    -      
    -      
    -    
    -    
    -      
    -      
    -    
    -    
    -      
    -      
    +      
    +      
    @@ -396,6 +341,14 @@
           
    +    
    +      
    +      
    +    
    +    
    +      
    +      
    +    
    @@ -412,27 +365,22 @@
           
    -    
    -      
    -      
    -    
    x, data

    MIC values created with as.mic() or disk diffusion values created with as.disk()

    main, title

    title of the plot

    xlab, ylab

    axis title

    x, object

    values created with as.mic(), as.disk() or as.rsi()

    moguideline

    interpretation guideline to use, defaults to the latest included EUCAST guideline, see Details

    main, title

    title of the plot

    xlab, ylab

    axis title

    colours_RSI

    colours to use for filling in the bars, must be a vector of three values (in the order R, S and I). The default colours are colour-blind friendly.

    ...

    arguments passed on to as.rsi()

    mapping

    aesthetic mappings to use for ggplot()

    Value

    -

    The ggplot functions return a ggplot model that is extendible with any ggplot2 function.

    +

    The autoplot() functions return a ggplot model that is extendible with any ggplot2 function.

    Details

    The interpretation of "I" will be named "Increased exposure" for all EUCAST guidelines since 2019, and will be named "Intermediate" in all other cases.

    For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the guideline argument are: "EUCAST 2021", "EUCAST 2020", "EUCAST 2019", "EUCAST 2018", "EUCAST 2017", "EUCAST 2016", "EUCAST 2015", "EUCAST 2014", "EUCAST 2013", "EUCAST 2012", "EUCAST 2011", "CLSI 2020", "CLSI 2019", "CLSI 2018", "CLSI 2017", "CLSI 2016", "CLSI 2015", "CLSI 2014", "CLSI 2013", "CLSI 2012", "CLSI 2011" and "CLSI 2010".

    Simply using "CLSI" or "EUCAST" as input will automatically select the latest version of that guideline.

    -

    Stable Lifecycle

    +

    Maturing Lifecycle

    -


    -The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

    -

    If the unlying code needs breaking changes, they will occur gradually. For example, a argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

    +


    +The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').

    Read more on Our Website!

    @@ -454,9 +402,9 @@ The lifecycle of this function is stable# \donttest{ if (require("ggplot2")) { - ggplot(some_mic_values) - ggplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") - ggplot(some_rsi_values) + autoplot(some_mic_values) + autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro") + autoplot(some_rsi_values) } # }
    diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index f0e2e8f4..dc842ee4 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -6,7 +6,7 @@ -Predict antimicrobial resistance — resistance_predict • AMR (for R) +Predict Antimicrobial Resistance — resistance_predict • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -82,7 +82,7 @@ AMR (for R) - 1.7.1.9005 + 1.7.1.9020 @@ -90,14 +90,14 @@