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 @@
AMR.Rmd
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.
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.
So only 28.4% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.5% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
For future use, the above two syntaxes can be shortened with the filter_first_isolate()
function:
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)
isolate | @@ -667,20 +667,20 @@||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-10 | -H7 | +2010-01-31 | +O3 | B_ESCHR_COL | +S | +S | R | S | -S | -S | TRUE | TRUE | |
2 | -2010-01-23 | -H7 | +2010-04-24 | +O3 | B_ESCHR_COL | S | S | @@ -691,20 +691,20 @@|||||||
3 | -2010-05-15 | -H7 | +2010-04-26 | +O3 | B_ESCHR_COL | -S | -S | -S | R | +S | +S | +S | FALSE | TRUE |
4 | -2010-08-16 | -H7 | +2010-05-07 | +O3 | B_ESCHR_COL | S | S | @@ -715,23 +715,23 @@|||||||
5 | -2010-09-26 | -H7 | +2010-07-07 | +O3 | B_ESCHR_COL | -S | -S | R | S | +S | +S | FALSE | TRUE | |
6 | -2010-11-01 | -H7 | +2010-07-28 | +O3 | B_ESCHR_COL | -R | -I | +S | +S | S | S | FALSE | @@ -739,11 +739,11 @@||
7 | -2010-12-11 | -H7 | +2010-08-30 | +O3 | B_ESCHR_COL | -S | -S | +R | +R | S | S | FALSE | @@ -751,32 +751,32 @@||
8 | -2011-02-11 | -H7 | +2010-09-08 | +O3 | B_ESCHR_COL | -S | +R | S | R | S | -TRUE | +FALSE | TRUE | |
9 | -2011-03-16 | -H7 | +2010-10-11 | +O3 | B_ESCHR_COL | -I | -S | R | S | +S | +S | FALSE | -FALSE | +TRUE |
10 | -2011-04-14 | -H7 | +2010-11-11 | +O3 | B_ESCHR_COL | S | S | @@ -787,11 +787,11 @@
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:
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:
@@ -817,75 +817,11 @@Time for the analysis!
@@ -928,9 +928,9 @@Or can be used like the dplyr
way, which is easier readable:
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
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:
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
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 @@ @@ -105,7 +105,7 @@EUCAST.Rmd
G_test.Rmd
SPSS.Rmd
WHONET.Rmd
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%