mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 06:06:12 +01:00
70 lines
2.5 KiB
R
70 lines
2.5 KiB
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/bactid.R
|
|
\name{as.bactid}
|
|
\alias{as.bactid}
|
|
\alias{guess_bactid}
|
|
\alias{is.bactid}
|
|
\title{Transform to bacteria ID}
|
|
\usage{
|
|
as.bactid(x)
|
|
|
|
guess_bactid(x)
|
|
|
|
is.bactid(x)
|
|
}
|
|
\arguments{
|
|
\item{x}{a character vector or a dataframe with one or two columns}
|
|
}
|
|
\value{
|
|
Character (vector) with class \code{"bactid"}. Unknown values will return \code{NA}.
|
|
}
|
|
\description{
|
|
Use this function to determine a valid ID based on a genus (and species). This input can be a full name (like \code{"Staphylococcus aureus"}), an abbreviated name (like \code{"S. aureus"}), or just a genus. You could also \code{\link{select}} a genus and species column, zie Examples.
|
|
}
|
|
\details{
|
|
Some exceptions have been built in to get more logical results, based on prevalence of human pathogens. For example:
|
|
\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}}
|
|
\item{Something like \code{"p aer"} will return the ID of \emph{Pseudomonas aeruginosa} and not \emph{Pasteurella aerogenes}}
|
|
\item{Something like \code{"stau"} or \code{"staaur"} will return the ID of \emph{Staphylococcus aureus} and not \emph{Staphylococcus auricularis}}
|
|
}
|
|
Moreover, this function also supports ID's based on only Gram stain, when the species is not known. \cr
|
|
For example, \code{"Gram negative rods"} and \code{"GNR"} will both return the ID of a Gram negative rod: \code{GNR}.
|
|
}
|
|
\examples{
|
|
# These examples all return "STAAUR", the ID of S. aureus:
|
|
as.bactid("stau")
|
|
as.bactid("STAU")
|
|
as.bactid("staaur")
|
|
as.bactid("S. aureus")
|
|
as.bactid("S aureus")
|
|
as.bactid("Staphylococcus aureus")
|
|
as.bactid("MRSA") # Methicillin Resistant S. aureus
|
|
as.bactid("VISA") # Vancomycin Intermediate S. aureus
|
|
as.bactid("VRSA") # Vancomycin Resistant S. aureus
|
|
|
|
\dontrun{
|
|
df$bactid <- as.bactid(df$microorganism_name)
|
|
|
|
# the select function of tidyverse is also supported:
|
|
library(dplyr)
|
|
df$bactid <- df \%>\%
|
|
select(microorganism_name) \%>\%
|
|
as.bactid()
|
|
|
|
# and can even contain 2 columns, which is convenient for genus/species combinations:
|
|
df$bactid <- df \%>\%
|
|
select(genus, species) \%>\%
|
|
as.bactid()
|
|
|
|
# same result:
|
|
df <- df \%>\%
|
|
mutate(bactid = paste(genus, species) \%>\%
|
|
as.bactid())
|
|
}
|
|
}
|
|
\seealso{
|
|
\code{\link{microorganisms}} for the dataframe that is being used to determine ID's.
|
|
}
|