diff --git a/DESCRIPTION b/DESCRIPTION index 690916ac..89f14c3a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 0.7.1.9002 +Version: 0.7.1.9003 Date: 2019-06-23 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 9403b9ea..8492fcf7 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# AMR 0.7.1.9002 +# AMR 0.7.1.9003 + +(no code changes yet) + +# AMR 0.7.1 #### New * Function `rsi_df()` to transform a `data.frame` to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions `count_df()` and `portion_df()` to immediately show resistance percentages and number of available isolates: diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7b7f78cc..0c7b7107 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@
diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 9ec1ab02..6496de6a 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -40,7 +40,7 @@ @@ -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 22 June 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 23 June 2019.
Now, let’s start the cleaning and the analysis!
@@ -411,8 +411,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,382 51.9% 10,382 51.9% -# 2 F 9,618 48.1% 20,000 100.0% +# 1 M 10,366 51.8% 10,366 51.8% +# 2 F 9,634 48.2% 20,000 100.0%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 %>%
@@ -442,14 +442,14 @@
# Pasteurella multocida (no new changes)
# Staphylococcus (no new changes)
# Streptococcus groups A, B, C, G (no new changes)
-# Streptococcus pneumoniae (1,472 new changes)
+# Streptococcus pneumoniae (1,453 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 (1,278 new changes)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,298 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 (2,802 new changes)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,747 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 (2,239 new changes)
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (112 new changes)
+# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,176 new changes)
+# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (121 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,529 out of 20,000 rows, making a total of 7,903 edits
+# EUCAST rules affected 6,468 out of 20,000 rows, making a total of 7,795 edits
# => added 0 test results
#
-# => changed 7,903 test results
-# - 117 test results changed from S to I
-# - 4,760 test results changed from S to R
-# - 1,044 test results changed from I to S
-# - 324 test results changed from I to R
-# - 1,642 test results changed from R to S
-# - 16 test results changed from R to I
+# => changed 7,795 test results
+# - 107 test results changed from S to I
+# - 4,725 test results changed from S to R
+# - 1,040 test results changed from I to S
+# - 329 test results changed from I to R
+# - 1,579 test results changed from R to S
+# - 15 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.2% 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:
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 L1, 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 M3, sorted on date:
isolate | @@ -529,19 +529,19 @@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-06-13 | -L1 | +2010-01-24 | +M3 | B_ESCHR_COL | S | S | -S | +R | S | TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | -2010-08-25 | -L1 | +2010-03-17 | +M3 | B_ESCHR_COL | S | S | @@ -551,10 +551,10 @@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | -2010-09-09 | -L1 | +2010-04-12 | +M3 | B_ESCHR_COL | -R | +S | S | R | S | @@ -562,63 +562,63 @@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | -2010-09-14 | -L1 | +2010-05-20 | +M3 | B_ESCHR_COL | -R | -I | +S | S | R | +S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | -2010-10-01 | -L1 | +2010-06-08 | +M3 | B_ESCHR_COL | +S | +S | R | S | -S | -S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | -2010-11-15 | -L1 | +2010-06-20 | +M3 | B_ESCHR_COL | -S | -S | +R | +I | S | S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | -2010-12-31 | -L1 | +2010-09-18 | +M3 | B_ESCHR_COL | -R | -I | +S | +S | S | S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | -2011-01-14 | -L1 | +2010-10-08 | +M3 | B_ESCHR_COL | +S | +S | R | S | -S | -S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | -2011-01-31 | -L1 | +2010-11-05 | +M3 | B_ESCHR_COL | S | S | @@ -628,10 +628,10 @@||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | -2011-03-23 | -L1 | +2010-12-23 | +M3 | B_ESCHR_COL | -R | +S | S | S | S | @@ -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,191 first weighted isolates (76.0% of total) +# => Found 15,080 first weighted isolates (75.4% of total)
isolate | @@ -667,34 +667,34 @@||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-06-13 | -L1 | +2010-01-24 | +M3 | B_ESCHR_COL | S | S | -S | +R | S | TRUE | TRUE | ||
2 | -2010-08-25 | -L1 | +2010-03-17 | +M3 | B_ESCHR_COL | S | S | S | S | FALSE | -FALSE | +TRUE | ||
3 | -2010-09-09 | -L1 | +2010-04-12 | +M3 | B_ESCHR_COL | -R | +S | S | R | S | @@ -703,35 +703,35 @@||||
4 | -2010-09-14 | -L1 | +2010-05-20 | +M3 | B_ESCHR_COL | -R | -I | +S | S | R | +S | +FALSE | FALSE | -TRUE |
5 | -2010-10-01 | -L1 | +2010-06-08 | +M3 | B_ESCHR_COL | +S | +S | R | S | -S | -S | FALSE | -TRUE | +FALSE |
6 | -2010-11-15 | -L1 | +2010-06-20 | +M3 | B_ESCHR_COL | -S | -S | +R | +I | S | S | FALSE | @@ -739,11 +739,11 @@||
7 | -2010-12-31 | -L1 | +2010-09-18 | +M3 | B_ESCHR_COL | -R | -I | +S | +S | S | S | FALSE | @@ -751,20 +751,20 @@||
8 | -2011-01-14 | -L1 | +2010-10-08 | +M3 | B_ESCHR_COL | +S | +S | R | S | -S | -S | -FALSE | FALSE | +TRUE |
9 | -2011-01-31 | -L1 | +2010-11-05 | +M3 | B_ESCHR_COL | S | S | @@ -775,23 +775,23 @@|||||||
10 | -2011-03-23 | -L1 | +2010-12-23 | +M3 | B_ESCHR_COL | -R | +S | S | S | S | FALSE | -TRUE | +FALSE |
Instead of 1, now 8 isolates are flagged. In total, 76% of all isolates are marked ‘first weighted’ - 47.5% 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 7 isolates are flagged. In total, 75.4% 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:
So we end up with 15,191 isolates for analysis.
+So we end up with 15,080 isolates for analysis.
We can remove unneeded columns:
@@ -817,47 +817,15 @@Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from data_1st
(15,191 x 13)
Frequency table of genus
and species
from data_1st
(15,080 x 13)
Columns: 2
-Length: 15,191 (of which NA: 0 = 0.00%)
+Length: 15,080 (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. 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:
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.4769129
+0.4658016
Hospital B
-0.4643125
+0.4614653
Hospital C
-0.4723793
+0.4744526
Hospital D
-0.4731788
+0.4686334
EUCAST.Rmd
MDR.Rmd
The data set looks like this now:
head(my_TB_data)
# rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1 S S R S R I
-# 2 S S R S R S
-# 3 R R S S S S
-# 4 S I S I S S
-# 5 S S I I R R
-# 6 R R R R R R
+# 1 R S R S S S
+# 2 I R S S I S
+# 3 S R R R S R
+# 4 R S R R I S
+# 5 I R R S R S
+# 6 S S S S R R
# kanamycin
-# 1 R
+# 1 S
# 2 I
-# 3 R
-# 4 I
-# 5 R
-# 6 I
We can now add the interpretation of MDR-TB to our data set:
my_TB_data$mdr <- mdr_tb(my_TB_data)
# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
@@ -277,40 +277,40 @@ Unique: 5
1
Mono-resistance
-3,284
-65.7%
-3,284
-65.7%
+3,206
+64.1%
+3,206
+64.1%
2
Negative
-675
-13.5%
-3,959
-79.2%
+689
+13.8%
+3,895
+77.9%
3
Multidrug resistance
-570
-11.4%
-4,529
-90.6%
+578
+11.6%
+4,473
+89.5%
4
Poly-resistance
-263
-5.3%
-4,792
-95.8%
+299
+6.0%
+4,772
+95.4%
5
Extensive drug resistance
-208
-4.2%
+228
+4.6%
5,000
100.0%
diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html
index a169c1cb..bbbf6767 100644
--- a/docs/articles/SPSS.html
+++ b/docs/articles/SPSS.html
@@ -40,7 +40,7 @@
SPSS.Rmd
WHONET.Rmd
benchmarks.Rmd
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") 400 400 430 430 450 450 10
-# as.mo("THEISL") 390 400 420 420 450 460 10
-# as.mo("T. islandicus") 210 210 260 240 270 430 10
-# as.mo("T. islandicus") 210 210 250 260 260 270 10
-# as.mo("Thermus islandicus") 74 75 94 76 120 120 10
That takes 7 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") 390 390 420 440 440 440 10 +# as.mo("THEISL") 390 390 420 440 440 450 10 +# as.mo("T. islandicus") 210 250 250 250 260 270 10 +# as.mo("T. islandicus") 210 210 240 220 250 410 10 +# as.mo("Thermus islandicus") 72 72 82 72 73 120 10 +That takes 6.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)
@@ -287,8 +287,8 @@
print(run_it, unit = "ms", signif = 3)
# Unit: milliseconds
# expr min lq mean median uq max neval
-# mo_fullname(x) 1090 1130 1190 1170 1230 1320 10
So transforming 500,000 values (!!) of 50 unique values only takes 1.17 seconds (1167 ms). You only lose time on your unique input values.
+# mo_fullname(x) 1120 1140 1190 1180 1210 1260 10 +So transforming 500,000 values (!!) of 50 unique values only takes 1.18 seconds (1182 ms). You only lose time on your unique input values.
So going from mo_fullname("Staphylococcus aureus")
to "Staphylococcus aureus"
takes 0.0018 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:
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"),
C = mo_fullname("Staphylococcus aureus"),
@@ -317,14 +317,14 @@
print(run_it, unit = "ms", signif = 3)
# Unit: milliseconds
# expr min lq mean median uq max neval
-# A 0.591 0.635 0.719 0.681 0.808 0.968 10
-# B 0.575 0.643 0.702 0.688 0.738 0.893 10
-# C 1.550 1.660 1.780 1.730 1.920 2.170 10
-# D 0.594 0.685 0.725 0.732 0.760 0.928 10
-# E 0.584 0.614 0.667 0.650 0.730 0.782 10
-# F 0.473 0.479 0.617 0.629 0.712 0.810 10
-# G 0.495 0.526 0.576 0.559 0.602 0.756 10
-# H 0.489 0.519 0.565 0.575 0.607 0.647 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.
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 bf33e9bf..b92bce59 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 ca20393e..76f11103 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -40,7 +40,7 @@ @@ -192,7 +192,7 @@freq.Rmd
as.mo(..., allow_uncertain = 3)
Contents