diff --git a/NAMESPACE b/NAMESPACE index ec2413be..de08bf3f 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -91,14 +91,18 @@ export(labels_rsi_count) export(left_join_microorganisms) export(like) export(mo_aerobic) +export(mo_class) export(mo_family) export(mo_fullname) export(mo_genus) export(mo_gramstain) +export(mo_order) +export(mo_phylum) export(mo_property) export(mo_shortname) export(mo_species) export(mo_subspecies) +export(mo_taxonomy) export(mo_type) export(n_rsi) export(p.symbol) diff --git a/NEWS.md b/NEWS.md index c3eaf75a..e8108efb 100755 --- a/NEWS.md +++ b/NEWS.md @@ -27,7 +27,11 @@ * All old syntaxes will still work with this version, but will throw warnings * Function `labels_rsi_count` to print datalabels on a RSI `ggplot2` model * Functions `as.atc` and `is.atc` to transform/look up antibiotic ATC codes as defined by the WHO. The existing function `guess_atc` is now an alias of `as.atc`. -* Aliases for existing function `mo_property`: `mo_family`, `mo_genus`, `mo_species`, `mo_subspecies`, `mo_fullname`, `mo_shortname`, `mo_aerobic`, `mo_type` and `mo_gramstain`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese, and it defaults to the systems locale: +* Aliases for existing function `mo_property` and new data from ITIS (Integrated Taxonomic Information System, https://www.itis.gov) + * Taxonomic names: `mo_phylum`, `mo_class`, `mo_order`, `mo_family`, `mo_genus`, `mo_species`, `mo_subspecies` + * Semantic names: `mo_fullname`, `mo_shortname` + * Microbial properties: `mo_aerobic`, `mo_type`, `mo_gramstain`. + They also come with support for German, Dutch, French, Italian, Spanish and Portuguese, and it defaults to the systems locale: ```r mo_gramstain("E. coli") # [1] "Negative rods" diff --git a/R/data.R b/R/data.R index 3600cefd..a70e83e7 100755 --- a/R/data.R +++ b/R/data.R @@ -123,34 +123,28 @@ #' Data set with human pathogenic microorganisms #' #' A data set containing (potential) human pathogenic microorganisms. MO codes can be looked up using \code{\link{guess_mo}}. -#' @format A \code{\link{tibble}} with 2,642 observations and 11 variables: +#' @format A \code{\link{tibble}} with 2,642 observations and 14 variables: #' \describe{ #' \item{\code{mo}}{ID of microorganism} #' \item{\code{bactsys}}{Bactsyscode of microorganism} -#' \item{\code{family}}{Family name of microorganism} #' \item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}} #' \item{\code{species}}{Species name of microorganism, like \code{"coli"}} #' \item{\code{subspecies}}{Subspecies name of bio-/serovar of microorganism, like \code{"EHEC"}} #' \item{\code{fullname}}{Full name, like \code{"Echerichia coli (EHEC)"}} -#' \item{\code{aerobic}}{Logical whether bacteria is aerobic} -#' \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}} #' \item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}} +#' \item{\code{aerobic}}{Logical whether bacteria is aerobic} +#' \item{\code{family}}{Taxonomic family of the microorganism as found in ITIS, see Source} +#' \item{\code{order}}{Taxonomic order of the microorganism as found in ITIS, see Source} +#' \item{\code{class}}{Taxonomic class of the microorganism as found in ITIS, see Source} +#' \item{\code{phylum}}{Taxonomic phylum of the microorganism as found in ITIS, see Source} +#' \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}} #' \item{\code{prevalence}}{A rounded integer based on prevalence of the microorganism. Used internally by \code{\link{as.mo}}, otherwise quite meaningless.} #' } -# source MOLIS (LIS of Certe) - \url{https://www.certe.nl} -# new <- microorganisms %>% filter(genus == "Bacteroides") %>% .[1,] -# new[1, 'mo'] <- "DIAPNU" -# new[1, 'bactsys'] <- "DIAPNU" -# new[1, 'family'] <- "Veillonellaceae" -# new[1, 'genus'] <- "Dialister" -# new[1, 'species'] <- "pneumosintes" -# new[1, 'subspecies'] <- NA -# new[1, 'fullname'] <- paste(new[1, 'genus'], new[1, 'species']) -# microorganisms <- microorganisms %>% bind_rows(new) %>% arrange(mo) +#' @source Integrated Taxonomic Information System (ITIS) on-line database, \url{https://www.itis.gov}. #' @seealso \code{\link{guess_mo}} \code{\link{antibiotics}} \code{\link{microorganisms.umcg}} "microorganisms" -#' Translation table for UMCG with ~1,100 microorganisms +#' Translation table for UMCG #' #' A data set containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{MO}s with \code{\link{guess_mo}}. #' @format A \code{\link{tibble}} with 1,095 observations and 2 variables: @@ -158,7 +152,6 @@ #' \item{\code{umcg}}{Code of microorganism according to UMCG MMB} #' \item{\code{mo}}{Code of microorganism in \code{\link{microorganisms}}} #' } -# source MOLIS (LIS of Certe) - \url{https://www.certe.nl} \cr \cr GLIMS (LIS of UMCG) - \url{https://www.umcg.nl} #' @seealso \code{\link{guess_mo}} \code{\link{microorganisms}} "microorganisms.umcg" diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R index 7f3f520b..634900cd 100644 --- a/R/ggplot_rsi.R +++ b/R/ggplot_rsi.R @@ -34,15 +34,15 @@ #' @details At default, the names of antibiotics will be shown on the plots using \code{\link{abname}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. #' #' \strong{The functions}\cr -#' \code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{portion_df}} at default, could also be \code{\link{count_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. +#' \code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{count_df}} at default, can also be \code{\link{portion_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. #' #' \code{facet_rsi} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2]{facet_wrap}}. #' -#' \code{scale_y_percent} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2]{scale_y_continuous}}. +#' \code{scale_y_percent} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2]{scale_continuous}}. #' -#' \code{scale_rsi_colours} sets colours to the bars: green for S, yellow for I and red for R, using \code{\link[ggplot2]{scale_fill_brewer}}. +#' \code{scale_rsi_colours} sets colours to the bars: green for S, yellow for I and red for R, using \code{\link[ggplot2]{scale_colour_brewer}}. #' -#' \code{theme_rsi} is a \code{\link[ggplot2]{theme}} with minimal distraction. +#' \code{theme_rsi} is a \code{ggplot \link[ggplot2]{theme}} with minimal distraction. #' #' \code{labels_rsi_count} print datalabels on the bars with percentage and amount of isolates using \code{\link[ggplot2]{geom_text}} #' @@ -71,10 +71,10 @@ #' select(amox, nitr, fosf, trim, cipr) %>% #' ggplot_rsi() #' -#' # get counts instead of percentages: +#' # get only portions and no counts: #' septic_patients %>% #' select(amox, nitr, fosf, trim, cipr) %>% -#' ggplot_rsi(fun = count_df) +#' ggplot_rsi(fun = portion_df) #' #' # add other ggplot2 parameters as you like: #' septic_patients %>% diff --git a/R/mo_property.R b/R/mo_property.R index ef77e293..3addd71d 100644 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -27,14 +27,19 @@ #' [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} #' #' [2] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571} +#' +#' [3] Integrated Taxonomic Information System (ITIS) on-line database, \url{https://www.itis.gov}. #' @rdname mo_property #' @name mo_property -#' @return Character or logical (only \code{mo_aerobic}) +#' @return A logical (in case of \code{mo_aerobic}), a list (in case of \code{mo_taxonomy}), a character otherwise #' @export #' @importFrom dplyr %>% left_join pull #' @seealso \code{\link{microorganisms}} #' @examples #' # All properties +#' mo_phylum("E. coli") # "Proteobacteria" +#' mo_class("E. coli") # "Gammaproteobacteria" +#' mo_order("E. coli") # "Enterobacteriales" #' mo_family("E. coli") # "Enterobacteriaceae" #' mo_genus("E. coli") # "Escherichia" #' mo_species("E. coli") # "coli" @@ -105,30 +110,10 @@ #' mo_fullname("S. pyogenes", #' Lancefield = TRUE, #' language = "nl") # "Streptococcus groep A" -mo_family <- function(x) { - mo_property(x, "family") -} - -#' @rdname mo_property -#' @export -mo_genus <- function(x, language = NULL) { - mo_property(x, "genus", language = language) -} - -#' @rdname mo_property -#' @export -mo_species <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) { - mo_property(x, "species", Becker = Becker, Lancefield = Lancefield, language = language) -} - -#' @rdname mo_property -#' @export -mo_subspecies <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) { - mo_property(x, "subspecies", Becker = Becker, Lancefield = Lancefield, language = language) -} - -#' @rdname mo_property -#' @export +#' +#' +#' # Complete taxonomy up to Phylum, returns a list +#' mo_taxonomy("E. coli") mo_fullname <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) { mo_property(x, "fullname", Becker = Becker, Lancefield = Lancefield, language = language) } @@ -164,6 +149,47 @@ mo_shortname <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) mo_translate(result, language = language) } +#' @rdname mo_property +#' @export +mo_subspecies <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) { + mo_property(x, "subspecies", Becker = Becker, Lancefield = Lancefield, language = language) +} + +#' @rdname mo_property +#' @export +mo_species <- function(x, Becker = FALSE, Lancefield = FALSE, language = NULL) { + mo_property(x, "species", Becker = Becker, Lancefield = Lancefield, language = language) +} + +#' @rdname mo_property +#' @export +mo_genus <- function(x, language = NULL) { + mo_property(x, "genus", language = language) +} + +#' @rdname mo_property +#' @export +mo_family <- function(x) { + mo_property(x, "family") +} + +#' @rdname mo_property +#' @export +mo_order <- function(x) { + mo_property(x, "order") +} + +#' @rdname mo_property +#' @export +mo_class <- function(x) { + mo_property(x, "class") +} + +#' @rdname mo_property +#' @export +mo_phylum <- function(x) { + mo_property(x, "phylum") +} #' @rdname mo_property #' @export @@ -204,6 +230,19 @@ mo_property <- function(x, property = 'fullname', Becker = FALSE, Lancefield = F result2 } +#' @rdname mo_property +#' @export +mo_taxonomy <- function(x) { + x <- as.mo(x) + base::list(phylum = mo_phylum(x), + class = mo_class(x), + order = mo_order(x), + family = mo_family(x), + genus = mo_genus(x), + species = mo_species(x), + subspecies = mo_subspecies(x)) +} + #' @importFrom dplyr %>% case_when mo_translate <- function(x, language) { if (is.null(language)) { diff --git a/README.md b/README.md index 3bd4f304..85290334 100755 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ This `AMR` package basically does four important things: * Use `first_isolate` to identify the first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute). * You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them. * Use `MDRO` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported. - * The data set `microorganisms` contains the family, genus, species, subspecies, colloquial name and Gram stain of almost 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). This enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family` or `mo_gramstain`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. These functions can be used to add new variables to your data. - * The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_name` and `ab_tradenames` to look up values. As the `mo_*` functions use `as.mo` internally, the `ab_*` functions use `as.atc` internally so it uses AI to guess your expected result. For example, `ab_name("Fluclox")`, `ab_name("Floxapen")` and `ab_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. + * The data set `microorganisms` contains the taxonomic properties of almost 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). Taxonomic names were downloaded from ITIS (Integrated Taxonomic Information System, http://www.itis.gov). Furhermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family`, `mo_gramstain` or even `mo_phylum`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. These functions can be used to add new variables to your data. + * The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_name` and `ab_tradenames` to look up values. The `ab_*` functions use `as.atc` internally so they support AI to guess your expected result. For example, `ab_name("Fluclox")`, `ab_name("Floxapen")` and `ab_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. 3. It **analyses the data** with convenient functions that use well-known methods. @@ -390,7 +390,7 @@ antibiotics # A tibble: 423 x 18 # Dataset with bacteria codes and properties like gram stain and # aerobic/anaerobic -microorganisms # A tibble: 2,642 x 11 +microorganisms # A tibble: 2,642 x 14 ``` ## Copyright diff --git a/data/microorganisms.rda b/data/microorganisms.rda index a6d4843b..193a6d33 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/man/ggplot_rsi.Rd b/man/ggplot_rsi.Rd index 537abf78..d5d9c286 100644 --- a/man/ggplot_rsi.Rd +++ b/man/ggplot_rsi.Rd @@ -62,15 +62,15 @@ Use these functions to create bar plots for antimicrobial resistance analysis. A At default, the names of antibiotics will be shown on the plots using \code{\link{abname}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. \strong{The functions}\cr -\code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{portion_df}} at default, could also be \code{\link{count_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. +\code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{count_df}} at default, can also be \code{\link{portion_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. \code{facet_rsi} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2]{facet_wrap}}. -\code{scale_y_percent} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2]{scale_y_continuous}}. +\code{scale_y_percent} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2]{scale_continuous}}. -\code{scale_rsi_colours} sets colours to the bars: green for S, yellow for I and red for R, using \code{\link[ggplot2]{scale_fill_brewer}}. +\code{scale_rsi_colours} sets colours to the bars: green for S, yellow for I and red for R, using \code{\link[ggplot2]{scale_colour_brewer}}. -\code{theme_rsi} is a \code{\link[ggplot2]{theme}} with minimal distraction. +\code{theme_rsi} is a \code{ggplot \link[ggplot2]{theme}} with minimal distraction. \code{labels_rsi_count} print datalabels on the bars with percentage and amount of isolates using \code{\link[ggplot2]{geom_text}} @@ -98,10 +98,10 @@ septic_patients \%>\% select(amox, nitr, fosf, trim, cipr) \%>\% ggplot_rsi() -# get counts instead of percentages: +# get only portions and no counts: septic_patients \%>\% select(amox, nitr, fosf, trim, cipr) \%>\% - ggplot_rsi(fun = count_df) + ggplot_rsi(fun = portion_df) # add other ggplot2 parameters as you like: septic_patients \%>\% diff --git a/man/microorganisms.Rd b/man/microorganisms.Rd index f7eecd09..d6a26726 100755 --- a/man/microorganisms.Rd +++ b/man/microorganisms.Rd @@ -4,20 +4,26 @@ \name{microorganisms} \alias{microorganisms} \title{Data set with human pathogenic microorganisms} -\format{A \code{\link{tibble}} with 2,642 observations and 11 variables: +\format{A \code{\link{tibble}} with 2,642 observations and 14 variables: \describe{ \item{\code{mo}}{ID of microorganism} \item{\code{bactsys}}{Bactsyscode of microorganism} - \item{\code{family}}{Family name of microorganism} \item{\code{genus}}{Genus name of microorganism, like \code{"Echerichia"}} \item{\code{species}}{Species name of microorganism, like \code{"coli"}} \item{\code{subspecies}}{Subspecies name of bio-/serovar of microorganism, like \code{"EHEC"}} \item{\code{fullname}}{Full name, like \code{"Echerichia coli (EHEC)"}} - \item{\code{aerobic}}{Logical whether bacteria is aerobic} - \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}} \item{\code{gramstain}}{Gram of microorganism, like \code{"Negative rods"}} + \item{\code{aerobic}}{Logical whether bacteria is aerobic} + \item{\code{family}}{Taxonomic family of the microorganism as found in ITIS, see Source} + \item{\code{order}}{Taxonomic order of the microorganism as found in ITIS, see Source} + \item{\code{class}}{Taxonomic class of the microorganism as found in ITIS, see Source} + \item{\code{phylum}}{Taxonomic phylum of the microorganism as found in ITIS, see Source} + \item{\code{type}}{Type of microorganism, like \code{"Bacteria"} and \code{"Fungus/yeast"}} \item{\code{prevalence}}{A rounded integer based on prevalence of the microorganism. Used internally by \code{\link{as.mo}}, otherwise quite meaningless.} }} +\source{ +Integrated Taxonomic Information System (ITIS) on-line database, \url{https://www.itis.gov}. +} \usage{ microorganisms } diff --git a/man/microorganisms.umcg.Rd b/man/microorganisms.umcg.Rd index 7b99880a..3140299d 100755 --- a/man/microorganisms.umcg.Rd +++ b/man/microorganisms.umcg.Rd @@ -3,7 +3,7 @@ \docType{data} \name{microorganisms.umcg} \alias{microorganisms.umcg} -\title{Translation table for UMCG with ~1,100 microorganisms} +\title{Translation table for UMCG} \format{A \code{\link{tibble}} with 1,095 observations and 2 variables: \describe{ \item{\code{umcg}}{Code of microorganism according to UMCG MMB} diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 53208dd3..1d478569 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -2,34 +2,46 @@ % Please edit documentation in R/mo_property.R \name{mo_property} \alias{mo_property} -\alias{mo_family} -\alias{mo_genus} -\alias{mo_species} -\alias{mo_subspecies} \alias{mo_fullname} \alias{mo_shortname} +\alias{mo_subspecies} +\alias{mo_species} +\alias{mo_genus} +\alias{mo_family} +\alias{mo_order} +\alias{mo_class} +\alias{mo_phylum} \alias{mo_type} \alias{mo_gramstain} \alias{mo_aerobic} +\alias{mo_taxonomy} \title{Property of a microorganism} \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} [2] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571} + +[3] Integrated Taxonomic Information System (ITIS) on-line database, \url{https://www.itis.gov}. } \usage{ -mo_family(x) - -mo_genus(x, language = NULL) - -mo_species(x, Becker = FALSE, Lancefield = FALSE, language = NULL) - -mo_subspecies(x, Becker = FALSE, Lancefield = FALSE, language = NULL) - mo_fullname(x, Becker = FALSE, Lancefield = FALSE, language = NULL) mo_shortname(x, Becker = FALSE, Lancefield = FALSE, language = NULL) +mo_subspecies(x, Becker = FALSE, Lancefield = FALSE, language = NULL) + +mo_species(x, Becker = FALSE, Lancefield = FALSE, language = NULL) + +mo_genus(x, language = NULL) + +mo_family(x) + +mo_order(x) + +mo_class(x) + +mo_phylum(x) + mo_type(x, language = NULL) mo_gramstain(x, language = NULL) @@ -38,12 +50,12 @@ mo_aerobic(x) mo_property(x, property = "fullname", Becker = FALSE, Lancefield = FALSE, language = NULL) + +mo_taxonomy(x) } \arguments{ \item{x}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link{as.mo}}} -\item{language}{language of the returned text, defaults to the systems language. Either one of \code{"en"} (English), \code{"de"} (German), \code{"nl"} (Dutch), \code{"es"} (Spanish) or \code{"pt"} (Portuguese).} - \item{Becker}{a logical to indicate whether \emph{Staphylococci} should be categorised into Coagulase Negative \emph{Staphylococci} ("CoNS") and Coagulase Positive \emph{Staphylococci} ("CoPS") instead of their own species, according to Karsten Becker \emph{et al.} [1]. This excludes \emph{Staphylococcus aureus} at default, use \code{Becker = "all"} to also categorise \emph{S. aureus} as "CoPS".} @@ -52,16 +64,21 @@ mo_property(x, property = "fullname", Becker = FALSE, This excludes \emph{Enterococci} at default (who are in group D), use \code{Lancefield = "all"} to also categorise all \emph{Enterococci} as group D.} +\item{language}{language of the returned text, defaults to the systems language. Either one of \code{"en"} (English), \code{"de"} (German), \code{"nl"} (Dutch), \code{"es"} (Spanish) or \code{"pt"} (Portuguese).} + \item{property}{one of the column names of one of the \code{\link{microorganisms}} data set, like \code{"mo"}, \code{"bactsys"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"fullname"}, \code{"gramstain"} and \code{"aerobic"}} } \value{ -Character or logical (only \code{mo_aerobic}) +A logical (in case of \code{mo_aerobic}), a list (in case of \code{mo_taxonomy}), a character otherwise } \description{ Use these functions to return a specific property of a microorganism from the \code{\link{microorganisms}} data set. All input values will be evaluated internally with \code{\link{as.mo}}. } \examples{ # All properties +mo_phylum("E. coli") # "Proteobacteria" +mo_class("E. coli") # "Gammaproteobacteria" +mo_order("E. coli") # "Enterobacteriales" mo_family("E. coli") # "Enterobacteriaceae" mo_genus("E. coli") # "Escherichia" mo_species("E. coli") # "coli" @@ -132,6 +149,10 @@ mo_fullname("S. pyogenes", mo_fullname("S. pyogenes", Lancefield = TRUE, language = "nl") # "Streptococcus groep A" + + +# Complete taxonomy up to Phylum, returns a list +mo_taxonomy("E. coli") } \seealso{ \code{\link{microorganisms}} diff --git a/tests/testthat/test-mo_property.R b/tests/testthat/test-mo_property.R index ca183bd2..d4f91bfe 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -1,6 +1,9 @@ context("mo_property.R") test_that("mo_property works", { + expect_equal(mo_phylum("E. coli"), "Proteobacteria") + expect_equal(mo_class("E. coli"), "Gammaproteobacteria") + expect_equal(mo_order("E. coli"), "Enterobacteriales") expect_equal(mo_family("E. coli"), "Enterobacteriaceae") expect_equal(mo_genus("E. coli"), "Escherichia") expect_equal(mo_species("E. coli"), "coli") diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index e6dedaf1..31a74f2e 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -34,9 +34,9 @@ This `AMR` package basically does four important things: * Use `first_isolate` to identify the first isolates of every patient [using guidelines from the CLSI](https://clsi.org/standards/products/microbiology/documents/m39/) (Clinical and Laboratory Standards Institute). * You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them. * Use `MDRO` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported. - * The data set `microorganisms` contains the family, genus, species, subspecies, colloquial name and Gram stain of almost 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). This enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family` or `mo_gramstain`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. These functions can be used to add new variables to your data. - * The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_official` and `ab_tradenames` to look up values. As the `mo_*` functions use `as.mo` internally, the `ab_*` functions use `as.atc` internally so it uses AI to guess your expected result. For example, `ab_official("Fluclox")`, `ab_official("Floxapen")` and `ab_official("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. - + * The data set `microorganisms` contains the taxonomic properties of almost 3,000 potential human pathogenic microorganisms (bacteria, fungi/yeasts and parasites). Taxonomic names were downloaded from ITIS (Integrated Taxonomic Information System, http://www.itis.gov). Furhermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus`, `mo_family`, `mo_gramstain` or even `mo_phylum`. As they use `as.mo` internally, they also use artificial intelligence. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, French, Italian, Spanish and Portuguese. These functions can be used to add new variables to your data. + * The data set `antibiotics` contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like `ab_name` and `ab_tradenames` to look up values. The `ab_*` functions use `as.atc` internally so they support AI to guess your expected result. For example, `ab_name("Fluclox")`, `ab_name("Floxapen")` and `ab_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. + 3. It **analyses the data** with convenient functions that use well-known methods. * Calculate the resistance (and even co-resistance) of microbial isolates with the `portion_R`, `portion_IR`, `portion_I`, `portion_SI` and `portion_S` functions. Similarly, the *amount* of isolates can be determined with the `count_R`, `count_IR`, `count_I`, `count_SI` and `count_S` functions. All these functions can be used [with the `dplyr` package](https://dplyr.tidyverse.org/#usage) (e.g. in conjunction with [`summarise`](https://dplyr.tidyverse.org/reference/summarise.html))