diff --git a/DESCRIPTION b/DESCRIPTION index 4c3603da..137b5ee2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9018 -Date: 2019-02-23 +Date: 2019-02-25 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/R/mo.R b/R/mo.R index 09be7250..fcce4506 100755 --- a/R/mo.R +++ b/R/mo.R @@ -56,7 +56,7 @@ #' This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order: #' \itemize{ #' \item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa} -#' \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones} +#' \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section \emph{Microbial prevalence of pathogens in humans})} #' \item{Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations} #' \item{Breakdown of input values: from here it starts to breakdown input values to find possible matches} #' } @@ -93,6 +93,17 @@ #' #' Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name. #' +#' @section Microbial prevalence of pathogens in humans: +#' The artificial intelligence takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are: +#' \itemize{ +#' \item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.} +#' \item{2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora \strong{or} genus is one of: \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton}.} +#' \item{3 (least prevalent): all others.} +#' } +#' +#' Group 1 contains all common Gram negatives, like all Enterobacteriaceae and e.g. \emph{Pseudomonas} and \emph{Legionella}. +#' +#' Group 2 probably contains all microbial pathogens ever found in humans. #' @inheritSection catalogue_of_life Catalogue of Life # (source as a section, so it can be inherited by other man pages) #' @section Source: @@ -251,7 +262,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } } else if (all(x %in% reference_df[, 1]) - & all(reference_df[, "mo"] %in% microorganismsDT[["mo"]])) { + & all(reference_df[, "mo"] %in% microorganismsDT[, "mo"][[1]])) { # all in reference df colnames(reference_df)[1] <- "x" suppressWarnings( @@ -261,7 +272,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, pull(property) ) - } else if (all(x %in% microorganismsDT[["mo"]])) { + } else if (all(x %in% microorganismsDT[, "mo"][[1]])) { # existing mo codes when not looking for property "mo", like mo_genus("B_ESCHR_COL") x <- microorganismsDT[data.table(mo = x), on = "mo", ..property][[1]] @@ -278,7 +289,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, y <- as.data.table(microorganisms.codes)[data.table(code = toupper(x)), on = "code", ] x <- microorganismsDT[data.table(mo = y[["mo"]]), on = "mo", ..property][[1]] - } else if (!all(x %in% microorganismsDT[[property]])) { + } else if (!all(x %in% microorganismsDT[, ..property][[1]])) { x_backup <- x diff --git a/R/mo_property.R b/R/mo_property.R index 49c4624f..2e7f4f51 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -494,7 +494,7 @@ mo_validate <- function(x, property, ...) { # check onLoad() in R/zzz.R: data tables are created there. } - if (!all(x %in% microorganismsDT[[property]]) + if (!all(x %in% microorganismsDT[, ..property][[1]]) | Becker %in% c(TRUE, "all") | Lancefield %in% c(TRUE, "all")) { exec_as.mo(x, property = property, ...) diff --git a/R/zzz.R b/R/zzz.R index 17bdba90..d5156bba 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -50,18 +50,28 @@ make_DT <- function() { microorganismsDT <- AMR::microorganisms %>% mutate(prevalence = case_when( class == "Gammaproteobacteria" - | order %in% c("Lactobacillales", "Bacillales") + | genus %in% c("Enterococcus", "Staphylococcus", "Streptococcus") ~ 1, phylum %in% c("Proteobacteria", "Firmicutes", "Actinobacteria", - "Bacteroidetes") - | genus %in% c("Candida", - "Aspergillus", - "Trichophyton", + "Sarcomastigophora") + | genus %in% c("Aspergillus", + "Bacteroides", + "Candida", + "Capnocytophaga", + "Chryseobacterium", + "Cryptococcus", + "Elisabethkingia", + "Flavobacterium", + "Fusobacterium", "Giardia", - "Dientamoeba", - "Entamoeba") + "Leptotrichia", + "Mycoplasma", + "Prevotella", + "Rhodotorula", + "Treponema", + "Trichophyton") ~ 2, TRUE ~ 3 )) %>% @@ -74,7 +84,7 @@ make_DT <- function() { } make_trans_tbl <- function() { -# conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life) + # conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life) c(B_ACHRMB = "B_ACHRM", B_ANNMA = "B_ACTNS", B_ACLLS = "B_ALCYC", B_AHNGM = "B_ARCHN", B_ARMTM = "B_ARMTMN", B_ARTHRS = "B_ARTHR", B_APHLS = "B_AZRHZP", B_BRCHA = "B_BRCHY", B_BCTRM = "B_BRVBCT", diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 7515f28e..3f2aa1fa 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -192,7 +192,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

