diff --git a/DESCRIPTION b/DESCRIPTION index d554bd86..4286641f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.9.0.9020 -Date: 2020-02-09 +Version: 0.9.0.9021 +Date: 2020-02-10 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 5a0bbf56..7875dfcc 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 0.9.0.9020 -## Last updated: 09-Feb-2020 +# AMR 0.9.0.9021 +## Last updated: 10-Feb-2020 ### New * Support for LOINC and SNOMED codes diff --git a/R/disk.R b/R/disk.R index a9a470d7..db6dfd5d 100644 --- a/R/disk.R +++ b/R/disk.R @@ -81,7 +81,7 @@ as.disk <- function(x, na.rm = FALSE) { #' @export #' @importFrom dplyr %>% is.disk <- function(x) { - class(x) %>% identical(c("disk", "integer")) + inherits(x, c("disk", "integer")) } #' @exportMethod print.disk diff --git a/R/mic.R b/R/mic.R index ced778bf..f2aacc82 100755 --- a/R/mic.R +++ b/R/mic.R @@ -130,7 +130,7 @@ as.mic <- function(x, na.rm = FALSE) { #' @export #' @importFrom dplyr %>% is.mic <- function(x) { - class(x) %>% identical(c("mic", "ordered", "factor")) + inherits(x, c("mic", "factor")) } #' @exportMethod as.double.mic diff --git a/R/rsi.R b/R/rsi.R index cb765618..d3b377c7 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -346,8 +346,7 @@ as.rsi.data.frame <- function(x, col_mo = NULL, guideline = "EUCAST", ...) { #' @rdname as.rsi #' @export is.rsi <- function(x) { - identical(class(x), - c("rsi", "ordered", "factor")) + inherits(x, c("rsi", "factor")) } #' @rdname as.rsi diff --git a/docs/404.html b/docs/404.html index caa5c3d8..6d127bbc 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 61e6bb74..27b2720b 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 0f0c5764..88deea93 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -41,7 +41,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 @@ -187,7 +187,7 @@

Benchmarks

Matthijs S. Berends

-

09 February 2020

+

10 February 2020

@@ -221,36 +221,21 @@ times = 10) print(S.aureus, unit = "ms", signif = 2) # Unit: milliseconds -# expr min lq mean median uq max -# as.mo("sau") 8.0 8.3 14 8.5 9.2 38.0 -# as.mo("stau") 36.0 37.0 42 38.0 43.0 64.0 -# as.mo("STAU") 37.0 38.0 50 45.0 64.0 74.0 -# as.mo("staaur") 7.9 8.3 12 8.9 9.3 37.0 -# as.mo("STAAUR") 8.0 8.2 14 8.3 9.5 36.0 -# as.mo("S. aureus") 14.0 14.0 22 15.0 37.0 40.0 -# as.mo("S aureus") 13.0 14.0 16 14.0 15.0 36.0 -# as.mo("Staphylococcus aureus") 4.6 4.8 5 4.9 5.3 5.4 -# as.mo("Staphylococcus aureus (MRSA)") 630.0 650.0 730 690.0 710.0 1100.0 -# as.mo("Sthafilokkockus aaureuz") 350.0 370.0 400 380.0 420.0 500.0 -# as.mo("MRSA") 8.0 8.2 11 8.3 9.3 33.0 -# as.mo("VISA") 24.0 25.0 46 36.0 49.0 140.0 -# as.mo("VRSA") 23.0 25.0 37 37.0 48.0 49.0 -# as.mo(22242419) 120.0 130.0 140 140.0 150.0 150.0 -# neval -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 -# 10 +# expr min lq mean median uq max neval +# as.mo("sau") 8.0 8.2 11.0 8.4 8.6 34 10 +# as.mo("stau") 37.0 37.0 41.0 38.0 40.0 65 10 +# as.mo("STAU") 37.0 38.0 47.0 41.0 62.0 69 10 +# as.mo("staaur") 8.1 8.2 16.0 8.4 8.8 57 10 +# as.mo("STAAUR") 8.1 8.3 11.0 8.5 8.9 34 10 +# as.mo("S. aureus") 14.0 14.0 21.0 14.0 36.0 37 10 +# as.mo("S aureus") 13.0 14.0 20.0 15.0 16.0 47 10 +# as.mo("Staphylococcus aureus") 4.7 4.8 8.6 4.9 6.2 39 10 +# as.mo("Staphylococcus aureus (MRSA)") 640.0 650.0 680.0 660.0 680.0 790 10 +# as.mo("Sthafilokkockus aaureuz") 330.0 350.0 390.0 390.0 430.0 500 10 +# as.mo("MRSA") 8.0 8.5 17.0 9.0 33.0 43 10 +# as.mo("VISA") 24.0 24.0 36.0 30.0 47.0 56 10 +# as.mo("VRSA") 24.0 25.0 60.0 36.0 50.0 270 10 +# as.mo(22242419) 120.0 120.0 130.0 130.0 140.0 150 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.

