diff --git a/DESCRIPTION b/DESCRIPTION index 76521423..d9500f25 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.7.1.9095 -Date: 2019-10-06 +Version: 0.7.1.9096 +Date: 2019-10-07 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index ca2829b0..fbec4890 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 0.7.1.9095 -Last updated: 06-Oct-2019 +# AMR 0.7.1.9096 +Last updated: 07-Oct-2019 ### Breaking * Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`: @@ -23,6 +23,7 @@ ``` This is important, because a value like `"testvalue"` could never be understood by e.g. `mo_name()`, although the class would suggest a valid microbial code. * Function `freq()` has moved to a new package, [`clean`](https://github.com/msberends/clean) ([CRAN link](https://cran.r-project.org/package=clean)), since creating frequency tables actually does not fit the scope of this package. The `freq()` function still works, since it is re-exported from the `clean` package (which will be installed automatically upon updating this `AMR` package). +* Renamed data set `septic_patients` to `example_isolates` ### New * Function `bug_drug_combinations()` to quickly get a `data.frame` with the antimicrobial resistance of any bug-drug combination in a data set. The columns with microorganism codes is guessed automatically and its input is transformed with `mo_shortname()` at default: @@ -94,8 +95,8 @@ * Added support for unknown yeasts and fungi * Changed most microorganism IDs to improve readability. For example, the old code `B_ENTRC_FAE` could have been both *E. faecalis* and *E. faecium*. Its new code is `B_ENTRC_FCLS` and *E. faecium* has become `B_ENTRC_FACM`. Also, the Latin character æ (ae) is now preserved at the start of each genus and species abbreviation. For example, the old code for *Aerococcus urinae* was `B_ARCCC_NAE`. This is now `B_AERCC_URIN`. **IMPORTANT:** Old microorganism IDs are still supported, but support will be dropped in a future version. Use `as.mo()` on your old codes to transform them to the new format. Using functions from the `mo_*` family (like `mo_name()` and `mo_gramstain()`) on old codes, will throw a warning. -* More intelligent guessing for `as.ab()` which also led to bidirectional language support -* Renamed data set `septic_patients` to `example_isolates` +* More intelligent guessing for `as.ab()`, including bidirectional language support +* Added support for the German national guideline (3MRGN/4MRGN) in the `mdro()` function, to determine multi-drug resistant organisms * Function `eucast_rules()`: * Fixed a bug for *Yersinia pseudotuberculosis* * Added more informative errors and warnings diff --git a/R/eucast_rules.R b/R/eucast_rules.R index 5f51bcf8..ce75cdb1 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -41,7 +41,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' @section Antibiotics: #' To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive), or use \code{NULL} to skip a column (e.g. \code{TIC = NULL} to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning. #' -#' The following antibiotics are used for the functions \code{\link{eucast_rules}} and \code{\link{mdro}}. These are shown below in the format '\strong{antimicrobial ID}: name (\emph{ATC code})', sorted by name: +#' The following antibiotics are used for the functions \code{\link{eucast_rules}} and \code{\link{mdro}}. These are shown below in the format '\strong{antimicrobial ID}: name (\href{https://www.whocc.no/atc/structure_and_principles/}{ATC code})', sorted by name: #' #' \strong{AMK}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), #' \strong{AMX}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), diff --git a/R/mdro.R b/R/mdro.R index d7d47303..a38d78cd 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -28,18 +28,20 @@ #' @inheritParams eucast_rules #' @param verbose print additional info: missing antibiotic columns per parameter #' @inheritSection eucast_rules Antibiotics -#' @details Currently supported guidelines are: +#' @details Currently supported guidelines are (case-insensitive): #' \itemize{ -#' \item{\code{guideline = "EUCAST"}: EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link})} -#' \item{\code{guideline = "TB"}: World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" (\href{https://www.who.int/tb/publications/pmdt_companionhandbook/en/}{link})} -#' \item{\code{guideline = "MRGN"}: (work in progress)} -#' \item{\code{guideline = "BRMO"}: Rijksinstituut voor Volksgezondheid en Milieu "WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) [ZKH]" (\href{https://www.rivm.nl/Documenten_en_publicaties/Professioneel_Praktisch/Richtlijnen/Infectieziekten/WIP_Richtlijnen/WIP_Richtlijnen/Ziekenhuizen/WIP_richtlijn_BRMO_Bijzonder_Resistente_Micro_Organismen_ZKH}{link})} +#' \item{\code{guideline = "EUCAST"}: The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link})} +#' \item{\code{guideline = "TB"}: The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" (\href{https://www.who.int/tb/publications/pmdt_companionhandbook/en/}{link})} +#' \item{\code{guideline = "MRGN"}: The German national guideline - Mueller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6} +#' \item{\code{guideline = "BRMO"}: The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu "WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) [ZKH]" (\href{https://www.rivm.nl/Documenten_en_publicaties/Professioneel_Praktisch/Richtlijnen/Infectieziekten/WIP_Richtlijnen/WIP_Richtlijnen/Ziekenhuizen/WIP_richtlijn_BRMO_Bijzonder_Resistente_Micro_Organismen_ZKH}{link})} #' } #' #' Please suggest your own (country-specific) guidelines by letting us know: \url{https://gitlab.com/msberends/AMR/issues/new}. -#' @return For TB (\code{mdr_tb()}): Ordered factor with levels \code{Negative < Mono-resistance < Poly-resistance < Multidrug resistance < Extensive drug resistance}. -#' -#' For everything else: Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests. +#' @return \itemize{ +#' \item{TB guideline - function \code{mdr_tb()} or \code{mdro(..., guideline = "TB")}:\cr Ordered factor with levels \code{Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant < Extensive drug-resistant}} +#' \item{German guideline - function \code{mrgn()} or \code{mdro(..., guideline = "MRGN")}:\cr Ordered factor with levels \code{Negative < 3MRGN < 4MRGN}} +#' \item{Everything else:\cr Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests} +#' } #' @rdname mdro #' @importFrom dplyr %>% #' @importFrom crayon red blue bold @@ -56,7 +58,13 @@ #' #' example_isolates %>% #' mutate(EUCAST = mdro(.), -#' BRMO = brmo(.)) +#' BRMO = brmo(.), +#' MRGN = mrgn(.)) +#' +#' example_isolates %>% +#' rename(PIP = TZP) # no piperacillin, so take piperacillin/tazobactam +#' mrgn() %>% # check German guideline +#' freq() # check frequencies mdro <- function(x, guideline = NULL, col_mo = NULL, @@ -120,10 +128,10 @@ mdro <- function(x, # support per country: } else if (guideline$code == "mrgn") { - guideline$name <- "Germany" - guideline$name <- "" - guideline$version <- "" - guideline$source <- "" + guideline$name <- "Cross-border comparison of the Dutch and German guidelines on multidrug-resistant Gram-negative microorganisms" + guideline$author <- "J. M\u00fcller, A. Voss, R. K\u00f6ck, ..., W.V. Kern, C. Wendt, A.W. Friedrich" + guideline$version <- "N/A" + guideline$source <- "M\u00fcller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6" } else if (guideline$code == "brmo") { guideline$name <- "WIP-Richtlijn Bijzonder Resistente Micro-organismen (BRMO)" guideline$author <- "RIVM (Rijksinstituut voor de Volksgezondheid)" @@ -153,6 +161,15 @@ mdro <- function(x, "RIB", "RFP"), verbose = verbose, ...) + } else if (guideline$code == "mrgn") { + cols_ab <- get_column_abx(x = x, + soft_dependencies = c("PIP", + "CTX", + "CAZ", + "IPM", + "MEM", + "CIP"), + verbose = verbose, ...) } else { cols_ab <- get_column_abx(x = x, verbose = verbose, ...) } @@ -269,7 +286,9 @@ mdro <- function(x, # join to microorganisms data set left_join_microorganisms(by = col_mo) %>% # add unconfirmed to where genus is available - mutate(MDRO = ifelse(!is.na(genus), 1, NA_integer_)) + mutate(MDRO = ifelse(!is.na(genus), 1, NA_integer_)) %>% + # transform to data.frame so subsetting is possible with x[y, z] (might not be the case with tibble/data.table/...) + as.data.frame(stringsAsFactors = FALSE) if (guideline$code == "eucast") { # EUCAST ------------------------------------------------------------------ @@ -302,7 +321,7 @@ mdro <- function(x, "any") # Table 6 trans_tbl(3, - which(x$fullname %like% "^Staphylococcus (aureus|epidermidis|coagulase negatief|hominis|haemolyticus|intermedius|pseudointermedius)"), + which(x$fullname %like% "^(Coagulase-negative|Staphylococcus (aureus|epidermidis|hominis|haemolyticus|intermedius|pseudointermedius))"), c(VAN, TEC, DAP, LNZ, QDA, TGC), "any") trans_tbl(3, @@ -314,7 +333,7 @@ mdro <- function(x, c(carbapenems, VAN, TEC, DAP, LNZ, QDA, TGC, RIF), "any") trans_tbl(3, # Sr. groups A/B/C/G - which(x$fullname %like% "^Streptococcus (pyogenes|agalactiae|equisimilis|equi|zooepidemicus|dysgalactiae|anginosus)"), + which(x$fullname %like% "^Streptococcus (group (A|B|C|G)|pyogenes|agalactiae|equisimilis|equi|zooepidemicus|dysgalactiae|anginosus)"), c(PEN, cephalosporins, VAN, TEC, DAP, LNZ, QDA, TGC), "any") trans_tbl(3, @@ -338,7 +357,51 @@ mdro <- function(x, if (guideline$code == "mrgn") { # Germany ----------------------------------------------------------------- - stop("We are still working on German guidelines in this beta version.", call. = FALSE) + CTX_or_CAZ <- CTX %or% CAZ + IPM_or_MEM <- IPM %or% MEM + x$missing <- NA_character_ + if (is.na(PIP)) PIP <- "missing" + if (is.na(CTX_or_CAZ)) CTX_or_CAZ <- "missing" + if (is.na(IPM_or_MEM)) IPM_or_MEM <- "missing" + if (is.na(IPM)) IPM <- "missing" + if (is.na(MEM)) MEM <- "missing" + if (is.na(CIP)) CIP <- "missing" + + # Table 1 + x[which((x$family == "Enterobacteriaceae" | + x$fullname %like% "^Acinetobacter baumannii") & + x[, PIP] == "R" & + x[, CTX_or_CAZ] == "R" & + x[, IPM_or_MEM] == "S" & + x[, CIP] == "R"), + "MDRO"] <- 2 # 2 = 3MRGN + + x[which((x$family == "Enterobacteriaceae" | + x$fullname %like% "^Acinetobacter baumannii") & + x[, PIP] == "R" & + x[, CTX_or_CAZ] == "R" & + x[, IPM_or_MEM] == "R" & + x[, CIP] == "R"), + "MDRO"] <- 3 # 3 = 4MRGN, overwrites 3MRGN if applicable + + x[which((x$family == "Enterobacteriaceae" | + x$fullname %like% "^Acinetobacter baumannii") & + x[, IPM] == "R" | x[, MEM] == "R"), + "MDRO"] <- 3 # 3 = 4MRGN, always when imipenem or meropenem is R + + x[which(x$fullname %like% "^Pseudomonas aeruginosa" & + (x[, PIP] == "S") + + (x[, CTX_or_CAZ] == "S") + + (x[, IPM_or_MEM] == "S") + + (x[, CIP] == "S") == 1), + "MDRO"] <- 2 # 2 = 3MRGN, if only 1 group is S + + x[which((x$fullname %like% "^Pseudomonas aeruginosa") & + x[, PIP] == "R" & + x[, CTX_or_CAZ] == "R" & + x[, IPM_or_MEM] == "R" & + x[, CIP] == "R"), + "MDRO"] <- 3 # 3 = 4MRGN } if (guideline$code == "brmo") { @@ -486,6 +549,11 @@ mdro <- function(x, levels = 1:5, labels = c("Negative", "Mono-resistant", "Poly-resistant", "Multi-drug-resistant", "Extensive drug-resistant"), ordered = TRUE) + } else if (guideline$code == "mrgn") { + factor(x = x$MDRO, + levels = 1:3, + labels = c("Negative", "3MRGN", "4MRGN"), + ordered = TRUE) } else { factor(x = x$MDRO, levels = 1:3, diff --git a/docs/404.html b/docs/404.html index f5434742..425de77f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index cada0e5d..0f44aaa4 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index d502016e..cb697ca1 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -41,7 +41,7 @@ AMR (for R) - 0.7.1.9091 + 0.7.1.9096 @@ -187,7 +187,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

