diff --git a/DESCRIPTION b/DESCRIPTION index 9ae2f8ce..9c8ef195 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 0.7.1.9104 +Version: 0.7.1.9105 Date: 2019-10-12 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 1506ee0f..b9e60df9 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 0.7.1.9104 +# AMR 0.7.1.9105 Last updated: 12-Oct-2019 ### Breaking diff --git a/docs/404.html b/docs/404.html index 06b98a56..4cc0d7f9 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 460d4d35..cc41073a 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 4cc6940c..8648b43d 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -41,7 +41,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 @@ -321,67 +321,67 @@ -2013-11-09 -N10 +2017-03-23 +O1 +Hospital A +Escherichia coli +S +S +S +S +F + + +2016-10-13 +G10 +Hospital D +Escherichia coli +I +S +S +S +M + + +2017-11-09 +M7 +Hospital D +Escherichia coli +I +R +S +S +M + + +2016-03-31 +P9 +Hospital D +Escherichia coli +S +R +R +S +F + + +2015-07-16 +U2 Hospital B Streptococcus pneumoniae +R S -S -S +R S F -2015-04-24 -S9 -Hospital D +2014-10-22 +B8 +Hospital B Staphylococcus aureus -R -R -R -S -F - - -2010-09-03 -Y7 -Hospital C -Escherichia coli S S -R -S -F - - -2012-01-10 -H4 -Hospital A -Escherichia coli -S -S -R -S -M - - -2015-10-06 -M7 -Hospital C -Escherichia coli -S -S -S -S -M - - -2014-12-13 -D6 -Hospital A -Escherichia coli -S -I S S M @@ -407,8 +407,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,499 52.50% 10,499 52.50% -# 2 F 9,501 47.51% 20,000 100.00% +# 1 M 10,324 51.62% 10,324 51.62% +# 2 F 9,676 48.38% 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,411 values changed)
+# Streptococcus pneumoniae (1,451 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,351 values changed)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,325 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,698 values changed)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,722 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,150 values changed)
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (105 values changed)
+# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,240 values changed)
+# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (134 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,413 out of 20,000 rows, making a total of 7,715 edits
+# EUCAST rules affected 6,530 out of 20,000 rows, making a total of 7,872 edits
 # => added 0 test results
 # 
-# => changed 7,715 test results
-#    - 108 test results changed from S to I
-#    - 4,673 test results changed from S to R
-#    - 1,037 test results changed from I to S
-#    - 329 test results changed from I to R
-#    - 1,546 test results changed from R to S
-#    - 22 test results changed from R to I
+# => changed 7,872 test results
+#    - 104 test results changed from S to I
+#    - 4,728 test results changed from S to R
+#    - 1,044 test results changed from I to S
+#    - 344 test results changed from I to R
+#    - 1,620 test results changed from R to S
+#    - 32 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,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,669 first isolates (28.3% of total) +

So only 28.3% 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 A2, 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 H5, sorted on date:

@@ -525,10 +525,10 @@ - - + + - + @@ -536,8 +536,8 @@ - - + + @@ -547,41 +547,41 @@ - - + + + - - + - - + + + + - - - - + + - + - - + + @@ -591,43 +591,43 @@ - - + + - - + + - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - + + - + @@ -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,216 first weighted isolates (76.1% of total) +# => Found 15,117 first weighted isolates (75.6% of total)
isolate
12010-02-02A22010-04-02H5 B_ESCHR_COLIRS S S S
22010-02-28A22010-05-11H5 B_ESCHR_COLI S S
32010-03-02A22010-08-11H5 B_ESCHR_COLIR SSSR S FALSE
42010-03-08A22010-08-26H5 B_ESCHR_COLISS R SSS FALSE
52010-05-16A22010-11-17H5 B_ESCHR_COLI RRS S S FALSE
62010-09-25A22010-12-20H5 B_ESCHR_COLI S S
72011-01-03A22011-03-21H5 B_ESCHR_COLIR SRSS S FALSE
82011-01-21A22011-04-16H5B_ESCHR_COLISSSSTRUE
92011-07-03H5 B_ESCHR_COLI RRS S S FALSE
92011-05-24A2B_ESCHR_COLISSRSTRUE
102011-06-13A22011-07-07H5 B_ESCHR_COLIRS S S S
@@ -663,10 +663,10 @@ - - + + - + @@ -675,47 +675,47 @@ - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + - - - - + + - + @@ -723,8 +723,8 @@ - - + + @@ -735,46 +735,46 @@ - - + + - - + + - + - - + + - - - + + + - - + + - - - + + + - - + + - + @@ -783,11 +783,11 @@
isolate
12010-02-02A22010-04-02H5 B_ESCHR_COLIRS S S S
22010-02-28A22010-05-11H5 B_ESCHR_COLI S S S S FALSEFALSE
32010-08-11H5B_ESCHR_COLIRSRSFALSE TRUE
32010-03-02A2B_ESCHR_COLISSSSFALSEFALSE
42010-03-08A22010-08-26H5 B_ESCHR_COLISS R SSS FALSE TRUE
52010-05-16A22010-11-17H5 B_ESCHR_COLI RRS S S FALSE
62010-09-25A22010-12-20H5 B_ESCHR_COLI S S
72011-01-03A22011-03-21H5 B_ESCHR_COLIR SRSS S FALSETRUEFALSE
82011-01-21A22011-04-16H5 B_ESCHR_COLIRR S SFALSESSTRUE TRUE
92011-05-24A22011-07-03H5 B_ESCHR_COLISS R STRUESSFALSE TRUE
102011-06-13A22011-07-07H5 B_ESCHR_COLIRS S S S
-

