diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 644e29e6..2509f224 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,7 +69,7 @@ R-release: - '*.Rcheck/*' expire_in: '1 month' cache: - key: "$CI_COMMIT_REF_SLUG" + key: "r350" paths: - installed_deps/ @@ -98,13 +98,17 @@ R-devel: paths: - '*.Rcheck/*' expire_in: '1 month' + cache: + key: "r360" + paths: + - installed_deps/ coverage: stage: test allow_failure: true when: on_success cache: - key: "$CI_COMMIT_REF_SLUG" + key: "r350" paths: - installed_deps/ only: @@ -121,17 +125,18 @@ coverage: pages: stage: deploy when: always - cache: - key: "$CI_COMMIT_REF_SLUG" - paths: - - installed_deps/ + #cache: + # key: "$CI_COMMIT_REF_SLUG" + # paths: + # - installed_deps/ only: - master script: + - mv docs public # install missing and outdated packages - - Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE)' - - Rscript -e "devtools::install(build = TRUE, upgrade = FALSE)" - - R -e "pkgdown::build_site(examples = FALSE, lazy = TRUE, override = list(destination = 'public'))" + #- Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE)' + #- Rscript -e "devtools::install(build = TRUE, upgrade = FALSE)" + #- R -e "pkgdown::build_site(examples = FALSE, lazy = TRUE, override = list(destination = 'public'))" artifacts: paths: - public diff --git a/DESCRIPTION b/DESCRIPTION index ae7ddc00..a361e464 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.6.1.9003 -Date: 2019-05-13 +Date: 2019-05-16 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/R/ab.R b/R/ab.R index 09fdf302..12caf08f 100755 --- a/R/ab.R +++ b/R/ab.R @@ -52,7 +52,7 @@ #' as.ab(" eryt 123") #' as.ab("ERYT") #' as.ab("ERY") -#' as.ab("erytromicine") # spelled wrong +#' as.ab("eritromicine") # spelled wrong, yet works #' as.ab("Erythrocin") # trade name #' as.ab("Romycin") # trade name #' @@ -64,13 +64,20 @@ as.ab <- function(x) { if (is.ab(x)) { return(x) } + + if (all(toupper(x) %in% AMR::antibiotics$ab)) { + # valid AB code, but not yet right class + return(structure(.Data = toupper(x), + class = "ab")) + } + x_bak <- x # remove suffices - x_bak_clean <- gsub("_(mic|rsi|disk|disc)$", "", x) + x_bak_clean <- gsub("_(mic|rsi|disk|disc)$", "", x, ignore.case = TRUE) # remove disk concentrations, like LVX_NM -> LVX x_bak_clean <- gsub("_[A-Z]{2}[0-9_]{0,3}$", "", x_bak_clean, ignore.case = TRUE) # clean rest of it - x_bak_clean <- gsub("[^a-zA-Z0-9/-]", "", x_bak_clean) + x_bak_clean <- gsub("[^A-Z0-9/-]", "", x_bak_clean, ignore.case = TRUE) # keep only a-z when it's not an ATC code or only numbers x_bak_clean[!x_bak_clean %like% "^([A-Z][0-9]{2}[A-Z]{2}[0-9]{2}|[0-9]+)$"] <- gsub("[^a-zA-Z]+", "", @@ -156,19 +163,25 @@ as.ab <- function(x) { x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) next } - x_spelling <- x[i] - x_spelling <- gsub("[iy]+", "[iy]+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("[sz]+", "[sz]+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("(c|k|q|qu)+", "(c|k|q|qu)+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("(ph|f|v)+", "(ph|f|v)+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("(th|t)+", "(th|t)+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("a+", "a+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("e+", "e+", x_spelling, ignore.case = TRUE) - x_spelling <- gsub("o+", "o+", x_spelling, ignore.case = TRUE) + x_spelling <- tolower(x[i]) + x_spelling <- gsub("[iy]+", "[iy]+", x_spelling) + x_spelling <- gsub("[sz]+", "[sz]+", x_spelling) + x_spelling <- gsub("(c|k|q|qu)+", "(c|k|q|qu)+", x_spelling) + x_spelling <- gsub("(ph|f|v)+", "(ph|f|v)+", x_spelling) + x_spelling <- gsub("(th|t)+", "(th|t)+", x_spelling) + x_spelling <- gsub("(x|ks)+", "(x|ks)+", x_spelling) + x_spelling <- gsub("a+", "a+", x_spelling) + x_spelling <- gsub("e+", "e+", x_spelling) + x_spelling <- gsub("o+", "o+", x_spelling) + # allow start with C/S/Z + x_spelling <- gsub("^(\\(c\\|k\\|q\\|qu\\)|\\[sz\\])", "(c|k|q|qu|s|z)", x_spelling) + x_spelling <- gsub("(c|k|q|qu)+[sz]", "(c|k|q|qu|s|x|z)", x_spelling, fixed = TRUE) # allow any ending of -in/-ine and -im/-ime - x_spelling <- gsub("(\\[iy\\]\\+(n|m)|\\[iy\\]\\+(n|m)e\\+)$", "[iy]+(n|m)e*", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("(\\[iy\\]\\+(n|m)|\\[iy\\]\\+(n|m)e\\+)$", "[iy]+(n|m)e*", x_spelling) # allow any ending of -ol/-ole - x_spelling <- gsub("(o\\+l|o\\+le\\+)$", "o+le*", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("(o\\+l|o\\+le\\+)$", "o+le*", x_spelling) + # allow any ending of -on/-one + x_spelling <- gsub("(o\\+n|o\\+ne\\+)$", "o+ne*", x_spelling) # try if name starts with it found <- AMR::antibiotics[which(AMR::antibiotics$name %like% paste0("^", x_spelling)),]$ab if (length(found) > 0) { @@ -203,11 +216,15 @@ as.ab <- function(x) { left_join(data.frame(x = x, x_new = x_new, stringsAsFactors = FALSE), by = "x") %>% pull(x_new) + if (length(x_result) == 0) { + x_result <- NA_character_ + } + structure(.Data = x_result, class = "ab") } -#' @rdname as.atc +#' @rdname as.ab #' @export is.ab <- function(x) { identical(class(x), "ab") diff --git a/R/ab_property.R b/R/ab_property.R index 0300e4c5..e6f90bbb 100644 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -35,7 +35,7 @@ #' @name ab_property #' @return \itemize{ #' \item{An \code{integer} in case of \code{ab_cid}} -#' \item{A named \code{list} in case of multiple \code{ab_synonyms}} +#' \item{A named \code{list} in case of \code{ab_info} and multiple \code{ab_synonyms}/\code{ab_tradenames}} #' \item{A \code{double} in case of \code{ab_ddd}} #' \item{A \code{character} in all other cases} #' } @@ -64,6 +64,8 @@ #' ab_ddd("AMX", "iv") # 1 #' ab_ddd("AMX", "iv", units = TRUE) # "g" #' +#' ab_info("AMX") # all properties as a list +#' #' # all ab_* functions use as.ab() internally: #' ab_name("Fluclox") # "Flucloxacillin" #' ab_name("fluklox") # "Flucloxacillin" @@ -113,20 +115,20 @@ ab_tradenames <- function(x, ...) { #' @rdname ab_property #' @export -ab_group <- function(x, ...) { - ab_validate(x = x, property = "group", ...) +ab_group <- function(x, language = get_locale(), ...) { + t(ab_validate(x = x, property = "group", ...), language = language) } #' @rdname ab_property #' @export -ab_atc_group1 <- function(x, ...) { - ab_validate(x = x, property = "atc_group1", ...) +ab_atc_group1 <- function(x, language = get_locale(), ...) { + t(ab_validate(x = x, property = "atc_group1", ...), language = language) } #' @rdname ab_property #' @export -ab_atc_group2 <- function(x, ...) { - ab_validate(x = x, property = "atc_group2", ...) +ab_atc_group2 <- function(x, language = get_locale(), ...) { + t(ab_validate(x = x, property = "atc_group2", ...), language = language) } #' @rdname ab_property @@ -144,6 +146,22 @@ ab_ddd <- function(x, administration = "oral", units = FALSE, ...) { ab_validate(x = x, property = ddd_prop, ...) } +ab_info <- function(x, language = get_locale(), ...) { + x <- AMR::as.ab(x, ...) + base::list(ab = x, + atc = ab_atc(x), + cid = ab_cid(x), + name = ab_name(x, language = language), + group = ab_group(x, language = language), + atc_group1 = ab_atc_group1(x, language = language), + atc_group2 = ab_atc_group2(x, language = language), + tradenames = ab_tradenames(x), + ddd = list(oral = list(amount = ab_ddd(x, administration = "oral", units = FALSE), + units = ab_ddd(x, administration = "oral", units = TRUE)), + iv = list(amount = ab_ddd(x, administration = "iv", units = FALSE), + units = ab_ddd(x, administration = "iv", units = TRUE)))) +} + #' @rdname ab_property #' @export ab_property <- function(x, property = 'name', language = get_locale(), ...) { @@ -169,8 +187,8 @@ ab_validate <- function(x, property, ...) { error = function(e) stop(e$message, call. = FALSE)) if (!all(x %in% AMR::antibiotics[, property])) { - x <- data.frame(ab = as.ab(x), stringsAsFactors = FALSE) %>% - left_join(antibiotics %>% select(c("ab", property)), by = "ab") %>% + x <- data.frame(ab = AMR::as.ab(x), stringsAsFactors = FALSE) %>% + left_join(AMR::antibiotics, by = "ab") %>% pull(property) } if (property %in% c("ab", "atc")) { diff --git a/R/atc.R b/R/atc.R index 4e97ec94..3cdaaa48 100755 --- a/R/atc.R +++ b/R/atc.R @@ -33,7 +33,7 @@ #' #' 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: \url{https://www.whocc.no/atc/structure_and_principles/} -#' @return Character (vector) with class \code{"act"}. Unknown values will return \code{NA}. +#' @return Character (vector) with class \code{"atc"}. Unknown values will return \code{NA}. #' @seealso \code{\link{antibiotics}} for the dataframe that is being used to determine ATCs. #' @inheritSection AMR Read more on our website! #' @examples diff --git a/R/freq.R b/R/freq.R index 305bb3f1..c452d457 100755 --- a/R/freq.R +++ b/R/freq.R @@ -250,7 +250,8 @@ frequency_tbl <- function(x, if (length(user_exprs) > 0) { new_list <- list(0) for (i in 1:length(user_exprs)) { - new_list[[i]] <- eval_tidy(user_exprs[[i]], data = x) + new_list[[i]] <- tryCatch(eval_tidy(user_exprs[[i]], data = x), + error = function(e) stop(e$message, call. = FALSE)) if (length(new_list[[i]]) == 1) { if (is.character(new_list[[i]]) & new_list[[i]] %in% colnames(x)) { # support septic_patients %>% freq("hospital_id") @@ -330,8 +331,27 @@ frequency_tbl <- function(x, cols <- NULL # mult.columns <- 2 } else { - x.name <- NULL - cols <- NULL + x.name <- deparse(substitute(x)) + if (x.name %like% "[$]") { + cols <- unlist(strsplit(x.name, "$", fixed = TRUE))[2] + x.name <- unlist(strsplit(x.name, "$", fixed = TRUE))[1] + # try to find the object to determine dimensions + x.obj <- tryCatch(get(x.name), error = function(e) NULL) + x.name <- paste0("`", x.name , "`") + if (!is.null(x.obj)) { + x.name <- paste0(x.name, + " (", + x.obj %>% + dim() %>% + format(decimal.mark = decimal.mark, big.mark = big.mark) %>% + trimws() %>% + paste(collapse = " x "), + ")") + } + } else { + x.name <- NULL + cols <- NULL + } } if (!is.null(ncol(x))) { @@ -566,7 +586,7 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ", # rsi if (has_length == TRUE & any(x_class == "rsi")) { ab <- tryCatch(as.ab(attributes(x)$opt$vars), error = function(e) NA) - if (!is.na(ab)) { + if (!is.na(ab) & isTRUE(length(ab) > 0)) { header$drug <- paste0(ab_name(ab[1L]), " (", ab[1L], ", ", ab_atc(ab[1L]), ")") header$group <- ab_group(ab[1L]) } diff --git a/R/misc.R b/R/misc.R index de04afc8..8335c362 100755 --- a/R/misc.R +++ b/R/misc.R @@ -390,9 +390,12 @@ t <- function(from, language = get_locale()) { df_trans$fixed[is.na(df_trans$fixed)] <- TRUE # check if text to look for is in one of the patterns - pattern_total <- tryCatch(paste0("(", paste(df_trans$pattern, collapse = "|"), ")"), - error = "") - if (NROW(df_trans) == 0 | !any(from %like% pattern_total)) { + any_form_in_patterns <- tryCatch(any(from %like% paste0("(", paste(df_trans$pattern, collapse = "|"), ")")), + error = function(e) { + warning("Translation not possible. Please open an issue on GitLab (https://gitlab.com/msberends/AMR/issues) or GitHub (https://github.com/msberends/AMR/issues).", call. = FALSE) + return(FALSE) + }) + if (NROW(df_trans) == 0 | !any_form_in_patterns) { return(from) } diff --git a/R/mo.R b/R/mo.R index 05c5203d..4e8da091 100755 --- a/R/mo.R +++ b/R/mo.R @@ -349,6 +349,7 @@ exec_as.mo <- function(x, # conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life) if (any(x %like% "^[BFP]_[A-Z]{3,7}") & !all(x %in% microorganisms$mo)) { + x <- gsub("^F_CANDD_GLB$", "F_CANDD_GLA", x) # specific old code for C. glabrata leftpart <- gsub("^([BFP]_[A-Z]{3,7}).*", "\\1", x) if (any(leftpart %in% names(mo_codes_v0.5.0))) { rightpart <- gsub("^[BFP]_[A-Z]{3,7}(.*)", "\\1", x) diff --git a/data/WHONET.rda b/data/WHONET.rda index 144c0cb2..358d0b2d 100644 Binary files a/data/WHONET.rda and b/data/WHONET.rda differ diff --git a/data/antibiotics.rda b/data/antibiotics.rda index 6aa57c28..14248d0e 100755 Binary files a/data/antibiotics.rda and b/data/antibiotics.rda differ diff --git a/data/microorganisms.codes.rda b/data/microorganisms.codes.rda index 9b5fd9f4..85322ea8 100644 Binary files a/data/microorganisms.codes.rda and b/data/microorganisms.codes.rda differ diff --git a/data/microorganisms.old.rda b/data/microorganisms.old.rda index 87cd2321..a62408fd 100644 Binary files a/data/microorganisms.old.rda and b/data/microorganisms.old.rda differ diff --git a/data/microorganisms.rda b/data/microorganisms.rda index d3e8ee0c..9b828512 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/data/rsi_translation.rda b/data/rsi_translation.rda index 8bea9e35..24f4af2c 100644 Binary files a/data/rsi_translation.rda and b/data/rsi_translation.rda differ diff --git a/data/septic_patients.rda b/data/septic_patients.rda index 953a95a0..3dab7fcd 100755 Binary files a/data/septic_patients.rda and b/data/septic_patients.rda differ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 5f62e156..9afd5d2f 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -192,7 +192,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