30 September 2019

+

07 October 2019

@@ -196,7 +196,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 30 September 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 07 October 2019.

Introduction

@@ -212,21 +212,21 @@ -2019-09-30 +2019-10-07 abcd Escherichia coli S S -2019-09-30 +2019-10-07 abcd Escherichia coli S R -2019-09-30 +2019-10-07 efgh Escherichia coli R @@ -321,68 +321,68 @@ -2016-02-07 -I4 -Hospital B -Escherichia coli -S -S -S -S -M - - -2015-09-17 -V3 +2012-10-04 +J3 Hospital B Streptococcus pneumoniae +S +R +S +R +M + + +2015-03-12 +S8 +Hospital A +Staphylococcus aureus +R +I +R +S +F + + +2015-05-15 +Q9 +Hospital A +Klebsiella pneumoniae R S S S F - -2015-02-01 -K5 + +2012-10-15 +G6 Hospital B Escherichia coli -S +I S S S M - -2010-03-05 -X1 -Hospital C -Klebsiella pneumoniae -R -R -S -S -F - -2012-01-13 -V5 +2012-04-15 +G8 +Hospital C +Staphylococcus aureus +R +R +S +R +M + + +2015-03-26 +M3 Hospital B Staphylococcus aureus S -S -S -S -F - - -2014-11-13 -C4 -Hospital B -Escherichia coli -S -S -S +R +R S M @@ -407,8 +407,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,446 52.23% 10,446 52.23% -# 2 F 9,554 47.77% 20,000 100.00% +# 1 M 10,403 52.02% 10,403 52.02% +# 2 F 9,597 47.99% 20,000 100.00%