23 February 2019

+

25 February 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 RMarkdown. However, the methodology remains unchanged. This page was generated on 23 February 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 RMarkdown. However, the methodology remains unchanged. This page was generated on 25 February 2019.

Introduction

@@ -217,21 +217,21 @@ -2019-02-23 +2019-02-25 abcd Escherichia coli S S -2019-02-23 +2019-02-25 abcd Escherichia coli S R -2019-02-23 +2019-02-25 efgh Escherichia coli R @@ -327,70 +327,70 @@ -2017-04-07 -O7 +2016-10-19 +U5 Hospital B -Staphylococcus aureus +Escherichia coli +S +S R S -S -S F -2017-04-12 -H4 -Hospital B -Staphylococcus aureus -R -S -R -S -M - - -2013-08-17 -C3 -Hospital B -Streptococcus pneumoniae -R -R -S -S -M - - -2015-05-18 -E9 -Hospital B -Klebsiella pneumoniae -R -R -S -S -M - - -2012-12-26 -W4 +2016-05-27 +C10 Hospital A Staphylococcus aureus R S S S +M + + +2014-11-05 +A2 +Hospital A +Staphylococcus aureus +S +S +R +S +M + + +2017-03-21 +N6 +Hospital B +Staphylococcus aureus +S +I +S +S +F + + +2010-03-02 +X6 +Hospital B +Escherichia coli +S +S +S +S F -2016-09-28 -W1 +2015-08-17 +B8 Hospital D Staphylococcus aureus R S S S -F +M @@ -411,8 +411,8 @@ #> #> Item Count Percent Cum. Count Cum. Percent #> --- ----- ------- -------- ----------- ------------- -#> 1 M 10,466 52.3% 10,466 52.3% -#> 2 F 9,534 47.7% 20,000 100.0% +#> 1 M 10,390 52.0% 10,390 52.0% +#> 2 F 9,610 48.1% 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 %>%
@@ -443,10 +443,10 @@
 #> Kingella kingae (no changes)
 #> 
 #> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 1:  Intrinsic resistance in Enterobacteriaceae (1291 changes)
+#> Table 1:  Intrinsic resistance in Enterobacteriaceae (1369 changes)
 #> Table 2:  Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
 #> Table 3:  Intrinsic resistance in other Gram-negative bacteria (no changes)
-#> Table 4:  Intrinsic resistance in Gram-positive bacteria (2705 changes)
+#> Table 4:  Intrinsic resistance in Gram-positive bacteria (2815 changes)
 #> Table 8:  Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
 #> Table 9:  Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
 #> Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)
@@ -462,9 +462,9 @@
 #> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
 #> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
 #> 
-#> => EUCAST rules affected 7,376 out of 20,000 rows
+#> => EUCAST rules affected 7,563 out of 20,000 rows
 #>    -> added 0 test results
-#>    -> changed 3,996 test results (0 to S; 0 to I; 3,996 to R)
+#> -> changed 4,184 test results (0 to S; 0 to I; 4,184 to R)

@@ -489,8 +489,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,641 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,780 first isolates (28.9% of total) +

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

