diff --git a/DESCRIPTION b/DESCRIPTION index a0092870..18a7ad0f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9012 -Date: 2019-01-25 +Date: 2019-01-26 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/NAMESPACE b/NAMESPACE index 4ef60676..aaf878ca 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -54,9 +54,16 @@ export(as.atc) export(as.mic) export(as.mo) export(as.rsi) -export(atc_ddd) -export(atc_groups) +export(atc_certe) +export(atc_name) +export(atc_official) +export(atc_online_ddd) +export(atc_online_groups) +export(atc_online_property) export(atc_property) +export(atc_tradenames) +export(atc_trivial_nl) +export(atc_umcg) export(brmo) export(count_I) export(count_IR) diff --git a/NEWS.md b/NEWS.md index 50dcadd1..0ddafb84 100755 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,17 @@ #### New * **BREAKING**: removed deprecated functions, parameters and references to 'bactid'. Use `as.mo()` to identify an MO code. +* All `ab_*` functions are deprecated and replaced by `atc_*` functions: + ```r + ab_property -> atc_property() + ab_name -> atc_name() + ab_official -> atc_official() + ab_trivial_nl -> atc_trivial_nl() + ab_certe -> atc_certe() + ab_umcg -> atc_umcg() + ab_tradenames -> atc_tradenames() + ``` + These functions use `as.atc()` internally. The old `atc_property` has been renamed `atc_online_property()`. This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class `atc` or must be coerable to this class. Properties of these classes should start with the same class name, analogous to `as.mo()` and e.g. `mo_genus`. * New website: https://msberends.gitlab.io/AMR (built with the great [`pkgdown`](https://pkgdown.r-lib.org/)) * Contains the complete manual of this package and all of its functions with an explanation of their parameters * Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis @@ -37,6 +48,8 @@ #### Changed * Added 65 antibiotics to the `antibiotics` data set, from the [Pharmaceuticals Community Register](http://ec.europa.eu/health/documents/community-register/html/atc.htm) of the European Commission * Removed columns `atc_group1_nl` and `atc_group2_nl` from the `antibiotics` data set +* Function `atc_ddd` has been renamed `atc_online_ddd()` +* Function `atc_groups` has been renamed `atc_online_groups()` * Function `eucast_rules()`: * Updated EUCAST Clinical breakpoints to [version 9.0 of 1 January 2019](http://www.eucast.org/clinical_breakpoints/) * Fixed a critical bug where some rules that depend on previous applied rules would not be applied adequately diff --git a/R/atc.R b/R/atc.R index 23cd1d1d..b68461d7 100755 --- a/R/atc.R +++ b/R/atc.R @@ -186,191 +186,3 @@ as.data.frame.atc <- function (x, ...) { pull.atc <- function(.data, ...) { pull(as.data.frame(.data), ...) } - -#' Properties of an ATC code -#' -#' Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. \cr \strong{This function requires an internet connection.} -#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s) -#' @param property property of an ATC code. Valid values are \code{"ATC"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"}, \code{"Note"} and \code{groups}. For this last option, all hierarchical groups of an ATC code will be returned, see Examples. -#' @param administration type of administration when using \code{property = "Adm.R"}, see Details -#' @param url url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes. -#' @param ... parameters to pass on to \code{atc_property} -#' @details -#' Options for parameter \code{administration}: -#' \itemize{ -#' \item{\code{"Implant"}}{ = Implant} -#' \item{\code{"Inhal"}}{ = Inhalation} -#' \item{\code{"Instill"}}{ = Instillation} -#' \item{\code{"N"}}{ = nasal} -#' \item{\code{"O"}}{ = oral} -#' \item{\code{"P"}}{ = parenteral} -#' \item{\code{"R"}}{ = rectal} -#' \item{\code{"SL"}}{ = sublingual/buccal} -#' \item{\code{"TD"}}{ = transdermal} -#' \item{\code{"V"}}{ = vaginal} -#' } -#' -#' Abbreviations of return values when using \code{property = "U"} (unit): -#' \itemize{ -#' \item{\code{"g"}}{ = gram} -#' \item{\code{"mg"}}{ = milligram} -#' \item{\code{"mcg"}}{ = microgram} -#' \item{\code{"U"}}{ = unit} -#' \item{\code{"TU"}}{ = thousand units} -#' \item{\code{"MU"}}{ = million units} -#' \item{\code{"mmol"}}{ = millimole} -#' \item{\code{"ml"}}{ = milliliter (e.g. eyedrops)} -#' } -#' @export -#' @rdname atc_property -#' @importFrom dplyr %>% progress_estimated -#' @importFrom xml2 read_html -#' @importFrom rvest html_children html_node html_nodes html_table -#' @importFrom curl nslookup -#' @source \url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/} -#' @examples -#' \donttest{ -#' # What's the ATC of amoxicillin? -#' guess_atc("Amoxicillin") -#' # [1] "J01CA04" -#' -#' # oral DDD (Defined Daily Dose) of amoxicillin -#' atc_property("J01CA04", "DDD", "O") -#' # parenteral DDD (Defined Daily Dose) of amoxicillin -#' atc_property("J01CA04", "DDD", "P") -#' -#' atc_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin -#' # [1] "ANTIINFECTIVES FOR SYSTEMIC USE" -#' # [2] "ANTIBACTERIALS FOR SYSTEMIC USE" -#' # [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS" -#' # [4] "Penicillins with extended spectrum" -#' } -atc_property <- function(atc_code, - property, - administration = 'O', - url = 'https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no') { - - # check active network interface, from https://stackoverflow.com/a/5078002/4575331 - has_internet <- function(url) { - # extract host from given url - # https://www.whocc.no/atc_ddd_index/ -> www.whocc.no - url <- url %>% - gsub("^(http://|https://)", "", .) %>% - strsplit('/', fixed = TRUE) %>% - unlist() %>% - .[1] - !is.null(curl::nslookup(url, error = FALSE)) - } - # check for connection using the ATC of amoxicillin - if (!has_internet(url = url)) { - message("The URL could not be reached.") - return(rep(NA, length(atc_code))) - } - - if (length(property) != 1L) { - stop('`property` must be of length 1', call. = FALSE) - } - if (length(administration) != 1L) { - stop('`administration` must be of length 1', call. = FALSE) - } - - # also allow unit as property - if (property %like% 'unit') { - property <- 'U' - } - - # validation of properties - valid_properties <- c("ATC", "Name", "DDD", "U", "Adm.R", "Note", "groups") - valid_properties.bak <- valid_properties - - property <- tolower(property) - valid_properties <- tolower(valid_properties) - - if (!property %in% valid_properties) { - stop('Invalid `property`, use one of ', paste(valid_properties.bak, collapse = ", "), '.') - } - - if (property == 'ddd') { - returnvalue <- rep(NA_real_, length(atc_code)) - } else if (property == 'groups') { - returnvalue <- list() - } else { - returnvalue <- rep(NA_character_, length(atc_code)) - } - - progress <- progress_estimated(n = length(atc_code)) - - for (i in 1:length(atc_code)) { - - progress$tick()$print() - - atc_url <- sub('%s', atc_code[i], url, fixed = TRUE) - - if (property == "groups") { - tbl <- xml2::read_html(atc_url) %>% - rvest::html_node("#content") %>% - rvest::html_children() %>% - rvest::html_node("a") - - # get URLS of items - hrefs <- tbl %>% rvest::html_attr("href") - # get text of items - texts <- tbl %>% rvest::html_text() - # select only text items where URL like "code=" - texts <- texts[grepl("?code=", tolower(hrefs), fixed = TRUE)] - # last one is antibiotics, skip it - texts <- texts[1:length(texts) - 1] - returnvalue <- c(list(texts), returnvalue) - - } else { - tbl <- xml2::read_html(atc_url) %>% - rvest::html_nodes('table') %>% - rvest::html_table(header = TRUE) %>% - as.data.frame(stringsAsFactors = FALSE) - - # case insensitive column names - colnames(tbl) <- tolower(colnames(tbl)) %>% gsub('^atc.*', 'atc', .) - - if (length(tbl) == 0) { - warning('ATC not found: ', atc_code[i], '. Please check ', atc_url, '.', call. = FALSE) - returnvalue[i] <- NA - next - } - - if (property %in% c('atc', 'name')) { - # ATC and name are only in first row - returnvalue[i] <- tbl[1, property] - } else { - if (!'adm.r' %in% colnames(tbl) | is.na(tbl[1, 'adm.r'])) { - returnvalue[i] <- NA - next - } else { - for (j in 1:nrow(tbl)) { - if (tbl[j, 'adm.r'] == administration) { - returnvalue[i] <- tbl[j, property] - } - } - } - } - } - } - - if (property == "groups" & length(returnvalue) == 1) { - returnvalue <- returnvalue[[1]] - } - - returnvalue -} - -#' @rdname atc_property -#' @export -atc_groups <- function(atc_code, ...) { - atc_property(atc_code = atc_code, property = "groups", ...) -} - -#' @rdname atc_property -#' @export -atc_ddd <- function(atc_code, ...) { - atc_property(atc_code = atc_code, property = "ddd", ...) -} - diff --git a/R/atc_online.R b/R/atc_online.R new file mode 100644 index 00000000..6461cc02 --- /dev/null +++ b/R/atc_online.R @@ -0,0 +1,204 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # +# # +# 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. # +# # +# This R package was created for academic research and was publicly # +# released in the hope that it will be useful, but it comes WITHOUT # +# ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitab.io/AMR. # +# ==================================================================== # + +#' Properties of an ATC code +#' +#' Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. \cr \strong{This function requires an internet connection.} +#' @param atc_code a character or character vector with ATC code(s) of antibiotic(s) +#' @param property property of an ATC code. Valid values are \code{"ATC"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"}, \code{"Note"} and \code{groups}. For this last option, all hierarchical groups of an ATC code will be returned, see Examples. +#' @param administration type of administration when using \code{property = "Adm.R"}, see Details +#' @param url url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes. +#' @param ... parameters to pass on to \code{atc_property} +#' @details +#' Options for parameter \code{administration}: +#' \itemize{ +#' \item{\code{"Implant"}}{ = Implant} +#' \item{\code{"Inhal"}}{ = Inhalation} +#' \item{\code{"Instill"}}{ = Instillation} +#' \item{\code{"N"}}{ = nasal} +#' \item{\code{"O"}}{ = oral} +#' \item{\code{"P"}}{ = parenteral} +#' \item{\code{"R"}}{ = rectal} +#' \item{\code{"SL"}}{ = sublingual/buccal} +#' \item{\code{"TD"}}{ = transdermal} +#' \item{\code{"V"}}{ = vaginal} +#' } +#' +#' Abbreviations of return values when using \code{property = "U"} (unit): +#' \itemize{ +#' \item{\code{"g"}}{ = gram} +#' \item{\code{"mg"}}{ = milligram} +#' \item{\code{"mcg"}}{ = microgram} +#' \item{\code{"U"}}{ = unit} +#' \item{\code{"TU"}}{ = thousand units} +#' \item{\code{"MU"}}{ = million units} +#' \item{\code{"mmol"}}{ = millimole} +#' \item{\code{"ml"}}{ = milliliter (e.g. eyedrops)} +#' } +#' @export +#' @rdname atc_online +#' @importFrom dplyr %>% progress_estimated +#' @importFrom xml2 read_html +#' @importFrom rvest html_children html_node html_nodes html_table +#' @importFrom curl nslookup +#' @source \url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/} +#' @examples +#' \donttest{ +#' # oral DDD (Defined Daily Dose) of amoxicillin +#' atc_online_property("J01CA04", "DDD", "O") +#' # parenteral DDD (Defined Daily Dose) of amoxicillin +#' atc_online_property("J01CA04", "DDD", "P") +#' +#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin +#' # [1] "ANTIINFECTIVES FOR SYSTEMIC USE" +#' # [2] "ANTIBACTERIALS FOR SYSTEMIC USE" +#' # [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS" +#' # [4] "Penicillins with extended spectrum" +#' } +atc_online_property <- function(atc_code, + property, + administration = 'O', + url = 'https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no') { + + # check active network interface, from https://stackoverflow.com/a/5078002/4575331 + has_internet <- function(url) { + # extract host from given url + # https://www.whocc.no/atc_ddd_index/ -> www.whocc.no + url <- url %>% + gsub("^(http://|https://)", "", .) %>% + strsplit('/', fixed = TRUE) %>% + unlist() %>% + .[1] + !is.null(curl::nslookup(url, error = FALSE)) + } + # check for connection using the ATC of amoxicillin + if (!has_internet(url = url)) { + message("The URL could not be reached.") + return(rep(NA, length(atc_code))) + } + + if (length(property) != 1L) { + stop('`property` must be of length 1', call. = FALSE) + } + if (length(administration) != 1L) { + stop('`administration` must be of length 1', call. = FALSE) + } + + # also allow unit as property + if (property %like% 'unit') { + property <- 'U' + } + + # validation of properties + valid_properties <- c("ATC", "Name", "DDD", "U", "Adm.R", "Note", "groups") + valid_properties.bak <- valid_properties + + property <- tolower(property) + valid_properties <- tolower(valid_properties) + + if (!property %in% valid_properties) { + stop('Invalid `property`, use one of ', paste(valid_properties.bak, collapse = ", "), '.') + } + + if (property == 'ddd') { + returnvalue <- rep(NA_real_, length(atc_code)) + } else if (property == 'groups') { + returnvalue <- list() + } else { + returnvalue <- rep(NA_character_, length(atc_code)) + } + + progress <- progress_estimated(n = length(atc_code)) + + for (i in 1:length(atc_code)) { + + progress$tick()$print() + + atc_url <- sub('%s', atc_code[i], url, fixed = TRUE) + + if (property == "groups") { + tbl <- xml2::read_html(atc_url) %>% + rvest::html_node("#content") %>% + rvest::html_children() %>% + rvest::html_node("a") + + # get URLS of items + hrefs <- tbl %>% rvest::html_attr("href") + # get text of items + texts <- tbl %>% rvest::html_text() + # select only text items where URL like "code=" + texts <- texts[grepl("?code=", tolower(hrefs), fixed = TRUE)] + # last one is antibiotics, skip it + texts <- texts[1:length(texts) - 1] + returnvalue <- c(list(texts), returnvalue) + + } else { + tbl <- xml2::read_html(atc_url) %>% + rvest::html_nodes('table') %>% + rvest::html_table(header = TRUE) %>% + as.data.frame(stringsAsFactors = FALSE) + + # case insensitive column names + colnames(tbl) <- tolower(colnames(tbl)) %>% gsub('^atc.*', 'atc', .) + + if (length(tbl) == 0) { + warning('ATC not found: ', atc_code[i], '. Please check ', atc_url, '.', call. = FALSE) + returnvalue[i] <- NA + next + } + + if (property %in% c('atc', 'name')) { + # ATC and name are only in first row + returnvalue[i] <- tbl[1, property] + } else { + if (!'adm.r' %in% colnames(tbl) | is.na(tbl[1, 'adm.r'])) { + returnvalue[i] <- NA + next + } else { + for (j in 1:nrow(tbl)) { + if (tbl[j, 'adm.r'] == administration) { + returnvalue[i] <- tbl[j, property] + } + } + } + } + } + } + + if (property == "groups" & length(returnvalue) == 1) { + returnvalue <- returnvalue[[1]] + } + + returnvalue +} + +#' @rdname atc_online +#' @export +atc_online_groups <- function(atc_code, ...) { + atc_online_property(atc_code = atc_code, property = "groups", ...) +} + +#' @rdname atc_online +#' @export +atc_online_ddd <- function(atc_code, ...) { + atc_online_property(atc_code = atc_code, property = "ddd", ...) +} + diff --git a/R/ab_property.R b/R/atc_property.R similarity index 74% rename from R/ab_property.R rename to R/atc_property.R index 97412f17..36a98486 100755 --- a/R/ab_property.R +++ b/R/atc_property.R @@ -25,20 +25,20 @@ #' @param x a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}} #' @param property one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"} #' @param language language of the returned text, defaults to English (\code{"en"}) and can be set with \code{\link{getOption}("AMR_locale")}. Either one of \code{"en"} (English) or \code{"nl"} (Dutch). -#' @rdname ab_property -#' @return A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. +#' @rdname atc_property +#' @return A vector of values. In case of \code{atc_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. #' @export #' @importFrom dplyr %>% left_join pull #' @seealso \code{\link{antibiotics}} #' @inheritSection AMR Read more on our website! #' @examples -#' ab_atc("amcl") # J01CR02 -#' ab_name("amcl") # Amoxicillin and beta-lactamase inhibitor -#' ab_name("amcl", "nl") # Amoxicilline met enzymremmer -#' ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur -#' ab_certe("amcl") # amcl -#' ab_umcg("amcl") # AMCL -ab_property <- function(x, property = 'official') { +#' as.atc("amcl") # J01CR02 +#' atc_name("amcl") # Amoxicillin and beta-lactamase inhibitor +#' atc_name("amcl", "nl") # Amoxicilline met enzymremmer +#' atc_trivial_nl("amcl") # Amoxicilline/clavulaanzuur +#' atc_certe("amcl") # amcl +#' atc_umcg("amcl") # AMCL +atc_property <- function(x, property = 'official') { property <- property[1] if (!property %in% colnames(AMR::antibiotics)) { stop("invalid property: ", property, " - use a column name of the `antibiotics` data set") @@ -53,15 +53,9 @@ ab_property <- function(x, property = 'official') { ) } -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_atc <- function(x) { - as.character(as.atc(x)) -} - -#' @rdname ab_property -#' @export -ab_official <- function(x, language = NULL) { +atc_official <- function(x, language = NULL) { if (is.null(language)) { language <- getOption("AMR_locale", default = "en")[1L] @@ -69,40 +63,40 @@ ab_official <- function(x, language = NULL) { language <- tolower(language[1]) } if (language %in% c("en", "")) { - ab_property(x, "official") + atc_property(x, "official") } else if (language == "nl") { - ab_property(x, "official_nl") + atc_property(x, "official_nl") } else { stop("Unsupported language: '", language, "' - use one of: 'en', 'nl'", call. = FALSE) } } -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_name <- ab_official +atc_name <- atc_official -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_trivial_nl <- function(x) { - ab_property(x, "trivial_nl") +atc_trivial_nl <- function(x) { + atc_property(x, "trivial_nl") } -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_certe <- function(x) { - ab_property(x, "certe") +atc_certe <- function(x) { + atc_property(x, "certe") } -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_umcg <- function(x) { - ab_property(x, "umcg") +atc_umcg <- function(x) { + atc_property(x, "umcg") } -#' @rdname ab_property +#' @rdname atc_property #' @export -ab_tradenames <- function(x) { - res <- ab_property(x, "trade_name") +atc_tradenames <- function(x) { + res <- atc_property(x, "trade_name") res <- strsplit(res, "|", fixed = TRUE) if (length(x) == 1) { res <- unlist(res) diff --git a/R/deprecated.R b/R/deprecated.R index a5559954..8c13028f 100755 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -21,7 +21,7 @@ #' Deprecated functions #' -#' These functions are \link{Deprecated}. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by. +#' These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one). #' @inheritSection AMR Read more on our website! #' @export #' @keywords internal @@ -53,3 +53,59 @@ guess_mo <- function(...) { .Deprecated(new = "as.mo", package = "AMR") as.mo(...) } + +#' @rdname AMR-deprecated +#' @export +ab_property <- function(...) { + .Deprecated(new = "atc_property", package = "AMR") + atc_property(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_atc <- function(...) { + .Deprecated(new = "as.atc", package = "AMR") + as.atc(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_official <- function(...) { + .Deprecated(new = "atc_official", package = "AMR") + atc_official(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_name <- function(...) { + .Deprecated(new = "atc_name", package = "AMR") + atc_name(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_trivial_nl <- function(...) { + .Deprecated(new = "atc_trivial_nl", package = "AMR") + atc_trivial_nl(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_certe <- function(...) { + .Deprecated(new = "atc_certe", package = "AMR") + atc_certe(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_umcg <- function(...) { + .Deprecated(new = "atc_umcg", package = "AMR") + atc_umcg(...) +} + +#' @rdname AMR-deprecated +#' @export +ab_tradenames <- function(...) { + .Deprecated(new = "atc_tradenames", package = "AMR") + atc_tradenames(...) +} diff --git a/R/zzz.R b/R/zzz.R index 585052ac..592756bc 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -25,7 +25,7 @@ #' @details #' This package was intended to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. #' -#' This package was created for academic research by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). +#' This package was created for both academic research and routine analysis by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). #' @section Read more on our website!: #' \if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr} #' On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a omprehensive tutorial} about how to conduct AMR analysis and find \href{https://msberends.gitlab.io/AMR/reference}{the complete documentation of all functions}, which reads a lot easier than in R. diff --git a/_pkgdown.yml b/_pkgdown.yml index 8c169cd7..29f376b6 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -104,8 +104,8 @@ reference: - '`mdro`' - '`key_antibiotics`' - '`mo_property`' - - '`ab_property`' - '`atc_property`' + - '`atc_online_property`' - '`abname`' - '`age`' - '`age_groups`' @@ -146,6 +146,8 @@ reference: - '`like`' - '`mo_failures`' - '`mo_renamed`' + - '`ab_property`' + authors: Matthijs S. Berends: diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 2929e674..34234277 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -178,7 +178,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