So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values M and F. From a researchers 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 %>%
@@ -438,14 +438,14 @@
 # Pasteurella multocida (no changes)
 # Staphylococcus (no changes)
 # Streptococcus groups A, B, C, G (no changes)
-# Streptococcus pneumoniae (1,448 values changed)
+# Streptococcus pneumoniae (1,466 values changed)
 # Viridans group streptococci (no changes)
 # 
 # EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-# Table 01: Intrinsic resistance in Enterobacteriaceae (1,335 values changed)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,304 values changed)
 # Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
 # Table 03: Intrinsic resistance in other Gram-negative bacteria (no changes)
-# Table 04: Intrinsic resistance in Gram-positive bacteria (2,751 values changed)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,787 values changed)
 # Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
 # Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
 # Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)
@@ -453,24 +453,24 @@
 # Table 13: Interpretive rules for quinolones (no changes)
 # 
 # Other rules
-# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,259 values changed)
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (125 values changed)
+# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,243 values changed)
+# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (114 values changed)
 # Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)
 # Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
 # Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)
 # Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
 # 
 # --------------------------------------------------------------------------
-# EUCAST rules affected 6,609 out of 20,000 rows, making a total of 7,918 edits
+# EUCAST rules affected 6,571 out of 20,000 rows, making a total of 7,914 edits
 # => added 0 test results
 # 