@@ -516,32 +516,32 @@ 1 -2010-01-24 -A4 +2010-01-05 +G4 B_ESCHR_COL -R -R +S +S S S TRUE 2 -2010-03-30 -A4 +2010-03-10 +G4 B_ESCHR_COL -I -S R S +S +S FALSE 3 -2010-07-21 -A4 +2010-07-15 +G4 B_ESCHR_COL -S +R S S S @@ -549,8 +549,8 @@ 4 -2010-09-23 -A4 +2010-09-07 +G4 B_ESCHR_COL S S @@ -560,8 +560,8 @@ 5 -2010-10-05 -A4 +2010-11-10 +G4 B_ESCHR_COL R S @@ -571,55 +571,55 @@ 6 -2010-10-26 -A4 +2011-01-23 +G4 B_ESCHR_COL +I R S S -S -FALSE - - -7 -2011-02-03 -A4 -B_ESCHR_COL -S -S -S -S TRUE + +7 +2011-02-21 +G4 +B_ESCHR_COL +S +I +S +S +FALSE + 8 -2011-02-16 -A4 +2011-02-25 +G4 B_ESCHR_COL R S -R +S S FALSE 9 -2011-04-19 -A4 +2011-02-28 +G4 B_ESCHR_COL S -R +S S S FALSE 10 -2011-05-17 -A4 +2011-04-03 +G4 B_ESCHR_COL R -R +S S S FALSE @@ -637,7 +637,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,939 first weighted isolates (79.7% of total) +#> => Found 15,963 first weighted isolates (79.8% of total) @@ -654,11 +654,11 @@ - - + + - - + + @@ -666,20 +666,32 @@ - - + + - - + + - - + + + + + + + + + + + + + + @@ -688,22 +700,10 @@ - - - - - - - - - - - - - - + + @@ -714,47 +714,47 @@ - - + + + - - - + + - - + + + - - - + + - - + + - + - - + + - + @@ -762,11 +762,11 @@ - - + + - + @@ -774,11 +774,11 @@
isolate
12010-01-24A42010-01-05G4 B_ESCHR_COLRRSS S S TRUE
22010-03-30A42010-03-10G4 B_ESCHR_COLIS R SSS FALSE TRUE
32010-07-21A42010-07-15G4B_ESCHR_COLRSSSFALSEFALSE
42010-09-07G4 B_ESCHR_COL S SFALSE TRUE
42010-09-23A4B_ESCHR_COLSSSSFALSEFALSE
52010-10-05A42010-11-10G4 B_ESCHR_COL R S
62010-10-26A42011-01-23G4 B_ESCHR_COLI R S SSFALSEFALSETRUETRUE
72011-02-03A42011-02-21G4 B_ESCHR_COL SI S SSTRUETRUEFALSEFALSE
82011-02-16A42011-02-25G4 B_ESCHR_COL R SRS S FALSE TRUE
92011-04-19A42011-02-28G4 B_ESCHR_COL SRS S S FALSE
102011-05-17A42011-04-03G4 B_ESCHR_COL RRS S S FALSE
-

Instead of 2, now 8 isolates are flagged. In total, 79.7% of all isolates are marked ‘first weighted’ - 51.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 2, now 8 isolates are flagged. In total, 79.8% of all isolates are marked ‘first weighted’ - 50.9% 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,939 isolates for analysis.

+

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

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -803,89 +803,9 @@ -2 -2017-04-12 -H4 -Hospital B -B_STPHY_AUR -R -S -R -S -M -Gram positive -Staphylococcus -aureus -TRUE - - -3 -2013-08-17 -C3 -Hospital B -B_STRPT_PNE -R -R -S -R -M -Gram positive -Streptococcus -pneumoniae -TRUE - - -4 -2015-05-18 -E9 -Hospital B -B_KLBSL_PNE -R -R -S -S -M -Gram negative -Klebsiella -pneumoniae -TRUE - - -5 -2012-12-26 -W4 -Hospital A -B_STPHY_AUR -R -S -S -S -F -Gram positive -Staphylococcus -aureus -TRUE - - -6 -2016-09-28 -W1 -Hospital D -B_STPHY_AUR -R -S -S -S -F -Gram positive -Staphylococcus -aureus -TRUE - - -7 -2016-05-04 -R2 +1 +2016-10-19 +U5 Hospital B B_ESCHR_COL S @@ -898,6 +818,86 @@ coli TRUE + +3 +2014-11-05 +A2 +Hospital A +B_STPHY_AUR +S +S +R +S +M +Gram positive +Staphylococcus +aureus +TRUE + + +5 +2010-03-02 +X6 +Hospital B +B_ESCHR_COL +S +S +S +S +F +Gram negative +Escherichia +coli +TRUE + + +6 +2015-08-17 +B8 +Hospital D +B_STPHY_AUR +R +S +S +S +M +Gram positive +Staphylococcus +aureus +TRUE + + +7 +2013-01-25 +M3 +Hospital A +B_STPHY_AUR +R +R +S +S +M +Gram positive +Staphylococcus +aureus +TRUE + + +8 +2013-07-27 +E2 +Hospital C +B_KLBSL_PNE +R +S +S +S +M +Gram negative +Klebsiella +pneumoniae +TRUE +

Time for the analysis!

@@ -915,9 +915,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,939 x 13)

+