12 May 2019

+

16 May 2019

@@ -201,7 +201,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 R Markdown. However, the methodology remains unchanged. This page was generated on 12 May 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 R Markdown. However, the methodology remains unchanged. This page was generated on 16 May 2019.

Introduction

@@ -217,21 +217,21 @@ -2019-05-12 +2019-05-16 abcd Escherichia coli S S -2019-05-12 +2019-05-16 abcd Escherichia coli S R -2019-05-12 +2019-05-16 efgh Escherichia coli R @@ -327,70 +327,70 @@ -2016-07-20 -N4 -Hospital A -Klebsiella pneumoniae -S -R -R -S -M - - -2013-12-24 -L1 -Hospital A -Escherichia coli -S -S -S -S -M - - -2010-04-21 -C10 +2013-05-13 +X4 Hospital D -Escherichia coli -R +Staphylococcus aureus I -R -S -M - - -2015-07-23 -A3 -Hospital B -Streptococcus pneumoniae S S S -S -M - - -2011-10-17 -V7 -Hospital A -Escherichia coli -R -R -R -S F -2014-09-20 -X4 +2016-09-19 +G9 +Hospital A +Escherichia coli +R +R +S +S +M + + +2015-09-22 +L6 +Hospital D +Escherichia coli +R +S +S +S +M + + +2017-09-13 +N3 +Hospital D +Escherichia coli +S +S +S +S +M + + +2015-12-01 +Z3 +Hospital A +Escherichia coli +S +R +S +S +F + + +2011-02-25 +F10 Hospital B Staphylococcus aureus S S -S -S -F +R +R +M @@ -411,8 +411,8 @@ #> #> Item Count Percent Cum. Count Cum. Percent #> --- ----- ------- -------- ----------- ------------- -#> 1 M 10,367 51.8% 10,367 51.8% -#> 2 F 9,633 48.2% 20,000 100.0% +#> 1 M 10,410 52.0% 10,410 52.0% +#> 2 F 9,590 48.0% 20,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:

data <- data %>%
@@ -442,14 +442,14 @@
 #> Pasteurella multocida (no new changes)
 #> Staphylococcus (no new changes)
 #> Streptococcus groups A, B, C, G (no new changes)
-#> Streptococcus pneumoniae (1473 new changes)
+#> Streptococcus pneumoniae (1532 new changes)
 #> Viridans group streptococci (no new changes)
 #> 
 #> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 01: Intrinsic resistance in Enterobacteriaceae (1282 new changes)
+#> Table 01: Intrinsic resistance in Enterobacteriaceae (1341 new changes)
 #> Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no new changes)
 #> Table 03: Intrinsic resistance in other Gram-negative bacteria (no new changes)
-#> Table 04: Intrinsic resistance in Gram-positive bacteria (2691 new changes)
+#> Table 04: Intrinsic resistance in Gram-positive bacteria (2834 new changes)
 #> Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no new changes)
 #> Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no new changes)
 #> Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no new changes)
@@ -457,24 +457,24 @@
 #> Table 13: Interpretive rules for quinolones (no new changes)
 #> 
 #> Other rules
-#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2218 new changes)
-#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (124 new changes)
+#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2225 new changes)
+#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (109 new changes)
 #> Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no new changes)
 #> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no new changes)
 #> Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no new changes)
 #> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no new changes)
 #> 
 #> --------------------------------------------------------------------------
-#> EUCAST rules affected 6,442 out of 20,000 rows, making a total of 7,788 edits
+#> EUCAST rules affected 6,633 out of 20,000 rows, making a total of 8,041 edits
 #> => added 0 test results
 #> 
-#> => changed 7,788 test results
-#>    - 105 test results changed from S to I
-#>    - 4,678 test results changed from S to R
-#>    - 1,081 test results changed from I to S
-#>    - 315 test results changed from I to R
-#>    - 1,587 test results changed from R to S
-#>    - 22 test results changed from R to I
+#> => changed 8,041 test results
+#>    - 118 test results changed from S to I
+#>    - 4,906 test results changed from S to R
+#>    - 1,094 test results changed from I to S
+#>    - 326 test results changed from I to R
+#>    - 1,577 test results changed from R to S
+#>    - 20 test results changed from R to I
 #> --------------------------------------------------------------------------
 #> 
 #> Use verbose = TRUE to get a data.frame with all specified edits instead.
@@ -502,8 +502,8 @@ #> NOTE: Using column `bacteria` as input for `col_mo`. #> NOTE: Using column `date` as input for `col_date`. #> NOTE: Using column `patient_id` as input for `col_patient_id`. -#> => Found 5,682 first isolates (28.4% of total)
-

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

+#> => Found 5,706 first isolates (28.5% of total) +

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

data_1st <- data %>% 
   filter(first == TRUE)

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

