diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4051166..0c081e01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,6 @@ pages: only: - master script: - #- Rscript -e "install.packages('pkgdown', repos = 'https://cran.rstudio.com')" - Rscript -e "devtools::install(build = TRUE, upgrade = FALSE)" - R -e "pkgdown::build_site(examples = FALSE, lazy = TRUE, override = list(destination = 'public'))" artifacts: diff --git a/NEWS.md b/NEWS.md index 140911f4..a8cedcf8 100755 --- a/NEWS.md +++ b/NEWS.md @@ -282,7 +282,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git * Functions `count_R`, `count_IR`, `count_I`, `count_SI` and `count_S` to selectively count resistant or susceptible isolates * Extra function `count_df` (which works like `portion_df`) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables * Function `is.rsi.eligible` to check for columns that have valid antimicrobial results, but do not have the `rsi` class yet. Transform the columns of your raw data with: `data %>% mutate_if(is.rsi.eligible, as.rsi)` -* Functions `as.mo` and `is.mo` as replacements for `as.bactid` and `is.bactid` (since the `microoganisms` data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The `as.mo` function determines microbial IDs using Artificial Intelligence (AI): +* Functions `as.mo` and `is.mo` as replacements for `as.bactid` and `is.bactid` (since the `microoganisms` data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The `as.mo` function determines microbial IDs using intelligent rules: ```r as.mo("E. coli") # [1] B_ESCHR_COL diff --git a/R/mo.R b/R/mo.R index b15f0268..94123298 100755 --- a/R/mo.R +++ b/R/mo.R @@ -21,7 +21,7 @@ #' Transform to microorganism ID #' -#' Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using Artificial Intelligence (AI) and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples. +#' Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples. #' @param x a character vector or a \code{data.frame} with one or two columns #' @param Becker a logical to indicate whether \emph{Staphylococci} should be categorised into Coagulase Negative \emph{Staphylococci} ("CoNS") and Coagulase Positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} [1]. #' @@ -55,8 +55,8 @@ #' #' Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples. #' -#' \strong{Artificial Intelligence} \cr -#' This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order: +#' \strong{Intelligent rules} \cr +#' This function uses intelligent rules 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 (see section \emph{Microbial prevalence of pathogens in humans})} @@ -73,7 +73,7 @@ #' This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms. #' #' \strong{Uncertain results} \cr -#' When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous AI rules failed to get valid results. These are: +#' When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are: #' \itemize{ #' \item{It tries to look for previously accepted (but now invalid) taxonomic names} #' \item{It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules} @@ -96,7 +96,7 @@ #' Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name. #' #' \strong{Microbial prevalence of pathogens in humans} \cr -#' 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: +#' The intelligent rules 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}, \emph{Ureaplasma}.} @@ -326,7 +326,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } # all empty - if (all(identical(trimws(x_input), "") | is.na(x_input))) { + if (all(identical(trimws(x_input), "") | is.na(x_input) | length(x) == 0)) { if (property == "mo") { return(structure(rep(NA_character_, length(x_input)), class = "mo")) diff --git a/_pkgdown.yml b/_pkgdown.yml index fad292db..c6e66e05 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -128,6 +128,7 @@ reference: - '`availability`' - '`count`' - '`portion`' + - '`filter_ab_class`' - '`freq`' - '`g.test`' - '`ggplot_rsi`' diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index a7ee28a7..6ccf67a4 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

-

14 February 2019

+

06 March 2019