-# => changed 7,918 test results
-#    - 101 test results changed from S to I
-#    - 4,771 test results changed from S to R
-#    - 1,065 test results changed from I to S
-#    - 321 test results changed from I to R
-#    - 1,636 test results changed from R to S
-#    - 24 test results changed from R to I
+# => changed 7,914 test results
+#    - 104 test results changed from S to I
+#    - 4,762 test results changed from S to R
+#    - 1,059 test results changed from I to S
+#    - 331 test results changed from I to R
+#    - 1,638 test results changed from R to S
+#    - 20 test results changed from R to I
 # --------------------------------------------------------------------------
 # 
 # Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.
@@ -498,8 +498,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,685 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,696 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:

@@ -509,7 +509,7 @@

First weighted isolates

-

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient K5, sorted on date:

+

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient E8, sorted on date:

@@ -525,8 +525,8 @@ - - + + @@ -536,8 +536,8 @@ - - + + @@ -547,10 +547,10 @@ - - + + - + @@ -558,8 +558,8 @@ - - + + @@ -569,30 +569,19 @@ - - + + - - + + - - - - - - - - - - - - - + + @@ -600,42 +589,53 @@ + + + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - + + + + + + + + + + +
isolate
12010-04-28K52010-01-14E8 B_ESCHR_COLI S S
22010-06-18K52010-03-24E8 B_ESCHR_COLI S S
32010-10-15K52010-05-23E8 B_ESCHR_COLIRS S S S
42010-12-16K52010-08-30E8 B_ESCHR_COLI S S
52011-01-17K52010-09-04E8 B_ESCHR_COLISSRR S S FALSE
62011-06-30K5B_ESCHR_COLISSSSTRUE
72011-08-11K52010-09-14E8 B_ESCHR_COLI R SS FALSE
72010-10-02E8B_ESCHR_COLISSRSFALSE
82011-10-18K52011-01-01E8 B_ESCHR_COLIRRSS S S FALSE
92012-04-24K52011-02-10E8 B_ESCHR_COLII S SRFALSE
102012-10-30K5B_ESCHR_COLIRS S S TRUE
102011-03-11E8B_ESCHR_COLISSSSFALSE
-

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 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 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.

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(.)) %>% 
@@ -646,7 +646,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,102 first weighted isolates (75.5% of total)
+# => Found 15,087 first weighted isolates (75.4% of total)
@@ -663,8 +663,8 @@ - - + + @@ -675,8 +675,8 @@ - - + + @@ -687,8 +687,44 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -697,61 +733,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + - - + + @@ -759,35 +759,35 @@ - - + + - - - + + + - - + + - - - + + +
isolate
12010-04-28K52010-01-14E8 B_ESCHR_COLI S S
22010-06-18K52010-03-24E8 B_ESCHR_COLI S S
32010-10-15K52010-05-23E8B_ESCHR_COLISSSSFALSEFALSE
42010-08-30E8B_ESCHR_COLISSSSFALSEFALSE
52010-09-04E8B_ESCHR_COLIRRSSFALSETRUE
62010-09-14E8 B_ESCHR_COLI R SFALSE TRUE
42010-12-16K5B_ESCHR_COLISSSSFALSETRUE
52011-01-17K5B_ESCHR_COLISSSSFALSEFALSE
62011-06-30K5B_ESCHR_COLISSSSTRUETRUE
72011-08-11K52010-10-02E8 B_ESCHR_COLISS R SSS FALSE TRUE
82011-10-18K52011-01-01E8 B_ESCHR_COLIRRSS S S FALSE
92012-04-24K52011-02-10E8 B_ESCHR_COLII S SRFALSESSTRUE TRUE
102012-10-30K52011-03-11E8 B_ESCHR_COLIR S S STRUETRUESFALSEFALSE
-