@@ -529,19 +529,19 @@ 1 -2010-01-10 -H7 +2010-01-31 +O3 B_ESCHR_COL +S +S R S -S -S TRUE 2 -2010-01-23 -H7 +2010-04-24 +O3 B_ESCHR_COL S S @@ -551,19 +551,19 @@ 3 -2010-05-15 -H7 +2010-04-26 +O3 B_ESCHR_COL -S -S -S R +S +S +S FALSE 4 -2010-08-16 -H7 +2010-05-07 +O3 B_ESCHR_COL S S @@ -573,63 +573,63 @@ 5 -2010-09-26 -H7 +2010-07-07 +O3 B_ESCHR_COL -S -S R S +S +S FALSE 6 -2010-11-01 -H7 +2010-07-28 +O3 B_ESCHR_COL -R -I +S +S S S FALSE 7 -2010-12-11 -H7 +2010-08-30 +O3 B_ESCHR_COL -S -S +R +R S S FALSE 8 -2011-02-11 -H7 +2010-09-08 +O3 B_ESCHR_COL -S -S R S -TRUE - - -9 -2011-03-16 -H7 -B_ESCHR_COL -I -S R S FALSE + +9 +2010-10-11 +O3 +B_ESCHR_COL +R +S +S +S +FALSE + 10 -2011-04-14 -H7 +2010-11-11 +O3 B_ESCHR_COL S S @@ -639,7 +639,7 @@ -

Only 2 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 should 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 1 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 should 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:

data <- data %>% 
   mutate(keyab = key_antibiotics(.)) %>% 
@@ -650,7 +650,7 @@
 #> NOTE: Using column `patient_id` as input for `col_patient_id`.
 #> NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics  = FALSE to prevent this.
 #> [Criterion] Inclusion based on key antibiotics, ignoring I.
-#> => Found 15,036 first weighted isolates (75.2% of total)
+#> => Found 15,027 first weighted isolates (75.1% of total) @@ -667,20 +667,20 @@ - - + + + + - - - - + + @@ -691,20 +691,20 @@ - - + + - - - + + + - - + + @@ -715,23 +715,23 @@ - - + + - - + + - - + + - - + + @@ -739,11 +739,11 @@ - - + + - - + + @@ -751,32 +751,32 @@ - - + + - + - + - - + + - - + + - + - - + + @@ -787,11 +787,11 @@
isolate
12010-01-10H72010-01-31O3 B_ESCHR_COLSS R SSS TRUE TRUE
22010-01-23H72010-04-24O3 B_ESCHR_COL S S
32010-05-15H72010-04-26O3 B_ESCHR_COLSSS RSSS FALSE TRUE
42010-08-16H72010-05-07O3 B_ESCHR_COL S S
52010-09-26H72010-07-07O3 B_ESCHR_COLSS R SSS FALSE TRUE
62010-11-01H72010-07-28O3 B_ESCHR_COLRISS S S FALSE
72010-12-11H72010-08-30O3 B_ESCHR_COLSSRR S S FALSE
82011-02-11H72010-09-08O3 B_ESCHR_COLSR S R STRUEFALSE TRUE
92011-03-16H72010-10-11O3 B_ESCHR_COLIS R SSS FALSEFALSETRUE
102011-04-14H72010-11-11O3 B_ESCHR_COL S S
-

Instead of 2, now 9 isolates are flagged. In total, 75.2% of all isolates are marked ‘first weighted’ - 46.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.

+

Instead of 1, now 10 isolates are flagged. In total, 75.1% of all isolates are marked ‘first weighted’ - 46.6% 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:

data_1st <- data %>% 
   filter_first_weighted_isolate()
-

So we end up with 15,036 isolates for analysis.

+

So we end up with 15,027 isolates for analysis.

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -817,75 +817,11 @@ 1 -2016-07-20 -N4 -Hospital A -B_KLBSL_PNE -R -R -R -S -M -Gram negative -Klebsiella -pneumoniae -TRUE - - -3 -2010-04-21 -C10 -Hospital D -B_ESCHR_COL -R -I -R -S -M -Gram negative -Escherichia -coli -TRUE - - -4 -2015-07-23 -A3 -Hospital B -B_STRPT_PNE -S -S -S -R -M -Gram positive -Streptococcus -pneumoniae -TRUE - - -5 -2011-10-17 -V7 -Hospital A -B_ESCHR_COL -R -R -R -S -F -Gram negative -Escherichia -coli -TRUE - - -6 -2014-09-20 +2013-05-13 X4 -Hospital B +Hospital D B_STPHY_AUR -S +I S S S @@ -896,11 +832,43 @@ TRUE -7 -2015-09-29 -S7 +2 +2016-09-19 +G9 +Hospital A +B_ESCHR_COL +R +R +S +S +M +Gram negative +Escherichia +coli +TRUE + + +3 +2015-09-22 +L6 Hospital D B_ESCHR_COL +R +S +S +S +M +Gram negative +Escherichia +coli +TRUE + + +5 +2015-12-01 +Z3 +Hospital A +B_ESCHR_COL S S S @@ -911,6 +879,38 @@ coli TRUE + +6 +2011-02-25 +F10 +Hospital B +B_STPHY_AUR +S +S +R +R +M +Gram positive +Staphylococcus +aureus +TRUE + + +7 +2010-08-13 +G10 +Hospital C +B_ESCHR_COL +S +S +S +S +M +Gram negative +Escherichia +coli +TRUE +

Time for the analysis!

@@ -928,9 +928,9 @@
freq(paste(data_1st$genus, data_1st$species))

Or can be used like the dplyr way, which is easier readable:

data_1st %>% freq(genus, species)
-

Frequency table of genus and species from a data.frame (15,036 x 13)

+

Frequency table of genus and species from a data.frame (15,027 x 13)

Columns: 2
-Length: 15,036 (of which NA: 0 = 0.00%)
+Length: 15,027 (of which NA: 0 = 0.00%)
Unique: 4

Shortest: 16
Longest: 24

@@ -947,33 +947,33 @@ Longest: 24

1 Escherichia coli -7,441 -49.5% -7,441 -49.5% +7,318 +48.7% +7,318 +48.7% 2 Staphylococcus aureus -3,779 -25.1% -11,220 -74.6% +3,729 +24.8% +11,047 +73.5% 3 Streptococcus pneumoniae -2,278 -15.2% -13,498 -89.8% +2,370 +15.8% +13,417 +89.3% 4 Klebsiella pneumoniae -1,538 -10.2% -15,036 +1,610 +10.7% +15,027 100.0% @@ -984,7 +984,7 @@ Longest: 24

Resistance percentages

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

data_1st %>% portion_IR(AMX)
-#> [1] 0.494879
+#> [1] 0.4973714

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

data_1st %>% 
   group_by(hospital) %>% 
@@ -997,19 +997,19 @@ Longest: 24

Hospital A -0.5024412 +0.4993375 Hospital B -0.5015980 +0.4931245 Hospital C -0.4683146 +0.5068182 Hospital D -0.4912927 +0.4949396 @@ -1027,23 +1027,23 @@ Longest: 24