To achieve this speed, the as.mo function also takes into account the prevalence of human pathogenic microorganisms. The downside of this is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Methanosarcina semesiae (B_MTHNSR_SEMS), a bug probably never found before in humans:

@@ -262,18 +247,18 @@ times = 10) print(M.semesiae, unit = "ms", signif = 4) # Unit: milliseconds -# expr min lq mean median uq -# as.mo("metsem") 1412.000 1475.000 1514.00 1503.00 1553.000 -# as.mo("METSEM") 1348.000 1448.000 1470.00 1471.00 1512.000 -# as.mo("M. semesiae") 14.410 14.600 20.03 14.84 16.170 -# as.mo("M. semesiae") 14.640 15.070 26.61 18.52 41.270 -# as.mo("Methanosarcina semesiae") 5.289 5.508 11.34 5.63 5.837 +# expr min lq mean median uq +# as.mo("metsem") 1422.000 1474.000 1511.000 1515.000 1544.00 +# as.mo("METSEM") 1381.000 1446.000 1457.000 1458.000 1477.00 +# as.mo("M. semesiae") 14.390 14.520 18.050 15.000 17.64 +# as.mo("M. semesiae") 14.330 14.570 17.690 14.740 15.14 +# as.mo("Methanosarcina semesiae") 5.261 5.342 7.848 5.459 5.63 # max neval -# 1634.00 10 -# 1554.00 10 -# 41.27 10 -# 45.83 10 -# 35.94 10 +# 1617.00 10 +# 1520.00 10 +# 39.73 10 +# 39.72 10 +# 29.36 10

That takes 5.6 times as much time on average. 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 Methanosarcina semesiae) are always very fast and only take some thousands of seconds to coerce - they 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 Methanosarcina semesiae (which is uncommon):

@@ -308,8 +293,8 @@ print(run_it, unit = "ms", signif = 3) # Unit: milliseconds # expr min lq mean median uq max neval -# mo_name(x) 574 626 649 644 660 787 100 -

So transforming 500,000 values (!!) of 50 unique values only takes 0.64 seconds (643 ms). You only lose time on your unique input values.

+# mo_name(x) 566 598 628 621 645 782 100 +

So transforming 500,000 values (!!) of 50 unique values only takes 0.62 seconds (620 ms). You only lose time on your unique input values.

@@ -321,11 +306,11 @@ times = 10) print(run_it, unit = "ms", signif = 3) # Unit: milliseconds -# expr min lq mean median uq max neval -# A 6.370 6.460 9.890 6.53 6.900 39.400 10 -# B 13.400 13.500 13.800 13.60 14.100 14.500 10 -# C 0.795 0.825 0.851 0.84 0.849 0.973 10

