diff --git a/DESCRIPTION b/DESCRIPTION index d25d3fb6..9ae2f8ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.7.1.9103 -Date: 2019-10-11 +Version: 0.7.1.9104 +Date: 2019-10-12 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index c21587b0..1506ee0f 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 0.7.1.9103 -Last updated: 11-Oct-2019 +# AMR 0.7.1.9104 +Last updated: 12-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`: diff --git a/docs/404.html b/docs/404.html index f5f2c53d..06b98a56 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 4e983b33..460d4d35 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index cb697ca1..4cc6940c 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -41,7 +41,7 @@ AMR (for R) - 0.7.1.9096 + 0.7.1.9104 @@ -187,7 +187,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

07 October 2019

+

12 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 07 October 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 12 October 2019.

Introduction

@@ -212,21 +212,21 @@ -2019-10-07 +2019-10-12 abcd Escherichia coli S S -2019-10-07 +2019-10-12 abcd Escherichia coli S R -2019-10-07 +2019-10-12 efgh Escherichia coli R @@ -321,68 +321,68 @@ -2012-10-04 -J3 +2013-11-09 +N10 Hospital B Streptococcus pneumoniae S -R S -R -M +S +S +F -2015-03-12 -S8 -Hospital A +2015-04-24 +S9 +Hospital D Staphylococcus aureus R -I +R R S F -2015-05-15 -Q9 -Hospital A -Klebsiella pneumoniae -R -S -S -S -F - - -2012-10-15 -G6 -Hospital B -Escherichia coli -I -S -S -S -M - - -2012-04-15 -G8 +2010-09-03 +Y7 Hospital C -Staphylococcus aureus -R -R +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 -2015-03-26 -M3 -Hospital B -Staphylococcus aureus +2014-12-13 +D6 +Hospital A +Escherichia coli +S +I S -R -R S M @@ -407,8 +407,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,403 52.02% 10,403 52.02% -# 2 F 9,597 47.99% 20,000 100.00% +# 1 M 10,499 52.50% 10,499 52.50% +# 2 F 9,501 47.51% 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,466 values changed)
+# Streptococcus pneumoniae (1,411 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,304 values changed)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,351 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,787 values changed)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,698 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,243 values changed)
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (114 values changed)
+# 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: 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,571 out of 20,000 rows, making a total of 7,914 edits
+# EUCAST rules affected 6,413 out of 20,000 rows, making a total of 7,715 edits
 # => added 0 test results
 # 
-# => 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
+# => 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
 # --------------------------------------------------------------------------
 # 
 # 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,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:

+# => 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:

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 E8, 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 A2, sorted on date:

@@ -525,19 +525,19 @@ - - + + - - + + - - + + @@ -547,8 +547,8 @@ - - + + @@ -558,10 +558,10 @@ - - + + - + @@ -569,8 +569,8 @@ - - + + @@ -580,10 +580,10 @@ - - + + - + @@ -591,10 +591,10 @@ - - + + - + @@ -602,32 +602,32 @@ - - + + - - + + - - + + - + - - + + - + @@ -645,8 +645,8 @@ # NOTE: Using column `date` as input for `col_date`.# 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,087 first weighted isolates (75.4% of total) +# [Criterion] Inclusion based on key antibiotics, ignoring I +# => Found 15,216 first weighted isolates (76.1% of total)
isolate
12010-01-14E82010-02-02A2 B_ESCHR_COLISS R SSS TRUE
22010-03-24E82010-02-28A2 B_ESCHR_COLI S S
32010-05-23E82010-03-02A2 B_ESCHR_COLI S S
42010-08-30E82010-03-08A2 B_ESCHR_COLISR S S S
52010-09-04E82010-05-16A2 B_ESCHR_COLI R R
62010-09-14E82010-09-25A2 B_ESCHR_COLIRS S S S
72010-10-02E82011-01-03A2 B_ESCHR_COLISR S R S
82011-01-01E82011-01-21A2 B_ESCHR_COLISSRR S S FALSE
92011-02-10E82011-05-24A2 B_ESCHR_COLI S SSR S TRUE
102011-03-11E82011-06-13A2 B_ESCHR_COLISR S S S
@@ -663,20 +663,20 @@ - - + + - - + + - - + + @@ -687,8 +687,8 @@ - - + + @@ -699,20 +699,20 @@ - - + + - + - + - - + + @@ -723,10 +723,10 @@ - - + + - + @@ -735,10 +735,10 @@ - - + + - + @@ -747,11 +747,11 @@ - - + + - - + + @@ -759,35 +759,35 @@ - - + + - + - - + + - + - +
isolate
12010-01-14E82010-02-02A2 B_ESCHR_COLISS R SSS TRUE TRUE
22010-03-24E82010-02-28A2 B_ESCHR_COLI S S
32010-05-23E82010-03-02A2 B_ESCHR_COLI S S
42010-08-30E82010-03-08A2 B_ESCHR_COLISR S S S FALSEFALSETRUE
52010-09-04E82010-05-16A2 B_ESCHR_COLI R R
62010-09-14E82010-09-25A2 B_ESCHR_COLIRS S S S
72010-10-02E82011-01-03A2 B_ESCHR_COLISR S R S
82011-01-01E82011-01-21A2 B_ESCHR_COLISSRR S S FALSE
92011-02-10E82011-05-24A2 B_ESCHR_COLI S SSR S TRUE TRUE
102011-03-11E82011-06-13A2 B_ESCHR_COLISR S S S FALSEFALSETRUE
-

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.