Instead of 3, now 9 isolates are flagged. In total, 75.5% of all isolates are marked ‘first weighted’ - 47.1% 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 2, now 7 isolates are flagged. In total, 75.4% of all isolates are marked ‘first weighted’ - 47.0% 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,102 isolates for analysis.

+

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

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -813,25 +813,89 @@ 1 -2016-02-07 -I4 +2012-10-04 +J3 Hospital B -B_ESCHR_COLI -S +B_STRPT_PNMN S S S +R M -Gram-negative -Escherichia -coli +Gram-positive +Streptococcus +pneumoniae TRUE 2 -2015-09-17 -V3 +2015-03-12 +S8 +Hospital A +B_STPHY_AURS +R +I +R +S +F +Gram-positive +Staphylococcus +aureus +TRUE + + +3 +2015-05-15 +Q9 +Hospital A +B_KLBSL_PNMN +R +S +S +S +F +Gram-negative +Klebsiella +pneumoniae +TRUE + + +5 +2012-04-15 +G8 +Hospital C +B_STPHY_AURS +R +R +S +R +M +Gram-positive +Staphylococcus +aureus +TRUE + + +6 +2015-03-26 +M3 Hospital B +B_STPHY_AURS +S +S +R +S +M +Gram-positive +Staphylococcus +aureus +TRUE + + +7 +2011-08-08 +V10 +Hospital A B_STRPT_PNMN R R @@ -843,70 +907,6 @@ pneumoniae TRUE - -3 -2015-02-01 -K5 -Hospital B -B_ESCHR_COLI -S -S -S -S -M -Gram-negative -Escherichia -coli -TRUE - - -4 -2010-03-05 -X1 -Hospital C -B_KLBSL_PNMN -R -R -S -S -F -Gram-negative -Klebsiella -pneumoniae -TRUE - - -7 -2016-04-24 -I9 -Hospital A -B_STPHY_AURS -R -S -S -S -M -Gram-positive -Staphylococcus -aureus -TRUE - - -9 -2015-09-18 -O7 -Hospital A -B_ESCHR_COLI -R -S -S -S -F -Gram-negative -Escherichia -coli -TRUE -

Time for the analysis!