Frequency table of genus and species from a data.frame (15,963 x 13)

Columns: 2
-Length: 15,939 (of which NA: 0 = 0.00%)
+Length: 15,963 (of which NA: 0 = 0.00%)
Unique: 4

Shortest: 16
Longest: 24

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

1 Escherichia coli -8,055 -50.5% -8,055 -50.5% +7,910 +49.6% +7,910 +49.6% 2 Staphylococcus aureus -3,886 +3,889 24.4% -11,941 -74.9% +11,799 +73.9% 3 Streptococcus pneumoniae -2,439 -15.3% -14,380 -90.2% +2,480 +15.5% +14,279 +89.5% 4 Klebsiella pneumoniae -1,559 -9.8% -15,939 +1,684 +10.5% +15,963 100.0% @@ -971,7 +971,7 @@ Longest: 24

Resistance percentages

The functions portion_R, portion_RI, portion_I, portion_IS and portion_S can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:

data_1st %>% portion_IR(amox)
-#> [1] 0.4705439
+#> [1] 0.4748481

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

data_1st %>% 
   group_by(hospital) %>% 
@@ -984,19 +984,19 @@ Longest: 24

Hospital A -0.4616191 +0.4765396 Hospital B -0.4714054 +0.4750632 Hospital C -0.4865089 +0.4830405 Hospital D -0.4703324 +0.4657107 @@ -1014,23 +1014,23 @@ Longest: 24

Hospital A -0.4616191 -4768 +0.4765396 +4774 Hospital B -0.4714054 -5543 +0.4750632 +5534 Hospital C -0.4865089 -2409 +0.4830405 +2447 Hospital D -0.4703324 -3219 +0.4657107 +3208 @@ -1050,27 +1050,27 @@ Longest: 24

Escherichia -0.7251397 -0.9020484 -0.9738051 +0.7353982 +0.8972187 +0.9734513 Klebsiella -0.7305965 -0.8941629 -0.9737011 +0.7369359 +0.9014252 +0.9786223 Staphylococcus -0.7174472 -0.9217705 -0.9804426 +0.7413217 +0.9161738 +0.9763435 Streptococcus -0.7437474 +0.7181452 0.0000000 -0.7437474 +0.7181452 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 b6f8a3eb..f154850a 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 bc660051..7c7015b5 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 847dd9de..566ac025 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 6847eec7..80319c61 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/EUCAST.html b/docs/articles/EUCAST.html index dbdfb913..00358ab3 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -192,7 +192,7 @@

How to apply EUCAST rules

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/G_test.html b/docs/articles/G_test.html index a9e944e4..fab4163e 100644 --- a/docs/articles/G_test.html +++ b/docs/articles/G_test.html @@ -192,7 +192,7 @@

How to use the G-test

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index dea88275..f2fbb6dc 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -192,7 +192,7 @@

How to work with WHONET data

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/atc_property.html b/docs/articles/atc_property.html index 83d221a5..10c2d65a 100644 --- a/docs/articles/atc_property.html +++ b/docs/articles/atc_property.html @@ -192,7 +192,7 @@

How to get properties of an antibiotic

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 9564482c..71f64d91 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -192,7 +192,7 @@

Benchmarks

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

@@ -217,14 +217,14 @@ times = 10) print(S.aureus, unit = "ms", signif = 3) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> as.mo("sau") 15.0 15.0 21.8 15.2 15.5 80.5 10 -#> as.mo("stau") 90.4 90.6 106.0 91.0 92.7 180.0 10 -#> as.mo("staaur") 15.0 15.1 19.2 15.2 15.7 54.5 10 -#> as.mo("S. aureus") 26.5 26.6 34.7 26.9 28.1 65.9 10 -#> as.mo("S. aureus") 26.6 26.7 31.8 26.8 26.9 76.8 10 -#> as.mo("STAAUR") 15.0 15.1 19.2 15.2 15.5 54.2 10 -#> as.mo("Staphylococcus aureus") 13.4 13.5 17.7 13.6 14.7 52.1 10
+#> expr min lq mean median uq max neval +#> as.mo("sau") 16.4 16.5 28.4 16.8 54.9 55.8 10 +#> as.mo("stau") 86.0 86.5 97.3 88.9 100.0 132.0 10 +#> as.mo("staaur") 16.3 16.6 23.0 16.8 21.0 56.8 10 +#> as.mo("S. aureus") 25.3 25.9 39.4 27.2 64.0 74.5 10 +#> as.mo("S. aureus") 25.2 25.3 29.7 25.6 27.0 64.3 10 +#> as.mo("STAAUR") 16.3 16.7 21.1 17.0 18.0 56.8 10 +#> as.mo("Staphylococcus aureus") 13.5 13.9 20.5 14.4 17.5 51.2 10