@@ -214,7 +214,7 @@
  • R is highly modular.

    The official R network (CRAN) features almost 14,000 packages at the time of writing, our AMR package being one of them. All these packages were peer-reviewed before publication. Aside from this official channel, there are also developers who choose not to submit to CRAN, but rather keep it on their own public repository, like GitLab or GitHub. So there may even be a lot more than 14,000 packages out there.

    -

    Bottomline is, you can really extend it yourself or ask somebody to do this for you. Take for example our AMR package. SPSS, SAS and Stata will never know what a valid MIC value is (so data might not be clean) or what the Gram stain of E. coli is. Or the fact that all species of Klebiella are resistant to amoxicillin.

    +

    Bottom line is, you can really extend it yourself or ask somebody to do this for you. Take for example our AMR package. Among other things, it adds reliable reference data to R to help you with the data cleaning and analysis. SPSS, SAS and Stata will never know what a valid MIC value is or what the Gram stain of E. coli is. Or that all species of Klebiella are resistant to amoxicillin and that Floxapen® is a trade name of flucloxacillin. These facts and properties are often needed to clean existing data, which would be very inconvenient in a software package without reliable reference data. See below for a demonstration.

  • R is extremely flexible.

    @@ -241,6 +241,38 @@
  • If you sometimes write syntaxes in SPSS to run a complete analysis or to ‘automate’ some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS.

    +

    To demonstrate the first point:

    +
    # not all values are valid MIC values:
    +as.mic(0.125)
    +#> Class 'mic'
    +#> [1] 0.125
    +as.mic("testvalue")
    +#> Class 'mic'
    +#> [1] <NA>
    +
    +# the Gram stain is avaiable for all bacteria:
    +mo_gramstain("E. coli")
    +#> [1] "Gram negative"
    +
    +# Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:
    +klebsiella_test <- data.frame(mo = "klebsiella", 
    +                              amox = "S",
    +                              stringsAsFactors = FALSE)
    +klebsiella_test
    +#>           mo amox
    +#> 1 klebsiella    S
    +eucast_rules(klebsiella_test, info = FALSE)
    +#>           mo amox
    +#> 1 klebsiella    R
    +
    +# hundreds of trade names can be translated to an ATC or name:
    +atc_name("floxapen")
    +#> [1] "Flucloxacillin"
    +as.atc("floxapen")
    +#> Class 'atc'
    +#> [1] J01CF05
    +atc_tradenames("floxapen")
    +#> [1] "Flopen"    "Floxapen"  "Fluclox"   "Sesamol"   "Softapen"  "Staphylex"

    @@ -248,105 +280,105 @@

    RStudio

    -

    To work with R, probably the best option is to use RStudio. It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menu to work with other data sources. You can also run RStudio Server, which is nothing less than the complete RStudio software available as a website (e.g. in your corporate network or at home).

    +

    To work with R, probably the best option is to use RStudio. It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menus to work with other data sources. You can also run RStudio Server, which is nothing less than the complete RStudio software available as a website (e.g. in your corporate network or at home).

    To import a data file, just click Import Dataset in the Environment tab:

    -

    +

    If additional packages are needed, RStudio will ask you if they should be installed on beforehand.

    In the the window that opens, you can define all options (parameters) that should be used for import and you’re ready to go:

    -

    +

    If you want named variables to be imported as factors so it resembles SPSS more, use as_factor().

    The difference is this:

    - +

    Base R

    To import data from SPSS, SAS or Stata, you can use the great haven package yourself:

    - +

    You can now import files as follows:

    SPSS

    To read files from SPSS into R:

    -
    # read any SPSS file based on file extension (best way):
    -read_spss(file = "path/to/file")
    -
    -# read .sav or .zsav file:
    -read_sav(file = "path/to/file")
    -
    -# read .por file:
    -read_por(file = "path/to/file")
    +
    # read any SPSS file based on file extension (best way):
    +read_spss(file = "path/to/file")
    +
    +# read .sav or .zsav file:
    +read_sav(file = "path/to/file")
    +
    +# read .por file:
    +read_por(file = "path/to/file")

    Do not forget about as_factor(), as mentioned above.

    To export your R objects to the SPSS file format:

    -
    # save as .sav file:
    -write_sav(data = yourdata, path = "path/to/file")
    -
    -# save as compressed .zsav file:
    -write_sav(data = yourdata, path = "path/to/file", compress = TRUE)
    +
    # save as .sav file:
    +write_sav(data = yourdata, path = "path/to/file")
    +
    +# save as compressed .zsav file:
    +write_sav(data = yourdata, path = "path/to/file", compress = TRUE)

    SAS

    To read files from SAS into R:

    -
    # read .sas7bdat + .sas7bcat files:
    -read_sas(data_file = "path/to/file", catalog_file = NULL)
    -
    -# read SAS transport files (version 5 and version 8):
    -read_xpt(file = "path/to/file")
    -

    To export your R objects to the SAS file format:

    -
    # save as regular SAS file:
    -write_sas(data = yourdata, path = "path/to/file")
    +
    # read .sas7bdat + .sas7bcat files:
    +read_sas(data_file = "path/to/file", catalog_file = NULL)
     
    -# the SAS transport format is an open format 
    -# (required for submission of the data to the FDA)
    -write_xpt(data = yourdata, path = "path/to/file", version = 8)
    +# read SAS transport files (version 5 and version 8): +read_xpt(file = "path/to/file")
    +

    To export your R objects to the SAS file format:

    +
    # save as regular SAS file:
    +write_sas(data = yourdata, path = "path/to/file")
    +
    +# the SAS transport format is an open format 
    +# (required for submission of the data to the FDA)
    +write_xpt(data = yourdata, path = "path/to/file", version = 8)

    Stata

    To read files from Stata into R:

    -
    # read .dta file:
    -read_stata(file = "/path/to/file")
    -
    -# works exactly the same:
    -read_dta(file = "/path/to/file")
    +
    # read .dta file:
    +read_stata(file = "/path/to/file")
    +
    +# works exactly the same:
    +read_dta(file = "/path/to/file")

    To export your R objects to the Stata file format:

    - +

    diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index d89b9b9c..9f5ef3fb 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -192,7 +192,7 @@

    Benchmarks

    Matthijs S. Berends

    -

    05 March 2019

    +

    06 March 2019

    @@ -201,12 +201,12 @@ -

    One of the most important features of this package is the complete microbial taxonomic database, supplied by the Catalogue of Life. We created a function as.mo() that transforms any user input value to a valid microbial ID by using AI (Artificial Intelligence) combined with the taxonomic tree of Catalogue of Life.

    +

    One of the most important features of this package is the complete microbial taxonomic database, supplied by the Catalogue of Life. We created a function as.mo() that transforms any user input value to a valid microbial ID by using intelligent rules combined with the taxonomic tree of Catalogue of Life.

    Using the microbenchmark package, we can review the calculation performance of this function. Its function microbenchmark() runs different input expressions independently of each other and measures their time-to-result.

    library(microbenchmark)
     library(AMR)

    In the next test, we try to ‘coerce’ different input values for Staphylococcus aureus. The actual result is the same every time: it returns its MO code B_STPHY_AUR (B stands for Bacteria, the taxonomic kingdom).

    -

    But the calculation time differs a lot. Here, the AI effect can be reviewed best:

    +

    But the calculation time differs a lot:

    S.aureus <- microbenchmark(as.mo("sau"),
                                as.mo("stau"),
                                as.mo("staaur"),
    @@ -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") 16.80 17.20 25.80  18.10 32.10 52.8    10
    -#>                   as.mo("stau") 32.20 33.10 43.30  34.00 42.40 82.3    10
    -#>                 as.mo("staaur") 16.70 16.80 25.40  17.20 19.80 60.4    10
    -#>                 as.mo("STAAUR") 16.70 16.80 22.40  17.90 20.20 61.7    10
    -#>              as.mo("S. aureus") 24.90 25.10 42.00  26.20 67.50 88.8    10
    -#>             as.mo("S.  aureus") 24.50 25.00 43.70  25.30 67.90 78.2    10
    -#>  as.mo("Staphylococcus aureus")  7.47  7.48  9.63   7.53  7.69 28.3    10
    +#> expr min lq mean median uq max neval +#> as.mo("sau") 16.50 16.60 17.0 16.70 17.00 19.0 10 +#> as.mo("stau") 31.70 31.90 51.5 32.10 49.10 166.0 10 +#> as.mo("staaur") 16.60 16.70 21.8 16.80 17.00 65.7 10 +#> as.mo("STAAUR") 16.70 16.70 27.1 16.80 17.60 77.3 10 +#> as.mo("S. aureus") 24.60 24.70 30.2 25.30 31.80 57.8 10 +#> as.mo("S. aureus") 24.60 24.60 37.7 25.10 66.00 67.4 10 +#> as.mo("Staphylococcus aureus") 7.47 7.48 11.1 7.65 8.02 41.1 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"),
    @@ -235,13 +235,13 @@
                                      times = 10)
     print(T.islandicus, unit = "ms", signif = 3)
     #> Unit: milliseconds
    -#>                         expr   min    lq mean median  uq max neval
    -#>              as.mo("theisl") 275.0 304.0  310  309.0 316 337    10
    -#>              as.mo("THEISL") 263.0 304.0  311  306.0 312 391    10
    -#>       as.mo("T. islandicus") 142.0 143.0  168  148.0 188 220    10
    -#>      as.mo("T.  islandicus") 142.0 142.0  169  143.0 185 312    10
    -#>  as.mo("Thermus islandicus")  68.1  68.6  101   89.8 122 179    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.

    +#> expr min lq mean median uq max neval +#> as.mo("theisl") 269.0 270.0 294.0 293.0 317 320 10 +#> as.mo("THEISL") 272.0 313.0 327.0 316.0 321 476 10 +#> as.mo("T. islandicus") 142.0 142.0 159.0 144.0 191 205 10 +#> as.mo("T. islandicus") 142.0 143.0 166.0 164.0 188 196 10 +#> as.mo("Thermus islandicus") 68.4 68.6 86.8 69.2 113 116 10 +

    That takes 7.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. 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) 687 738  767    770 774 887    10
    -

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

    +#> mo_fullname(x) 688 757 800 758 919 921 10 +

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

    @@ -300,10 +300,10 @@ times = 10) print(run_it, unit = "ms", signif = 3) #> Unit: milliseconds -#> expr min lq mean median uq max neval -#> A 11.100 11.300 15.600 11.400 11.600 53.4 10 -#> B 22.200 22.500 22.800 22.800 23.000 23.7 10 -#> C 0.322 0.326 0.518 0.563 0.578 0.8 10

    +#> expr min lq mean median uq max neval +#> A 11.200 11.300 11.900 12.200 12.300 12.600 10 +#> B 22.300 22.500 23.300 23.100 23.900 24.700 10 +#> C 0.339 0.519 0.612 0.564 0.768 0.776 10

    So going from mo_fullname("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0006 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"),
    @@ -317,14 +317,14 @@
     print(run_it, unit = "ms", signif = 3)
     #> Unit: milliseconds
     #>  expr   min    lq  mean median    uq   max neval
    -#>     A 0.330 0.345 0.421  0.441 0.461 0.525    10
    -#>     B 0.355 0.378 0.453  0.435 0.464 0.754    10
    -#>     C 0.315 0.374 0.506  0.516 0.633 0.700    10
    -#>     D 0.273 0.329 0.353  0.365 0.385 0.391    10
    -#>     E 0.279 0.322 0.330  0.335 0.343 0.366    10
    -#>     F 0.247 0.263 0.315  0.319 0.355 0.429    10
    -#>     G 0.276 0.320 0.342  0.328 0.371 0.447    10
    -#>     H 0.251 0.258 0.315  0.329 0.360 0.368    10
    +#> A 0.321 0.434 0.481 0.501 0.519 0.665 10 +#> B 0.352 0.414 0.482 0.475 0.513 0.715 10 +#> C 0.394 0.648 0.670 0.679 0.770 0.839 10 +#> D 0.354 0.371 0.393 0.395 0.410 0.428 10 +#> E 0.286 0.353 0.370 0.369 0.399 0.443 10 +#> F 0.317 0.373 0.377 0.380 0.392 0.437 10 +#> G 0.272 0.307 0.352 0.348 0.387 0.431 10 +#> H 0.293 0.338 0.366 0.361 0.412 0.441 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.

    @@ -351,13 +351,13 @@ print(run_it, unit = "ms", signif = 4) #> Unit: milliseconds #> expr min lq mean median uq max neval -#> en 14.98 15.35 19.58 15.51 15.58 56.78 10 -#> de 27.26 27.69 28.05 27.85 28.01 29.44 10 -#> nl 27.07 27.73 31.89 27.87 28.00 69.50 10 -#> es 26.98 27.43 31.98 27.84 28.09 69.30 10 -#> it 27.26 27.57 28.38 27.82 28.92 32.14 10 -#> fr 27.21 27.72 36.16 27.83 28.19 70.08 10 -#> pt 27.21 27.78 36.17 27.96 28.54 69.43 10
    +#> en 14.97 15.49 15.46 15.56 15.60 15.65 10 +#> de 27.29 27.76 44.46 27.98 69.27 71.00 10 +#> nl 27.22 27.97 28.53 28.03 29.40 31.36 10 +#> es 27.45 27.96 32.24 28.00 28.08 69.99 10 +#> it 27.21 27.32 28.01 27.89 28.05 29.41 10 +#> fr 27.26 27.94 28.16 28.12 28.25 29.47 10 +#> pt 27.08 27.45 36.14 27.92 28.07 70.34 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 12367582..d8aa9d5a 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/index.html b/docs/index.html index 9a7bfa51..9735202a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -311,9 +311,9 @@

    The AMR package basically does four important things:

    1. -

      It cleanses existing data by providing new classes for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use artificial intelligence to guess results that you would expect:

      +

      It cleanses existing data by providing new classes for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect:

    2. Use mdro() (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported.
    3. -
    4. The data set microorganisms contains the complete taxonomic tree of almost 60,000 microorganisms. Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). As they use as.mo() internally, they also use artificial intelligence. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
    5. -
    6. The data set antibiotics contains almost 500 antimicrobial drugs with their ATC code, EARS-Net code, common LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains hundreds of trade names. Use functions like atc_name() and atc_tradenames() to look up values. The atc_* functions use as.atc() internally so they support AI to guess your expected result. For example, atc_name("Fluclox"), atc_name("Floxapen") and atc_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
    7. +
    8. The data set microorganisms contains the complete taxonomic tree of almost 60,000 microorganisms. Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). As they use as.mo() internally, they also use the same intelligent rules for determination. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
    9. +
    10. The data set antibiotics contains almost 500 antimicrobial drugs with their ATC code, EARS-Net code, common LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains hundreds of trade names. Use functions like atc_name() and atc_tradenames() to look up values. The atc_* functions use as.atc() internally so they support the same intelligent rules to guess the most probable result. For example, atc_name("Fluclox"), atc_name("Floxapen") and atc_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
    11. @@ -349,14 +349,14 @@
    12. Aside from this website with many tutorials, the package itself contains extensive help pages with many examples for all functions.
    13. The package also contains example data sets:
    14. diff --git a/docs/news/index.html b/docs/news/index.html index 256228bf..3c187f88 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -611,7 +611,7 @@ These functions use as.atc()
    15. Function is.rsi.eligible to check for columns that have valid antimicrobial results, but do not have the rsi class yet. Transform the columns of your raw data with: data %>% mutate_if(is.rsi.eligible, as.rsi)
    16. -

      Functions as.mo and is.mo as replacements for as.bactid and is.bactid (since the microoganisms data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo function determines microbial IDs using Artificial Intelligence (AI):

      +

      Functions as.mo and is.mo as replacements for as.bactid and is.bactid (since the microoganisms data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo function determines microbial IDs using intelligent rules:

      as.mo("E. coli")
       # [1] B_ESCHR_COL
       as.mo("MRSA")
      diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html
      index 9f360adc..3faf0f12 100644
      --- a/docs/reference/as.mo.html
      +++ b/docs/reference/as.mo.html
      @@ -47,7 +47,7 @@
         
       
       
      -
      +
       
       
       
      @@ -237,7 +237,7 @@
       
           
      -

      Use this function to determine a valid microorganism ID (mo). Determination is done using Artificial Intelligence (AI) and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like "Staphylococcus aureus"), an abbreviated name (like "S. aureus"), an abbreviation known in the field (like "MRSA"), or just a genus. You could also select a genus and species column, zie Examples.

      +

      Use this function to determine a valid microorganism ID (mo). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like "Staphylococcus aureus"), an abbreviated name (like "S. aureus"), an abbreviation known in the field (like "MRSA"), or just a genus. You could also select a genus and species column, zie Examples.

      @@ -301,8 +301,8 @@

      Values that cannot be coered will be considered 'unknown' and have an MO code UNKNOWN.

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

      -

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

        +

        Intelligent rules
        +This function uses intelligent rules to help getting fast and logical results. It tries to find matches in this order:

        • Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa

        • Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see section Microbial prevalence of pathogens in humans)

        • Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations

        • @@ -314,7 +314,7 @@ This function uses Artificial Intelligence (AI) to help getting fast and logical
        • Something like "stau" or "S aur" will return the ID of Staphylococcus aureus and not Staphylococcus auricularis

        This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms.

        Uncertain results
        -When using allow_uncertain = TRUE (which is the default setting), it will use additional rules if all previous AI rules failed to get valid results. These are:

          +When using allow_uncertain = TRUE (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are:

          • It tries to look for previously accepted (but now invalid) taxonomic names

          • It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules

          • It strips off words from the end one by one and re-evaluates the input with all previous rules

          • @@ -330,7 +330,7 @@ When using allow_uncertain = TRUE (which is the default setting), i

            Use mo_uncertainties() to get a data.frame 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:

              +The intelligent rules 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:

              • 1 (most prevalent): class is Gammaproteobacteria or genus is one of: Enterococcus, Staphylococcus, Streptococcus.

              • 2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora or genus is one of: Aspergillus, Bacteroides, Candida, Capnocytophaga, Chryseobacterium, Cryptococcus, Elisabethkingia, Flavobacterium, Fusobacterium, Giardia, Leptotrichia, Mycoplasma, Prevotella, Rhodotorula, Treponema, Trichophyton, Ureaplasma.

              • 3 (least prevalent): all others.

              • diff --git a/docs/reference/index.html b/docs/reference/index.html index 64624283..2ed17949 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -428,6 +428,12 @@

                Calculate resistance of isolates

                + +

                filter_ab_class() filter_aminoglycosides() filter_carbapenems() filter_cephalosporins() filter_1st_cephalosporins() filter_2nd_cephalosporins() filter_3rd_cephalosporins() filter_4th_cephalosporins() filter_fluoroquinolones() filter_glycopeptides() filter_macrolides() filter_tetracyclines()

                + +

                Filter on antibiotic class

                + +

                frequency_tbl() freq() top_freq() header() print(<frequency_tbl>)

                diff --git a/index.md b/index.md index 77a3dd93..4e15ef7f 100644 --- a/index.md +++ b/index.md @@ -130,9 +130,9 @@ Read our tutorial about [how to work with WHONET data here](./articles/WHONET.ht The `AMR` package basically does four important things: -1. It **cleanses existing data** by providing new *classes* for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use artificial intelligence to guess results that you would expect: +1. It **cleanses existing data** by providing new *classes* for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect: - * Use `as.mo()` to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using artificial intelligence on the included Catalogue of Life data set, consisting of almost 60,000 microorganisms. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)). + * Use `as.mo()` to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set, consisting of almost 60,000 microorganisms. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)). * Use `as.rsi()` to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like "<=0.002; S" (combined MIC/RSI) will result in "S". * Use `as.mic()` to cleanse your MIC values. It produces a so-called factor (called *ordinal* in SPSS) with valid MIC values as levels. A value like "<=0.002; S" (combined MIC/RSI) will result in "<=0.002". * Use `as.atc()` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ATC code of Nitrofurantoine. @@ -143,8 +143,8 @@ The `AMR` package basically does four important things: * Use `first_isolate()` to identify the first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute). * You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them. * Use `mdro()` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported. - * The [data set `microorganisms`](./reference/microorganisms.html) contains the complete taxonomic tree of almost 60,000 microorganisms. Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus()`, `mo_family()`, `mo_gramstain()` or even `mo_phylum()`. As they use `as.mo()` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data. - * The [data set `antibiotics`](./reference/antibiotics.html) contains almost 500 antimicrobial drugs with their ATC code, EARS-Net code, common LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains hundreds of trade names. Use functions like `atc_name()` and `atc_tradenames()` to look up values. The `atc_*` functions use `as.atc()` internally so they support AI to guess your expected result. For example, `atc_name("Fluclox")`, `atc_name("Floxapen")` and `atc_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. + * The [data set `microorganisms`](./reference/microorganisms.html) contains the complete taxonomic tree of almost 60,000 microorganisms. Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus()`, `mo_family()`, `mo_gramstain()` or even `mo_phylum()`. As they use `as.mo()` internally, they also use the same intelligent rules for determination. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data. + * The [data set `antibiotics`](./reference/antibiotics.html) contains almost 500 antimicrobial drugs with their ATC code, EARS-Net code, common LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains hundreds of trade names. Use functions like `atc_name()` and `atc_tradenames()` to look up values. The `atc_*` functions use `as.atc()` internally so they support the same intelligent rules to guess the most probable result. For example, `atc_name("Fluclox")`, `atc_name("Floxapen")` and `atc_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. 3. It **analyses the data** with convenient functions that use well-known methods. @@ -157,11 +157,11 @@ The `AMR` package basically does four important things: * Aside from this website with many tutorials, the package itself contains extensive help pages with many examples for all functions. * The package also contains example data sets: - * The [`septic_patients` data set](.reference/septic_patients.html). This data set contains: + * The [`septic_patients` data set](./reference/septic_patients.html). This data set contains: * 2,000 blood culture isolates from anonymised septic patients between 2001 and 2017 in the Northern Netherlands * Results of 40 antibiotics (each antibiotic in its own column) with a total ~40,000 antimicrobial results * Real and genuine data - * The [`WHONET` data set](.reference/WHONET.html). This data set only contains fake data, but with the exact same structure as files exported by WHONET. Read more about WHONET [on its tutorial page](./articles/WHONET.html). + * The [`WHONET` data set](./reference/WHONET.html). This data set only contains fake data, but with the exact same structure as files exported by WHONET. Read more about WHONET [on its tutorial page](./articles/WHONET.html). #### Partners diff --git a/man/as.mo.Rd b/man/as.mo.Rd index 0e7c54f5..ca9bd668 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -39,7 +39,7 @@ mo_renamed() Character (vector) with class \code{"mo"}. Unknown values will return \code{NA}. } \description{ -Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using Artificial Intelligence (AI) and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples. +Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Archaea, Bacteria, Protozoa, Viruses and most microbial species from the kingdom Fungi (see Source), so the input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples. } \details{ A microbial ID from this package (class: \code{mo}) typically looks like these examples:\cr @@ -62,8 +62,8 @@ Values that cannot be coered will be considered 'unknown' and have an MO code \c Use the \code{\link{mo_property}} functions to get properties based on the returned code, see Examples. -\strong{Artificial Intelligence} \cr -This function uses Artificial Intelligence (AI) to help getting fast and logical results. It tries to find matches in this order: +\strong{Intelligent rules} \cr +This function uses intelligent rules 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 (see section \emph{Microbial prevalence of pathogens in humans})} @@ -80,7 +80,7 @@ A couple of effects because of these rules: This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms. \strong{Uncertain results} \cr -When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous AI rules failed to get valid results. These are: +When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous rules failed to get valid results. These are: \itemize{ \item{It tries to look for previously accepted (but now invalid) taxonomic names} \item{It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules} @@ -103,7 +103,7 @@ Use \code{mo_uncertainties()} to get a data.frame with all values that were coer Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name. \strong{Microbial prevalence of pathogens in humans} \cr -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: +The intelligent rules 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}, \emph{Ureaplasma}.} diff --git a/vignettes/SPSS.Rmd b/vignettes/SPSS.Rmd index de5fe2de..f468b958 100755 --- a/vignettes/SPSS.Rmd +++ b/vignettes/SPSS.Rmd @@ -1,7 +1,7 @@ --- title: "How to import data from SPSS / SAS / Stata" author: "Matthijs S. Berends" -date: "14 February 2019" +date: '`r format(Sys.Date(), "%d %B %Y")`' output: rmarkdown::html_vignette: toc: true @@ -20,6 +20,7 @@ knitr::opts_chunk$set( ) # set to original language (English) Sys.setlocale(locale = "C") +library(AMR) ``` ## SPSS / SAS / Stata @@ -34,7 +35,7 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major The [official R network (CRAN)](https://cran.r-project.org/web/packages/) features almost 14,000 packages at the time of writing, our `AMR` package being one of them. All these packages were peer-reviewed before publication. Aside from this official channel, there are also developers who choose not to submit to CRAN, but rather keep it on their own public repository, like GitLab or GitHub. So there may even be a lot more than 14,000 packages out there. - Bottomline is, you can really extend it yourself or ask somebody to do this for you. Take for example our `AMR` package. SPSS, SAS and Stata will never know what a valid MIC value is (so data might not be clean) or what the Gram stain of *E. coli* is. Or the fact that all species of *Klebiella* are resistant to amoxicillin. + Bottom line is, you can really extend it yourself or ask somebody to do this for you. Take for example our `AMR` package. Among other things, it adds reliable reference data to R to help you with the data cleaning and analysis. SPSS, SAS and Stata will never know what a valid MIC value is or what the Gram stain of *E. coli* is. Or that all species of *Klebiella* are resistant to amoxicillin and that Floxapen^®^ is a trade name of flucloxacillin. These facts and properties are often needed to clean existing data, which would be very inconvenient in a software package without reliable reference data. See below for a demonstration. * **R is extremely flexible.** @@ -65,20 +66,43 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major If you sometimes write syntaxes in SPSS to run a complete analysis or to 'automate' some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. +To demonstrate the first point: + +```{r, warning = FALSE, message = FALSE} +# not all values are valid MIC values: +as.mic(0.125) +as.mic("testvalue") + +# the Gram stain is avaiable for all bacteria: +mo_gramstain("E. coli") + +# Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST: +klebsiella_test <- data.frame(mo = "klebsiella", + amox = "S", + stringsAsFactors = FALSE) +klebsiella_test +eucast_rules(klebsiella_test, info = FALSE) + +# hundreds of trade names can be translated to an ATC or name: +atc_name("floxapen") +as.atc("floxapen") +atc_tradenames("floxapen") +``` + ## Import data from SPSS/SAS/Stata ### RStudio -To work with R, probably the best option is to use [RStudio](https://www.rstudio.com/products/rstudio/). It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menu to work with other data sources. You can also run [RStudio Server](https://www.rstudio.com/products/rstudio/), which is nothing less than the complete RStudio software available as a website (e.g. in your corporate network or at home). +To work with R, probably the best option is to use [RStudio](https://www.rstudio.com/products/rstudio/). It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menus to work with other data sources. You can also run [RStudio Server](https://www.rstudio.com/products/rstudio/), which is nothing less than the complete RStudio software available as a website (e.g. in your corporate network or at home). To import a data file, just click *Import Dataset* in the Environment tab: -![](../import1.png) +![](https://gitlab.com/msberends/AMR/raw/master/docs/import1.png) If additional packages are needed, RStudio will ask you if they should be installed on beforehand. In the the window that opens, you can define all options (parameters) that should be used for import and you're ready to go: -![](../import2.png) +![](https://gitlab.com/msberends/AMR/raw/master/docs/import2.png) If you want named variables to be imported as factors so it resembles SPSS more, use `as_factor()`. diff --git a/vignettes/benchmarks.Rmd b/vignettes/benchmarks.Rmd index bccd617d..5a69fe1f 100755 --- a/vignettes/benchmarks.Rmd +++ b/vignettes/benchmarks.Rmd @@ -23,7 +23,7 @@ knitr::opts_chunk$set( ) ``` -One of the most important features of this package is the complete microbial taxonomic database, supplied by the [Catalogue of Life](http://catalogueoflife.org). We created a function `as.mo()` that transforms any user input value to a valid microbial ID by using AI (Artificial Intelligence) combined with the taxonomic tree of Catalogue of Life. +One of the most important features of this package is the complete microbial taxonomic database, supplied by the [Catalogue of Life](http://catalogueoflife.org). We created a function `as.mo()` that transforms any user input value to a valid microbial ID by using intelligent rules combined with the taxonomic tree of Catalogue of Life. Using the `microbenchmark` package, we can review the calculation performance of this function. Its function `microbenchmark()` runs different input expressions independently of each other and measures their time-to-result. @@ -38,7 +38,7 @@ library(AMR) In the next test, we try to 'coerce' different input values for *Staphylococcus aureus*. The actual result is the same every time: it returns its MO code `B_STPHY_AUR` (*B* stands for *Bacteria*, the taxonomic kingdom). -But the calculation time differs a lot. Here, the AI effect can be reviewed best: +But the calculation time differs a lot: ```{r} S.aureus <- microbenchmark(as.mo("sau"),