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

How to conduct AMR analysis

Matthijs S. Berends

-

10 May 2019

+

12 May 2019

@@ -201,7 +201,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 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.

Introduction

@@ -217,21 +217,21 @@ -2019-05-10 +2019-05-12 abcd Escherichia coli S S -2019-05-10 +2019-05-12 abcd Escherichia coli S R -2019-05-10 +2019-05-12 efgh Escherichia coli R @@ -327,9 +327,31 @@ -2017-12-11 -C4 +2016-07-20 +N4 Hospital A +Klebsiella pneumoniae +S +R +R +S +M + + +2013-12-24 +L1 +Hospital A +Escherichia coli +S +S +S +S +M + + +2010-04-21 +C10 +Hospital D Escherichia coli R I @@ -338,20 +360,9 @@ M -2010-12-13 -K6 +2015-07-23 +A3 Hospital B -Escherichia coli -S -I -S -S -M - - -2014-03-15 -J1 -Hospital C Streptococcus pneumoniae S S @@ -359,39 +370,28 @@ S M + +2011-10-17 +V7 +Hospital A +Escherichia coli +R +R +R +S +F + -2010-09-09 -T6 -Hospital C +2014-09-20 +X4 +Hospital B Staphylococcus aureus S S -R -R -F - - -2011-07-28 -P4 -Hospital A -Escherichia coli -S -I S S F - -2010-01-15 -M8 -Hospital A -Streptococcus pneumoniae -I -R -R -S -M -

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.
@@ -502,8 +502,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,643 first isolates (28.2% of total)
-

So only 28.2% 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:

@@ -529,74 +529,74 @@ 1 -2010-01-22 -M1 +2010-01-10 +H7 B_ESCHR_COL -S -S R S +S +S TRUE 2 -2010-03-11 -M1 +2010-01-23 +H7 B_ESCHR_COL S S -R +S S FALSE 3 -2010-03-17 -M1 +2010-05-15 +H7 B_ESCHR_COL +S +S +S R -S -S -S FALSE 4 -2010-04-28 -M1 +2010-08-16 +H7 B_ESCHR_COL -R S -R +S +S S FALSE 5 -2010-05-26 -M1 +2010-09-26 +H7 B_ESCHR_COL +S +S R S -S -S FALSE 6 -2010-06-03 -M1 +2010-11-01 +H7 B_ESCHR_COL R -R +I S S FALSE 7 -2010-07-03 -M1 +2010-12-11 +H7 B_ESCHR_COL S S @@ -606,32 +606,32 @@ 8 -2010-07-07 -M1 +2011-02-11 +H7 B_ESCHR_COL -R -R S S -FALSE +R +S +TRUE 9 -2010-07-30 -M1 +2011-03-16 +H7 B_ESCHR_COL +I S -S -S +R S FALSE 10 -2010-10-12 -M1 +2011-04-14 +H7 B_ESCHR_COL -R +S S S S @@ -639,7 +639,7 @@ -

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)
+#> => Found 15,036 first weighted isolates (75.2% of total) @@ -667,71 +667,71 @@ - - + + - - + + - - + + - - - - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + - - + + + + - - - - + + - + @@ -739,8 +739,8 @@ - - + + @@ -751,34 +751,34 @@ - - + + - - - + + + - - + + + - - + - + - - + + - + @@ -787,11 +787,11 @@
isolate
12010-01-22M12010-01-10H7 B_ESCHR_COLSS R SSS TRUE TRUE
22010-03-11M12010-01-23H7 B_ESCHR_COL S SRSFALSEFALSE
32010-03-17M1B_ESCHR_COLRS S S FALSE TRUE
42010-04-28M1
32010-05-15H7 B_ESCHR_COLRSS S RFALSETRUE
42010-08-16H7B_ESCHR_COLSSS S FALSE TRUE
52010-05-26M12010-09-26H7 B_ESCHR_COLSS R SSS FALSE TRUE
62010-06-03M12010-11-01H7 B_ESCHR_COL RRI S S FALSE
72010-07-03M12010-12-11H7 B_ESCHR_COL S S
82010-07-07M12011-02-11H7 B_ESCHR_COLRR S SFALSERSTRUE TRUE
92010-07-30M12011-03-16H7 B_ESCHR_COLI SSSR S FALSETRUEFALSE
102010-10-12M12011-04-14H7 B_ESCHR_COLRS S S S
-

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:

data_1st <- data %>% 
   filter_first_weighted_isolate()