Hospital A -0.5024412 -4506 +0.4993375 +4528 Hospital B -0.5015980 -5319 +0.4931245 +5236 Hospital C -0.4683146 -2225 +0.5068182 +2200 Hospital D -0.4912927 -2986 +0.4949396 +3063 @@ -1063,27 +1063,27 @@ Longest: 24

Escherichia -0.8770327 -0.8982664 -0.9908614 +0.8800219 +0.8938234 +0.9885215 Klebsiella -0.7418726 -0.9037711 -0.9817945 +0.7136646 +0.9012422 +0.9732919 Staphylococcus -0.8840963 -0.9237894 -0.9886213 +0.8806651 +0.9115044 +0.9895414 Streptococcus -0.5697981 +0.5751055 0.0000000 -0.5697981 +0.5751055 @@ -1167,13 +1167,13 @@ Longest: 24

IR -24 -33 +25 +77 S -25 -77 +24 +33 @@ -1194,10 +1194,10 @@ Longest: 24

#> p-value = 0.03104 #> alternative hypothesis: true odds ratio is not equal to 1 #> 95 percent confidence interval: -#> 1.054283 4.735995 +#> 0.2111489 0.9485124 #> sample estimates: #> odds ratio -#> 2.228006
+#> 0.4488318

As can be seen, the p value is 0.03, which means that the fosfomycin resistances found in hospital A and D are really different.

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 9d1133ac..21c067cd 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 04d91141..8285c7ea 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 040e277b..b841dd0b 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 424d72d3..1d3cbbe4 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 5e05b9fd..30465c6a 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -40,7 +40,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -105,7 +105,7 @@
  • - + Get properties of an antibiotic @@ -192,7 +192,7 @@

    How to apply EUCAST rules

    Matthijs S. Berends

    -

    27 March 2019

    +

    16 May 2019

    diff --git a/docs/articles/G_test.html b/docs/articles/G_test.html index 9f07c8e3..fbb905f1 100644 --- a/docs/articles/G_test.html +++ b/docs/articles/G_test.html @@ -40,7 +40,7 @@
    AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -105,7 +105,7 @@
  • - + Get properties of an antibiotic @@ -192,7 +192,7 @@

    How to use the G-test

    Matthijs S. Berends

    -

    27 March 2019

    +

    16 May 2019

    diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index 8f8d34cf..f726b5d4 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -192,7 +192,7 @@

    How to import data from SPSS / SAS / Stata

    Matthijs S. Berends

    -

    12 May 2019

    +

    16 May 2019

    diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index ff1d5e4b..3286f33b 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -40,7 +40,7 @@
    AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -105,7 +105,7 @@
  • - + Get properties of an antibiotic @@ -192,7 +192,7 @@

    How to work with WHONET data

    Matthijs S. Berends

    -

    27 March 2019

    +

    16 May 2019

    @@ -336,12 +336,13 @@ Species: 38

    # amoxicillin/clavulanic acid (J01CR02) as an example data %>% freq(AMC_ND2)

    Frequency table of AMC_ND2 from a data.frame (500 x 54)

    -
    # Warning: These values could not be coerced to a valid atc: "AMCND".

    Class: factor > ordered > rsi (numeric)
    Length: 500 (of which NA: 19 = 3.80%)
    Levels: 3: S < I < R
    Unique: 3

    -

    %IR: 25.99%

    +

    Drug: Amoxicillin/clavulanic acid (AMC, J01CR02)
    +Group: Beta-lactams/penicillins
    +%SI: 78.59%

    diff --git a/docs/articles/ab_property.html b/docs/articles/ab_property.html index b7e95d43..1364f68f 100644 --- a/docs/articles/ab_property.html +++ b/docs/articles/ab_property.html @@ -192,7 +192,7 @@

    How to get properties of an antibiotic

    Matthijs S. Berends

    -

    12 May 2019

    +

    16 May 2019

    diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 03572dca..6031f919 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -192,7 +192,7 @@

    Benchmarks

    Matthijs S. Berends

    -

    12 May 2019

    +

    16 May 2019

    @@ -217,14 +217,14 @@ times = 10)print(S.aureus, unit ="ms", signif =2)#> Unit: milliseconds -#> expr min lq mean median uq max neval -#> as.mo("sau") 17.0 17.0 22.0 18 18 65 10 -#> as.mo("stau") 47.0 47.0 52.0 47 48 92 10 -#> as.mo("staaur") 17.0 18.0 18.0 18 18 18 10 -#> as.mo("STAAUR") 17.0 18.0 32.0 18 62 77 10 -#> as.mo("S. aureus") 28.0 28.0 37.0 28 30 72 10 -#> as.mo("S. aureus") 28.0 28.0 46.0 29 72 110 10 -#> as.mo("Staphylococcus aureus") 7.9 7.9 8.4 8 8 12 10 +#> expr min lq mean median uq max neval +#> as.mo("sau") 17.0 18 26 18.0 18.0 65 10 +#> as.mo("stau") 47.0 47 52 48.0 49.0 92 10 +#> as.mo("staaur") 17.0 18 22 18.0 18.0 62 10 +#> as.mo("STAAUR") 18.0 18 24 18.0 18.0 78 10 +#> as.mo("S. aureus") 28.0 28 37 28.0 30.0 73 10 +#> as.mo("S. aureus") 28.0 28 46 28.0 72.0 120 10 +#> as.mo("Staphylococcus aureus") 7.9 8 13 8.3 8.5 52 10

    In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.

    To achieve this speed, the as.mo function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Thermus islandicus (B_THERMS_ISL), a bug probably never found before in humans:

    T.islandicus <- microbenchmark(as.mo("theisl"),
    @@ -236,12 +236,12 @@
     print(T.islandicus, unit = "ms", signif = 2)
     #> Unit: milliseconds
     #>                         expr min  lq mean median  uq max neval
    -#>              as.mo("theisl") 470 470  490    480 520 530    10
    -#>              as.mo("THEISL") 470 520  520    520 520 530    10
    -#>       as.mo("T. islandicus")  75  76   76     76  76  77    10
    -#>      as.mo("T.  islandicus")  76  76   86     77  79 130    10
    -#>  as.mo("Thermus islandicus")  74  74   89     75 120 120    10
    -

    That takes 8.2 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.

    +#> as.mo("theisl") 470 470 490 470 520 530 10 +#> as.mo("THEISL") 470 470 490 480 520 530 10 +#> as.mo("T. islandicus") 76 76 91 77 120 120 10 +#> as.mo("T. islandicus") 76 76 90 76 120 120 10 +#> as.mo("Thermus islandicus") 74 74 95 81 120 130 10 +

    That takes 8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.

    In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Thermus islandicus (which is very uncommon):

    par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
     
    @@ -286,9 +286,9 @@
                              times = 10)
     print(run_it, unit = "ms", signif = 3)
     #> Unit: milliseconds
    -#>            expr min  lq mean median  uq  max neval
    -#>  mo_fullname(x) 836 837  893    883 925 1000    10
    -

    So transforming 500,000 values (!!) of 50 unique values only takes 0.88 seconds (882 ms). You only lose time on your unique input values.

    +#> expr min lq mean median uq max neval +#> mo_fullname(x) 732 811 816 817 819 941 10 +

    So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (817 ms). You only lose time on your unique input values.

    @@ -301,9 +301,9 @@ print(run_it, unit = "ms", signif = 3) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> A 12.80 13.10 13.20 13.20 13.20 13.50 10 -#> B 25.20 25.30 30.00 25.60 25.90 69.70 10 -#> C 1.26 1.37 1.58 1.69 1.72 1.73 10

    +#> A 12.80 12.90 13.30 13.30 13.60 14.20 10 +#> B 25.40 25.60 30.70 25.90 27.40 70.80 10 +#> C 1.25 1.36 1.54 1.68 1.69 1.74 10

    So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0017 seconds - it doesn’t even start calculating if the result would be the same as the expected resulting value. That goes for all helper functions:

    run_it <- microbenchmark(A = mo_species("aureus"),
                              B = mo_genus("Staphylococcus"),
    @@ -317,14 +317,14 @@
     print(run_it, unit = "ms", signif = 3)
     #> Unit: milliseconds
     #>  expr   min    lq  mean median    uq   max neval
    -#>     A 0.429 0.441 0.486  0.491 0.510 0.562    10
    -#>     B 0.437 0.521 0.555  0.577 0.596 0.651    10
    -#>     C 1.300 1.460 1.730  1.890 1.900 1.960    10
    -#>     D 0.444 0.531 0.565  0.563 0.619 0.704    10
    -#>     E 0.399 0.431 0.471  0.471 0.508 0.535    10
    -#>     F 0.344 0.396 0.432  0.445 0.471 0.500    10
    -#>     G 0.390 0.397 0.464  0.465 0.492 0.624    10
    -#>     H 0.201 0.222 0.291  0.303 0.339 0.423    10
    +#> A 0.403 0.504 0.523 0.531 0.563 0.627 10 +#> B 0.431 0.542 0.620 0.640 0.685 0.785 10 +#> C 1.310 1.450 1.640 1.650 1.880 1.980 10 +#> D 0.427 0.468 0.599 0.566 0.597 0.943 10 +#> E 0.406 0.510 0.542 0.526 0.593 0.715 10 +#> F 0.358 0.422 0.492 0.481 0.511 0.678 10 +#> G 0.349 0.425 0.487 0.485 0.512 0.661 10 +#> H 0.204 0.292 0.360 0.341 0.434 0.528 10

    Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.

    @@ -351,13 +351,13 @@ print(run_it, unit = "ms", signif = 4) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> en 18.01 18.11 18.30 18.27 18.35 18.78 10 -#> de 22.91 23.00 27.53 23.03 23.28 67.49 10 -#> nl 35.30 35.42 44.34 35.49 35.90 79.60 10 -#> es 22.98 23.02 23.18 23.09 23.31 23.58 10 -#> it 22.82 22.89 23.02 22.95 23.19 23.29 10 -#> fr 22.95 23.05 23.08 23.08 23.10 23.36 10 -#> pt 22.99 23.06 32.00 23.16 23.32 67.65 10
    +#> en 18.16 18.21 18.27 18.23 18.25 18.53 10 +#> de 23.02 23.12 23.25 23.19 23.40 23.62 10 +#> nl 35.25 35.46 40.22 35.93 36.49 79.63 10 +#> es 22.97 23.07 27.79 23.34 23.69 68.06 10 +#> it 22.91 22.91 32.09 23.21 23.96 67.71 10 +#> fr 23.10 23.13 27.95 23.46 23.65 67.64 10 +#> pt 22.96 23.07 23.22 23.14 23.42 23.63 10

    Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.

    diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png index 950a5887..64024219 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/freq.html b/docs/articles/freq.html index bcd802ec..4d514cb6 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -192,7 +192,7 @@

    How to create frequency tables

    Matthijs S. Berends

    -

    12 May 2019

    +

    16 May 2019

    diff --git a/docs/articles/mo_property.html b/docs/articles/mo_property.html index a730030e..4aee7ecb 100644 --- a/docs/articles/mo_property.html +++ b/docs/articles/mo_property.html @@ -40,7 +40,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -105,7 +105,7 @@
  • - + Get properties of an antibiotic @@ -192,7 +192,7 @@

    How to get properties of a microorganism

    Matthijs S. Berends

    -

    27 March 2019

    +

    16 May 2019

    diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index 2fb4ec24..7d748d0a 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -192,7 +192,7 @@

    How to predict antimicrobial resistance

    Matthijs S. Berends

    -

    13 May 2019

    +

    16 May 2019

    diff --git a/docs/extra.js b/docs/extra.js index 35858b3a..4737e496 100644 --- a/docs/extra.js +++ b/docs/extra.js @@ -67,6 +67,8 @@ $( document ).ready(function() { x = x.replace("Alex", "Prof Dr Alex"); x = x.replace("Bhanu", "Prof Dr Bhanu"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); + x = x.replace(/Author, maintainer./g, ""); + x = x.replace(/Author./g, ""); } return(x); } diff --git a/docs/index.html b/docs/index.html index dbb82f62..db1cc47a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -315,9 +315,9 @@

    It cleanses existing data by providing new classes for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:

  • diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index d83d7e74..eb022f0a 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index 8063e468..389cc770 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic @@ -271,7 +271,7 @@
    Inducible clindamycin resistance

    Clindamycin can be induced?

    Comment

    Other comments

    Date of data entry

    Date this data was entered in WHONET

    -
    AMP_ND10:CIP_EE

    27 different antibiotics. You can lookup the abbreviatons in the antibiotics data set, or use e.g. atc_name("AMP") to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using as.rsi.

    +
    AMP_ND10:CIP_EE

    27 different antibiotics. You can lookup the abbreviatons in the antibiotics data set, or use e.g. atc_name("AMP") to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using as.rsi.

    Read more on our website!

    diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index 6097afb1..4e7d4bac 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -251,11 +251,11 @@ ab_tradenames(x, ...) -ab_group(x, ...) +ab_group(x, language = get_locale(), ...) -ab_atc_group1(x, ...) +ab_atc_group1(x, language = get_locale(), ...) -ab_atc_group2(x, ...) +ab_atc_group2(x, language = get_locale(), ...) ab_ddd(x, administration = "oral", units = FALSE, ...) @@ -299,7 +299,7 @@ @@ -349,6 +349,8 @@ ab_ddd("AMX", "iv") # 1 ab_ddd("AMX", "iv", units = TRUE) # "g" +ab_info("AMX") # all properties as a list + # all ab_* functions use as.ab() internally: ab_name("Fluclox") # "Flucloxacillin" ab_name("fluklox") # "Flucloxacillin" diff --git a/docs/reference/age.html b/docs/reference/age.html index dfddd698..ed527a1c 100644 --- a/docs/reference/age.html +++ b/docs/reference/age.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index be457dde..cf428083 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -241,7 +241,9 @@ -
    as.ab(x)
    +
    as.ab(x)
    +
    +is.ab(x)

    Arguments

  • @@ -298,7 +300,7 @@ This package contains all ~450 antimicrobial drugs and their An as.ab(" eryt 123") as.ab("ERYT") as.ab("ERY") -as.ab("erytromicine") # spelled wrong +as.ab("eritromicine") # spelled wrong, yet worksas.ab("Erythrocin") # trade nameas.ab("Romycin") # trade name diff --git a/docs/reference/as.atc.html b/docs/reference/as.atc.html index 88b6b92d..c19d1c9e 100644 --- a/docs/reference/as.atc.html +++ b/docs/reference/as.atc.html @@ -6,7 +6,7 @@ -Transform to ATC code — is.ab • AMR (for R) +Transform to ATC code — as.atc • AMR (for R) @@ -45,7 +45,7 @@ - + @@ -241,9 +241,7 @@ -
    is.ab(x)
    -
    -as.atc(x)
    +    
    as.atc(x)
     
     is.atc(x)
    @@ -258,7 +256,7 @@

    Value

    -

    Character (vector) with class "act". Unknown values will return NA.

    +

    Character (vector) with class "atc". Unknown values will return NA.

    Details

    diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index 22b38836..9d020a33 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/availability.html b/docs/reference/availability.html index b5f13cab..2fdd2163 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index 8230bac4..d16fc8a1 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/index.html b/docs/reference/index.html index 53b3ad07..1f7dcfe6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -281,13 +281,13 @@
  • diff --git a/docs/reference/join.html b/docs/reference/join.html index 9187065b..ced75a64 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index 4d1de794..05cbb8df 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/like.html b/docs/reference/like.html index 6bd7eb46..6ed81acf 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index 2aca4e00..c521e4a5 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -81,7 +81,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -146,7 +146,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
  • - + Get properties of an antibiotic diff --git a/docs/reference/p.symbol.html b/docs/reference/p.symbol.html index f964ee4e..c8d43e31 100644 --- a/docs/reference/p.symbol.html +++ b/docs/reference/p.symbol.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/read.4D.html b/docs/reference/read.4D.html index 35e2b122..c36046fe 100644 --- a/docs/reference/read.4D.html +++ b/docs/reference/read.4D.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic diff --git a/docs/reference/septic_patients.html b/docs/reference/septic_patients.html index 9bcae10a..77ebdc49 100644 --- a/docs/reference/septic_patients.html +++ b/docs/reference/septic_patients.html @@ -80,7 +80,7 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -145,7 +145,7 @@
  • - + Get properties of an antibiotic @@ -255,7 +255,7 @@
    gender

    gender of the patient

    patient_id

    ID of the patient, first 10 characters of an SHA hash containing irretrievable information

    mo

    ID of microorganism created with as.mo, see also microorganisms

    -
    peni:rifa

    40 different antibiotics with class rsi (see as.rsi); these column names occur in antibiotics data set and can be translated with abname

    +
    peni:rifa

    40 different antibiotics with class rsi (see as.rsi); these column names occur in antibiotics data set and can be translated with abname

    Read more on our website!

    diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index 6bd398f1..1895e97c 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -81,7 +81,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -146,7 +146,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
  • - + Get properties of an antibiotic diff --git a/index.md b/index.md index 44c362ad..f6dd6d71 100644 --- a/index.md +++ b/index.md @@ -134,9 +134,9 @@ The `AMR` package basically does four important things: 1. It **cleanses existing data** by providing new *classes* for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect: * Use `as.mo()` to get a microbial ID. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)). + * Use `as.ab()` to get an antibiotic ID. Like microbial IDs, these IDs are also human readable based on those used by EARS-Net. For example, the ID of amoxicillin is `AMX` and the ID of gentamicin is `GEN`. The `as.ab()` function also uses intelligent rules to find results like accepting misspelling, trade names and abbrevations used in many laboratory systems. For instance, the values "Furabid", "Furadantin", "nitro" all return the ID of Nitrofurantoine. To accomplish this, the package contains a database with most LIS codes, official names, trade names, DDDs and categories of antibiotics. The function `as.atc()` will return the ATC code of an antibiotic as defined by the WHO. * Use `as.rsi()` to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like "<=0.002; S" (combined MIC/RSI) will result in "S". * Use `as.mic()` to cleanse your MIC values. It produces a so-called factor (called *ordinal* in SPSS) with valid MIC values as levels. A value like "<=0.002; S" (combined MIC/RSI) will result in "<=0.002". - * Use `as.ab()` to get a antibiotic ID, which are abbreviations used by EARS-Net whenever available. Use `as.atc()` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ID of Nitrofurantoine. 2. It **enhances existing data** and **adds new data** from data sets included in this package. diff --git a/inst/translations.tsv b/inst/translations.tsv index 53e028a3..2a1c4df3 100644 --- a/inst/translations.tsv +++ b/inst/translations.tsv @@ -191,7 +191,7 @@ nl Cefmetazole Cefmetazol nl Cefodizime Cefodizim nl Cefonicid Cefonicide nl Cefoperazone Cefoperazon -nl Cefoperazone/beta-lactamase inhibitor Cefoperazon combinatiepreparaten +nl Cefoperazone/beta-lactamase inhibitor Cefoperazon/enzymremmer nl Cefotaxime Cefotaxim nl Cefoxitin Cefoxitine nl Cefpirome Cefpirom @@ -297,8 +297,8 @@ nl Quinupristin/dalfopristin Quinupristine/dalfopristine nl Ribostamycin Ribostamycine nl Rifabutin Rifabutine nl Rifampicin Rifampicine -nl Rifampicin, pyrazinamide, ethambutol/isoniazid Rifampicine/pyrazinamide, ethambutol en isoniazide -nl Rifampicin, pyrazinamide/isoniazid Rifampicine/pyrazinamide en isoniazide +nl Rifampicin/pyrazinamide/ethambutol/isoniazid Rifampicine/pyrazinamide/ethambutol/isoniazide +nl Rifampicin/pyrazinamide/isoniazid Rifampicine/pyrazinamide/isoniazide nl Rifampicin/isoniazid Rifampicine/isoniazide nl Rifamycin Rifamycine nl Rifaximin Rifaximine @@ -307,11 +307,11 @@ nl Rosoxacin Rosoxacine nl Roxithromycin Roxitromycine nl Rufloxacin Rufloxacine nl Sisomicin Sisomicine -nl Sodium aminosalicylate Aminosalicylzuur,4- (na-zout) +nl Sodium aminosalicylate Aminosalicylzuur nl Sparfloxacin Sparfloxacine nl Spectinomycin Spectinomycine nl Spiramycin Spiramycine -nl Spiramycin/metronidazole Spiramycine/andere antibacteriele middelen +nl Spiramycin/metronidazole Spiramycine/metronidazol nl Staphylococcus immunoglobulin Stafylokokkenimmunoglobuline nl Streptoduocin Streptoduocine nl Streptomycin Streptomycine @@ -345,7 +345,6 @@ nl Temocillin Temocilline nl Tenofovir disoproxil Tenofovir nl Terizidone Terizidon nl Thiamphenicol Thiamfenicol -nl Thiamphenicol Thiamfenicol combinatiepreparaten nl Thioacetazone/isoniazid Thioacetazon/isoniazide nl Ticarcillin Ticarcilline nl Ticarcillin/beta-lactamase inhibitor Ticarcilline/enzymremmer @@ -355,3 +354,18 @@ nl Troleandomycin Troleandomycine nl Trovafloxacin Trovafloxacine nl Vancomycin Vancomycine nl Voriconazole Voriconazol +nl Aminoglycosides Aminoglycosiden TRUE FALSE +nl Amphenicols Amfenicolen TRUE FALSE +nl Antifungals/antimycotics Antifungica/antimycotica TRUE FALSE +nl Antimycobacterials Antimycobacteriele middelen TRUE FALSE +nl Beta-lactams/penicillins Beta-lactams/penicillines TRUE FALSE +nl Cephalosporins (1st gen.) Cefalosporines (1e gen.) TRUE FALSE +nl Cephalosporins (2nd gen.) Cefalosporines (2e gen.) TRUE FALSE +nl Cephalosporins (3rd gen.) Cefalosporines (3e gen.) TRUE FALSE +nl Cephalosporins (4th gen.) Cefalosporines (4e gen.) TRUE FALSE +nl Cephalosporins Cefalosporines TRUE FALSE +nl Glycopeptides Glycopeptiden TRUE FALSE +nl Macrolides/lincosamides Macroliden/lincosamiden TRUE FALSE +nl Other antibacterials Overige antibiotica TRUE FALSE +nl Polymyxins Polymyxines TRUE FALSE +nl Quinolones Quinolonen TRUE FALSE diff --git a/man/ab_property.Rd b/man/ab_property.Rd index 8abb59dc..ea7c8248 100644 --- a/man/ab_property.Rd +++ b/man/ab_property.Rd @@ -23,11 +23,11 @@ ab_synonyms(x, ...) ab_tradenames(x, ...) -ab_group(x, ...) +ab_group(x, language = get_locale(), ...) -ab_atc_group1(x, ...) +ab_atc_group1(x, language = get_locale(), ...) -ab_atc_group2(x, ...) +ab_atc_group2(x, language = get_locale(), ...) ab_ddd(x, administration = "oral", units = FALSE, ...) @@ -51,7 +51,7 @@ ab_property(x, property = "name", language = get_locale(), ...) \value{ \itemize{ \item{An \code{integer} in case of \code{ab_cid}} - \item{A named \code{list} in case of multiple \code{ab_synonyms}} + \item{A named \code{list} in case of \code{ab_info} and multiple \code{ab_synonyms}/\code{ab_tradenames}} \item{A \code{double} in case of \code{ab_ddd}} \item{A \code{character} in all other cases} } @@ -98,6 +98,8 @@ ab_ddd("AMX", "oral", units = TRUE) # "g" ab_ddd("AMX", "iv") # 1 ab_ddd("AMX", "iv", units = TRUE) # "g" +ab_info("AMX") # all properties as a list + # all ab_* functions use as.ab() internally: ab_name("Fluclox") # "Flucloxacillin" ab_name("fluklox") # "Flucloxacillin" diff --git a/man/as.ab.Rd b/man/as.ab.Rd index bbc072bd..5dd468f2 100644 --- a/man/as.ab.Rd +++ b/man/as.ab.Rd @@ -2,9 +2,12 @@ % Please edit documentation in R/ab.R \name{as.ab} \alias{as.ab} +\alias{is.ab} \title{Transform to antibiotic ID} \usage{ as.ab(x) + +is.ab(x) } \arguments{ \item{x}{character vector to determine to antibiotic ID} @@ -56,7 +59,7 @@ as.ab("eryt") as.ab(" eryt 123") as.ab("ERYT") as.ab("ERY") -as.ab("erytromicine") # spelled wrong +as.ab("eritromicine") # spelled wrong, yet works as.ab("Erythrocin") # trade name as.ab("Romycin") # trade name diff --git a/man/as.atc.Rd b/man/as.atc.Rd index 7c8b623b..b4260c7b 100644 --- a/man/as.atc.Rd +++ b/man/as.atc.Rd @@ -1,14 +1,11 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ab.R, R/atc.R -\name{is.ab} -\alias{is.ab} +% Please edit documentation in R/atc.R +\name{as.atc} \alias{as.atc} \alias{atc} \alias{is.atc} \title{Transform to ATC code} \usage{ -is.ab(x) - as.atc(x) is.atc(x) @@ -17,7 +14,7 @@ is.atc(x) \item{x}{character vector to determine \code{ATC} code} } \value{ -Character (vector) with class \code{"act"}. Unknown values will return \code{NA}. +Character (vector) with class \code{"atc"}. Unknown values will return \code{NA}. } \description{ Use this function to determine the ATC code of one or more antibiotics. The data set \code{\link{antibiotics}} will be searched for abbreviations, official names and trade names. diff --git a/pkgdown/extra.js b/pkgdown/extra.js index 35858b3a..4737e496 100644 --- a/pkgdown/extra.js +++ b/pkgdown/extra.js @@ -67,6 +67,8 @@ $( document ).ready(function() { x = x.replace("Alex", "Prof Dr Alex"); x = x.replace("Bhanu", "Prof Dr Bhanu"); x = x.replace(/Author, thesis advisor/g, "Doctoral advisor"); + x = x.replace(/Author, maintainer./g, ""); + x = x.replace(/Author./g, ""); } return(x); } diff --git a/tests/testthat/test-ab_property.R b/tests/testthat/test-ab_property.R index fb42cd10..529950f4 100644 --- a/tests/testthat/test-ab_property.R +++ b/tests/testthat/test-ab_property.R @@ -49,6 +49,8 @@ test_that("ab_property works", { expect_identical(ab_name(x = c("AMC", "PLB"), tolower = TRUE), c("amoxicillin/clavulanic acid", "polymyxin B")) + expect_equal(class(ab_info("AMX")), "list") + expect_error(ab_property("amox", "invalid property")) expect_error(ab_name("amox", language = "INVALID")) expect_output(print(ab_name("amox", language = NULL)))
  • -

    as.ab()

    +

    as.ab() is.ab()

    Transform to antibiotic ID

    -

    is.ab() as.atc() is.atc()

    +

    as.atc() is.atc()

    Transform to ATC code