mirror of
https://github.com/msberends/AMR.git
synced 2025-07-12 02:22:08 +02:00
algorithm update
This commit is contained in:
@ -23,10 +23,14 @@ 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 AI (Artificial Intelligence) 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.
|
||||
|
||||
```{r, message = FALSE, echo = FALSE}
|
||||
library(dplyr)
|
||||
```
|
||||
|
||||
```{r, message = FALSE}
|
||||
library(microbenchmark)
|
||||
library(AMR)
|
||||
@ -46,10 +50,10 @@ S.aureus <- microbenchmark(as.mo("sau"),
|
||||
as.mo("Staphylococcus aureus"),
|
||||
as.mo("B_STPHY_AUR"),
|
||||
times = 10)
|
||||
print(S.aureus, unit = "ms", signif = 3)
|
||||
print(S.aureus, unit = "ms", signif = 2)
|
||||
```
|
||||
|
||||
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 more an input value resembles a full name, the faster the result will be found. In case of `as.mo("B_STPHY_AUR")`, the input is already a valid MO code, so it only almost takes no time at all (`r as.integer(min(S.aureus$time, na.rm = TRUE) / 1000)` millionths of seconds).
|
||||
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 more an input value resembles a full name, the faster the result will be found. In case of `as.mo("B_STPHY_AUR")`, the input is already a valid MO code, so it only almost takes no time at all (`r as.integer(S.aureus %>% filter(expr == 'as.mo("B_STPHY_AUR")') %>% pull(time) %>% median(na.rm = TRUE) / 1000)` millionths of a second).
|
||||
|
||||
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:
|
||||
|
||||
@ -62,7 +66,7 @@ M.leonicaptivi <- microbenchmark(as.mo("myle"),
|
||||
as.mo("Mycoplasma leonicaptivi"),
|
||||
as.mo("B_MYCPL_LEO"),
|
||||
times = 10)
|
||||
print(M.leonicaptivi, unit = "ms", signif = 4)
|
||||
print(M.leonicaptivi, unit = "ms", signif = 2)
|
||||
```
|
||||
|
||||
That takes `r round(mean(M.leonicaptivi$time, na.rm = TRUE) / mean(S.aureus$time, na.rm = TRUE), 1)` 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:
|
||||
|
Reference in New Issue
Block a user