-

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:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -817,9 +817,25 @@ 1 -2017-12-11 -C4 +2016-07-20 +N4 Hospital A +B_KLBSL_PNE +R +R +R +S +M +Gram negative +Klebsiella +pneumoniae +TRUE + + +3 +2010-04-21 +C10 +Hospital D B_ESCHR_COL R I @@ -831,11 +847,11 @@ coli TRUE - -3 -2014-03-15 -J1 -Hospital C + +4 +2015-07-23 +A3 +Hospital B B_STRPT_PNE S S @@ -847,16 +863,32 @@ pneumoniae TRUE + +5 +2011-10-17 +V7 +Hospital A +B_ESCHR_COL +R +R +R +S +F +Gram negative +Escherichia +coli +TRUE + -4 -2010-09-09 -T6 -Hospital C +6 +2014-09-20 +X4 +Hospital B B_STPHY_AUR S S -R -R +S +S F Gram positive Staphylococcus @@ -864,46 +896,14 @@ TRUE -6 -2010-01-15 -M8 -Hospital A -B_STRPT_PNE -I -I -R -R -M -Gram positive -Streptococcus -pneumoniae -TRUE - - 7 -2015-04-19 -E5 -Hospital C -B_KLBSL_PNE -R -S -S -S -M -Gram negative -Klebsiella -pneumoniae -TRUE - - -8 -2016-03-04 -R4 -Hospital A +2015-09-29 +S7 +Hospital D B_ESCHR_COL S S -R +S S F Gram negative @@ -928,9 +928,9 @@
freq(paste(data_1st$genus, data_1st$species))

Or can be used like the dplyr way, which is easier readable:

data_1st %>% freq(genus, species)
-

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

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

1 Escherichia coli -7,579 -50.1% -7,579 -50.1% +7,441 +49.5% +7,441 +49.5% 2 Staphylococcus aureus -3,675 -24.3% -11,254 -74.4% +3,779 +25.1% +11,220 +74.6% 3 Streptococcus pneumoniae -2,319 -15.3% -13,573 -89.7% +2,278 +15.2% +13,498 +89.8% 4 Klebsiella pneumoniae -1,556 -10.3% -15,129 +1,538 +10.2% +15,036 100.0% @@ -984,7 +984,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. They can be used on their own:

data_1st %>% portion_IR(AMX)
-#> [1] 0.4931588
+#> [1] 0.494879

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

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

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

@@ -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
+#> expr min lq mean median uq max neval +#> as.mo("sau") 17.0 17.0 22.0 18 18 65 10 +#> as.mo("stau") 47.0 47.0 52.0 47 48 92 10 +#> as.mo("staaur") 17.0 18.0 18.0 18 18 18 10 +#> as.mo("STAAUR") 17.0 18.0 32.0 18 62 77 10 +#> as.mo("S. aureus") 28.0 28.0 37.0 28 30 72 10 +#> as.mo("S. aureus") 28.0 28.0 46.0 29 72 110 10 +#> as.mo("Staphylococcus aureus") 7.9 7.9 8.4 8 8 12 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
+#> as.mo("theisl") 470 470 490 480 520 530 10 +#> as.mo("THEISL") 470 520 520 520 520 530 10 +#> as.mo("T. islandicus") 75 76 76 76 76 77 10 +#> as.mo("T. islandicus") 76 76 86 77 79 130 10 +#> as.mo("Thermus islandicus") 74 74 89 75 120 120 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.

@@ -300,11 +300,11 @@ times = 10) print(run_it, unit = "ms", signif = 3) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> A 13.30 14.0 14.3 14.1 14.30 17.30 10 -#> B 25.20 25.5 36.5 26.5 39.60 71.30 10 -#> C 1.68 1.7 1.9 1.8 1.94 2.81 10

-

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:

+#> expr min lq mean median uq max neval +#> A 12.80 13.10 13.20 13.20 13.20 13.50 10 +#> B 25.20 25.30 30.00 25.60 25.90 69.70 10 +#> C 1.26 1.37 1.58 1.69 1.72 1.73 10 +

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
+#> A 0.429 0.441 0.486 0.491 0.510 0.562 10 +#> B 0.437 0.521 0.555 0.577 0.596 0.651 10 +#> C 1.300 1.460 1.730 1.890 1.900 1.960 10 +#> D 0.444 0.531 0.565 0.563 0.619 0.704 10 +#> E 0.399 0.431 0.471 0.471 0.508 0.535 10 +#> F 0.344 0.396 0.432 0.445 0.471 0.500 10 +#> G 0.390 0.397 0.464 0.465 0.492 0.624 10 +#> H 0.201 0.222 0.291 0.303 0.339 0.423 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.