Instead of 2, now 9 isolates are flagged. In total, 76.1% of all isolates are marked ‘first weighted’ - 47.7% 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 8 isolates are flagged. In total, 75.6% of all isolates are marked ‘first weighted’ - 47.2% 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,216 isolates for analysis.

+

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

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -795,7 +795,6 @@
head(data_1st)
- @@ -812,62 +811,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + @@ -876,13 +841,12 @@ - - + - + - - + + @@ -892,14 +856,28 @@ - - - - + + + + + + + + + + + + + + + + + + - - - + + + @@ -907,6 +885,21 @@ + + + + + + + + + + + + + + +
date patient_id hospital
12013-11-09N10Hospital BB_STRPT_PNMNSSSRFGram-positiveStreptococcuspneumoniaeTRUE
22015-04-24S9Hospital DB_STPHY_AURSRRRSFGram-positiveStaphylococcusaureusTRUE
32010-09-03Y7Hospital CB_ESCHR_COLISSRSFGram-negativeEscherichiacoliTRUE
42012-01-10H42017-03-23O1 Hospital A B_ESCHR_COLI S SRSSFGram-negativeEscherichiacoliTRUE
2016-10-13G10Hospital DB_ESCHR_COLIISS S M Gram-negativeTRUE
52015-10-062017-11-09 M7Hospital CHospital D B_ESCHR_COLISSRR S S MTRUE
72010-10-26V9Hospital C2016-03-31P9Hospital DB_ESCHR_COLISSRSFGram-negativeEscherichiacoliTRUE
2015-07-16U2Hospital B B_STRPT_PNMNSSSRRR R F Gram-positivepneumoniae TRUE
2014-10-22B8Hospital BB_STPHY_AURSSSSSMGram-positiveStaphylococcusaureusTRUE

Time for the analysis!

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

Frequency table

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

Shortest: 16
Longest: 24

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

1 Escherichia coli -7,521 -49.43% -7,521 -49.43% +7,403 +48.97% +7,403 +48.97% 2 Staphylococcus aureus -3,772 -24.79% -11,293 -74.22% +3,757 +24.85% +11,160 +73.82% 3 Streptococcus pneumoniae -2,273 -14.94% -13,566 -89.16% +2,307 +15.26% +13,467 +89.09% 4 Klebsiella pneumoniae 1,650 -10.84% -15,216 +10.91% +15,117 100.00% @@ -980,7 +973,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.4679942
+# [1] 0.470133

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

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

Hospital A -0.4673913 +0.4604743 Hospital B -0.4702744 +0.4653298 Hospital C -0.4699524 +0.4791855 Hospital D -0.4635025 +0.4865761 @@ -1023,23 +1016,23 @@ Longest: 24

Hospital A -0.4673913 -4600 +0.4604743 +4554 Hospital B -0.4702744 -5248 +0.4653298 +5336 Hospital C -0.4699524 -2313 +0.4791855 +2210 Hospital D -0.4635025 -3055 +0.4865761 +3017 @@ -1059,27 +1052,27 @@ Longest: 24

Escherichia -0.9274033 -0.8917697 -0.9932190 +0.9227340 +0.8974740 +0.9940565 Klebsiella -0.8212121 -0.8909091 -0.9818182 +0.8127273 +0.9024242 +0.9872727 Staphylococcus -0.9223224 -0.9141039 -0.9909862 +0.9291988 +0.9124301 +0.9933458 Streptococcus -0.6317642 +0.6146511 0.0000000 -0.6317642 +0.6146511 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 fec9ba7e..7a8b6bc7 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 2a9cdcd4..ac83a9be 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 f5243c9b..7b95eba6 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 3673f72b..19b7b3dd 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 1b5eefad..a711c7f6 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105
diff --git a/docs/authors.html b/docs/authors.html index 4d12a9e5..28675281 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 diff --git a/docs/index.html b/docs/index.html index 7c497a3b..ea31b853 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 diff --git a/docs/news/index.html b/docs/news/index.html index ee35b502..298bb5a0 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9104 + 0.7.1.9105 @@ -231,9 +231,9 @@ -
+

-AMR 0.7.1.9104 Unreleased +AMR 0.7.1.9105 Unreleased

Last updated: 12-Oct-2019

@@ -1292,7 +1292,7 @@ Using as.mo(..., allow_uncertain = 3)

Contents

diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index 4d389935..3dae082c 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -210,7 +210,7 @@ data <- data %>% mutate(first = first_isolate(.)) ``` -So only `r percentage(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package: +So only `r AMR:::percentage(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package: ```{r 1st isolate filter} data_1st <- data %>% @@ -272,7 +272,7 @@ weighted_df2 %>% knitr::kable(align = "c") ``` -Instead of `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r percentage((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` 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 `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r AMR:::percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r AMR:::percentage((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` 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: ```{r 1st isolate filter 3, results = 'hide', message = FALSE, warning = FALSE}