In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 10 milliseconds means it can determine 100 input values per second. It case of 50 milliseconds, this is only 20 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 is a WHONET code) or common laboratory codes, or common full organism names like the last one.

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 Mycoplasma leonicaptivi (B_MYCPL_LEO), a bug probably never found before in humans:

M.leonicaptivi <- microbenchmark(as.mo("myle"),
@@ -236,14 +236,21 @@
                                  times = 10)
 print(M.leonicaptivi, unit = "ms", signif = 3)
 #> Unit: milliseconds
-#>                              expr min  lq mean median  uq max neval
-#>                     as.mo("myle") 136 137  141    137 138 176    10
-#>                   as.mo("mycleo") 447 464  484    487 490 551    10
-#>          as.mo("M. leonicaptivi") 206 208  225    210 248 252    10
-#>         as.mo("M.  leonicaptivi") 207 208  230    229 251 255    10
-#>                   as.mo("MYCLEO") 444 446  462    446 486 487    10
-#>  as.mo("Mycoplasma leonicaptivi") 147 148  170    173 187 192    10
-

That takes 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.

+#> expr min lq mean median uq max +#> as.mo("myle") 135.0 135.0 147.0 135.0 174.0 176.0 +#> as.mo("mycleo") 211.0 213.0 233.0 232.0 251.0 262.0 +#> as.mo("M. leonicaptivi") 59.2 59.2 63.6 59.4 59.6 98.7 +#> as.mo("M. leonicaptivi") 59.0 59.1 59.3 59.3 59.3 59.7 +#> as.mo("MYCLEO") 211.0 211.0 220.0 211.0 222.0 250.0 +#> as.mo("Mycoplasma leonicaptivi") 22.5 22.5 26.5 22.6 22.7 61.0 +#> neval +#> 10 +#> 10 +#> 10 +#> 10 +#> 10 +#> 10 +

That takes 3.4 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.

In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Mycoplasma leonicaptivi (which is very uncommon):

par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
 
@@ -283,8 +290,8 @@
 print(run_it, unit = "ms", signif = 3)
 #> Unit: milliseconds
 #>            expr min  lq mean median  uq max neval
-#>  mo_fullname(x) 615 647  698    649 801 851    10
-

So transforming 500,000 values (!) of 95 unique values only takes 0.65 seconds (649 ms). You only lose time on your unique input values.

+#> mo_fullname(x) 610 641 644 644 657 665 10 +

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

@@ -297,10 +304,10 @@ print(run_it, unit = "ms", signif = 3) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> A 6.420 6.570 6.670 6.730 6.760 6.780 10 -#> B 27.100 27.200 28.000 27.600 27.800 32.900 10 -#> C 0.255 0.383 0.394 0.412 0.431 0.527 10

-

So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0004 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:

+#> A 7.500 7.540 7.720 7.610 7.710 8.750 10 +#> B 25.800 26.200 27.100 27.800 27.800 27.900 10 +#> C 0.604 0.628 0.704 0.729 0.755 0.791 10 +

So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0007 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"),
@@ -313,14 +320,14 @@
 print(run_it, unit = "ms", signif = 3)
 #> Unit: milliseconds
 #>  expr   min    lq  mean median    uq   max neval
-#>     A 0.311 0.355 0.435  0.437 0.492 0.566    10
-#>     B 0.283 0.299 0.340  0.337 0.362 0.411    10
-#>     C 0.393 0.447 0.503  0.496 0.566 0.662    10
-#>     D 0.253 0.288 0.324  0.305 0.325 0.523    10
-#>     E 0.243 0.249 0.315  0.288 0.342 0.506    10
-#>     F 0.239 0.295 0.349  0.327 0.411 0.482    10
-#>     G 0.249 0.323 0.364  0.347 0.410 0.493    10
-#>     H 0.226 0.303 0.368  0.339 0.478 0.523    10
+#> A 0.704 0.806 0.897 0.867 1.040 1.130 10 +#> B 0.671 0.722 0.841 0.807 0.903 1.110 10 +#> C 0.702 0.768 0.856 0.816 0.967 1.160 10 +#> D 0.641 0.695 0.746 0.746 0.755 0.976 10 +#> E 0.627 0.702 0.781 0.762 0.789 1.100 10 +#> F 0.651 0.694 0.779 0.733 0.761 1.220 10 +#> G 0.552 0.745 0.801 0.764 0.815 1.090 10 +#> H 0.637 0.661 0.722 0.724 0.766 0.803 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.