@@ -350,14 +350,14 @@ times = 10) print(run_it, unit = "ms", signif = 4) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> en 18.34 18.37 23.22 18.54 19.53 63.17 10 -#> de 23.46 23.50 23.76 23.57 23.76 25.10 10 -#> nl 50.78 52.48 62.59 53.54 57.07 100.20 10 -#> es 23.53 23.59 28.70 23.76 24.17 68.55 10 -#> it 23.31 23.40 23.69 23.51 23.79 24.73 10 -#> fr 23.45 23.52 24.21 24.06 24.88 25.21 10 -#> pt 23.54 23.72 24.37 24.39 24.90 25.58 10
+#> expr min lq mean median uq max neval +#> en 18.01 18.11 18.30 18.27 18.35 18.78 10 +#> de 22.91 23.00 27.53 23.03 23.28 67.49 10 +#> nl 35.30 35.42 44.34 35.49 35.90 79.60 10 +#> es 22.98 23.02 23.18 23.09 23.31 23.58 10 +#> it 22.82 22.89 23.02 22.95 23.19 23.29 10 +#> fr 22.95 23.05 23.08 23.08 23.10 23.36 10 +#> pt 22.99 23.06 32.00 23.16 23.32 67.65 10

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 @@ AMR (for R) - 0.6.0 + 0.6.1.9003 @@ -105,7 +105,7 @@
  • - + Get properties of an antibiotic @@ -192,7 +192,7 @@

    How to create frequency tables

    Matthijs S. Berends

    -

    27 March 2019

    +

    12 May 2019

    @@ -239,7 +239,7 @@ Longest: 1

    2 F 969 -48.5% +48.4% 2,000 100.0% @@ -258,17 +258,16 @@ Longest: 1

    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:

    dim(septic_patients)
     # [1] 2000   49
     dim(my_patients)
    -# [1] 2000   64
    +# [1] 2000 63

    So now the genus and species variables are available. A frequency table of these combined variables can be created like this:

    my_patients %>%
       freq(genus, species, nmax = 15)
    -

    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

    @@ -296,7 +295,7 @@ Longest: 34

    2 Staphylococcus coagulase-negative 313 -15.7% +15.6% 780 39.0% @@ -304,7 +303,7 @@ Longest: 34

    3 Staphylococcus aureus 235 -11.8% +11.7% 1,015 50.7% @@ -314,13 +313,13 @@ Longest: 34

    174 8.7% 1,189 -59.5% +59.4% 5 Streptococcus pneumoniae 117 -5.9% +5.8% 1,306 65.3% @@ -328,7 +327,7 @@ Longest: 34

    6 Staphylococcus hominis 81 -4.1% +4.0% 1,387 69.4% @@ -338,7 +337,7 @@ Longest: 34

    58 2.9% 1,445 -72.3% +72.2% 8 @@ -368,7 +367,7 @@ Longest: 34

    11 Serratia marcescens 25 -1.3% +1.2% 1,575 78.8% @@ -384,7 +383,7 @@ Longest: 34

    13 Enterococcus faecium 21 -1.1% +1.0% 1,619 81.0% @@ -392,7 +391,7 @@ Longest: 34

    14 Staphylococcus capitis 21 -1.1% +1.0% 1,640 82.0% @@ -525,13 +524,13 @@ Unique: 4

    663 33.2% 1,425 -71.3% +71.2% 3 A 321 -16.1% +16.0% 1,746 87.3% @@ -567,9 +566,9 @@ Unique: 4

    1 A 321 -16.1% +16.0% 321 -16.1% +16.0% 2 @@ -599,14 +598,15 @@ Unique: 4

    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):

    septic_patients %>%
    -  freq(amox, header = TRUE)
    -

    Frequency table of amox from a data.frame (2,000 x 49)

    + freq(AMX, header = TRUE) +

    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% 412.1%2.0%
    @@ -731,14 +731,15 @@ Median: 31 July 2009 (47.39%)

    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:

    septic_patients %>%
    -  freq(amox, na.rm = FALSE)
    -

    Frequency table of amox from a data.frame (2,000 x 49)

    + freq(AMX, na.rm = FALSE) +

    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

    - + @@ -817,12 +818,12 @@ Unique: 4

    - + - + @@ -872,13 +873,13 @@ Unique: 4

    - + - + diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index c7cce89e..9e37ea09 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -192,7 +192,7 @@

    How to predict antimicrobial resistance

    Matthijs S. Berends

    -

    10 May 2019

    +

    12 May 2019

    diff --git a/vignettes/freq.Rmd b/vignettes/freq.Rmd index 250a51f9..9f9c64de 100644 --- a/vignettes/freq.Rmd +++ b/vignettes/freq.Rmd @@ -114,7 +114,7 @@ All classes will be printed into the header (default is `FALSE` when using markd ```{r, echo = TRUE} septic_patients %>% - freq(amox, header = TRUE) + freq(AMX, header = TRUE) ``` ## Frequencies of dates @@ -148,7 +148,7 @@ With the `na.rm` parameter (defaults to `TRUE`, but they will always be shown in ```{r, echo = TRUE} septic_patients %>% - freq(amox, na.rm = FALSE) + freq(AMX, na.rm = FALSE) ``` ### Parameter `row.names`
    543 27.2% 1,99799.9%99.8%
    4 663 33.2% 1,42571.3%71.2%
    A 32116.1%16.0% 1,746 87.3%
    663 33.2% 1,42571.3%71.2%
    3 A 32116.1%16.0% 1,746 87.3%