@@ -926,7 +926,7 @@
data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 15,102 (of which NA: 0 = 0%)
+Length: 15,087 (of which NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

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

1 Escherichia coli -7,408 -49.05% -7,408 -49.05% +7,412 +49.13% +7,412 +49.13% 2 Staphylococcus aureus -3,747 -24.81% -11,155 -73.86% +3,773 +25.01% +11,185 +74.14% 3 Streptococcus pneumoniae -2,341 -15.50% -13,496 -89.37% +2,331 +15.45% +13,516 +89.59% 4 Klebsiella pneumoniae -1,606 -10.63% -15,102 +1,571 +10.41% +15,087 100.00% @@ -980,7 +980,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. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (portion_R()) and susceptibility as the portion of S and I (portion_SI()). These functions can be used on their own:

data_1st %>% portion_R(AMX)
-# [1] 0.4662959
+# [1] 0.4716643

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

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

Hospital A -0.4653354 +0.4725537 Hospital B -0.4673178 +0.4704871 Hospital C -0.4720576 +0.4684529 Hospital D -0.4613045 +0.4749061 @@ -1023,23 +1023,23 @@ Longest: 24

Hospital A -0.4653354 -4457 +0.4725537 +4609 Hospital B -0.4673178 -5324 +0.4704871 +5235 Hospital C -0.4720576 -2362 +0.4684529 +2314 Hospital D -0.4613045 -2959 +0.4749061 +2929 @@ -1059,27 +1059,27 @@ Longest: 24

Escherichia -0.9226512 -0.8964633 -0.9943305 +0.9202644 +0.8950351 +0.9919050 Klebsiella -0.8281445 -0.8953923 -0.9856787 +0.8166773 +0.9019733 +0.9847231 Staphylococcus -0.9236723 -0.9196691 -0.9954630 +0.9247283 +0.9196926 +0.9939041 Streptococcus -0.6253738 +0.6194766 0.0000000 -0.6253738 +0.6194766 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 1140c870..7797d727 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 1a157cce..a0813f87 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 6039720d..66384219 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 32d3dbdb..1b63c680 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/index.html b/docs/articles/index.html index 1ef2919f..0c630127 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096
diff --git a/docs/authors.html b/docs/authors.html index 9ff80543..d707e21e 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096 diff --git a/docs/index.html b/docs/index.html index f19e24e8..b9cf59af 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096 diff --git a/docs/news/index.html b/docs/news/index.html index 27f9a702..b8521788 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9095 + 0.7.1.9096 @@ -231,11 +231,11 @@ -
+

-AMR 0.7.1.9095 Unreleased +AMR 0.7.1.9096 Unreleased

-

Last updated: 06-Oct-2019

+

Last updated: 07-Oct-2019

Breaking

@@ -258,7 +258,8 @@ For WHONET users, this means that all records/isolates with organism code #> Warning message: #> invalid microorganism code, NA generated
This is important, because a value like "testvalue" could never be understood by e.g. mo_name(), although the class would suggest a valid microbial code. -
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

  • +
  • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).
  • +
  • Renamed data set septic_patients to example_isolates

  • @@ -336,9 +337,8 @@ Since this is a major change, usage of the old also_single_tested w
  • Changed most microorganism IDs to improve readability. For example, the old code B_ENTRC_FAE could have been both E. faecalis and E. faecium. Its new code is B_ENTRC_FCLS and E. faecium has become B_ENTRC_FACM. Also, the Latin character æ (ae) is now preserved at the start of each genus and species abbreviation. For example, the old code for Aerococcus urinae was B_ARCCC_NAE. This is now B_AERCC_URIN. IMPORTANT: Old microorganism IDs are still supported, but support will be dropped in a future version. Use as.mo() on your old codes to transform them to the new format. Using functions from the mo_* family (like mo_name() and mo_gramstain()) on old codes, will throw a warning.
  • -
  • More intelligent guessing for as.ab() which also led to bidirectional language support
  • -
  • Renamed data set septic_patients to example_isolates -
  • +
  • More intelligent guessing for as.ab(), including bidirectional language support
  • +
  • Added support for the German national guideline (3MRGN/4MRGN) in the mdro() function, to determine multi-drug resistant organisms
  • Function eucast_rules():
  • diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index 43ebb124..e2bc7c15 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -15,21 +15,25 @@ + + - + + - - + + + @@ -45,15 +49,15 @@ + - - + @@ -64,6 +68,7 @@ + @@ -80,7 +85,7 @@ AMR (for R) - 0.7.1.9067 + 0.7.1.9096
    @@ -189,7 +194,6 @@ - -