diff --git a/R/catalogue_of_life.R b/R/catalogue_of_life.R index 25c41ba5..30e9f626 100755 --- a/R/catalogue_of_life.R +++ b/R/catalogue_of_life.R @@ -30,7 +30,7 @@ #' \itemize{ #' \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} #' \item{All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera \emph{Aspergillus}, \emph{Candida}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} -#' \item{All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed} +#' \item{All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed} #' \item{The complete taxonomic tree of all included (sub)species: from kingdom to subspecies} #' \item{The responsible author(s) and year of scientific publication} #' } diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index f50800a3..c8d17ea9 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -218,26 +218,26 @@ times = 10) print(S.aureus, unit = "ms") #> Unit: milliseconds -#> expr min lq mean median -#> as.mo("sau") 42.58139 42.645368 43.3006677 42.970095 -#> as.mo("stau") 76.60094 77.168264 83.7686909 77.316642 -#> as.mo("staaur") 42.86607 42.947083 43.5035571 43.497293 -#> as.mo("S. aureus") 18.39354 18.432582 22.4304233 18.495928 -#> as.mo("S. aureus") 18.46513 18.559903 18.6640991 18.579110 -#> as.mo("STAAUR") 42.71975 42.788612 44.3280682 43.069864 -#> as.mo("Staphylococcus aureus") 11.56285 11.591419 15.9457298 11.667161 -#> as.mo("B_STPHY_AUR") 0.40487 0.450128 0.5036822 0.481417 +#> expr min lq mean median +#> as.mo("sau") 42.680497 42.766053 43.5046242 43.2246305 +#> as.mo("stau") 76.627901 76.760320 82.2084011 77.2020310 +#> as.mo("staaur") 42.751945 42.828281 46.8816599 43.0017665 +#> as.mo("S. aureus") 18.328588 18.370632 22.3298018 18.4252830 +#> as.mo("S. aureus") 18.258048 18.385997 18.7710600 18.5449555 +#> as.mo("STAAUR") 42.734554 42.854751 43.6593017 43.6353320 +#> as.mo("Staphylococcus aureus") 11.466961 11.572841 16.5287637 11.6172940 +#> as.mo("B_STPHY_AUR") 0.284603 0.302692 0.4095492 0.4190475 #> uq max neval -#> 43.448543 45.058105 10 -#> 78.335591 127.180349 10 -#> 43.817095 44.999509 10 -#> 19.007097 56.501460 10 -#> 18.651814 19.373275 10 -#> 43.741388 54.703256 10 -#> 12.323077 50.121808 10 -#> 0.519271 0.766578 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 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 (404 millionths of seconds).
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 far less faster. See this example for the ID of Mycoplasma leonicaptivi (B_MYCPL_LEO
), a bug probably never found before in humans:
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 (284 millionths of seconds).
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"),
as.mo("mycleo"),
as.mo("M. leonicaptivi"),
@@ -248,22 +248,22 @@
times = 10)
print(M.leonicaptivi, unit = "ms")
#> Unit: milliseconds
-#> expr min lq mean
-#> as.mo("myle") 112.28656 112.372601 112.751678
-#> as.mo("mycleo") 382.46812 382.757612 383.432440
-#> as.mo("M. leonicaptivi") 202.68674 203.654949 210.461303
-#> as.mo("M. leonicaptivi") 202.89759 203.440956 203.816387
-#> as.mo("MYCLEO") 382.27864 383.090895 401.904482
-#> as.mo("Mycoplasma leonicaptivi") 102.99676 103.191196 109.196394
-#> as.mo("B_MYCPL_LEO") 0.32155 0.564807 4.320068
-#> median uq max neval
-#> 112.540884 112.76874 113.76321 10
-#> 383.232219 384.05897 385.28587 10
-#> 204.255445 205.80976 242.53035 10
-#> 203.613673 203.82802 206.15038 10
-#> 386.478757 421.87837 437.26978 10
-#> 103.596136 104.65940 142.25748 10
-#> 0.593652 0.62522 37.96384 10
That takes 6 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:
par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
@@ -273,9 +273,8 @@
boxplot(S.aureus, horizontal = TRUE, las = 1, unit = "ms", log = FALSE, xlab = "", ylim = c(0, max_y_axis),
main = expression(paste("Benchmark of ", italic("Staphylococcus aureus"))))
-boxplot(M.leonicaptivi, horizontal = TRUE, las = 1, unit = "ms", log = FALSE, xlab = "", ylim = c(0, max_y_axis),
- main = expression(paste("Benchmark of ", italic("Mycoplasma leonicaptivi"))))
boxplot(M.leonicaptivi, horizontal = TRUE, las = 1, unit = "ms", log = FALSE, xlab = "", ylim = c(0, max_y_axis),
+ main = expression(paste("Benchmark of ", italic("Mycoplasma leonicaptivi"))))
To relieve this pitfall and further improve performance, two important calculations take almost no time at all: repetitive results and already precalculated results.
Repetitive results mean that unique values are present more than once. Unique values will only be calculated once by as.mo()
. We will use mo_fullname()
for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses as.mo()
internally.
library(dplyr)
-#>
-#> Attaching package: 'dplyr'
-#> The following objects are masked from 'package:stats':
-#>
-#> filter, lag
-#> The following objects are masked from 'package:base':
-#>
-#> intersect, setdiff, setequal, union
-# take 500,000 random MO codes from the septic_patients data set
-x = septic_patients %>%
- sample_n(500000, replace = TRUE) %>%
- pull(mo)
-
-# got the right length?
-length(x)
-#> [1] 500000
-
-# and how many unique values do we have?
-n_distinct(x)
-#> [1] 95
-
-# now let's see:
-run_it <- microbenchmark(X = mo_fullname(x),
- times = 10)
-print(run_it, unit = "ms")
-#> Unit: milliseconds
-#> expr min lq mean median uq max neval
-#> X 435.7086 442.1682 465.5949 468.8453 477.1915 505.961 10
So transforming 500,000 values (!) of 95 unique values only takes 0.47 seconds (468 ms). You only lose time on your unique input values.
+# take 500,000 random MO codes from the septic_patients data set +x = septic_patients %>% + sample_n(500000, replace = TRUE) %>% + pull(mo) + +# got the right length? +length(x) +#> [1] 500000 + +# and how many unique values do we have? +n_distinct(x) +#> [1] 95 + +# now let's see: +run_it <- microbenchmark(X = mo_fullname(x), + times = 10) +print(run_it, unit = "ms") +#> Unit: milliseconds +#> expr min lq mean median uq max neval +#> X 413.2556 431.8327 448.3355 445.8654 465.2447 480.5499 10So transforming 500,000 values (!) of 95 unique values only takes 0.45 seconds (445 ms). You only lose time on your unique input values.
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:
microbenchmark(A = mo_species("aureus"),
B = mo_genus("Staphylococcus"),
@@ -340,20 +331,20 @@
unit = "ms")
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> A 0.250242 0.292496 0.3891774 0.4266960 0.456902 0.520388 10
-#> B 0.259461 0.311702 0.3428727 0.3412800 0.374141 0.443912 10
-#> C 0.290960 0.313169 0.4334429 0.4097595 0.520389 0.725373 10
-#> D 0.271823 0.282789 0.3187217 0.3192800 0.352909 0.375398 10
-#> E 0.245353 0.270985 0.3081197 0.2960235 0.330839 0.429036 10
-#> F 0.246122 0.266585 0.2991101 0.3089435 0.332794 0.351582 10
-#> G 0.271893 0.272452 0.3085039 0.2850580 0.368204 0.385525 10
-#> H 0.252686 0.259251 0.3161791 0.2985025 0.334820 0.422680 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.
When the system language is non-English and supported by this AMR
package, some functions take a little while longer:
When the system language is non-English and supported by this AMR
package, some functions will have a translated result. This almost does’t take extra time:
mo_fullname("CoNS", language = "en") # or just mo_fullname("CoNS") on an English system
#> [1] "Coagulase Negative Staphylococcus (CoNS)"
@@ -371,13 +362,13 @@
unit = "ms")
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> en 10.67105 11.03136 11.06332 11.07271 11.15310 11.45006 10
-#> de 19.13393 19.50080 26.13799 19.61419 20.23400 52.66501 10
-#> nl 19.05410 19.53789 22.94707 19.59205 20.12616 52.47399 10
-#> es 19.31635 19.55221 26.22342 19.58633 20.01875 52.97636 10
-#> it 19.21725 19.47105 19.63980 19.58053 19.68162 20.58914 10
-#> fr 19.07854 19.45450 19.67303 19.56153 19.64517 20.45651 10
-#> pt 19.00668 19.28388 19.53493 19.57857 19.66423 20.55317 10
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 331cac82..5d6d8993 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-4-2.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-2.png index c1225095..d979007f 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-2.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-2.png differ diff --git a/docs/index.html b/docs/index.html index 2b9faf0d..aa2572ee 100644 --- a/docs/index.html +++ b/docs/index.html @@ -197,11 +197,12 @@(
AMR
is a free and open-source R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. It supports any data format, including WHONET/EARS-Net data.
After installing this package, R knows almost all ~20,000 microorganisms and ~500 antibiotics by name and code, and knows all about valid RSI and MIC values.
+After installing this package, R knows almost all ~60,000 microorganisms and ~500 antibiotics by name and code, and knows all about valid RSI and MIC values.
Used to SPSS? Read our tutorial on how to import data from SPSS, SAS or Stata and learn in which ways R outclasses any of these statistical packages.
We created this package for both academic research and routine analysis at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is actively maintained and is free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation. Read the full license here.
This package can be used for:
The latest and unpublished development version can be installed with (precaution: may be unstable):
+The latest and unpublished development version can be installed with (precaution: may be unstable):
We support WHONET and EARS-Net data. Exported files from WHONET can be imported into R and can be analysed easily using this package. For education purposes, we created an example data set WHONET
with the exact same structure as a WHONET export file. Furthermore, this package also contains a data set antibiotics
with all EARS-Net antibiotic abbreviations, and knows almost all WHONET abbreviations for microorganisms. When using WHONET data as input for analysis, all input parameters will be set automatically.
Read our tutorial about how to work with WHONET data here.
+Microbial (taxonomic) reference data + +This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (www.catalogueoflife.org).
+Included are:
+This data is updated annually - check the included version with catalogue_of_life_version()
.
About
+The Catalogue of Life (www.catalogueoflife.org) is the most comprehensive and authoritative global index of species currently available. It holds essential information on the names, relationships and distributions of over 1.6 million species. The Catalogue of Life is used to support the major biodiversity and conservation information services such as the Global Biodiversity Information Facility (GBIF), Encyclopedia of Life (EoL) and the International Union for Conservation of Nature Red List. It is recognised by the Convention on Biological Diversity as a significant component of the Global Taxonomy Initiative and a contribution to Target 1 of the Global Strategy for Plant Conservation.
+Read more about the data from the Catalogue of Life in our manual.
This package contains all ~500 antimicrobial drugs and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the Pharmaceuticals Community Register of the European Commission.
Read more about the data from WHOCC in our manual.
This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
-The Catalogue of Life (www.catalogueoflife.org) is the most comprehensive and authoritative global index of species currently available. It holds essential information on the names, relationships and distributions of over 1.6 million species. The Catalogue of Life is used to support the major biodiversity and conservation information services such as the Global Biodiversity Information Facility (GBIF), Encyclopedia of Life (EoL) and the International Union for Conservation of Nature Red List. It is recognised by the Convention on Biological Diversity as a significant component of the Global Taxonomy Initiative and a contribution to Target 1 of the Global Strategy for Plant Conservation.
-Read more about the data from the Catalogue of Life in our manual.
+WHONET / EARS-Net + +We support WHONET and EARS-Net data. Exported files from WHONET can be imported into R and can be analysed easily using this package. For education purposes, we created an example data set WHONET
with the exact same structure as a WHONET export file. Furthermore, this package also contains a data set antibiotics
with all EARS-Net antibiotic abbreviations, and knows almost all WHONET abbreviations for microorganisms. When using WHONET data as input for analysis, all input parameters will be set automatically.
Read our tutorial about how to work with WHONET data here.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera Aspergillus, Candida, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of (sub)species that have been taxonomically renamed
All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed
The complete taxonomic tree of all included (sub)species: from kingdom to subspecies
The responsible author(s) and year of scientific publication