@@ -187,7 +187,7 @@ -

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 25 January 2019.

+

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 26 January 2019.

Introduction

@@ -203,21 +203,21 @@ -2019-01-25 +2019-01-26 abcd Escherichia coli S S -2019-01-25 +2019-01-26 abcd Escherichia coli S R -2019-01-25 +2019-01-26 efgh Escherichia coli R @@ -229,11 +229,14 @@

Needed R packages

-

As with many uses in R, we need some additional packages for AMR analysis. The most important one is dplyr, which tremendously improves the way we work with data - it allows for a very natural way of writing syntaxes in R. Another important dependency is ggplot2. This package can be used to create beautiful plots in R.

+

As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the tidyverse packages dplyr and ggplot2 by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.

Our AMR package depends on these packages and even extends their use and functions.

-
library(dplyr)   # the data science package
-library(AMR)     # this package, to simplify and automate AMR analysis
-library(ggplot2) # for appealing plots
+

@@ -275,18 +278,18 @@

Put everything together

-

Using the sample() function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the prob parameter.

-
data <- data.frame(date = sample(dates, 5000, replace = TRUE),
-                   patient_id = sample(patients, 5000, replace = TRUE),
-                   hospital = sample(hospitals, 5000, replace = TRUE, prob = c(0.30, 0.35, 0.15, 0.20)),
-                   bacteria = sample(bacteria, 5000, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)),
-                   amox = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.60, 0.05, 0.35)),
-                   amcl = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.75, 0.10, 0.15)),
-                   cipr = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.80, 0.00, 0.20)),
-                   gent = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.92, 0.00, 0.08))
+