@@ -347,13 +354,13 @@ print(run_it, unit = "ms", signif = 4) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> en 17.14 17.39 20.87 17.54 17.93 50.49 10 -#> de 25.94 26.02 32.71 26.11 26.24 59.33 10 -#> nl 25.41 25.86 29.47 26.04 27.08 59.40 10 -#> es 25.55 25.97 32.75 26.11 26.77 59.62 10 -#> it 25.65 25.90 26.07 26.09 26.11 26.75 10 -#> fr 25.47 25.79 26.10 26.09 26.20 27.23 10 -#> pt 25.72 25.85 29.33 26.07 26.09 59.41 10
+#> en 18.95 18.99 19.59 19.04 19.49 23.47 10 +#> de 27.13 27.26 27.69 27.63 27.88 29.05 10 +#> nl 26.95 27.62 34.90 27.99 32.35 61.05 10 +#> es 27.42 27.55 38.05 27.75 60.86 61.40 10 +#> it 26.99 27.30 34.13 27.48 27.70 61.28 10 +#> fr 27.35 27.52 30.95 27.58 27.72 61.11 10 +#> pt 27.26 27.33 27.67 27.53 27.91 28.44 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 9a89bdc9..05045eea 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 3d5d055a..5e013356 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -192,7 +192,7 @@

How to create frequency tables

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/mo_property.html b/docs/articles/mo_property.html index 22ba4aa4..974b617e 100644 --- a/docs/articles/mo_property.html +++ b/docs/articles/mo_property.html @@ -192,7 +192,7 @@

How to get properties of a microorganism

Matthijs S. Berends

-

23 February 2019

+

25 February 2019

diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index 2ef2ffe9..3a394d4d 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

-

23 February 2019

+

25 February 2019

diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index be279295..b3818aa3 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -302,7 +302,7 @@

Use the mo_property functions to get properties based on the returned code, see Examples.

This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order:

@@ -329,6 +329,17 @@ When using allow_uncertain = TRUE (which is the default setting), i

Use mo_uncertainties() to get a vector with all values that were coerced to a valid value, but with uncertainty.

Use mo_renamed() to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name.

+

Microbial prevalence of pathogens in humans

+ + +

The artificial intelligence takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are:

+

Group 1 contains all common Gram negatives, like all Enterobacteriaceae and e.g. Pseudomonas and Legionella.

+

Group 2 probably contains all microbial pathogens ever found in humans.

+

Source

@@ -421,6 +432,8 @@ The mo_property functions (like Details +
  • Microbial prevalence of pathogens in humans
  • +
  • Source
  • Catalogue of Life
  • diff --git a/man/as.mo.Rd b/man/as.mo.Rd index dcf74582..a2ed36a4 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -63,7 +63,7 @@ Use the \code{\link{mo_property}} functions to get properties based on the retur This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order: \itemize{ \item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa} - \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones} + \item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section \emph{Microbial prevalence of pathogens in humans})} \item{Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations} \item{Breakdown of input values: from here it starts to breakdown input values to find possible matches} } @@ -100,6 +100,20 @@ Use \code{mo_uncertainties()} to get a vector with all values that were coerced Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name. } +\section{Microbial prevalence of pathogens in humans}{ + +The artificial intelligence takes into account microbial prevalence of pathogens in humans. It uses three groups and every (sub)species is in the group it matches first. These groups are: +\itemize{ + \item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.} + \item{2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora \strong{or} genus is one of: \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton}.} + \item{3 (least prevalent): all others.} +} + +Group 1 contains all common Gram negatives, like all Enterobacteriaceae and e.g. \emph{Pseudomonas} and \emph{Legionella}. + +Group 2 probably contains all microbial pathogens ever found in humans. +} + \section{Source}{ [1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \url{https://dx.doi.org/10.1128/CMR.00109-13}