-

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0008 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 6.120 6.540 7.44 6.900 8.830 9.12 10 +# B 13.600 13.800 14.50 14.200 15.000 16.30 10 +# C 0.841 0.859 3.82 0.876 0.917 30.30 10 +

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0009 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_name("Staphylococcus aureus"),
@@ -338,14 +323,14 @@
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #  expr   min    lq  mean median    uq   max neval
-#     A 0.451 0.485 0.488  0.489 0.495 0.518    10
-#     B 0.507 0.510 0.526  0.522 0.538 0.554    10
-#     C 0.732 0.742 0.769  0.781 0.786 0.807    10
-#     D 0.507 0.514 0.534  0.531 0.549 0.585    10
-#     E 0.469 0.486 0.492  0.489 0.499 0.532    10
-#     F 0.473 0.479 0.483  0.481 0.482 0.513    10
-#     G 0.466 0.469 0.481  0.480 0.486 0.517    10
-#     H 0.468 0.476 0.502  0.483 0.494 0.665    10
+# A 0.517 0.522 0.570 0.540 0.575 0.756 10 +# B 0.536 0.550 0.584 0.559 0.579 0.801 10 +# C 0.696 0.776 0.804 0.828 0.841 0.908 10 +# D 0.531 0.552 0.597 0.576 0.616 0.784 10 +# E 0.520 0.529 0.549 0.534 0.569 0.626 10 +# F 0.483 0.491 0.519 0.517 0.521 0.580 10 +# G 0.509 0.514 0.545 0.520 0.537 0.763 10 +# H 0.464 0.514 0.555 0.542 0.593 0.698 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" anyway, 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.

@@ -372,13 +357,13 @@ print(run_it, unit = "ms", signif = 4) # Unit: milliseconds # expr min lq mean median uq max neval -# en 24.62 25.46 32.22 25.95 27.72 146.70 100 -# de 25.97 26.93 33.24 27.52 29.66 64.41 100 -# nl 31.00 32.90 37.58 33.48 35.16 69.10 100 -# es 25.86 26.98 32.09 27.47 28.42 67.33 100 -# it 25.71 26.95 33.87 27.67 31.49 62.06 100 -# fr 25.80 27.00 31.05 27.41 28.07 72.99 100 -# pt 25.80 27.02 33.26 27.51 31.44 63.41 100
+# en 23.52 25.12 30.94 26.03 26.90 68.07 100 +# de 24.94 26.64 33.82 27.81 30.86 152.10 100 +# nl 30.28 32.60 37.42 33.81 35.15 72.52 100 +# es 24.86 26.55 31.91 27.42 28.91 80.24 100 +# it 24.54 26.61 32.10 27.45 28.35 69.43 100 +# fr 24.75 26.30 30.43 27.50 28.37 64.56 100 +# pt 24.95 26.38 31.37 27.32 28.38 66.08 100

Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png index b5e3e534..2398f800 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png index 345118f4..9bd84173 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index e1540098..326df2ec 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 diff --git a/docs/authors.html b/docs/authors.html index 95aaec11..91c14c70 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 diff --git a/docs/index.html b/docs/index.html index 9c353d20..bbf424f8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -45,7 +45,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 diff --git a/docs/news/index.html b/docs/news/index.html index a51a68f4..dc9f9400 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021 @@ -231,13 +231,13 @@ -
+

-AMR 0.9.0.9020 Unreleased +AMR 0.9.0.9021 Unreleased

-
+

-Last updated: 09-Feb-2020 +Last updated: 10-Feb-2020

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

Contents

diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 7a7e298b..2f04059e 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -85,7 +85,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021
diff --git a/docs/reference/index.html b/docs/reference/index.html index 9f948521..ec8b6192 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021
diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html index c91ada55..7a4f578a 100644 --- a/docs/reference/microorganisms.codes.html +++ b/docs/reference/microorganisms.codes.html @@ -85,7 +85,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021
diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index b826f971..7b2c1482 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -85,7 +85,7 @@ AMR (for R) - 0.9.0.9020 + 0.9.0.9021