AMR/man/as.mo.Rd

219 lines
13 KiB
Plaintext
Raw Normal View History

2018-07-23 14:14:03 +02:00
% Generated by roxygen2: do not edit by hand
2019-03-15 13:57:25 +01:00
% Please edit documentation in R/mo.R, R/mo_history.R
2018-08-31 13:36:19 +02:00
\name{as.mo}
\alias{as.mo}
\alias{mo}
\alias{is.mo}
2019-02-08 16:06:54 +01:00
\alias{mo_failures}
\alias{mo_uncertainties}
\alias{mo_renamed}
2019-03-15 13:57:25 +01:00
\alias{clean_mo_history}
2018-08-31 13:36:19 +02:00
\title{Transform to microorganism ID}
2018-07-23 14:14:03 +02:00
\usage{
2018-12-07 12:04:55 +01:00
as.mo(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
2019-03-15 13:57:25 +01:00
reference_df = get_mo_source(), ...)
2018-07-23 14:14:03 +02:00
2018-08-31 13:36:19 +02:00
is.mo(x)
2019-02-08 16:06:54 +01:00
mo_failures()
mo_uncertainties()
mo_renamed()
2019-03-15 13:57:25 +01:00
2019-03-26 14:24:03 +01:00
clean_mo_history(...)
2018-07-23 14:14:03 +02:00
}
\arguments{
\item{x}{a character vector or a \code{data.frame} with one or two columns}
2019-03-26 14:24:03 +01:00
\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,2]. Note that this does not include species that were newly named after these publications, like \emph{S. caeli}.
This excludes \emph{Staphylococcus aureus} at default, use \code{Becker = "all"} to also categorise \emph{S. aureus} as "CoPS".}
2019-03-26 14:24:03 +01:00
\item{Lancefield}{a logical to indicate whether beta-haemolytic \emph{Streptococci} should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield [3]. These \emph{Streptococci} will be categorised in their first group, e.g. \emph{Streptococcus dysgalactiae} will be group C, although officially it was also categorised into groups G and L.
This excludes \emph{Enterococci} at default (who are in group D), use \code{Lancefield = "all"} to also categorise all \emph{Enterococci} as group D.}
2018-09-24 23:33:29 +02:00
2019-03-12 12:19:27 +01:00
\item{allow_uncertain}{a logical (\code{TRUE} or \code{FALSE}) or a value between 0 and 3 to indicate whether the input should be checked for less possible results, see Details}
2018-10-01 11:39:43 +02:00
2019-01-21 15:53:01 +01:00
\item{reference_df}{a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. See \code{\link{set_mo_source}} and \code{\link{get_mo_source}} to automate the usage of your own codes (e.g. used in your analysis or organisation).}
2019-03-15 13:57:25 +01:00
\item{...}{other parameters passed on to functions}
2018-07-23 14:14:03 +02:00
}
\value{
2019-03-26 14:24:03 +01:00
Character (vector) with class \code{"mo"}
2018-07-23 14:14:03 +02:00
}
\description{
2019-03-18 14:29:41 +01:00
Use this function to determine a valid microorganism ID (\code{mo}). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), an abbreviation known in the field (like \code{"MRSA"}), or just a genus. Please see Examples.
2018-07-23 14:14:03 +02:00
}
\details{
2019-03-15 13:57:25 +01:00
\strong{General info} \cr
2018-10-01 11:39:43 +02:00
A microbial ID from this package (class: \code{mo}) typically looks like these examples:\cr
2018-09-24 23:33:29 +02:00
\preformatted{
2018-12-07 12:04:55 +01:00
Code Full name
--------------- --------------------------------------
B_KLBSL Klebsiella
B_KLBSL_PNE Klebsiella pneumoniae
B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
2018-09-24 23:33:29 +02:00
| | | |
| | | |
| | | ----> subspecies, a 3-4 letter acronym
| | ----> species, a 3-4 letter acronym
| ----> genus, a 5-7 letter acronym, mostly without vowels
2019-03-26 14:24:03 +01:00
----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
C (Chromista), F (Fungi), P (Protozoa) or
PL (Plantae)
2018-09-24 23:33:29 +02:00
}
2018-08-01 08:03:31 +02:00
2019-03-26 14:24:03 +01:00
Values that cannot be coered will be considered 'unknown' and will get the MO code \code{UNKNOWN}.
2019-03-02 22:47:04 +01:00
2019-03-15 13:57:25 +01:00
Use the \code{\link{mo_property}_*} functions to get properties based on the returned code, see Examples.
2019-03-18 14:29:41 +01:00
The algorithm uses data from the Catalogue of Life (see below) and from one other source (see \code{?microorganisms}).
2019-03-15 17:36:42 +01:00
\strong{Self-learning algoritm} \cr
2019-03-26 14:24:03 +01:00
The \code{as.mo()} function gains experience from previously determined microbial IDs and learns from it. This drastically improves both speed and reliability. Use \code{clean_mo_history()} to reset the algorithms. Only experience from your current \code{AMR} package version is used. This is done because in the future the taxonomic tree (which is included in this package) may change for any organism and it consequently has to rebuild its knowledge. Usually, any guess after the first try runs 80-95\% faster than the first try. The algorithm saves its previous findings to \code{~/.Rhistory_mo}.
2019-03-06 14:39:02 +01:00
\strong{Intelligent rules} \cr
This function uses intelligent rules to help getting fast and logical results. It tries to find matches in this order:
2018-10-31 12:10:49 +01:00
\itemize{
2018-11-24 20:25:09 +01:00
\item{Valid MO codes and full names: it first searches in already valid MO code and known genus/species combinations}
2019-03-12 12:19:27 +01:00
\item{Human pathogenic prevalence: it first searches in more prevalent microorganisms, then less prevalent ones (see \emph{Microbial prevalence of pathogens in humans} below)}
2019-03-18 14:29:41 +01:00
\item{Taxonomic kingdom: it first searches in Bacteria/Chromista, then Fungi, then Protozoa}
2018-10-31 12:10:49 +01:00
\item{Breakdown of input values: from here it starts to breakdown input values to find possible matches}
}
2018-12-07 12:04:55 +01:00
A couple of effects because of these rules:
2018-07-23 14:14:03 +02:00
\itemize{
\item{\code{"E. coli"} will return the ID of \emph{Escherichia coli} and not \emph{Entamoeba coli}, although the latter would alphabetically come first}
\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}}
2018-07-23 14:14:03 +02:00
}
2019-02-28 13:56:28 +01:00
This means that looking up human pathogenic microorganisms takes less time than looking up human non-pathogenic microorganisms.
2018-09-24 23:33:29 +02:00
2019-02-28 13:56:28 +01:00
\strong{Uncertain results} \cr
2019-03-26 14:24:03 +01:00
The algorithm can additionally use three different levels of uncertainty to guess valid results. The default is \code{allow_uncertain = TRUE}, which is equal to uncertainty level 2. Using \code{allow_uncertain = FALSE} will skip all of these additional rules:
2019-02-08 16:06:54 +01:00
\itemize{
2019-03-12 12:19:27 +01:00
\item{(uncertainty level 1): It tries to look for only matching genera}
\item{(uncertainty level 1): It tries to look for previously accepted (but now invalid) taxonomic names}
\item{(uncertainty level 2): It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
\item{(uncertainty level 2): It strips off words from the end one by one and re-evaluates the input with all previous rules}
\item{(uncertainty level 3): It strips off words from the start one by one and re-evaluates the input with all previous rules}
\item{(uncertainty level 3): It tries any part of the name}
2019-02-08 16:06:54 +01:00
}
2019-03-12 12:19:27 +01:00
You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty.
2019-02-08 16:06:54 +01:00
Examples:
2018-12-07 12:04:55 +01:00
\itemize{
2019-02-18 02:33:37 +01:00
\item{\code{"Streptococcus group B (known as S. agalactiae)"}. The text between brackets will be removed and a warning will be thrown that the result \emph{Streptococcus group B} (\code{B_STRPT_GRB}) needs review.}
2018-12-07 12:04:55 +01:00
\item{\code{"S. aureus - please mind: MRSA"}. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result \emph{Staphylococcus aureus} (\code{B_STPHY_AUR}) needs review.}
2019-02-08 16:06:54 +01:00
\item{\code{"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 \emph{Neisseria gonorrhoeae} (\code{B_NESSR_GON}) needs review.}
2018-12-07 12:04:55 +01:00
}
2019-02-08 16:06:54 +01:00
Use \code{mo_failures()} to get a vector with all values that could not be coerced to a valid value.
2019-02-28 13:56:28 +01:00
Use \code{mo_uncertainties()} to get a data.frame with all values that were coerced to a valid value, but with uncertainty.
2019-02-08 16:06:54 +01:00
Use \code{mo_renamed()} to get a vector with all values that could be coerced based on an old, previously accepted taxonomic name.
2019-02-25 10:42:57 +01:00
2019-02-28 13:56:28 +01:00
\strong{Microbial prevalence of pathogens in humans} \cr
2019-03-12 12:19:27 +01:00
The intelligent rules takes into account microbial prevalence of pathogens in humans. It uses three groups and all (sub)species are in only one group. These groups are:
2019-02-25 10:42:57 +01:00
\itemize{
\item{1 (most prevalent): class is Gammaproteobacteria \strong{or} genus is one of: \emph{Enterococcus}, \emph{Staphylococcus}, \emph{Streptococcus}.}
2019-02-25 15:52:32 +01:00
\item{2: phylum is one of: Proteobacteria, Firmicutes, Actinobacteria, Sarcomastigophora \strong{or} genus is one of: \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton}, \emph{Ureaplasma}.}
2019-02-25 10:42:57 +01:00
\item{3 (least prevalent): all others.}
}
Group 1 contains all common Gram negatives, like all Enterobacteriaceae and e.g. \emph{Pseudomonas} and \emph{Legionella}.
2019-02-28 13:56:28 +01:00
Group 2 probably contains all other microbial pathogens ever found in humans.
2019-02-25 10:42:57 +01:00
}
2019-01-02 23:24:07 +01:00
\section{Source}{
[1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870926. \url{https://dx.doi.org/10.1128/CMR.00109-13}
2019-03-26 14:24:03 +01:00
[2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).}. 2019. Clin Microbiol Infect. 2019 Mar 11. \url{https://doi.org/10.1016/j.cmi.2019.02.028}
2019-01-02 23:24:07 +01:00
2019-03-26 14:24:03 +01:00
[3] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 57195. \url{https://dx.doi.org/10.1084/jem.57.4.571}
[4] Catalogue of Life: Annual Checklist (public online taxonomic database), \url{www.catalogueoflife.org} (check included annual version with \code{\link{catalogue_of_life_version}()}).
2019-01-02 23:24:07 +01:00
}
2019-02-20 00:04:48 +01:00
\section{Catalogue of Life}{
2018-09-24 23:33:29 +02:00
2019-02-28 13:56:28 +01:00
\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.
2018-10-01 11:39:43 +02:00
2019-02-28 13:56:28 +01:00
\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}()}.
2018-09-24 23:33:29 +02:00
}
2019-01-02 23:24:07 +01:00
\section{Read more on our website!}{
2018-09-24 23:33:29 +02:00
2019-01-29 20:20:09 +01:00
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}.
2018-07-23 14:14:03 +02:00
}
2018-09-24 23:33:29 +02:00
2018-07-23 14:14:03 +02:00
\examples{
2018-10-01 11:39:43 +02:00
# These examples all return "B_STPHY_AUR", the ID of S. aureus:
2019-03-09 08:21:00 +01:00
as.mo("sau") # WHONET code
2018-08-31 13:36:19 +02:00
as.mo("stau")
as.mo("STAU")
as.mo("staaur")
as.mo("S. aureus")
as.mo("S aureus")
as.mo("Staphylococcus aureus")
2018-12-07 12:04:55 +01:00
as.mo("Staphylococcus aureus (MRSA)")
2019-03-12 12:19:27 +01:00
as.mo("Sthafilokkockus aaureuz") # handles incorrect spelling
2018-08-31 13:36:19 +02:00
as.mo("MRSA") # Methicillin Resistant S. aureus
as.mo("VISA") # Vancomycin Intermediate S. aureus
as.mo("VRSA") # Vancomycin Resistant S. aureus
2018-07-23 14:14:03 +02:00
2019-03-18 14:29:41 +01:00
# Dyslexia is no problem - these all work:
as.mo("Ureaplasma urealyticum")
as.mo("Ureaplasma urealyticus")
as.mo("Ureaplasmium urealytica")
as.mo("Ureaplazma urealitycium")
2018-09-05 10:51:46 +02:00
as.mo("Streptococcus group A")
as.mo("GAS") # Group A Streptococci
as.mo("GBS") # Group B Streptococci
2019-01-06 20:23:49 +01:00
as.mo("S. epidermidis") # will remain species: B_STPHY_EPI
as.mo("S. epidermidis", Becker = TRUE) # will not remain species: B_STPHY_CNS
2019-02-18 02:33:37 +01:00
as.mo("S. pyogenes") # will remain species: B_STRPT_PYO
as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRA
2019-03-18 14:29:41 +01:00
# All mo_* functions use as.mo() internally too (see ?mo_property):
2018-09-24 23:33:29 +02:00
mo_genus("E. coli") # returns "Escherichia"
2019-03-18 14:29:41 +01:00
mo_gramstain("E. coli") # returns "Gram negative"#'
2018-07-23 14:14:03 +02:00
\dontrun{
2018-08-31 13:36:19 +02:00
df$mo <- as.mo(df$microorganism_name)
2018-07-23 14:14:03 +02:00
# the select function of tidyverse is also supported:
library(dplyr)
2018-08-31 13:36:19 +02:00
df$mo <- df \%>\%
2018-07-23 14:14:03 +02:00
select(microorganism_name) \%>\%
2018-11-24 20:25:09 +01:00
as.mo()
2018-07-23 14:14:03 +02:00
# and can even contain 2 columns, which is convenient for genus/species combinations:
2018-08-31 13:36:19 +02:00
df$mo <- df \%>\%
2018-07-23 14:14:03 +02:00
select(genus, species) \%>\%
2018-11-24 20:25:09 +01:00
as.mo()
# although this works easier and does the same:
2018-07-23 14:14:03 +02:00
df <- df \%>\%
2018-11-24 20:25:09 +01:00
mutate(mo = as.mo(paste(genus, species)))
2018-07-23 14:14:03 +02:00
}
}
\seealso{
2019-02-20 00:04:48 +01:00
\code{\link{microorganisms}} for the \code{data.frame} that is being used to determine ID's. \cr
2018-09-24 23:33:29 +02:00
The \code{\link{mo_property}} functions (like \code{\link{mo_genus}}, \code{\link{mo_gramstain}}) to get properties based on the returned code.
2018-07-23 14:14:03 +02:00
}
2018-08-03 14:49:29 +02:00
\keyword{Becker}
\keyword{Lancefield}
\keyword{becker}
\keyword{guess}
\keyword{lancefield}
2018-08-31 13:36:19 +02:00
\keyword{mo}