Using the sample() function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the prob parameter.

+
data <- data.frame(date = sample(dates, 5000, replace = TRUE),
+                   patient_id = sample(patients, 5000, replace = TRUE),
+                   hospital = sample(hospitals, 5000, replace = TRUE, prob = c(0.30, 0.35, 0.15, 0.20)),
+                   bacteria = sample(bacteria, 5000, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)),
+                   amox = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.60, 0.05, 0.35)),
+                   amcl = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.75, 0.10, 0.15)),
+                   cipr = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.80, 0.00, 0.20)),
+                   gent = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.92, 0.00, 0.08))
                    )
-

Using the left_join() function from the dplyr package, we can ‘map’ the gender to the patient ID using the patients_table object we created earlier:

- +

Using the left_join() function from the dplyr package, we can ‘map’ the gender to the patient ID using the patients_table object we created earlier:

+

The resulting data set contains 5,000 blood culture isolates. With the head() function we can preview the first 6 values of this data set:

head(data)
@@ -303,32 +306,32 @@ - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + @@ -336,10 +339,10 @@ - - + + - + @@ -347,24 +350,24 @@ - - + + + + - - - + - - - - - + + + + + @@ -386,15 +389,15 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------ -------- ----------- ------------- -# 1 M 2,653 53.1% 2,653 53.1% -# 2 F 2,347 46.9% 5,000 100.0% +# 1 M 2,593 51.9% 2,593 51.9% +# 2 F 2,407 48.1% 5,000 100.0%

So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values M and F. From a researcher perspective: there are slightly more men. Nothing we didn’t already know.

-

The data is already quite clean, but we still need to transform some variables. The bacteria column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate() function of the dplyr package makes this really easy:

+

The data is already quite clean, but we still need to transform some variables. The bacteria column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate() function of the dplyr package makes this really easy:

data <- data %>%
-  mutate(bacteria = as.mo(bacteria))
-

We also want to transform the antibiotics, because in real life data we don’t know if they are really clean. The as.rsi() function ensures reliability and reproducibility in these kind of variables. The mutate_at() will run the as.rsi() function on defined variables:

+ mutate(bacteria =as.mo(bacteria)) +

We also want to transform the antibiotics, because in real life data we don’t know if they are really clean. The as.rsi() function ensures reliability and reproducibility in these kind of variables. The mutate_at() will run the as.rsi() function on defined variables:

data <- data %>%
-  mutate_at(vars(amox:gent), as.rsi)
+ mutate_at(vars(amox:gent), as.rsi)

Finally, we will apply EUCAST rules on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the eucast_rules() function can also apply additional rules, like forcing ampicillin = R when amoxicillin/clavulanic acid = R.

Because the amoxicillin (column amox) and amoxicillin/clavulanic acid (column amcl) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The eucast_rules() fixes this:

+# => EUCAST rules affected 1,860 out of 5,000 rows -> changed 1,018 test results.

Adding new variables

Now that we have the microbial ID, we can add some taxonomic properties:

data <- data %>% 
-  mutate(gramstain = mo_gramstain(bacteria),
+  mutate(gramstain = mo_gramstain(bacteria),
          genus = mo_genus(bacteria),
          species = mo_species(bacteria))
@@ -458,14 +461,14 @@

This AMR package includes this methodology with the first_isolate() function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:

-

So only 58.6% is suitable for resistance analysis! We can now filter on is with the filter() function, also from the dplyr package:

+# => Found 2,924 first isolates (58.5% of total)
+

So only 58.5% is suitable for resistance analysis! We can now filter on is with the filter() function, also from the dplyr package:

+ filter(first == TRUE)

For future use, the above two syntaxes can be shortened with the filter_first_isolate() function:

@@ -489,41 +492,30 @@ - - + + + - - + - - + + - - + + - - - - - - - - - - - - - + + @@ -531,86 +523,97 @@ + + + + + + + + + + + - - + + + + - - - + - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + - - - + - - + + + + + + + + + + + + + - - - - - - - - - - -
2013-03-25O52012-01-02K9Hospital AEscherichia coliISSSM
2011-05-22Y3 Hospital B Streptococcus pneumoniae S SRSF
2014-05-07W10Hospital AKlebsiella pneumoniaeRS S S F
2014-08-13L5Hospital DEscherichia coli2015-11-10F1Hospital CStaphylococcus aureus S S SM
2014-07-10Z22011-10-10X7 Hospital DEscherichia coliStaphylococcus aureus R S SF
2014-09-18Z92017-11-10B3 Hospital D Staphylococcus aureusR SR SSSFM
2015-04-27Q3Hospital CEscherichia coliS2014-11-09O5Hospital BKlebsiella pneumoniae S SR S F
12010-03-08V62010-08-27Q10 B_ESCHR_COLR SSSR S TRUE
22011-02-03V62010-10-24Q10 B_ESCHR_COLR S SRSS FALSE
32011-12-31V6B_ESCHR_COLSISSTRUE
42012-10-20V62010-10-26Q10 B_ESCHR_COL S SS FALSE
42011-12-25Q10B_ESCHR_COLRSSSTRUE
52012-12-17V62012-05-04Q10 B_ESCHR_COLII SSSSR FALSE
62013-08-27V62012-05-18Q10B_ESCHR_COLSISSFALSE
72012-05-23Q10 B_ESCHR_COLR SSSTRUE
72013-09-21V6B_ESCHR_COL I S SR FALSE
82014-07-19V62012-06-18Q10 B_ESCHR_COLRR SSSSR FALSE
92014-07-24V62013-10-02Q10 B_ESCHR_COLSS R STRUE
102013-10-22Q10B_ESCHR_COLSS S S FALSE
102014-11-23V6B_ESCHR_COLSSSSTRUE
-

Only 4 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and show be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

+

Only 3 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and show be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

If a column exists with a name like ‘key(…)ab’ the first_isolate() function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:

+# => Found 4,414 first weighted isolates (88.3% of total)
@@ -627,68 +630,44 @@ - - + + + - - + - - + + - - + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -698,67 +677,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - + - - + + + + - - - + - - + + + + + + + + + + + + + + - - - - - - - - - - - -
isolate
12010-03-08V62010-08-27Q10 B_ESCHR_COLR SSSR S TRUE TRUE
22011-02-03V62010-10-24Q10 B_ESCHR_COLR S SRSS FALSE TRUE
32011-12-31V62010-10-26Q10 B_ESCHR_COL SI S STRUETRUESFALSEFALSE
42012-10-20V6B_ESCHR_COLSSSSFALSEFALSE
52012-12-17V6B_ESCHR_COLSSSSFALSEFALSE
62013-08-27V62011-12-25Q10 B_ESCHR_COL R STRUE
52012-05-04Q10B_ESCHR_COLIISRFALSETRUE
62012-05-18Q10B_ESCHR_COLSISSFALSETRUE
72013-09-21V62012-05-23Q10 B_ESCHR_COLS I S SR FALSETRUEFALSE
82014-07-19V62012-06-18Q10 B_ESCHR_COLRR SSSSR FALSE TRUE
92014-07-24V62013-10-02Q10 B_ESCHR_COLSS R STRUETRUE
102013-10-22Q10B_ESCHR_COLSS S S FALSE TRUE
102014-11-23V6B_ESCHR_COLSSSSTRUETRUE
-

Instead of 4, now 8 isolates are flagged. In total, 88.4% of all isolates are marked ‘first weighted’ - 147% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

+

Instead of 3, now 8 isolates are flagged. In total, 88.3% of all isolates are marked ‘first weighted’ - 146.8% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

As with filter_first_isolate(), there’s a shortcut for this new algorithm too:

-

So we end up with 4,422 isolates for analysis.

+

So we end up with 4,414 isolates for analysis.

We can remove unneeded columns:

+ select(-c(first, keyab))

Now our data looks like:

head(data_1st)
+ @@ -775,13 +779,14 @@ - - + + + - + @@ -790,56 +795,28 @@ - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - + + + - - + + + - + @@ -850,15 +827,48 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -879,7 +889,7 @@
data_1st %>% freq(genus, species)

Frequency table of genus and species
Columns: 2
-Length: 4,422 (of which NA: 0 = 0.00%)
+Length: 4,414 (of which NA: 0 = 0.00%)
Unique: 4

Shortest: 16
Longest: 24

@@ -896,33 +906,33 @@ Longest: 24

- - - - + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -932,11 +942,11 @@ Longest: 24

Resistance percentages

The functions portion_R, portion_RI, portion_I, portion_IS and portion_S can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:

-

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

+# [1] 0.4857272 +

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

data_1st %>% 
-  group_by(hospital) %>% 
-  summarise(amoxicillin = portion_IR(amox))
+ group_by(hospital) %>% + summarise(amoxicillin =portion_IR(amox))
date patient_id hospital
2013-03-25O522011-05-22Y3 Hospital B B_STRPTC_PNE S SRS R F Gram positiveTRUE
2014-05-07W10Hospital AB_KLBSL_PNERSSSFGram negativeKlebsiellapneumoniaeTRUE
2014-08-13L5Hospital DB_ESCHR_COL32015-11-10F1Hospital CB_STPHY_AUR S S S S MGram negativeEscherichiacoliTRUE
2014-07-10Z2Hospital DB_ESCHR_COLRSSSFGram negativeEscherichiacoliGram positiveStaphylococcusaureus TRUE
2014-09-18Z942011-10-10X7 Hospital D B_STPHY_AURSR S S STRUE
2015-04-27Q3Hospital C52017-11-10B3Hospital DB_STPHY_AURRSRSMGram positiveStaphylococcusaureusTRUE
62014-11-09O5Hospital BB_KLBSL_PNERSRSFGram negativeKlebsiellapneumoniaeTRUE
72013-01-26F4Hospital B B_ESCHR_COL S S S SFM Gram negative Escherichia coli
1 Escherichia coli2,18349.4%2,18349.4%2,15348.8%2,15348.8%
2 Staphylococcus aureus1,12025.3%3,30374.7%1,10725.1%3,26073.9%
3 Streptococcus pneumoniae66615.1%3,96989.8%67715.3%3,93789.2%
4 Klebsiella pneumoniae45310.2%4,42247710.8%4,414 100.0%
@@ -945,26 +955,26 @@ Longest: 24

- + - + - + - +
hospital
Hospital A0.49807840.4615385
Hospital B0.45163320.4961089
Hospital C0.47058820.4975767
Hospital D0.47678370.4942288
-

Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi() can be used, which works exactly like n_distinct() from the dplyr package. It counts all isolates available for every group (i.e. values S, I or R):

+

Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi() can be used, which works exactly like n_distinct() from the dplyr package. It counts all isolates available for every group (i.e. values S, I or R):

data_1st %>% 
-  group_by(hospital) %>% 
-  summarise(amoxicillin = portion_IR(amox),
+  group_by(hospital) %>% 
+  summarise(amoxicillin = portion_IR(amox),
             available = n_rsi(amox))
@@ -975,30 +985,30 @@ Longest: 24

- - + + - - + + - - + + - - + +
Hospital A0.498078413010.46153851300
Hospital B0.451633215920.49610891542
Hospital C0.47058826460.4975767619
Hospital D0.47678378830.4942288953

These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:

data_1st %>% 
-  group_by(genus) %>% 
-  summarise(amoxicillin = portion_S(amcl),
+  group_by(genus) %>% 
+  summarise(amoxicillin = portion_S(amcl),
             gentamicin = portion_S(gent),
             "amox + gent" = portion_S(amcl, gent))
@@ -1011,34 +1021,34 @@ Longest: 24

- - - + + + - - - + + + - - - + + + - + - +
Escherichia0.74988550.90792490.97755380.74454250.91732470.9804923
Klebsiella0.75055190.90066230.97130240.71698110.91194970.9769392
Staphylococcus0.74375000.91964290.97678570.77055100.91689250.9828365
Streptococcus0.73573570.7474151 0.00000000.73573570.7474151

To make a transition to the next part, let’s see how this difference could be plotted:

data_1st %>% 
-  group_by(genus) %>% 
-  summarise("1. Amoxicillin" = portion_S(amcl),
+  group_by(genus) %>% 
+  summarise("1. Amoxicillin" = portion_S(amcl),
             "2. Gentamicin" = portion_S(gent),
             "3. Amox + gent" = portion_S(amcl, gent)) %>% 
   tidyr::gather("Antibiotic", "S", -genus) %>%
@@ -1071,7 +1081,7 @@ Longest: 24

Omit the translate_ab = FALSE to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin).

If we group on e.g. the genus column and add some additional functions from our package, we can create this:

# group the data on `genus`
-ggplot(data_1st %>% group_by(genus)) + 
+ggplot(data_1st %>% group_by(genus)) + 
   # create bars with genus on x axis
   # it looks for variables with class `rsi`,
   # of which we have 4 (earlier created with `as.rsi`)
@@ -1093,7 +1103,7 @@ Longest: 24

To simplify this, we also created the ggplot_rsi() function, which combines almost all above functions:

data_1st %>% 
-  group_by(genus) %>%
+  group_by(genus) %>%
   ggplot_rsi(x = "genus",
              facet = "Antibiotic",
              breaks = 0:4 * 25,
@@ -1127,12 +1137,12 @@ Longest: 24

We can transform the data and apply the test in only a couple of lines:

septic_patients %>%
-  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
-  select(hospital_id, fosf) %>%            # select the hospitals and fosfomycin
-  group_by(hospital_id) %>%                # group on the hospitals
+  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
+  select(hospital_id, fosf) %>%            # select the hospitals and fosfomycin
+  group_by(hospital_id) %>%                # group on the hospitals
   count_df(combine_IR = TRUE) %>%          # count all isolates per group (hospital_id)
   tidyr::spread(hospital_id, Value) %>%    # transform output so A and D are columns
-  select(A, D) %>%                         # and select these only
+  select(A, D) %>%                         # and select these only
   as.matrix() %>%                          # transform to good old matrix for fisher.test()
   fisher.test()                            # do Fisher's Exact Test
 # 
diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png
index c668b4fd..cfd432d9 100644
Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ
diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png
index 07a7ae2d..99177314 100644
Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ
diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png
index ce2ce98d..04478c71 100644
Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ
diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png
index 448130d7..aa523929 100644
Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ
diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html
index fd36c25f..577986e8 100644
--- a/docs/articles/EUCAST.html
+++ b/docs/articles/EUCAST.html
@@ -178,7 +178,7 @@
       

How to apply EUCAST rules

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/articles/G_test.html b/docs/articles/G_test.html index 6cb2e9a2..7994429a 100644 --- a/docs/articles/G_test.html +++ b/docs/articles/G_test.html @@ -178,7 +178,7 @@

How to use the G-test

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/articles/Predict.html b/docs/articles/Predict.html index 1855e80c..1099d4d7 100644 --- a/docs/articles/Predict.html +++ b/docs/articles/Predict.html @@ -178,7 +178,7 @@

How to predict antimicrobial resistance

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/articles/ab_property.html b/docs/articles/ab_property.html index 193760fa..646f2b66 100644 --- a/docs/articles/ab_property.html +++ b/docs/articles/ab_property.html @@ -178,7 +178,7 @@

How to get properties of an antibiotic

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index b58129a7..5336f0bd 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -178,7 +178,7 @@

Benchmarks

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

@@ -240,15 +240,15 @@
library(dplyr)
 # take 500,000 random MO codes from the septic_patients data set
 x = septic_patients %>%
-  sample_n(500000, replace = TRUE) %>%
-  pull(mo)
+  sample_n(500000, replace = TRUE) %>%
+  pull(mo)
   
 # got the right length?
 length(x)
 # [1] 500000
 
 # and how many unique values do we have?
-n_distinct(x)
+n_distinct(x)
 # [1] 96
 
 # only 96, but distributed in 500,000 results. now let's see:
diff --git a/docs/articles/freq.html b/docs/articles/freq.html
index 8156c10b..fdba7fd2 100644
--- a/docs/articles/freq.html
+++ b/docs/articles/freq.html
@@ -178,7 +178,7 @@
       

How to create frequency tables

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/articles/mo_property.html b/docs/articles/mo_property.html index 1f380407..23456cc7 100644 --- a/docs/articles/mo_property.html +++ b/docs/articles/mo_property.html @@ -178,7 +178,7 @@

How to get properties of a microorganism

Matthijs S. Berends

-

25 January 2019

+

26 January 2019

diff --git a/docs/extra.css b/docs/extra.css index 8fd48767..bab9e252 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -71,7 +71,7 @@ pre, code { font-family: 'Courier New', monospace; font-size: 100% !important; font-weight: bold; - background-color: transparent; + background-color: #f4f4f4; } pre { font-size: 90% !important; @@ -84,7 +84,7 @@ kbd { font-size: small; vertical-align: text-bottom; color: #2c3e50; - background: #eee; + background: #eeeeee; font-weight: bold; } diff --git a/docs/index.html b/docs/index.html index 84b5d2f6..f4f8b940 100644 --- a/docs/index.html +++ b/docs/index.html @@ -178,14 +178,26 @@

(TLDR - to find out how to conduct AMR analysis, please continue reading here to get started.


AMR is a free and open-source R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods.

-

We created this package for academic research at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation. Read further about our GPL-2 licence here.

+

We created this package for both academic research and routine analysis at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is actively maintained and free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public Licence version 2.0 (GPL-2), as published by the Free Software Foundation. Read the full licence here.

+

This package can be used for:

+
    +
  • Calculating antimicrobial resistance
  • +
  • Predicting antimicrobial resistance using regression models
  • +
  • Getting properties for any microorganism (like Gram stain, species, genus or family)
  • +
  • Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)
  • +
  • Plotting antimicrobial resistance
  • +
  • Determining first isolates to be used for AMR analysis
  • +
  • Applying EUCAST rules
  • +
  • Determining multi-drug resistance organisms (MDRO)
  • +
  • Descriptive statistics: frequency tables, kurtosis and skewness
  • +

This package is ready-to-use for a professional environment by specialists in the following fields:

-

Medical Microbiology:

+

Medical Microbiology

  • Epidemiologists (both clinical microbiological and research)
  • Research Microbiologists
  • @@ -193,18 +205,18 @@
  • Research Pharmacologists
  • Data Scientists / Data Analysts
-

Veterinary Microbiology:

+

Veterinary Microbiology

  • Research Veterinarians
  • Veterinary Epidemiologists
-

Microbial Ecology:

+

Microbial Ecology

  • Soil Microbiologists
  • Extremophile Researchers
  • Astrobiologists
-

Developers:

+

Developers

  • Package developers for R
  • Software developers
  • @@ -267,7 +279,7 @@
  • Use mdro() (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported.
  • The data set microorganisms contains the complete taxonomic tree of more than 18,000 microorganisms (bacteria, fungi/yeasts and protozoa). Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). As they use as.mo() internally, they also use artificial intelligence. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
  • -
  • The data set antibiotics contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like ab_name() and ab_tradenames() to look up values. The ab_* functions use as.atc() internally so they support AI to guess your expected result. For example, ab_name("Fluclox"), ab_name("Floxapen") and ab_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
  • +
  • The data set antibiotics contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like ab_name() and ab_tradenames() to look up values. The ab_* functions use as.atc() internally so they support AI to guess your expected result. For example, ab_name("Fluclox"), ab_name("Floxapen") and ab_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
  • diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index 00000000..48b92531 Binary files /dev/null and b/docs/logo.png differ diff --git a/docs/news/index.html b/docs/news/index.html index c2f8ed50..aa73431e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -229,6 +229,16 @@
  • diff --git a/docs/reference/AMR-deprecated.html b/docs/reference/AMR-deprecated.html index 7d3c902b..600851b2 100644 --- a/docs/reference/AMR-deprecated.html +++ b/docs/reference/AMR-deprecated.html @@ -47,7 +47,7 @@ - + @@ -223,13 +223,29 @@
    -

    These functions are Deprecated. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by.

    +

    These functions are so-called 'Deprecated'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).

    ratio(x, ratio)
     
    -guess_mo(...)
    +guess_mo(...) + +ab_property(...) + +ab_atc(...) + +ab_official(...) + +ab_name(...) + +ab_trivial_nl(...) + +ab_certe(...) + +ab_umcg(...) + +ab_tradenames(...)

    Read more on our website!

    diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index 23faa41a..3591c047 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -231,7 +231,7 @@

    Details

    This package was intended to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods.

    -

    This package was created for academic research by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG).

    +

    This package was created for both academic research and routine analysis by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG).

    Read more on our website!

    diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html index 1972e1f6..59b4079e 100644 --- a/docs/reference/WHOCC.html +++ b/docs/reference/WHOCC.html @@ -246,9 +246,9 @@ On our website https://msberends.gitla

    Examples

    # NOT RUN {
     as.atc("meropenem")
    -ab_name("J01DH02")
    +ab_name("J01DH02")
     
    -ab_tradenames("flucloxacillin")
    +ab_tradenames("flucloxacillin")
     # }
    diff --git a/docs/reference/as.atc.html b/docs/reference/as.atc.html index 29856a79..6862575f 100644 --- a/docs/reference/as.atc.html +++ b/docs/reference/as.atc.html @@ -248,7 +248,7 @@

    Details

    -

    Use the ab_property functions to get properties based on the returned ATC code, see Examples.

    +

    Use the ab_property functions to get properties based on the returned ATC code, see Examples.

    In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups. Source: https://www.whocc.no/atc/structure_and_principles/

    @@ -286,8 +286,8 @@ On our website https://msberends.gitla # Use ab_* functions to get a specific property based on an ATC code Cipro <- as.atc("cipro") # returns `J01MA02` -ab_official(Cipro) # returns "Ciprofloxacin" -ab_umcg(Cipro) # returns "CIPR", the code used in the UMCG +ab_official(Cipro) # returns "Ciprofloxacin" +ab_umcg(Cipro) # returns "CIPR", the code used in the UMCG # }
    diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html new file mode 100644 index 00000000..004b63d7 --- /dev/null +++ b/docs/reference/atc_online.html @@ -0,0 +1,353 @@ + + + + + + + + +Properties of an ATC code — atc_online_property • AMR (for R) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit.
    This function requires an internet connection.

    + +
    + +
    atc_online_property(atc_code, property, administration = "O",
    +  url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no")
    +
    +atc_online_groups(atc_code, ...)
    +
    +atc_online_ddd(atc_code, ...)
    + +

    Arguments

    + + + + + + + + + + + + + + + + + + + + + + +
    atc_code

    a character or character vector with ATC code(s) of antibiotic(s)

    property

    property of an ATC code. Valid values are "ATC", "Name", "DDD", "U" ("unit"), "Adm.R", "Note" and groups. For this last option, all hierarchical groups of an ATC code will be returned, see Examples.

    administration

    type of administration when using property = "Adm.R", see Details

    url

    url of website of the WHO. The sign %s can be used as a placeholder for ATC codes.

    ...

    parameters to pass on to atc_property

    + +

    Source

    + +

    https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/

    + +

    Details

    + +

    Options for parameter administration:

      +
    • "Implant" = Implant

    • +
    • "Inhal" = Inhalation

    • +
    • "Instill" = Instillation

    • +
    • "N" = nasal

    • +
    • "O" = oral

    • +
    • "P" = parenteral

    • +
    • "R" = rectal

    • +
    • "SL" = sublingual/buccal

    • +
    • "TD" = transdermal

    • +
    • "V" = vaginal

    • +
    +

    Abbreviations of return values when using property = "U" (unit):

      +
    • "g" = gram

    • +
    • "mg" = milligram

    • +
    • "mcg" = microgram

    • +
    • "U" = unit

    • +
    • "TU" = thousand units

    • +
    • "MU" = million units

    • +
    • "mmol" = millimole

    • +
    • "ml" = milliliter (e.g. eyedrops)

    • +
    + + +

    Examples

    +
    # NOT RUN {
    +# oral DDD (Defined Daily Dose) of amoxicillin
    +atc_online_property("J01CA04", "DDD", "O")
    +# parenteral DDD (Defined Daily Dose) of amoxicillin
    +atc_online_property("J01CA04", "DDD", "P")
    +
    +atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
    +# [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
    +# [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
    +# [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
    +# [4] "Penicillins with extended spectrum"
    +# }
    +
    + +
    + + +
    + + + + + + + + + diff --git a/docs/reference/atc_property.html b/docs/reference/atc_property.html index c6ad52c9..208b4d07 100644 --- a/docs/reference/atc_property.html +++ b/docs/reference/atc_property.html @@ -6,7 +6,7 @@ -Properties of an ATC code — atc_property • AMR (for R) +Property of an antibiotic — atc_property • AMR (for R) @@ -45,9 +45,9 @@ - + - + @@ -216,95 +216,71 @@
    -

    Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit.
    This function requires an internet connection.

    +

    Use these functions to return a specific property of an antibiotic from the antibiotics data set, based on their ATC code. Get such a code with as.atc.

    -
    atc_property(atc_code, property, administration = "O",
    -  url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no")
    +    
    atc_property(x, property = "official")
     
    -atc_groups(atc_code, ...)
    +atc_official(x, language = NULL)
     
    -atc_ddd(atc_code, ...)
    +atc_name(x, language = NULL) + +atc_trivial_nl(x) + +atc_certe(x) + +atc_umcg(x) + +atc_tradenames(x)

    Arguments

    - - + + - + - - - - - - - - - - + +
    atc_code

    a character or character vector with ATC code(s) of antibiotic(s)

    x

    a (vector of a) valid atc code or any text that can be coerced to a valid atc with as.atc

    property

    property of an ATC code. Valid values are "ATC", "Name", "DDD", "U" ("unit"), "Adm.R", "Note" and groups. For this last option, all hierarchical groups of an ATC code will be returned, see Examples.

    one of the column names of one of the antibiotics data set, like "atc" and "official"

    administration

    type of administration when using property = "Adm.R", see Details

    url

    url of website of the WHO. The sign %s can be used as a placeholder for ATC codes.

    ...

    parameters to pass on to atc_property

    language

    language of the returned text, defaults to English ("en") and can be set with getOption("AMR_locale"). Either one of "en" (English) or "nl" (Dutch).

    -

    Source

    +

    Value

    -

    https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/

    +

    A vector of values. In case of atc_tradenames, if x is of length one, a vector will be returned. Otherwise a list, with x as names.

    -

    Details

    +

    Read more on our website!

    -

    Options for parameter administration:

      -
    • "Implant" = Implant

    • -
    • "Inhal" = Inhalation

    • -
    • "Instill" = Instillation

    • -
    • "N" = nasal

    • -
    • "O" = oral

    • -
    • "P" = parenteral

    • -
    • "R" = rectal

    • -
    • "SL" = sublingual/buccal

    • -
    • "TD" = transdermal

    • -
    • "V" = vaginal

    • -
    -

    Abbreviations of return values when using property = "U" (unit):

      -
    • "g" = gram

    • -
    • "mg" = milligram

    • -
    • "mcg" = microgram

    • -
    • "U" = unit

    • -
    • "TU" = thousand units

    • -
    • "MU" = million units

    • -
    • "mmol" = millimole

    • -
    • "ml" = milliliter (e.g. eyedrops)

    • -
    + +


    +On our website https://msberends.gitlab.io/AMR you can find a omprehensive tutorial about how to conduct AMR analysis and find the complete documentation of all functions, which reads a lot easier than in R.

    + +

    See also

    + +

    Examples

    # NOT RUN {
    -# What's the ATC of amoxicillin?
    -guess_atc("Amoxicillin")
    -# [1] "J01CA04"
    -
    -# oral DDD (Defined Daily Dose) of amoxicillin
    -atc_property("J01CA04", "DDD", "O")
    -# parenteral DDD (Defined Daily Dose) of amoxicillin
    -atc_property("J01CA04", "DDD", "P")
    -
    -atc_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
    -# [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
    -# [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
    -# [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
    -# [4] "Penicillins with extended spectrum"
    +as.atc("amcl")         # J01CR02
    +atc_name("amcl")        # Amoxicillin and beta-lactamase inhibitor
    +atc_name("amcl", "nl")  # Amoxicilline met enzymremmer
    +atc_trivial_nl("amcl")  # Amoxicilline/clavulaanzuur
    +atc_certe("amcl")       # amcl
    +atc_umcg("amcl")        # AMCL
     # }
    diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 3256de9c..72d7bf17 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -368,11 +368,11 @@ On our website https://msberends.gitla library(dplyr) # Filter on first isolates: septic_patients %>% - mutate(first_isolate = first_isolate(., + mutate(first_isolate = first_isolate(., col_date = "date", col_patient_id = "patient_id", col_mo = "mo")) %>% - filter(first_isolate == TRUE) + filter(first_isolate == TRUE) # Which can be shortened to: septic_patients %>% @@ -383,14 +383,14 @@ On our website https://msberends.gitla # Now let's see if first isolates matter: A <- septic_patients %>% - group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability + group_by(hospital_id) %>% + summarise(count = n_rsi(gent), # gentamicin availability resistance = portion_IR(gent)) # gentamicin resistance B <- septic_patients %>% filter_first_weighted_isolate() %>% # the 1st isolate filter - group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability + group_by(hospital_id) %>% + summarise(count = n_rsi(gent), # gentamicin availability resistance = portion_IR(gent)) # gentamicin resistance # Have a look at A and B. diff --git a/docs/reference/freq.html b/docs/reference/freq.html index 4f4c7ded..d8db6949 100644 --- a/docs/reference/freq.html +++ b/docs/reference/freq.html @@ -385,34 +385,34 @@ On our website https://msberends.gitla # you could also use `select` or `pull` to get your variables septic_patients %>% - filter(hospital_id == "A") %>% - select(mo) %>% + filter(hospital_id == "A") %>% + select(mo) %>% freq() # multiple selected variables will be pasted together septic_patients %>% left_join_microorganisms %>% - filter(hospital_id == "A") %>% + filter(hospital_id == "A") %>% freq(genus, species) # group a variable and analyse another septic_patients %>% - group_by(hospital_id) %>% + group_by(hospital_id) %>% freq(gender) # get top 10 bugs of hospital A as a vector septic_patients %>% - filter(hospital_id == "A") %>% + filter(hospital_id == "A") %>% freq(mo) %>% top_freq(10) # save frequency table to an object years <- septic_patients %>% - mutate(year = format(date, "%Y")) %>% + mutate(year = format(date, "%Y")) %>% freq(year) @@ -463,11 +463,11 @@ On our website https://msberends.gitla # only get selected columns septic_patients %>% freq(hospital_id) %>% - select(item, percent) + select(item, percent) septic_patients %>% freq(hospital_id) %>% - select(-count, -cum_count) + select(-count, -cum_count) # check differences between frequency tables diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index c4d2ae56..a3a1c163 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -334,7 +334,7 @@ On our website https://msberends.gitla library(ggplot2) # get antimicrobial results for drugs against a UTI: -ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + +ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + geom_rsi() # prettify the plot using some additional functions: @@ -348,17 +348,17 @@ On our website https://msberends.gitla # or better yet, simplify this using the wrapper function - a single command: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi() # get only portions and no counts: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi(fun = portion_df) # add other ggplot2 parameters as you like: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi(width = 0.5, colour = "black", size = 1, @@ -367,25 +367,25 @@ On our website https://msberends.gitla # resistance of ciprofloxacine per age group septic_patients %>% - mutate(first_isolate = first_isolate(.)) %>% - filter(first_isolate == TRUE, + mutate(first_isolate = first_isolate(.)) %>% + filter(first_isolate == TRUE, mo == as.mo("E. coli")) %>% # `age_group` is also a function of this package: - group_by(age_group = age_groups(age)) %>% - select(age_group, + group_by(age_group = age_groups(age)) %>% + select(age_group, cipr) %>% ggplot_rsi(x = "age_group") # }# NOT RUN { # for colourblind mode, use divergent colours from the viridis package: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(amox, nitr, fosf, trim, cipr) %>% ggplot_rsi() + scale_fill_viridis_d() # it also supports groups (don't forget to use the group var on `x` or `facet`): septic_patients %>% - select(hospital_id, amox, nitr, fosf, trim, cipr) %>% - group_by(hospital_id) %>% + select(hospital_id, amox, nitr, fosf, trim, cipr) %>% + group_by(hospital_id) %>% ggplot_rsi(x = hospital_id, facet = Antibiotic, nrow = 1) + @@ -395,22 +395,22 @@ On our website https://msberends.gitla # genuine analysis: check 2 most prevalent microorganisms septic_patients %>% # create new bacterial ID's, with all CoNS under the same group (Becker et al.) - mutate(mo = as.mo(mo, Becker = TRUE)) %>% + mutate(mo = as.mo(mo, Becker = TRUE)) %>% # filter on top three bacterial ID's - filter(mo %in% top_freq(freq(.$mo), 3)) %>% + filter(mo %in% top_freq(freq(.$mo), 3)) %>% # determine first isolates - mutate(first_isolate = first_isolate(., + mutate(first_isolate = first_isolate(., col_date = "date", col_patient_id = "patient_id", col_mo = "mo")) %>% # filter on first isolates - filter(first_isolate == TRUE) %>% + filter(first_isolate == TRUE) %>% # get short MO names (like "E. coli") - mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% + mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% # select this short name and some antiseptic drugs - select(mo, cfur, gent, cipr) %>% + select(mo, cfur, gent, cipr) %>% # group by MO - group_by(mo) %>% + group_by(mo) %>% # plot the thing, putting MOs on the facet ggplot_rsi(x = Antibiotic, facet = mo, diff --git a/docs/reference/index.html b/docs/reference/index.html index 839e49a3..fe6fd670 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -341,13 +341,13 @@ -

    ab_property() ab_atc() ab_official() ab_name() ab_trivial_nl() ab_certe() ab_umcg() ab_tradenames()

    +

    atc_property() atc_official() atc_name() atc_trivial_nl() atc_certe() atc_umcg() atc_tradenames()

    Property of an antibiotic

    -

    atc_property() atc_groups() atc_ddd()

    +

    atc_online_property() atc_online_groups() atc_online_ddd()

    Properties of an ATC code

    @@ -518,6 +518,12 @@

    mo_renamed()

    Vector of taxonomic renamed items

    + + + +

    ratio() guess_mo() ab_property() ab_atc() ab_official() ab_name() ab_trivial_nl() ab_certe() ab_umcg() ab_tradenames()

    + +

    Deprecated functions

    diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 57ca05ad..1ecdd5f0 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -334,8 +334,8 @@ On our website https://msberends.gitla library(dplyr) # set key antibiotics to a new variable my_patients <- septic_patients %>% - mutate(keyab = key_antibiotics(.)) %>% - mutate( + mutate(keyab = key_antibiotics(.)) %>% + mutate( # now calculate first isolates first_regular = first_isolate(., col_keyantibiotics = FALSE), # and first WEIGHTED isolates diff --git a/docs/reference/like.html b/docs/reference/like.html index 6dfd0338..f7819f2c 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -295,7 +295,7 @@ On our website https://msberends.gitla library(dplyr) septic_patients %>% left_join_microorganisms() %>% - filter(genus %like% '^ent') %>% + filter(genus %like% '^ent') %>% freq(genus, species) # }
    diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 43ed5daa..0bd55d9a 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -618,7 +618,7 @@ On our website https://msberends.gitla library(dplyr) septic_patients %>% - mutate(EUCAST = mdro(.), + mutate(EUCAST = mdro(.), BRMO = brmo(.)) # }

    diff --git a/docs/reference/portion.html b/docs/reference/portion.html index d046bdcc..d8673b9e 100644 --- a/docs/reference/portion.html +++ b/docs/reference/portion.html @@ -340,17 +340,17 @@ On our website https://msberends.gitla septic_patients %>% portion_SI(amox) septic_patients %>% - group_by(hospital_id) %>% - summarise(p = portion_S(cipr), + group_by(hospital_id) %>% + summarise(p = portion_S(cipr), n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr septic_patients %>% - group_by(hospital_id) %>% - summarise(R = portion_R(cipr, as_percent = TRUE), + group_by(hospital_id) %>% + summarise(R = portion_R(cipr, as_percent = TRUE), I = portion_I(cipr, as_percent = TRUE), S = portion_S(cipr, as_percent = TRUE), n = n_rsi(cipr), # works like n_distinct in dplyr - total = n()) # NOT the amount of tested isolates! + total = n()) # NOT the amount of tested isolates! # Calculate co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy: @@ -365,8 +365,8 @@ On our website https://msberends.gitla septic_patients %>% - group_by(hospital_id) %>% - summarise(cipro_p = portion_S(cipr, as_percent = TRUE), + group_by(hospital_id) %>% + summarise(cipro_p = portion_S(cipr, as_percent = TRUE), cipro_n = count_all(cipr), genta_p = portion_S(gent, as_percent = TRUE), genta_n = count_all(gent), @@ -375,22 +375,22 @@ On our website https://msberends.gitla # Get portions S/I/R immediately of all rsi columns septic_patients %>% - select(amox, cipr) %>% + select(amox, cipr) %>% portion_df(translate = FALSE) # It also supports grouping variables septic_patients %>% - select(hospital_id, amox, cipr) %>% - group_by(hospital_id) %>% + select(hospital_id, amox, cipr) %>% + group_by(hospital_id) %>% portion_df(translate = FALSE) # }# NOT RUN { # calculate current empiric combination therapy of Helicobacter gastritis: my_table %>% - filter(first_isolate == TRUE, + filter(first_isolate == TRUE, genus == "Helicobacter") %>% - summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole + summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole n = count_all(amox, metr)) # }
    diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index e2f7a9a0..f2c57789 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -341,7 +341,7 @@ On our website https://msberends.gitla library(dplyr) x <- septic_patients %>% filter_first_isolate() %>% - filter(mo_genus(mo) == "Staphylococcus") %>% + filter(mo_genus(mo) == "Staphylococcus") %>% resistance_predict("peni") plot(x) @@ -350,7 +350,7 @@ On our website https://msberends.gitla if (!require(ggplot2)) { data <- septic_patients %>% - filter(mo == as.mo("E. coli")) %>% + filter(mo == as.mo("E. coli")) %>% resistance_predict(col_ab = "amox", col_date = "date", info = FALSE, diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 23a976c0..76568930 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -15,9 +15,6 @@ https://msberends.gitlab.io/AMR/reference/WHOCC.html - - https://msberends.gitlab.io/AMR/reference/ab_property.html - https://msberends.gitlab.io/AMR/reference/abname.html @@ -42,6 +39,9 @@ https://msberends.gitlab.io/AMR/reference/as.rsi.html + + https://msberends.gitlab.io/AMR/reference/atc_online.html + https://msberends.gitlab.io/AMR/reference/atc_property.html diff --git a/index.md b/index.md index fced3873..dfde3922 100644 --- a/index.md +++ b/index.md @@ -1,4 +1,4 @@ -# `AMR` (for R) +# `AMR` (for R) *(TLDR - to find out how to conduct AMR analysis, please [continue reading here to get started](./articles/AMR.html).* @@ -6,12 +6,24 @@ `AMR` is a free and open-source [R package](https://www.r-project.org) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. -We created this package for academic research at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). -This R package is free software; you can freely use and distribute it for both personal and commercial (but **not** patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation. Read further about our GPL-2 licence [here](./LICENSE-text.html). +We created this package for both academic research and routine analysis at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). +This R package is actively maintained and free software; you can freely use and distribute it for both personal and commercial (but **not** patent) purposes under the terms of the GNU General Public Licence version 2.0 (GPL-2), as published by the Free Software Foundation. Read the full licence [here](./LICENSE-text.html). + +This package can be used for: + + * Calculating antimicrobial resistance + * Predicting antimicrobial resistance using regression models + * Getting properties for any microorganism (like Gram stain, species, genus or family) + * Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name) + * Plotting antimicrobial resistance + * Determining first isolates to be used for AMR analysis + * Applying EUCAST rules + * Determining multi-drug resistance organisms (MDRO) + * Descriptive statistics: frequency tables, kurtosis and skewness This package is ready-to-use for a professional environment by specialists in the following fields: -Medical Microbiology: +Medical Microbiology * Epidemiologists (both clinical microbiological and research) * Research Microbiologists @@ -19,18 +31,18 @@ Medical Microbiology: * Research Pharmacologists * Data Scientists / Data Analysts -Veterinary Microbiology: +Veterinary Microbiology * Research Veterinarians * Veterinary Epidemiologists -Microbial Ecology: +Microbial Ecology * Soil Microbiologists * Extremophile Researchers * Astrobiologists -Developers: +Developers * Package developers for R * Software developers diff --git a/man/AMR-deprecated.Rd b/man/AMR-deprecated.Rd index 0c4ba589..78aa1816 100644 --- a/man/AMR-deprecated.Rd +++ b/man/AMR-deprecated.Rd @@ -4,14 +4,38 @@ \alias{AMR-deprecated} \alias{ratio} \alias{guess_mo} +\alias{ab_property} +\alias{ab_atc} +\alias{ab_official} +\alias{ab_name} +\alias{ab_trivial_nl} +\alias{ab_certe} +\alias{ab_umcg} +\alias{ab_tradenames} \title{Deprecated functions} \usage{ ratio(x, ratio) guess_mo(...) + +ab_property(...) + +ab_atc(...) + +ab_official(...) + +ab_name(...) + +ab_trivial_nl(...) + +ab_certe(...) + +ab_umcg(...) + +ab_tradenames(...) } \description{ -These functions are \link{Deprecated}. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by. +These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one). } \section{Read more on our website!}{ diff --git a/man/AMR.Rd b/man/AMR.Rd index 3347c90a..38471a41 100644 --- a/man/AMR.Rd +++ b/man/AMR.Rd @@ -9,7 +9,7 @@ Welcome to the \code{AMR} package. This page gives some additional contact infor \details{ This package was intended to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. -This package was created for academic research by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). +This package was created for both academic research and routine analysis by PhD students of the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). } \section{Read more on our website!}{ diff --git a/man/ab_property.Rd b/man/ab_property.Rd deleted file mode 100644 index 0e0274c5..00000000 --- a/man/ab_property.Rd +++ /dev/null @@ -1,59 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ab_property.R -\name{ab_property} -\alias{ab_property} -\alias{ab_atc} -\alias{ab_official} -\alias{ab_name} -\alias{ab_trivial_nl} -\alias{ab_certe} -\alias{ab_umcg} -\alias{ab_tradenames} -\title{Property of an antibiotic} -\usage{ -ab_property(x, property = "official") - -ab_atc(x) - -ab_official(x, language = NULL) - -ab_name(x, language = NULL) - -ab_trivial_nl(x) - -ab_certe(x) - -ab_umcg(x) - -ab_tradenames(x) -} -\arguments{ -\item{x}{a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}} - -\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}} - -\item{language}{language of the returned text, defaults to English (\code{"en"}) and can be set with \code{\link{getOption}("AMR_locale")}. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).} -} -\value{ -A vector of values. In case of \code{ab_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. -} -\description{ -Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}. -} -\section{Read more on our website!}{ - -\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr} -On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a omprehensive tutorial} about how to conduct AMR analysis and find \href{https://msberends.gitlab.io/AMR/reference}{the complete documentation of all functions}, which reads a lot easier than in R. -} - -\examples{ -ab_atc("amcl") # J01CR02 -ab_name("amcl") # Amoxicillin and beta-lactamase inhibitor -ab_name("amcl", "nl") # Amoxicilline met enzymremmer -ab_trivial_nl("amcl") # Amoxicilline/clavulaanzuur -ab_certe("amcl") # amcl -ab_umcg("amcl") # AMCL -} -\seealso{ -\code{\link{antibiotics}} -} diff --git a/man/atc_online.Rd b/man/atc_online.Rd new file mode 100644 index 00000000..f5646b4a --- /dev/null +++ b/man/atc_online.Rd @@ -0,0 +1,73 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/atc_online.R +\name{atc_online_property} +\alias{atc_online_property} +\alias{atc_online_groups} +\alias{atc_online_ddd} +\title{Properties of an ATC code} +\source{ +\url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/} +} +\usage{ +atc_online_property(atc_code, property, administration = "O", + url = "https://www.whocc.no/atc_ddd_index/?code=\%s&showdescription=no") + +atc_online_groups(atc_code, ...) + +atc_online_ddd(atc_code, ...) +} +\arguments{ +\item{atc_code}{a character or character vector with ATC code(s) of antibiotic(s)} + +\item{property}{property of an ATC code. Valid values are \code{"ATC"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"}, \code{"Note"} and \code{groups}. For this last option, all hierarchical groups of an ATC code will be returned, see Examples.} + +\item{administration}{type of administration when using \code{property = "Adm.R"}, see Details} + +\item{url}{url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes.} + +\item{...}{parameters to pass on to \code{atc_property}} +} +\description{ +Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. \cr \strong{This function requires an internet connection.} +} +\details{ +Options for parameter \code{administration}: +\itemize{ + \item{\code{"Implant"}}{ = Implant} + \item{\code{"Inhal"}}{ = Inhalation} + \item{\code{"Instill"}}{ = Instillation} + \item{\code{"N"}}{ = nasal} + \item{\code{"O"}}{ = oral} + \item{\code{"P"}}{ = parenteral} + \item{\code{"R"}}{ = rectal} + \item{\code{"SL"}}{ = sublingual/buccal} + \item{\code{"TD"}}{ = transdermal} + \item{\code{"V"}}{ = vaginal} +} + +Abbreviations of return values when using \code{property = "U"} (unit): +\itemize{ + \item{\code{"g"}}{ = gram} + \item{\code{"mg"}}{ = milligram} + \item{\code{"mcg"}}{ = microgram} + \item{\code{"U"}}{ = unit} + \item{\code{"TU"}}{ = thousand units} + \item{\code{"MU"}}{ = million units} + \item{\code{"mmol"}}{ = millimole} + \item{\code{"ml"}}{ = milliliter (e.g. eyedrops)} +} +} +\examples{ +\donttest{ +# oral DDD (Defined Daily Dose) of amoxicillin +atc_online_property("J01CA04", "DDD", "O") +# parenteral DDD (Defined Daily Dose) of amoxicillin +atc_online_property("J01CA04", "DDD", "P") + +atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin +# [1] "ANTIINFECTIVES FOR SYSTEMIC USE" +# [2] "ANTIBACTERIALS FOR SYSTEMIC USE" +# [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS" +# [4] "Penicillins with extended spectrum" +} +} diff --git a/man/atc_property.Rd b/man/atc_property.Rd index afda0e59..1edac996 100755 --- a/man/atc_property.Rd +++ b/man/atc_property.Rd @@ -1,77 +1,56 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/atc.R +% Please edit documentation in R/atc_property.R \name{atc_property} \alias{atc_property} -\alias{atc_groups} -\alias{atc_ddd} -\title{Properties of an ATC code} -\source{ -\url{https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/} -} +\alias{atc_official} +\alias{atc_name} +\alias{atc_trivial_nl} +\alias{atc_certe} +\alias{atc_umcg} +\alias{atc_tradenames} +\title{Property of an antibiotic} \usage{ -atc_property(atc_code, property, administration = "O", - url = "https://www.whocc.no/atc_ddd_index/?code=\%s&showdescription=no") +atc_property(x, property = "official") -atc_groups(atc_code, ...) +atc_official(x, language = NULL) -atc_ddd(atc_code, ...) +atc_name(x, language = NULL) + +atc_trivial_nl(x) + +atc_certe(x) + +atc_umcg(x) + +atc_tradenames(x) } \arguments{ -\item{atc_code}{a character or character vector with ATC code(s) of antibiotic(s)} +\item{x}{a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}} -\item{property}{property of an ATC code. Valid values are \code{"ATC"}, \code{"Name"}, \code{"DDD"}, \code{"U"} (\code{"unit"}), \code{"Adm.R"}, \code{"Note"} and \code{groups}. For this last option, all hierarchical groups of an ATC code will be returned, see Examples.} +\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}} -\item{administration}{type of administration when using \code{property = "Adm.R"}, see Details} - -\item{url}{url of website of the WHO. The sign \code{\%s} can be used as a placeholder for ATC codes.} - -\item{...}{parameters to pass on to \code{atc_property}} +\item{language}{language of the returned text, defaults to English (\code{"en"}) and can be set with \code{\link{getOption}("AMR_locale")}. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).} +} +\value{ +A vector of values. In case of \code{atc_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. } \description{ -Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit. \cr \strong{This function requires an internet connection.} +Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}. } -\details{ -Options for parameter \code{administration}: -\itemize{ - \item{\code{"Implant"}}{ = Implant} - \item{\code{"Inhal"}}{ = Inhalation} - \item{\code{"Instill"}}{ = Instillation} - \item{\code{"N"}}{ = nasal} - \item{\code{"O"}}{ = oral} - \item{\code{"P"}}{ = parenteral} - \item{\code{"R"}}{ = rectal} - \item{\code{"SL"}}{ = sublingual/buccal} - \item{\code{"TD"}}{ = transdermal} - \item{\code{"V"}}{ = vaginal} +\section{Read more on our website!}{ + +\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr} +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a omprehensive tutorial} about how to conduct AMR analysis and find \href{https://msberends.gitlab.io/AMR/reference}{the complete documentation of all functions}, which reads a lot easier than in R. } -Abbreviations of return values when using \code{property = "U"} (unit): -\itemize{ - \item{\code{"g"}}{ = gram} - \item{\code{"mg"}}{ = milligram} - \item{\code{"mcg"}}{ = microgram} - \item{\code{"U"}}{ = unit} - \item{\code{"TU"}}{ = thousand units} - \item{\code{"MU"}}{ = million units} - \item{\code{"mmol"}}{ = millimole} - \item{\code{"ml"}}{ = milliliter (e.g. eyedrops)} -} -} \examples{ -\donttest{ -# What's the ATC of amoxicillin? -guess_atc("Amoxicillin") -# [1] "J01CA04" - -# oral DDD (Defined Daily Dose) of amoxicillin -atc_property("J01CA04", "DDD", "O") -# parenteral DDD (Defined Daily Dose) of amoxicillin -atc_property("J01CA04", "DDD", "P") - -atc_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin -# [1] "ANTIINFECTIVES FOR SYSTEMIC USE" -# [2] "ANTIBACTERIALS FOR SYSTEMIC USE" -# [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS" -# [4] "Penicillins with extended spectrum" +as.atc("amcl") # J01CR02 +atc_name("amcl") # Amoxicillin and beta-lactamase inhibitor +atc_name("amcl", "nl") # Amoxicilline met enzymremmer +atc_trivial_nl("amcl") # Amoxicilline/clavulaanzuur +atc_certe("amcl") # amcl +atc_umcg("amcl") # AMCL } +\seealso{ +\code{\link{antibiotics}} } diff --git a/pkgdown/extra.css b/pkgdown/extra.css index 8fd48767..bab9e252 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -71,7 +71,7 @@ pre, code { font-family: 'Courier New', monospace; font-size: 100% !important; font-weight: bold; - background-color: transparent; + background-color: #f4f4f4; } pre { font-size: 90% !important; @@ -84,7 +84,7 @@ kbd { font-size: small; vertical-align: text-bottom; color: #2c3e50; - background: #eee; + background: #eeeeee; font-weight: bold; } diff --git a/pkgdown/logos/logo.png b/pkgdown/logos/logo.png new file mode 100644 index 00000000..48b92531 Binary files /dev/null and b/pkgdown/logos/logo.png differ diff --git a/tests/testthat/test-atc.R b/tests/testthat/test-atc.R index a51556c9..467604a1 100755 --- a/tests/testthat/test-atc.R +++ b/tests/testthat/test-atc.R @@ -21,27 +21,6 @@ context("atc.R") -# test_that("atc_property works", { -# skip_on_cran() # relies on internet connection of server, don't test -# skip_on_appveyor() # security error on AppVeyor -# -# if (!is.null(curl::nslookup("www.whocc.no", error = FALSE))) { -# expect_equal(tolower(atc_property("J01CA04", property = "Name")), "amoxicillin") -# expect_equal(atc_property("J01CA04", property = "unit"), "g") -# expect_equal(atc_property("J01CA04", property = "DDD"), -# atc_ddd("J01CA04")) -# -# expect_identical(atc_property("J01CA04", property = "Groups"), -# atc_groups("J01CA04")) -# -# expect_warning(atc_property("ABCDEFG", property = "DDD")) -# -# expect_error(atc_property("J01CA04", property = c(1:5))) -# expect_error(atc_property("J01CA04", property = "test")) -# expect_error(atc_property("J01CA04", property = "test", administration = c(1:5))) -# } -# }) - test_that("guess_atc works", { expect_equal(as.character(guess_atc(c("J01FA01", "Erythromycin", @@ -55,7 +34,7 @@ test_that("guess_atc works", { expect_identical(class(as.atc("amox")), "atc") expect_identical(class(pull(antibiotics, atc)), "atc") - expect_identical(ab_trivial_nl("Cefmenoxim"), "Cefmenoxim") + expect_identical(atc_trivial_nl("Cefmenoxim"), "Cefmenoxim") expect_warning(as.atc("Z00ZZ00")) # not yet available in data set expect_warning(as.atc("UNKNOWN")) diff --git a/tests/testthat/test-ab_property.R b/tests/testthat/test-atc_property.R similarity index 66% rename from tests/testthat/test-ab_property.R rename to tests/testthat/test-atc_property.R index 0b618535..68abf8ce 100644 --- a/tests/testthat/test-ab_property.R +++ b/tests/testthat/test-atc_property.R @@ -19,20 +19,19 @@ # Visit our website for more info: https://msberends.gitab.io/AMR. # # ==================================================================== # -context("ab_property.R") +context("atc_property.R") -test_that("ab_property works", { - expect_equal(ab_certe("amox"), "amox") - expect_equal(ab_name("amox", language = "en"), "Amoxicillin") - expect_equal(ab_name("amox", language = "nl"), "Amoxicilline") - expect_equal(ab_official("amox", language = "en"), "Amoxicillin") - expect_equal(ab_trivial_nl("amox"), "Amoxicilline") - expect_equal(ab_umcg("amox"), "AMOX") - expect_equal(class(ab_tradenames("amox")), "character") - expect_equal(class(ab_tradenames(c("amox", "amox"))), "list") - expect_equal(ab_atc("amox"), as.character(as.atc("amox"))) +test_that("atc_property works", { + expect_equal(atc_certe("amox"), "amox") + expect_equal(atc_name("amox", language = "en"), "Amoxicillin") + expect_equal(atc_name("amox", language = "nl"), "Amoxicilline") + expect_equal(atc_official("amox", language = "en"), "Amoxicillin") + expect_equal(atc_trivial_nl("amox"), "Amoxicilline") + expect_equal(atc_umcg("amox"), "AMOX") + expect_equal(class(atc_tradenames("amox")), "character") + expect_equal(class(atc_tradenames(c("amox", "amox"))), "list") - expect_error(ab_property("amox", "invalid property")) - expect_error(ab_name("amox", language = "INVALID")) - expect_output(print(ab_name("amox", language = NULL))) + expect_error(atc_property("amox", "invalid property")) + expect_error(atc_name("amox", language = "INVALID")) + expect_output(print(atc_name("amox", language = NULL))) }) diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index d6fe1289..317231c7 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -41,14 +41,17 @@ knitr::kable(dplyr::tibble(date = Sys.Date(), ``` ## Needed R packages -As with many uses in R, we need some additional packages for AMR analysis. The most important one is [`dplyr`](https://dplyr.tidyverse.org/), which tremendously improves the way we work with data - it allows for a very natural way of writing syntaxes in R. Another important dependency is [`ggplot2`](https://ggplot2.tidyverse.org/). This package can be used to create beautiful plots in R. +As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the [tidyverse packages](https://www.tidyverse.org) [`dplyr`](https://dplyr.tidyverse.org/) and [`ggplot2`](https://ggplot2.tidyverse.org) by [Dr Hadley Wickham](https://www.linkedin.com/in/hadleywickham/). The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R. -Our `AMR` package depends on these packages and even extends their use and functions. +Our `AMR` package depends on these packages and even extends their use and functions. ```{r lib packages, message = FALSE} -library(dplyr) # the data science package -library(AMR) # this package, to simplify and automate AMR analysis -library(ggplot2) # for appealing plots +library(dplyr) +library(ggplot2) +library(AMR) + +# (if not yet installed, install with:) +# install.packages(c("tidyverse", "AMR")) ``` ## Creation of data