+

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.

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,087 isolates for analysis.

+

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

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -813,15 +813,15 @@ 1 -2012-10-04 -J3 +2013-11-09 +N10 Hospital B B_STRPT_PNMN S S S R -M +F Gram-positive Streptococcus pneumoniae @@ -829,12 +829,12 @@ 2 -2015-03-12 -S8 -Hospital A +2015-04-24 +S9 +Hospital D B_STPHY_AURS R -I +R R S F @@ -845,60 +845,60 @@ 3 -2015-05-15 -Q9 -Hospital A -B_KLBSL_PNMN +2010-09-03 +Y7 +Hospital C +B_ESCHR_COLI +S +S R S -S -S F Gram-negative -Klebsiella -pneumoniae +Escherichia +coli TRUE -5 -2012-04-15 -G8 -Hospital C -B_STPHY_AURS -R -R +4 +2012-01-10 +H4 +Hospital A +B_ESCHR_COLI +S S R +S M -Gram-positive -Staphylococcus -aureus +Gram-negative +Escherichia +coli TRUE -6 -2015-03-26 -M3 -Hospital B -B_STPHY_AURS +5 +2015-10-06 +M7 +Hospital C +B_ESCHR_COLI +S S S -R S M -Gram-positive -Staphylococcus -aureus +Gram-negative +Escherichia +coli TRUE 7 -2011-08-08 -V10 -Hospital A +2010-10-26 +V9 +Hospital C B_STRPT_PNMN -R -R +S +S S R F @@ -926,7 +926,7 @@
data_1st %>% freq(genus, species)

Frequency table

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

Shortest: 16
Longest: 24

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

1 Escherichia coli -7,412 -49.13% -7,412 -49.13% +7,521 +49.43% +7,521 +49.43% 2 Staphylococcus aureus -3,773 -25.01% -11,185 -74.14% +3,772 +24.79% +11,293 +74.22% 3 Streptococcus pneumoniae -2,331 -15.45% -13,516 -89.59% +2,273 +14.94% +13,566 +89.16% 4 Klebsiella pneumoniae -1,571 -10.41% -15,087 +1,650 +10.84% +15,216 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.4716643
+# [1] 0.4679942

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.4725537 +0.4673913 Hospital B -0.4704871 +0.4702744 Hospital C -0.4684529 +0.4699524 Hospital D -0.4749061 +0.4635025 @@ -1023,23 +1023,23 @@ Longest: 24

Hospital A -0.4725537 -4609 +0.4673913 +4600 Hospital B -0.4704871 -5235 +0.4702744 +5248 Hospital C -0.4684529 -2314 +0.4699524 +2313 Hospital D -0.4749061 -2929 +0.4635025 +3055 @@ -1059,27 +1059,27 @@ Longest: 24

Escherichia -0.9202644 -0.8950351 -0.9919050 +0.9274033 +0.8917697 +0.9932190 Klebsiella -0.8166773 -0.9019733 -0.9847231 +0.8212121 +0.8909091 +0.9818182 Staphylococcus -0.9247283 -0.9196926 -0.9939041 +0.9223224 +0.9141039 +0.9909862 Streptococcus -0.6194766 +0.6317642 0.0000000 -0.6194766 +0.6317642 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 7797d727..fec9ba7e 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 a0813f87..2a9cdcd4 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 66384219..f5243c9b 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 1b63c680..3673f72b 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 c2e28a27..1b5eefad 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104
diff --git a/docs/authors.html b/docs/authors.html index 89a90bd4..4d12a9e5 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104 diff --git a/docs/index.html b/docs/index.html index 3fd71501..7c497a3b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104 diff --git a/docs/news/index.html b/docs/news/index.html index 398a7995..ee35b502 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104 @@ -231,11 +231,11 @@ -
+

-AMR 0.7.1.9103 Unreleased +AMR 0.7.1.9104 Unreleased

-

Last updated: 11-Oct-2019

+

Last updated: 12-Oct-2019

Breaking

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

Contents

diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index d70d5d72..708d96af 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -85,7 +85,7 @@ AMR (for R) - 0.7.1.9102 + 0.7.1.9104
diff --git a/docs/reference/index.html b/docs/reference/index.html index f872d64f..bd2643cd 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.7.1.9103 + 0.7.1.9104
diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index 85f11526..4d389935 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -210,7 +210,7 @@ data <- data %>% mutate(first = first_isolate(.)) ``` -So only `r clean:::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 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 clean:::percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r clean:::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 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. 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}