diff --git a/DESCRIPTION b/DESCRIPTION index 3b9c49e8..5c62f9b3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.5.0.9019 -Date: 2019-02-27 +Version: 0.5.0.9020 +Date: 2019-02-28 Title: Antimicrobial Resistance Analysis Authors@R: c( person( @@ -52,7 +52,7 @@ Imports: hms, knitr (>= 1.0.0), microbenchmark, - rlang (>= 0.2.0), + rlang (>= 0.3.1), tidyr (>= 0.7.0) Suggests: covr (>= 3.0.1), diff --git a/NAMESPACE b/NAMESPACE index 15abcb3d..44c0422e 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,6 +26,8 @@ S3method(print,atc) S3method(print,frequency_tbl) S3method(print,mic) S3method(print,mo) +S3method(print,mo_renamed) +S3method(print,mo_uncertainties) S3method(print,rsi) S3method(pull,atc) S3method(pull,mo) @@ -179,6 +181,8 @@ exportMethods(print.atc) exportMethods(print.frequency_tbl) exportMethods(print.mic) exportMethods(print.mo) +exportMethods(print.mo_renamed) +exportMethods(print.mo_uncertainties) exportMethods(print.rsi) exportMethods(pull.atc) exportMethods(pull.mo) @@ -203,6 +207,7 @@ importFrom(crayon,magenta) importFrom(crayon,red) importFrom(crayon,silver) importFrom(crayon,strip_style) +importFrom(crayon,yellow) importFrom(data.table,as.data.table) importFrom(data.table,data.table) importFrom(data.table,setkey) diff --git a/NEWS.md b/NEWS.md index 971c292a..83092115 100755 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ We've got a new website: [https://msberends.gitlab.io/AMR](https://msberends.git * Catalogue of Life as a new taxonomic source for data about microorganisms, which also contains all ITIS data we used previously. The `microorganisms` data set now contains: * 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 (covering at least like all species of *Aspergillus*, *Candida*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*) + * All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like *Strongyloides* and *Taenia*) * All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed * The responsible author(s) and year of scientific publication diff --git a/R/catalogue_of_life.R b/R/catalogue_of_life.R index 4bca4357..0b9c98fd 100755 --- a/R/catalogue_of_life.R +++ b/R/catalogue_of_life.R @@ -23,13 +23,16 @@ #' #' This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life. #' @section Catalogue of Life: -#' \if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -#' This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +#' \if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +#' This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. #' +#' \link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. +#' @section Included taxa: #' Included are: #' \itemize{ #' \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} -#' \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} +#' \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} +#' \item{All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like \emph{Strongyloides} and \emph{Taenia})} #' \item{All ~15,000 previously accepted names of included (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/R/mo.R b/R/mo.R index a381f408..a1b38299 100755 --- a/R/mo.R +++ b/R/mo.R @@ -47,12 +47,13 @@ #' | | | ----> subspecies, a 3-4 letter acronym #' | | ----> species, a 3-4 letter acronym #' | ----> genus, a 5-7 letter acronym, mostly without vowels -#' ----> taxonomic kingdom: A (Archaea), B (Bacteria), C (Chromista), -#' F (Fungi), P (Protozoa) or V (Viruses) +#' ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), C (Chromista), +#' F (Fungi), P (Protozoa), PL (Plantae) or V (Viruses) #' } #' #' 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: #' \itemize{ #' \item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa} @@ -67,9 +68,9 @@ #' \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae} for the same reason} #' \item{Something like \code{"stau"} or \code{"S aur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}} #' } -#' This means that looking up human pathogenic microorganisms takes less time than looking up human \strong{non}-pathogenic microorganisms. +#' This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms. #' -#' \strong{UNCERTAIN RESULTS} \cr +#' \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: #' \itemize{ #' \item{It tries to look for previously accepted (but now invalid) taxonomic names} @@ -88,11 +89,11 @@ #' #' Use \code{mo_failures()} to get a vector with all values that could not be coerced to a valid value. #' -#' Use \code{mo_uncertainties()} to get info about all values that were coerced to a valid value, but with uncertainty. +#' Use \code{mo_uncertainties()} to get a data.frame with all values that were coerced to a valid value, but with uncertainty. #' #' 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: +#' \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: #' \itemize{ #' \item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.} @@ -102,7 +103,7 @@ #' #' 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. +#' Group 2 probably contains all other 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: @@ -618,10 +619,6 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, if (length(found) > 0) { return(found[1L]) } - found <- data_to_check[fullname %like% f.x_withspaces_end_only, ..property][[1]] - if (length(found) > 0 & nchar(b.x_trimmed) >= 6) { - return(found[1L]) - } # try splitting of characters in the middle and then find ID ---- # only when text length is 6 or lower @@ -709,7 +706,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, # check for uncertain results ---- if (allow_uncertain == TRUE) { - uncertain_fn <- function(a.x_backup, b.x_trimmed, c.x_withspaces_start_end, d.x_withspaces_start_only) { + uncertain_fn <- function(a.x_backup, b.x_trimmed, c.x_withspaces_start_end, d.x_withspaces_start_only, f.x_withspaces_end_only) { # (1) look for genus only, part of name ---- if (nchar(b.x_trimmed) > 4 & !b.x_trimmed %like% " ") { @@ -719,7 +716,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, if (length(found) > 0) { x[i] <- found[1L] uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 2, + input = a.x_backup, fullname = microorganismsDT[mo == found[1L], fullname][[1]], mo = found[1L])) return(x) @@ -745,27 +743,42 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, ref_new = microorganismsDT[col_id == found[1, col_id_new], ref], mo = microorganismsDT[col_id == found[1, col_id_new], mo]) uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 1, + input = a.x_backup, fullname = found[1, fullname], mo = paste("CoL", found[1, col_id]))) return(x) } - # (3) strip values between brackets ---- - a.x_backup_stripped <- gsub("( [(].*[)])", "", a.x_backup) - a.x_backup_stripped <- trimws(gsub(" ", " ", a.x_backup_stripped, fixed = TRUE)) - found <- suppressMessages(suppressWarnings(exec_as.mo(a.x_backup_stripped, clear_options = FALSE, allow_uncertain = FALSE))) - if (!is.na(found) & nchar(b.x_trimmed) >= 6) { + # (3) not yet implemented taxonomic changes in Catalogue of Life ---- + found <- suppressMessages(suppressWarnings(exec_as.mo(TEMPORARY_TAXONOMY(b.x_trimmed), clear_options = FALSE, allow_uncertain = FALSE))) + if (!is.na(found)) { found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 1, + input = a.x_backup, fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], mo = found_result[1L])) return(found[1L]) } - # (4) try to strip off one element from end and check the remains ---- + # (4) strip values between brackets ---- + a.x_backup_stripped <- gsub("( *[(].*[)] *)", " ", a.x_backup) + a.x_backup_stripped <- trimws(gsub(" +", " ", a.x_backup_stripped)) + found <- suppressMessages(suppressWarnings(exec_as.mo(a.x_backup_stripped, clear_options = FALSE, allow_uncertain = FALSE))) + if (!is.na(found) & nchar(b.x_trimmed) >= 6) { + found_result <- found + found <- microorganismsDT[mo == found, ..property][[1]] + uncertainties <<- rbind(uncertainties, + data.frame(uncertainty = 2, + input = a.x_backup, + fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], + mo = found_result[1L])) + return(found[1L]) + } + + # (5) try to strip off one element from end and check the remains ---- x_strip <- a.x_backup %>% strsplit(" ") %>% unlist() if (length(x_strip) > 1 & nchar(b.x_trimmed) >= 6) { for (i in 1:(length(x_strip) - 1)) { @@ -775,7 +788,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 2, + input = a.x_backup, fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], mo = found_result[1L])) return(found[1L]) @@ -783,7 +797,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } } - # (5) try to strip off one element from start and check the remains ---- + # (6) try to strip off one element from start and check the remains ---- x_strip <- a.x_backup %>% strsplit(" ") %>% unlist() if (length(x_strip) > 1 & nchar(b.x_trimmed) >= 6) { for (i in 2:(length(x_strip))) { @@ -793,7 +807,8 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, found_result <- found found <- microorganismsDT[mo == found, ..property][[1]] uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 3, + input = a.x_backup, fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], mo = found_result[1L])) return(found[1L]) @@ -801,13 +816,14 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, } } - # (6) not yet implemented taxonomic changes in Catalogue of Life ---- - found <- suppressMessages(suppressWarnings(exec_as.mo(TEMPORARY_TAXONOMY(b.x_trimmed), clear_options = FALSE, allow_uncertain = FALSE))) - if (!is.na(found)) { - found_result <- found - found <- microorganismsDT[mo == found, ..property][[1]] + # (7) part of a name (very unlikely match) ---- + found <- microorganismsDT[fullname %like% f.x_withspaces_end_only] + if (nrow(found) > 0) { + found_result <- found[["mo"]] + found <- microorganismsDT[mo == found_result[1L], ..property][[1]] uncertainties <<- rbind(uncertainties, - data.frame(input = a.x_backup, + data.frame(uncertainty = 3, + input = a.x_backup, fullname = microorganismsDT[mo == found_result[1L], fullname][[1]], mo = found_result[1L])) return(found[1L]) @@ -817,7 +833,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, return(NA_character_) } - x[i] <- uncertain_fn(x_backup[i], x_trimmed[i], x_withspaces_start_end[i], x_withspaces_start_only[i]) + x[i] <- uncertain_fn(x_backup[i], x_trimmed[i], x_withspaces_start_end[i], x_withspaces_start_only[i], x_withspaces_end_only[i]) if (!is.na(x[i])) { next } @@ -1041,20 +1057,53 @@ mo_failures <- function() { #' @importFrom crayon italic #' @export mo_uncertainties <- function() { - df <- as.data.frame(getOption("mo_uncertainties")) + structure(.Data = as.data.frame(getOption("mo_uncertainties"), stringsAsFactors = FALSE), + class = c("mo_uncertainties", "data.frame")) +} + +#' @exportMethod print.mo_uncertainties +#' @importFrom crayon green yellow red bgGreen bgYellow bgRed +#' @export +#' @noRd +print.mo_uncertainties <- function(x, ...) { + cat(paste0(bold(nrow(x), "unique result(s) guessed with uncertainty:"), + "\n(1 = ", green("renamed"), + ", 2 = ", yellow("uncertain"), + ", 3 = ", red("very uncertain"), ")\n")) + msg <- "" - for (i in 1:nrow(df)) { + for (i in 1:nrow(x)) { + if (x[i, "uncertainty"] == 1) { + colour1 <- green + colour2 <- bgGreen + } else if (x[i, "uncertainty"] == 2) { + colour1 <- yellow + colour2 <- bgYellow + } else { + colour1 <- red + colour2 <- bgRed + } msg <- paste(msg, - paste0('"', df[i, "input"], '" -> ', italic(df[i, "fullname"]), " (", df[i, "mo"], ")"), + paste0("[", colour2(paste0(" ", x[i, "uncertainty"], " ")), '] - "', x[i, "input"], '" -> ', + colour1(paste0(italic(x[i, "fullname"]), " (", x[i, "mo"], ")"))), sep = "\n") } - cat(paste0(bold("Results guessed with uncertainty:"), msg)) + cat(msg) } #' @rdname as.mo #' @export mo_renamed <- function() { - strip_style(gsub("was renamed", "->", getOption("mo_renamed"), fixed = TRUE)) + structure(.Data = strip_style(gsub("was renamed", "->", getOption("mo_renamed"), fixed = TRUE)), + class = c("mo_renamed", "character")) +} + +#' @exportMethod print.mo_renamed +#' @importFrom crayon blue +#' @export +#' @noRd +print.mo_renamed <- function(x, ...) { + cat(blue(paste(getOption("mo_renamed"), collapse = "\n"))) } nr2char <- function(x) { diff --git a/R/mo_property.R b/R/mo_property.R index bfb8c85d..c6a2df7d 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -260,13 +260,17 @@ mo_type <- function(x, language = get_locale(), ...) { #' @export mo_gramstain <- function(x, language = get_locale(), ...) { x.bak <- x - x <- mo_phylum(x, ...) - x[x %in% c("Actinobacteria", - "Chloroflexi", - "Firmicutes", - "Tenericutes")] <- "Gram positive" + x.mo <- as.mo(x, ...) + x.phylum <- mo_phylum(x.mo) + x[x.phylum %in% c("Actinobacteria", + "Chloroflexi", + "Firmicutes", + "Tenericutes")] <- "Gram positive" x[x != "Gram positive"] <- "Gram negative" - x[mo_kingdom(x.bak) != "Bacteria"] <- NA_character_ + x[mo_kingdom(x.mo) != "Bacteria"] <- NA_character_ + x[x.mo == "B_GRAMP"] <- "Gram positive" + x[x.mo == "B_GRAMN"] <- "Gram negative" + mo_translate(x, language = language) } diff --git a/R/mo_source.R b/R/mo_source.R index f4cc7fe1..43a4fd29 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -21,7 +21,9 @@ #' Use predefined reference data set #' -#' These functions can be used to predefine your own reference to be used in \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}. +#' @description These functions can be used to predefine your own reference to be used in \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}. +#' +#' This is \strong{the fastest way} to have your organisation (or analysis) specific codes picked up and translated by this package. #' @param path location of your reference file, see Details #' @rdname mo_source #' @name mo_source @@ -33,45 +35,71 @@ #' \code{get_mo_source} will return the data set by reading \code{"~/.mo_source.rds"} with \code{\link{readRDS}}. If the original file has changed (the file defined with \code{path}), it will call \code{set_mo_source} to update the data file automatically. #' #' Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by \code{get_mo_source} in only a couple of microseconds (a millionth of a second). +#' @section How it works: +#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package: +#' \preformatted{ +#' | A | B | +#' --|--------------------|-------------| +#' 1 | Organisation XYZ | mo | +#' 2 | lab_mo_ecoli | B_ESCHR_COL | +#' 3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +#' 4 | | | +#' } +#' +#' We save it as \code{'home/me/ourcodes.xlsx'}. Now we have to set it as a source: +#' \preformatted{ +#' set_mo_source("home/me/ourcodes.xlsx") +#' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +#' } +#' +#' It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression. +#' +#' And now we can use it in our functions: +#' \preformatted{ +#' as.mo("lab_mo_ecoli") +#' # B_ESCHR_COL +#' +#' mo_genus("lab_mo_kpneumoniae") +#' # "Klebsiella" +#' } +#' +#' If we edit the Excel file to, let's say, this: +#' \preformatted{ +#' | A | B | +#' --|--------------------|-------------| +#' 1 | Organisation XYZ | mo | +#' 2 | lab_mo_ecoli | B_ESCHR_COL | +#' 3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +#' 4 | lab_Staph_aureus | B_STPHY_AUR | +#' 5 | | | +#' } +#' +#' ...any new usage of an MO function in this package will update your data: +#' \preformatted{ +#' as.mo("lab_mo_ecoli") +#' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +#' # B_ESCHR_COL +#' +#' mo_genus("lab_Staph_aureus") +#' # "Staphylococcus" +#' } +#' +#' To remove the reference completely, just use any of these: +#' \preformatted{ +#' set_mo_source("") +#' set_mo_source(NULL) +#' # Removed mo_source file '~/.mo_source.rds'. +#' } #' @importFrom dplyr select everything #' @export #' @inheritSection AMR Read more on our website! -#' @examples -#' \dontrun{ -#' -#' # imagine this Excel file (mo codes looked up in `microorganisms` data set): -#' # A B -#' # 1 our code mo -#' # 2 lab_mo_ecoli B_ESCHR_COL -#' # 3 lab_mo_kpneumoniae B_KLBSL_PNE -#' -#' # 1. We save it as 'home/me/ourcodes.xlsx' -#' -#' # 2. We use it for input: -#' set_mo_source("home/me/ourcodes.xlsx") -#' #> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#' -#' # 3. And use it in our functions: -#' as.mo("lab_mo_ecoli") -#' #> B_ESCHR_COL -#' -#' mo_genus("lab_mo_kpneumoniae") -#' #> "Klebsiella" -#' -#' # 4. It will look for changes itself: -#' # (add new row to the Excel file and save it) -#' -#' mo_genus("lab_mo_kpneumoniae") -#' #> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#' #> "Klebsiella" -#' } set_mo_source <- function(path) { if (!is.character(path) | length(path) > 1) { stop("`path` must be a character of length 1.") } - if (path == "") { + if (path %in% c(NULL, "")) { options(mo_source = NULL) options(mo_source_timestamp = NULL) if (file.exists("~/.mo_source.rds")) { diff --git a/data/microorganisms.old.rda b/data/microorganisms.old.rda index b35d6827..7ea93cfe 100644 Binary files a/data/microorganisms.old.rda and b/data/microorganisms.old.rda differ diff --git a/data/microorganisms.rda b/data/microorganisms.rda index ad0de3ba..0e3d9f6d 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 05482055..17b48a67 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@
diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 508954b6..31d7506c 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -40,7 +40,7 @@ @@ -192,7 +192,7 @@AMR.Rmd
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 27 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 28 February 2019.
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 (1264 changes)
+#> Table 1: Intrinsic resistance in Enterobacteriaceae (1275 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 (2835 changes)
+#> Table 4: Intrinsic resistance in Gram-positive bacteria (2727 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,417 out of 20,000 rows
+#> => EUCAST rules affected 7,427 out of 20,000 rows
#> -> added 0 test results
-#> -> changed 4,099 test results (0 to S; 0 to I; 4,099 to R)
So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.3% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
For future use, the above two syntaxes can be shortened with the filter_first_isolate()
function:
isolate | @@ -654,11 +654,11 @@|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-07 | -E5 | +2010-04-26 | +H9 | B_ESCHR_COL | R | -R | +S | S | S | TRUE | @@ -666,23 +666,23 @@||||
2 | -2010-01-14 | -E5 | +2010-05-27 | +H9 | B_ESCHR_COL | S | S | R | -R | +S | FALSE | TRUE | |||
3 | -2010-02-07 | -E5 | +2010-07-20 | +H9 | B_ESCHR_COL | -S | -S | +R | +I | S | S | FALSE | @@ -690,70 +690,70 @@|||
4 | -2010-03-28 | -E5 | +2010-11-25 | +H9 | B_ESCHR_COL | -I | +S | S | S | S | FALSE | -FALSE | +TRUE | ||
5 | -2010-05-25 | -E5 | +2011-01-19 | +H9 | B_ESCHR_COL | S | S | -R | +S | S | FALSE | -TRUE | +FALSE | ||
6 | -2010-07-23 | -E5 | +2011-01-24 | +H9 | B_ESCHR_COL | -R | S | -R | -R | +S | +S | +S | +FALSE | FALSE | -TRUE |
7 | -2010-08-18 | -E5 | +2011-03-09 | +H9 | B_ESCHR_COL | -I | +R | S | R | -R | -FALSE | +S | FALSE | +TRUE | |
8 | -2010-11-19 | -E5 | +2011-06-07 | +H9 | B_ESCHR_COL | -I | S | S | S | -FALSE | +S | +TRUE | TRUE | ||
9 | -2010-12-05 | -E5 | +2011-07-30 | +H9 | B_ESCHR_COL | -R | +S | S | S | S | @@ -762,23 +762,23 @@|||||
10 | -2011-02-04 | -E5 | +2011-08-01 | +H9 | B_ESCHR_COL | S | S | -R | S | -TRUE | -TRUE | +S | +FALSE | +FALSE |
Instead of 2, now 7 isolates are flagged. In total, 79.3% of all isolates are marked ‘first weighted’ - 51.1% 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 6 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.8% 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:
So we end up with 15,867 isolates for analysis.
+So we end up with 15,814 isolates for analysis.
We can remove unneeded columns:
@@ -803,63 +803,63 @@Time for the analysis!
@@ -915,9 +915,9 @@Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from a data.frame
(15,867 x 13)
Frequency table of genus
and species
from a data.frame
(15,814 x 13)
Columns: 2
-Length: 15,867 (of which NA: 0 = 0.00%)
+Length: 15,814 (of which NA: 0 = 0.00%)
Unique: 4
Shortest: 16
Longest: 24
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:
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:
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.4797111
+0.4752371
Hospital B
-0.4868636
+0.4825898
Hospital C
-0.4661747
+0.4705631
Hospital D
-0.4581512
+0.4711928
@@ -1014,72 +1014,72 @@ Longest: 24
Hospital A
-0.4797111
-4707
+0.4752371
+4745
Hospital B
-0.4868636
-5519
+0.4825898
+5514
Hospital C
-0.4661747
-2439
+0.4705631
+2344
Hospital D
-0.4581512
-3202
+0.4711928
+3211
-These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:
+These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
data_1st %>%
group_by(genus) %>%
- summarise(amoxicillin = portion_S(amcl),
+ summarise(amoxiclav = portion_S(amcl),
gentamicin = portion_S(gent),
- "amox + gent" = portion_S(amcl, gent))
+ amoxiclav_genta = portion_S(amcl, gent))
genus | -amoxicillin | +amoxiclav | gentamicin | -amox + gent | +amoxiclav_genta | |
---|---|---|---|---|---|---|
Escherichia | -0.7345189 | -0.8976459 | -0.9721085 | +0.7346552 | +0.8993433 | +0.9744885 |
Klebsiella | -0.7433914 | -0.8949065 | -0.9767892 | +0.7406230 | +0.9020979 | +0.9726637 |
Staphylococcus | -0.7285215 | -0.9153347 | -0.9787712 | +0.7322122 | +0.9210867 | +0.9785252 |
Streptococcus | -0.7315705 | +0.7135883 | 0.0000000 | -0.7315705 | +0.7135883 |
To make a transition to the next part, let’s see how this difference could be plotted:
data_1st %>%
group_by(genus) %>%
- summarise("1. Amoxicillin" = portion_S(amcl),
+ summarise("1. Amoxi/clav" = portion_S(amcl),
"2. Gentamicin" = portion_S(gent),
- "3. Amox + gent" = portion_S(amcl, gent)) %>%
+ "3. Amoxi/clav + gent" = portion_S(amcl, gent)) %>%
tidyr::gather("Antibiotic", "S", -genus) %>%
ggplot(aes(x = genus,
y = S,
@@ -1100,9 +1100,9 @@ Longest: 24
x = "My X axis",
y = "My Y axis")
-ggplot(a_data_set,
- aes(year, value) +
- geom_bar()
The AMR
package contains functions to extend this ggplot2
package, for example geom_rsi()
. It automatically transforms data with count_df()
or portion_df()
and show results in stacked bars. Its simplest and shortest example:
EUCAST.Rmd
G_test.Rmd
R is extremely flexible.
-Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. It may be a bit flexible, but you can never create that very specific publication-ready plot without using other (paid) software.
+Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software.
R can be easily automated.
Over the last years, R Markdown has really made an interesting development. With R Markdown, you can very easily reproduce your reports, whether it’s to Word, Powerpoint, a website, a PDF document or just the raw data to Excel. I use this a lot to generate monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.
-For an even more professional environment, you could create Shiny apps: live manipulation of data using a custom made website. The webdesign knowledge needed (Javascript, CSS, HTML) is almost zero.
+For an even more professional environment, you could create Shiny apps: live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost zero.
R has a huge community.
-Many R users just ask questions on website like stackoverflow.com, the largest online community for programmers. At the time of writing, around 275,000 R questions have been asked on this platform (which covers questions and answer for any programming language). In my own experience, most questions are answered within a couple of minutes.
+Many R users just ask questions on websites like StackOverflow.com, the largest online community for programmers. At the time of writing, more than 275,000 R-related questions have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.
R understands any data type, including SPSS/SAS/Stata.
diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index c7332bcb..b249cb45 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -40,7 +40,7 @@ @@ -192,7 +192,7 @@WHONET.Rmd
atc_property.Rmd
benchmarks.Rmd
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") 289.0 291.0 314.0 312.0 336.0 343 10
-#> as.mo("THEISL") 290.0 293.0 319.0 331.0 337.0 344 10
-#> as.mo("T. islandicus") 73.5 73.8 90.6 75.1 114.0 118 10
-#> as.mo("T. islandicus") 73.7 73.9 78.5 74.6 74.7 115 10
-#> as.mo("Thermus islandicus") 66.5 67.3 80.3 69.5 107.0 108 10
That takes 6.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") 262.0 292.0 296.0 304.0 310 312 10 +#> as.mo("THEISL") 261.0 263.0 286.0 288.0 307 311 10 +#> as.mo("T. islandicus") 142.0 143.0 164.0 165.0 184 187 10 +#> as.mo("T. islandicus") 142.0 143.0 170.0 163.0 192 229 10 +#> as.mo("Thermus islandicus") 67.7 68.1 94.3 89.4 117 132 10 +That takes 7.5 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)
@@ -260,7 +260,7 @@
Repetitive 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.
+Repetitive results are unique values that 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)
# take all MO codes from the septic_patients data set
x <- septic_patients$mo %>%
@@ -286,9 +286,9 @@
times = 10)
print(run_it, unit = "ms", signif = 3)
#> Unit: milliseconds
-#> expr min lq mean median uq max neval
-#> mo_fullname(x) 732 768 800 794 799 949 10
-So transforming 500,000 values (!!) of 50 unique values only takes 0.79 seconds (793 ms). You only lose time on your unique input values.
+#> expr min lq mean median uq max neval
+#> mo_fullname(x) 732 739 818 819 837 1040 10
+So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (818 ms). You only lose time on your unique input values.
So going from mo_fullname("Staphylococcus aureus")
to "Staphylococcus aureus"
takes 0.0005 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:
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"),
C = mo_fullname("Staphylococcus aureus"),
@@ -317,14 +317,14 @@
print(run_it, unit = "ms", signif = 3)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> A 0.274 0.333 0.417 0.412 0.481 0.611 10
-#> B 0.337 0.353 0.403 0.411 0.438 0.461 10
-#> C 0.336 0.362 0.530 0.528 0.682 0.755 10
-#> D 0.263 0.316 0.340 0.331 0.360 0.474 10
-#> E 0.252 0.326 0.326 0.329 0.345 0.389 10
-#> F 0.250 0.300 0.319 0.327 0.351 0.351 10
-#> G 0.240 0.246 0.288 0.277 0.325 0.351 10
-#> H 0.242 0.257 0.304 0.294 0.332 0.395 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.
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 b76d5495..b9b48285 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 9bf1d365..c331ff99 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -40,7 +40,7 @@ @@ -192,7 +192,7 @@freq.Rmd
mo_property.Rmd
resistance_predict.Rmd
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales.
The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (like all species of Aspergillus, Candida, Cryptococcus, Histoplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like Strongyloides and Taenia)
All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed
The responsible author(s) and year of scientific publication
The responsible author(s) and year of scientific publication
diff --git a/docs/reference/AMR-deprecated.html b/docs/reference/AMR-deprecated.html index 66bada1f..a1b048db 100644 --- a/docs/reference/AMR-deprecated.html +++ b/docs/reference/AMR-deprecated.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index c634b443..617f2556 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html index 06c54047..59a38ca1 100644 --- a/docs/reference/WHOCC.html +++ b/docs/reference/WHOCC.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index 4b55fbad..a82e7592 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/abname.html b/docs/reference/abname.html index ec256fd7..7e597412 100644 --- a/docs/reference/abname.html +++ b/docs/reference/abname.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/age.html b/docs/reference/age.html index 969e0d09..a427f2d0 100644 --- a/docs/reference/age.html +++ b/docs/reference/age.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html index f66bac17..ac81bc1c 100644 --- a/docs/reference/age_groups.html +++ b/docs/reference/age_groups.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html index 46d80e72..f04b89ae 100644 --- a/docs/reference/antibiotics.html +++ b/docs/reference/antibiotics.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/as.atc.html b/docs/reference/as.atc.html index e2574214..4055d3ae 100644 --- a/docs/reference/as.atc.html +++ b/docs/reference/as.atc.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index b705333b..e55c6e5b 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index c0ed089d..6397dac0 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -80,7 +80,7 @@ @@ -296,11 +296,12 @@ | | | ----> subspecies, a 3-4 letter acronym | | ----> species, a 3-4 letter acronym | ----> genus, a 5-7 letter acronym, mostly without vowels - ----> taxonomic kingdom: A (Archaea), B (Bacteria), C (Chromista), - F (Fungi), P (Protozoa) or V (Viruses) + ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), C (Chromista), + F (Fungi), P (Protozoa), PL (Plantae) or V (Viruses)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:
Artificial Intelligence
+This function uses Artificial Intelligence (AI) 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
"E. coli"
will return the ID of Escherichia coli and not Entamoeba coli, although the latter would alphabetically come first
"H. influenzae"
will return the ID of Haemophilus influenzae and not Haematobacter influenzae for the same reason
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
+
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:
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
allow_uncertain = TRUE
(which is the default setting), i
"Fluoroquinolone-resistant Neisseria gonorrhoeae"
. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result Neisseria gonorrhoeae (B_NESSR_GON
) needs review.
Use mo_failures()
to get a vector with all values that could not be coerced to a valid value.
Use mo_uncertainties()
to get info about all values that were coerced to a valid value, but with uncertainty.
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.
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:
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:
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.
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.
+Group 2 probably contains all other microbial pathogens ever found in humans.
allow_uncertain = TRUE
(which is the default setting), i
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
mo_property
functions (like
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like Strongyloides and Taenia)
All ~15,000 previously accepted names of included (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
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
-This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). This data is updated annually - check the included version with catalogue_of_life_version()
.
Included are:
All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses
All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of Aspergillus, Candida, Cryptococcus, Histplasma, Pneumocystis, Saccharomyces and Trichophyton).
All ~15,000 previously accepted names of included (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
The Catalogue of Life (http://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.
-The syntax used to transform the original data to a cleansed R format, can be found here: https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R.
+
+This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (http://www.catalogueoflife.org). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available.
Click here for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with catalogue_of_life_version()
.
These functions can be used to predefine your own reference to be used in as.mo
and consequently all mo_*
functions like mo_genus
and mo_gramstain
.
This is the fastest way to have your organisation (or analysis) specific codes picked up and translated by this package.
get_mo_source
will return the data set by reading "~/.mo_source.rds"
with readRDS
. If the original file has changed (the file defined with path
), it will call set_mo_source
to update the data file automatically.
Reading an Excel file (.xlsx
) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by get_mo_source
in only a couple of microseconds (a millionth of a second).
Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
+ | A | B | +--|--------------------|-------------| +1 | Organisation XYZ | mo | +2 | lab_mo_ecoli | B_ESCHR_COL | +3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +4 | | | ++
We save it as 'home/me/ourcodes.xlsx'
. Now we have to set it as a source:
+set_mo_source("home/me/ourcodes.xlsx") +# Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. ++
It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression.
+And now we can use it in our functions:
+as.mo("lab_mo_ecoli") +# B_ESCHR_COL + mo_genus("lab_mo_kpneumoniae") +# "Klebsiella" ++
If we edit the Excel file to, let's say, this:
+ | A | B | +--|--------------------|-------------| +1 | Organisation XYZ | mo | +2 | lab_mo_ecoli | B_ESCHR_COL | +3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +4 | lab_Staph_aureus | B_STPHY_AUR | +5 | | | ++
...any new usage of an MO function in this package will update your data:
+as.mo("lab_mo_ecoli") +# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +# B_ESCHR_COL + mo_genus("lab_Staph_aureus") +# "Staphylococcus" ++
To remove the reference completely, just use any of these:
+set_mo_source("") +set_mo_source(NULL) +# Removed mo_source file '~/.mo_source.rds'. ++
On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
-# NOT RUN { -# imagine this Excel file (mo codes looked up in `microorganisms` data set): -# A B -# 1 our code mo -# 2 lab_mo_ecoli B_ESCHR_COL -# 3 lab_mo_kpneumoniae B_KLBSL_PNE - -# 1. We save it as 'home/me/ourcodes.xlsx' - -# 2. We use it for input: -set_mo_source("home/me/ourcodes.xlsx") -#> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. - -# 3. And use it in our functions: -as.mo("lab_mo_ecoli") -#> B_ESCHR_COL - -mo_genus("lab_mo_kpneumoniae") -#> "Klebsiella" - -# 4. It will look for changes itself: -# (add new row to the Excel file and save it) - -mo_genus("lab_mo_kpneumoniae") -#> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#> "Klebsiella" -# }diff --git a/docs/reference/p.symbol.html b/docs/reference/p.symbol.html index 10c07b8d..bd572dcb 100644 --- a/docs/reference/p.symbol.html +++ b/docs/reference/p.symbol.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/portion.html b/docs/reference/portion.html index 28e9bf9e..bdfe1066 100644 --- a/docs/reference/portion.html +++ b/docs/reference/portion.html @@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port diff --git a/docs/reference/read.4D.html b/docs/reference/read.4D.html index ae9df9d3..d77a0b46 100644 --- a/docs/reference/read.4D.html +++ b/docs/reference/read.4D.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index a0c4268d..2dc70e28 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/rsi.html b/docs/reference/rsi.html index 8b8725c0..ff3d0437 100644 --- a/docs/reference/rsi.html +++ b/docs/reference/rsi.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/septic_patients.html b/docs/reference/septic_patients.html index 4125bbb1..53e04a86 100644 --- a/docs/reference/septic_patients.html +++ b/docs/reference/septic_patients.html @@ -80,7 +80,7 @@ diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index a179fb9d..32a53957 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -81,7 +81,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr diff --git a/index.md b/index.md index 7ea44bbc..77a3dd93 100644 --- a/index.md +++ b/index.md @@ -96,6 +96,8 @@ Included are: The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (like all species of *Aspergillus*, *Candida*, *Cryptococcus*, *Histoplasma*, *Pneumocystis*, *Saccharomyces* and *Trichophyton*). +* All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like *Strongyloides* and *Taenia*) + * All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed * The responsible author(s) and year of scientific publication diff --git a/man/as.mo.Rd b/man/as.mo.Rd index 27631cf3..908cc775 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -54,12 +54,13 @@ A microbial ID from this package (class: \code{mo}) typically looks like these e | | | ----> subspecies, a 3-4 letter acronym | | ----> species, a 3-4 letter acronym | ----> genus, a 5-7 letter acronym, mostly without vowels - ----> taxonomic kingdom: A (Archaea), B (Bacteria), C (Chromista), - F (Fungi), P (Protozoa) or V (Viruses) + ----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria), C (Chromista), + F (Fungi), P (Protozoa), PL (Plantae) or V (Viruses) } 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: \itemize{ \item{Taxonomic kingdom: it first searches in Bacteria, then Fungi, then Protozoa} @@ -74,9 +75,9 @@ A couple of effects because of these rules: \item{\code{"H. influenzae"} will return the ID of \emph{Haemophilus influenzae} and not \emph{Haematobacter influenzae} for the same reason} \item{Something like \code{"stau"} or \code{"S aur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}} } -This means that looking up human pathogenic microorganisms takes less time than looking up human \strong{non}-pathogenic microorganisms. +This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms. -\strong{UNCERTAIN RESULTS} \cr +\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: \itemize{ \item{It tries to look for previously accepted (but now invalid) taxonomic names} @@ -95,12 +96,11 @@ Examples: Use \code{mo_failures()} to get a vector with all values that could not be coerced to a valid value. -Use \code{mo_uncertainties()} to get info about all values that were coerced to a valid value, but with uncertainty. +Use \code{mo_uncertainties()} to get a data.frame with all values that were coerced to a valid value, but with uncertainty. 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}{ +\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: \itemize{ \item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.} @@ -110,9 +110,8 @@ The artificial intelligence takes into account microbial prevalence of pathogens 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. +Group 2 probably contains all other 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} @@ -124,21 +123,10 @@ Group 2 probably contains all microbial pathogens ever found in humans. \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Read more on our website!}{ diff --git a/man/catalogue_of_life.Rd b/man/catalogue_of_life.Rd index d3b4594a..f4e4631d 100644 --- a/man/catalogue_of_life.Rd +++ b/man/catalogue_of_life.Rd @@ -8,13 +8,19 @@ This package contains the complete taxonomic tree of almost all microorganisms f } \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. + +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. +} + +\section{Included taxa}{ Included are: \itemize{ \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} + \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant fungi are covered (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} + \item{All ~2,000 (sub)species from ~100 other relevant genera, from the kingdoms of Animalia and Plantae (like \emph{Strongyloides} and \emph{Taenia})} \item{All ~15,000 previously accepted names of included (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/man/catalogue_of_life_version.Rd b/man/catalogue_of_life_version.Rd index 1d93bcf6..3c5d26b6 100644 --- a/man/catalogue_of_life_version.Rd +++ b/man/catalogue_of_life_version.Rd @@ -14,21 +14,10 @@ The list item \code{is_latest_annual_release} is based on the system date. } \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Read more on our website!}{ diff --git a/man/microorganisms.Rd b/man/microorganisms.Rd index 7891b863..119b128b 100755 --- a/man/microorganisms.Rd +++ b/man/microorganisms.Rd @@ -40,21 +40,10 @@ Manually added were: } \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Read more on our website!}{ diff --git a/man/microorganisms.codes.Rd b/man/microorganisms.codes.Rd index 5780854d..2bb9fe22 100644 --- a/man/microorganisms.codes.Rd +++ b/man/microorganisms.codes.Rd @@ -17,21 +17,10 @@ A data set containing commonly used codes for microorganisms, from laboratory sy } \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Read more on our website!}{ diff --git a/man/microorganisms.old.Rd b/man/microorganisms.old.Rd index 58823c46..2bc9285a 100644 --- a/man/microorganisms.old.Rd +++ b/man/microorganisms.old.Rd @@ -22,21 +22,10 @@ A data set containing old (previously valid or accepted) taxonomic names accordi } \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Read more on our website!}{ diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 2ca40659..085dbd3d 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -101,21 +101,10 @@ Supported languages are \code{"en"} (English), \code{"de"} (German), \code{"nl"} \section{Catalogue of Life}{ -\if{html}{\figure{logo_col.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains the complete taxonomic tree of almost all microorganisms from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). This data is updated annually - check the included version with \code{\link{catalogue_of_life_version}()}. +\if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} +This package contains the complete taxonomic tree of almost all microorganisms (~60,000 species) from the authoritative and comprehensive Catalogue of Life (\url{http://www.catalogueoflife.org}). The Catalogue of Life is the most comprehensive and authoritative global index of species currently available. -Included are: -\itemize{ - \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} - \item{All ~3,500 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales, Schizosaccharomycetales and Tremellales. This covers the most relevant microbial fungi (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Cryptococcus}, \emph{Histplasma}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} - \item{All ~15,000 previously accepted names of included (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} -} - -The Catalogue of Life (\url{http://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. - -The syntax used to transform the original data to a cleansed R format, can be found here: \url{https://gitlab.com/msberends/AMR/blob/master/reproduction_of_microorganisms.R}. +\link[=catalogue_of_life]{Click here} for more information about the included taxa. The Catalogue of Life releases updates annually; check which version was included in this package with \code{\link{catalogue_of_life_version}()}. } \section{Source}{ diff --git a/man/mo_source.Rd b/man/mo_source.Rd index 0bb9308f..e0fce598 100644 --- a/man/mo_source.Rd +++ b/man/mo_source.Rd @@ -15,6 +15,8 @@ get_mo_source() } \description{ These functions can be used to predefine your own reference to be used in \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}. + +This is \strong{the fastest way} to have your organisation (or analysis) specific codes picked up and translated by this package. } \details{ The reference file can be a text file seperated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the \code{readxl} package installed. @@ -25,38 +27,66 @@ The reference file can be a text file seperated with commas (CSV) or tabs or pip Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by \code{get_mo_source} in only a couple of microseconds (a millionth of a second). } +\section{How it works}{ + +Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package: +\preformatted{ + | A | B | +--|--------------------|-------------| +1 | Organisation XYZ | mo | +2 | lab_mo_ecoli | B_ESCHR_COL | +3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +4 | | | +} + +We save it as \code{'home/me/ourcodes.xlsx'}. Now we have to set it as a source: +\preformatted{ +set_mo_source("home/me/ourcodes.xlsx") +# Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +} + +It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression. + +And now we can use it in our functions: +\preformatted{ +as.mo("lab_mo_ecoli") +# B_ESCHR_COL + +mo_genus("lab_mo_kpneumoniae") +# "Klebsiella" +} + +If we edit the Excel file to, let's say, this: +\preformatted{ + | A | B | +--|--------------------|-------------| +1 | Organisation XYZ | mo | +2 | lab_mo_ecoli | B_ESCHR_COL | +3 | lab_mo_kpneumoniae | B_KLBSL_PNE | +4 | lab_Staph_aureus | B_STPHY_AUR | +5 | | | +} + +...any new usage of an MO function in this package will update your data: +\preformatted{ +as.mo("lab_mo_ecoli") +# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +# B_ESCHR_COL + +mo_genus("lab_Staph_aureus") +# "Staphylococcus" +} + +To remove the reference completely, just use any of these: +\preformatted{ +set_mo_source("") +set_mo_source(NULL) +# Removed mo_source file '~/.mo_source.rds'. +} +} + \section{Read more on our website!}{ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. } -\examples{ -\dontrun{ - -# imagine this Excel file (mo codes looked up in `microorganisms` data set): -# A B -# 1 our code mo -# 2 lab_mo_ecoli B_ESCHR_COL -# 3 lab_mo_kpneumoniae B_KLBSL_PNE - -# 1. We save it as 'home/me/ourcodes.xlsx' - -# 2. We use it for input: -set_mo_source("home/me/ourcodes.xlsx") -#> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. - -# 3. And use it in our functions: -as.mo("lab_mo_ecoli") -#> B_ESCHR_COL - -mo_genus("lab_mo_kpneumoniae") -#> "Klebsiella" - -# 4. It will look for changes itself: -# (add new row to the Excel file and save it) - -mo_genus("lab_mo_kpneumoniae") -#> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#> "Klebsiella" -} -} diff --git a/reproduction_of_microorganisms.R b/reproduction_of_microorganisms.R index 8db0197a..76c9043d 100644 --- a/reproduction_of_microorganisms.R +++ b/reproduction_of_microorganisms.R @@ -23,13 +23,29 @@ MOs <- taxon %>% # tibble for future transformations as_tibble() %>% filter( - # we only want all microorganisms and viruses - !kingdom %in% c("Animalia", "Plantae"), - # and no entries above genus - they all already have a taxonomic tree - !taxonRank %in% c("kingdom", "phylum", "superfamily", "class", "order", "family"), - # not all fungi: Aspergillus, Candida, Trichphyton and Pneumocystis are the most important, - # so only keep these orders from the fungi: - !(kingdom == "Fungi" & !order %in% c("Eurotiales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales", "Onygenales", "Pneumocystales"))) %>% + ( + # we only want all microorganisms and viruses + !kingdom %in% c("Animalia", "Plantae") + # and no entries above genus - they all already have a taxonomic tree + & !taxonRank %in% c("kingdom", "phylum", "superfamily", "class", "order", "family") + # not all fungi: Aspergillus, Candida, Trichphyton and Pneumocystis are the most important, + # so only keep these orders from the fungi: + & !(kingdom == "Fungi" + & !order %in% c("Eurotiales", "Saccharomycetales", "Schizosaccharomycetales", "Tremellales", "Onygenales", "Pneumocystales")) + ) + # or the genus has to be one of the genera we found in our hospitals last decades + | genus %in% c("Absidia", "Acremonium", "Actinotignum", "Alternaria", "Anaerosalibacter", "Ancylostoma", "Anisakis", "Apophysomyces", + "Arachnia", "Ascaris", "Aureobacterium", "Aureobasidium", "Balantidum", "Bilophilia", "Branhamella", "Brochontrix", + "Brugia", "Calymmatobacterium", "Catabacter", "Cdc", "Chilomastix", "Chryseomonas", "Cladophialophora", "Cladosporium", + "Clonorchis", "Cordylobia", "Curvularia", "Demodex", "Dermatobia", "Diphyllobothrium", "Dracunculus", "Echinococcus", + "Enterobius", "Euascomycetes", "Exophiala", "Fasciola", "Fusarium", "Hendersonula", "Hymenolepis", "Kloeckera", + "Koserella", "Larva", "Leishmania", "Lelliottia", "Loa", "Lumbricus", "Malassezia", "Metagonimus", "Molonomonas", + "Mucor", "Nattrassia", "Necator", "Novospingobium", "Onchocerca", "Opistorchis", "Paragonimus", "Paramyxovirus", + "Pediculus", "Phoma", "Phthirus", "Pityrosporum", "Pseudallescheria", "Pulex", "Rhizomucor", "Rhizopus", "Rhodotorula", + "Salinococcus", "Sanguibacteroides", "Schistosoma", "Scopulariopsis", "Scytalidium", "Sporobolomyces", "Stomatococcus", + "Strongyloides", "Syncephalastraceae", "Taenia", "Torulopsis", "Trichinella", "Trichobilharzia", "Trichomonas", + "Trichosporon", "Trichuris", "Trypanosoma", "Wuchereria") + ) %>% # remove text if it contains 'Not assigned' like phylum in viruses mutate_all(funs(gsub("Not assigned", "", .))) %>% # Transform 'Smith, Jones, 2011' to 'Smith et al., 2011': @@ -143,7 +159,11 @@ MOs <- MOs %>% ungroup() %>% # remove trailing underscores mutate(mo = gsub("_+$", "", - toupper(paste(substr(kingdom, 1, 1), + toupper(paste(ifelse(kingdom == "Animalia", + "AN", + ifelse(kingdom == "Plantae", + "PL", + substr(kingdom, 1, 1))), abbr_genus, abbr_species, abbr_subspecies, @@ -152,14 +172,11 @@ MOs <- MOs %>% paste0(mo, "1"), mo), fullname = ifelse(fullname == "", - trimws(paste(genus, species, subspecies), - fullname))) %>% + trimws(paste(genus, species, subspecies)), + fullname)) %>% select(mo, everything(), -abbr_genus, -abbr_species, -abbr_subspecies) -# everything distinct? -sum(duplicated(MOs$mo)) - # add non-taxonomic entries MOs <- MOs %>% bind_rows( @@ -273,6 +290,10 @@ MOs <- MOs %>% stringsAsFactors = FALSE) ) + +# everything distinct? +sum(duplicated(MOs$mo)) + # save it MOs <- as.data.frame(MOs %>% arrange(mo), stringsAsFactors = FALSE) MOs.old <- as.data.frame(MOs.old, stringsAsFactors = FALSE) @@ -282,5 +303,7 @@ saveRDS(MOs, "microorganisms.rds") saveRDS(MOs.old, "microorganisms.old.rds") # on the server: -# usethis::use_data(microorganisms, overwrite = TRUE) -# usethis::use_data(microorganisms.old, overwrite = TRUE) +usethis::use_data(microorganisms, overwrite = TRUE) +usethis::use_data(microorganisms.old, overwrite = TRUE) +rm(microorganisms) +rm(microorganisms.old) diff --git a/tests/testthat/test-mo.R b/tests/testthat/test-mo.R index bde52dec..76618d18 100644 --- a/tests/testthat/test-mo.R +++ b/tests/testthat/test-mo.R @@ -193,11 +193,7 @@ test_that("as.mo works", { # check old names expect_equal(suppressMessages(as.character(as.mo("Escherichia blattae"))), "B_SHMWL_BLA") - # # - Didymosphaeria spartinae (unprevalent) - # expect_warning(suppressMessages(as.mo("D spartin", allow_uncertain = TRUE))) - # # - was renamed to Leptosphaeria obiones - # expect_equal(suppressWarnings(suppressMessages(as.character(as.mo("D spartin", allow_uncertain = TRUE)))), - # "F_LPTSP_OBI") + print(mo_renamed()) # check uncertain names expect_equal(suppressWarnings(as.character(as.mo("esco extra_text", allow_uncertain = FALSE))), NA_character_) @@ -234,6 +230,7 @@ test_that("as.mo works", { "Streptococcus suis (bovis gr)", "Raoultella (here some text) terrigena")))), c("B_MCRBC", "B_STRPT_SUI", "B_RLTLL_TER")) + print(mo_uncertainties()) # Salmonella (City) are all actually Salmonella enterica spp (City) expect_equal(as.character(suppressMessages(as.mo("Salmonella Goettingen"))), diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index eb1a644e..6a0f2a01 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -315,7 +315,7 @@ data_1st %>% ## 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: +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: ```{r} data_1st %>% portion_IR(amox) @@ -351,21 +351,21 @@ data_1st %>% knitr::kable(align = "c", big.mark = ",") ``` -These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily: +These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily: ```{r, eval = FALSE} data_1st %>% group_by(genus) %>% - summarise(amoxicillin = portion_S(amcl), + summarise(amoxiclav = portion_S(amcl), gentamicin = portion_S(gent), - "amox + gent" = portion_S(amcl, gent)) + amoxiclav_genta = portion_S(amcl, gent)) ``` ```{r, echo = FALSE} data_1st %>% group_by(genus) %>% - summarise(amoxicillin = portion_S(amcl), + summarise(amoxiclav = portion_S(amcl), gentamicin = portion_S(gent), - "amox + gent" = portion_S(amcl, gent)) %>% + amoxiclav_genta = portion_S(amcl, gent)) %>% knitr::kable(align = "c", big.mark = ",") ``` @@ -374,9 +374,9 @@ To make a transition to the next part, let's see how this difference could be pl ```{r plot 1} data_1st %>% group_by(genus) %>% - summarise("1. Amoxicillin" = portion_S(amcl), + summarise("1. Amoxi/clav" = portion_S(amcl), "2. Gentamicin" = portion_S(gent), - "3. Amox + gent" = portion_S(amcl, gent)) %>% + "3. Amoxi/clav + gent" = portion_S(amcl, gent)) %>% tidyr::gather("Antibiotic", "S", -genus) %>% ggplot(aes(x = genus, y = S, @@ -397,9 +397,9 @@ ggplot(data = a_data_set, x = "My X axis", y = "My Y axis") -ggplot(a_data_set, - aes(year, value) + - geom_bar() +# or as short as: +ggplot(a_data_set) + + geom_bar(aes(year)) ``` The `AMR` package contains functions to extend this `ggplot2` package, for example `geom_rsi()`. It automatically transforms data with `count_df()` or `portion_df()` and show results in stacked bars. Its simplest and shortest example: diff --git a/vignettes/SPSS.Rmd b/vignettes/SPSS.Rmd index 01e1cd0a..de5fe2de 100755 --- a/vignettes/SPSS.Rmd +++ b/vignettes/SPSS.Rmd @@ -38,17 +38,17 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major * **R is extremely flexible.** - Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. It may be a bit flexible, but you can never create that very specific publication-ready plot without using other (paid) software. + Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software. * **R can be easily automated.** Over the last years, [R Markdown](https://rmarkdown.rstudio.com/) has really made an interesting development. With R Markdown, you can very easily reproduce your reports, whether it's to Word, Powerpoint, a website, a PDF document or just the raw data to Excel. I use this a lot to generate monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like. - For an even more professional environment, you could create [Shiny apps](https://shiny.rstudio.com/): live manipulation of data using a custom made website. The webdesign knowledge needed (Javascript, CSS, HTML) is almost *zero*. + For an even more professional environment, you could create [Shiny apps](https://shiny.rstudio.com/): live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost *zero*. * **R has a huge community.** - Many R users just ask questions on website like [stackoverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, around [275,000 R questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have been asked on this platform (which covers questions and answer for any programming language). In my own experience, most questions are answered within a couple of minutes. + Many R users just ask questions on websites like [StackOverflow.com](https://stackoverflow.com), the largest online community for programmers. At the time of writing, more than [275,000 R-related questions](https://stackoverflow.com/questions/tagged/r?sort=votes) have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes. * **R understands any data type, including SPSS/SAS/Stata.** diff --git a/vignettes/benchmarks.Rmd b/vignettes/benchmarks.Rmd index 0fbac976..bccd617d 100755 --- a/vignettes/benchmarks.Rmd +++ b/vignettes/benchmarks.Rmd @@ -89,7 +89,7 @@ Uncommon microorganisms take a lot more time than common microorganisms. To reli ### Repetitive 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. +Repetitive results are unique values that 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. ```{r, message = FALSE} library(dplyr)