diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 780ea8c9..5f62e156 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 10 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 12 May 2019.
Now, let’s start the cleaning and the analysis!
@@ -411,8 +411,8 @@ #> #> Item Count Percent Cum. Count Cum. Percent #> --- ----- ------- -------- ----------- ------------- -#> 1 M 10,314 51.6% 10,314 51.6% -#> 2 F 9,686 48.4% 20,000 100.0% +#> 1 M 10,367 51.8% 10,367 51.8% +#> 2 F 9,633 48.2% 20,000 100.0%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 (1422 new changes)
+#> Streptococcus pneumoniae (1473 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 (1271 new changes)
+#> Table 01: Intrinsic resistance in Enterobacteriaceae (1282 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 (2747 new changes)
+#> Table 04: Intrinsic resistance in Gram-positive bacteria (2691 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 (2255 new changes)
-#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (112 new changes)
+#> 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: 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,518 out of 20,000 rows, making a total of 7,807 edits
+#> EUCAST rules affected 6,442 out of 20,000 rows, making a total of 7,788 edits
#> => added 0 test results
#>
-#> => changed 7,807 test results
-#> - 104 test results changed from S to I
-#> - 4,681 test results changed from S to R
-#> - 1,080 test results changed from I to S
-#> - 336 test results changed from I to R
-#> - 1,588 test results changed from R to S
-#> - 18 test results changed from R to I
+#> => 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
#> --------------------------------------------------------------------------
#>
#> Use verbose = TRUE to get a data.frame with all specified edits instead.
So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.4% 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 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.
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(.)) %>%
@@ -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,129 first weighted isolates (75.6% of total)
isolate | @@ -667,71 +667,71 @@||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-22 | -M1 | +2010-01-10 | +H7 | B_ESCHR_COL | -S | -S | R | S | +S | +S | TRUE | TRUE | |
2 | -2010-03-11 | -M1 | +2010-01-23 | +H7 | B_ESCHR_COL | S | S | -R | -S | -FALSE | -FALSE | -|||
3 | -2010-03-17 | -M1 | -B_ESCHR_COL | -R | -S | S | S | FALSE | TRUE | |||||
4 | -2010-04-28 | -M1 | +||||||||||||
3 | +2010-05-15 | +H7 | B_ESCHR_COL | -R | +S | +S | S | R | +FALSE | +TRUE | +||||
4 | +2010-08-16 | +H7 | +B_ESCHR_COL | +S | +S | +S | S | FALSE | TRUE | |||||
5 | -2010-05-26 | -M1 | +2010-09-26 | +H7 | B_ESCHR_COL | +S | +S | R | S | -S | -S | FALSE | TRUE | |
6 | -2010-06-03 | -M1 | +2010-11-01 | +H7 | B_ESCHR_COL | R | -R | +I | S | S | FALSE | @@ -739,8 +739,8 @@|||
7 | -2010-07-03 | -M1 | +2010-12-11 | +H7 | B_ESCHR_COL | S | S | @@ -751,34 +751,34 @@|||||||
8 | -2010-07-07 | -M1 | +2011-02-11 | +H7 | B_ESCHR_COL | -R | -R | S | S | -FALSE | +R | +S | +TRUE | TRUE |
9 | -2010-07-30 | -M1 | +2011-03-16 | +H7 | B_ESCHR_COL | +I | S | -S | -S | +R | S | FALSE | -TRUE | +FALSE |
10 | -2010-10-12 | -M1 | +2011-04-14 | +H7 | B_ESCHR_COL | -R | +S | S | S | S | @@ -787,11 +787,11 @@
Instead of 1, now 9 isolates are flagged. In total, 75.6% of all isolates are marked ‘first weighted’ - 47.4% 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, 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.
As with filter_first_isolate()
, there’s a shortcut for this new algorithm too:
So we end up with 15,129 isolates for analysis.
+So we end up with 15,036 isolates for analysis.
We can remove unneeded columns:
@@ -817,9 +817,25 @@Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from a data.frame
(15,129 x 13)
Frequency table of genus
and species
from a data.frame
(15,036 x 13)
Columns: 2
-Length: 15,129 (of which NA: 0 = 0.00%)
+Length: 15,036 (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.4884229
+0.5024412
Hospital B
-0.4994329
+0.5015980
Hospital C
-0.4838561
+0.4683146
Hospital D
-0.4959586
+0.4912927
@@ -1027,23 +1027,23 @@ Longest: 24
Hospital A
-0.4884229
-4578
+0.5024412
+4506
Hospital B
-0.4994329
-5290
+0.5015980
+5319
Hospital C
-0.4838561
-2168
+0.4683146
+2225
Hospital D
-0.4959586
-3093
+0.4912927
+2986
@@ -1063,27 +1063,27 @@ Longest: 24
Escherichia
-0.8857369
-0.8953688
-0.9886529
+0.8770327
+0.8982664
+0.9908614
Klebsiella
-0.7345758
-0.8901028
-0.9678663
+0.7418726
+0.9037711
+0.9817945
Staphylococcus
-0.8775510
-0.9235374
-0.9874830
+0.8840963
+0.9237894
+0.9886213
Streptococcus
-0.5804226
+0.5697981
0.0000000
-0.5804226
+0.5697981
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 947d5fb2..9d1133ac 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 0415a6c9..04d91141 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 dddd8d91..040e277b 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 febecb5a..424d72d3 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/SPSS.html b/docs/articles/SPSS.html
index 84c4f9b7..8f8d34cf 100644
--- a/docs/articles/SPSS.html
+++ b/docs/articles/SPSS.html
@@ -192,7 +192,7 @@
How to import data from SPSS / SAS / Stata
Matthijs S. Berends
- 10 May 2019
+ 12 May 2019
SPSS.Rmd
diff --git a/docs/articles/ab_property.html b/docs/articles/ab_property.html
index 20431050..b7e95d43 100644
--- a/docs/articles/ab_property.html
+++ b/docs/articles/ab_property.html
@@ -192,7 +192,7 @@
How to get properties of an antibiotic
Matthijs S. Berends
- 10 May 2019
+ 12 May 2019
ab_property.Rmd
diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html
index 92b6608a..03572dca 100644
--- a/docs/articles/benchmarks.html
+++ b/docs/articles/benchmarks.html
@@ -192,7 +192,7 @@
Benchmarks
Matthijs S. Berends
- 10 May 2019
+ 12 May 2019
benchmarks.Rmd
@@ -217,14 +217,14 @@
times = 10)
print(S.aureus, unit = "ms", signif = 2)
#> Unit: milliseconds
-#> expr min lq mean median uq max neval
-#> as.mo("sau") 18.0 18 23.0 18 18.0 65 10
-#> as.mo("stau") 47.0 48 48.0 48 48.0 50 10
-#> as.mo("staaur") 18.0 18 22.0 18 18.0 62 10
-#> as.mo("STAAUR") 18.0 18 32.0 19 62.0 62 10
-#> as.mo("S. aureus") 28.0 28 42.0 28 28.0 120 10
-#> as.mo("S. aureus") 28.0 28 40.0 28 29.0 98 10
-#> as.mo("Staphylococcus aureus") 7.9 8 9.2 8 8.1 20 10
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,11 +236,11 @@
print(T.islandicus, unit = "ms", signif = 2)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> as.mo("theisl") 470 470 490 470 520 520 10
-#> as.mo("THEISL") 470 470 500 510 520 520 10
-#> as.mo("T. islandicus") 76 76 81 76 77 120 10
-#> as.mo("T. islandicus") 76 76 94 78 120 120 10
-#> as.mo("Thermus islandicus") 74 74 96 77 120 150 10
That takes 8.2 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) 777 780 859 864 870 1080 10
So transforming 500,000 values (!!) of 50 unique values only takes 0.86 seconds (864 ms). You only lose time on your unique input values.
+#> mo_fullname(x) 836 837 893 883 925 1000 10 +So transforming 500,000 values (!!) of 50 unique values only takes 0.88 seconds (882 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.417 0.456 0.511 0.494 0.558 0.612 10
-#> B 0.416 0.555 0.620 0.614 0.658 0.837 10
-#> C 1.360 1.630 1.970 1.880 1.970 3.220 10
-#> D 0.435 0.519 0.671 0.665 0.734 1.120 10
-#> E 0.356 0.429 0.491 0.452 0.486 0.916 10
-#> F 0.384 0.450 0.559 0.502 0.543 1.180 10
-#> G 0.407 0.450 0.591 0.527 0.663 1.080 10
-#> H 0.219 0.272 0.295 0.276 0.311 0.420 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 0684ac82..950a5887 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 d9147c73..bcd802ec 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -40,7 +40,7 @@ @@ -105,7 +105,7 @@freq.Rmd
colnames(microorganisms)
# [1] "mo" "col_id" "fullname" "kingdom" "phylum"
# [6] "class" "order" "family" "genus" "species"
-# [11] "subspecies" "rank" "ref" "species_id" "source"
-# [16] "prevalence"
If we compare the dimensions between the old and new dataset, we can see that these 15 variables were added:
+# [11] "subspecies" "rank" "ref" "species_id" "source" +If we compare the dimensions between the old and new dataset, we can see that these 14 variables were added:
+# [1] 2000 63So now the genus
and species
variables are available. A frequency table of these combined variables can be created like this:
Frequency table of genus
and species
from a data.frame
(2,000 x 64)
Frequency table of genus
and species
from a data.frame
(2,000 x 63)
Columns: 2
Length: 2,000 (of which NA: 0 = 0.00%)
Unique: 95
All classes will be printed into the header (default is FALSE
when using markdown like this document). Variables with the new rsi
class of this AMR package are actually ordered factors and have three classes (look at Class
in the header):
Frequency table of amox
from a data.frame
(2,000 x 49)
Frequency table of AMX
from a data.frame
(2,000 x 49)
Class: factor
> ordered
> rsi
(numeric
)
Length: 2,000 (of which NA: 771 = 38.55%)
Levels: 3: S
< I
< R
Unique: 3
Drug: Amoxicillin
-%IR: 55.82%
Drug: Amoxicillin (AMX, J01CA04)
+Group: Beta-lactams/penicillins
+%SI: 44.43%
@@ -705,7 +705,7 @@ Median: 31 July 2009 (47.39%) | 7 | 0.4% | 41 | -2.1% | +2.0% |
---|
With the na.rm
parameter (defaults to TRUE
, but they will always be shown into the header), you can include NA
values in the frequency table:
Frequency table of amox
from a data.frame
(2,000 x 49)
Frequency table of AMX
from a data.frame
(2,000 x 49)
Class: factor
> ordered
> rsi
(numeric
)
Length: 2,000 (of which NA: 771 = 38.55%)
Levels: 3: S
< I
< R
Unique: 4
Drug: Amoxicillin
-%IR: 55.82%
Drug: Amoxicillin (AMX, J01CA04)
+Group: Beta-lactams/penicillins
+%SI: 44.43%
@@ -771,7 +772,7 @@ Unique: 4 | 543 | 27.2% | 1,997 | -99.9% | +99.8% | |
---|---|---|---|---|---|---|
4 | @@ -817,12 +818,12 @@ Unique: 4663 | 33.2% | 1,425 | -71.3% | +71.2% | |
A | 321 | -16.1% | +16.0% | 1,746 | 87.3% | 663 | 33.2% | 1,425 | -71.3% | +71.2% |
3 | A | 321 | -16.1% | +16.0% | 1,746 | 87.3% |