1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 00:02:38 +02:00

new class bactid

This commit is contained in:
2018-07-23 14:14:03 +02:00
parent 40de1b4ac2
commit 8421638b60
21 changed files with 408 additions and 251 deletions

69
man/as.bactid.Rd Normal file
View File

@ -0,0 +1,69 @@
% 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.
}

View File

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/first_isolates.R
% Please edit documentation in R/first_isolate.R
\name{first_isolate}
\alias{first_isolate}
\title{Determine first (weighted) isolates}
@ -21,7 +21,7 @@ first_isolate(tbl, col_date, col_patient_id, col_bactid = NA,
\item{col_patient_id}{column name of the unique IDs of the patients}
\item{col_bactid}{column name of the unique IDs of the microorganisms (should occur in the \code{\link{microorganisms}} dataset). Get your bactid's with the function \code{\link{guess_bactid}}, that takes microorganism names as input.}
\item{col_bactid}{column name of the unique IDs of the microorganisms: \code{bactid}'s. If this column has another class than \code{"bactid"}, values will be coerced using \code{\link{as.bactid}}.}
\item{col_testcode}{column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.}

View File

@ -1,43 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/guess_bactid.R
\name{guess_bactid}
\alias{guess_bactid}
\title{Find bacteria ID based on genus/species}
\usage{
guess_bactid(x)
}
\arguments{
\item{x}{character vector or a dataframe with one or two columns}
}
\value{
Character (vector).
}
\description{
Use this function to determine a valid ID based on a genus (and species). This input could 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.
}
\examples{
# These examples all return "STAAUR", the ID of S. aureus:
guess_bactid("stau")
guess_bactid("STAU")
guess_bactid("staaur")
guess_bactid("S. aureus")
guess_bactid("S aureus")
guess_bactid("Staphylococcus aureus")
guess_bactid("MRSA") # Methicillin-resistant S. aureus
guess_bactid("VISA") # Vancomycin Intermediate S. aureus
\dontrun{
df$bactid <- guess_bactid(df$microorganism_name)
# the select function of tidyverse is also supported:
df$bactid <- df \%>\% select(microorganism_name) \%>\% guess_bactid()
# and can even contain 2 columns, which is convenient for genus/species combinations:
df$bactid <- df \%>\% select(genus, species) \%>\% guess_bactid()
# same result:
df <- df \%>\% mutate(bactid = paste(genus, species)) \%>\% guess_bactid())
}
}
\seealso{
\code{\link{microorganisms}} for the dataframe that is being used to determine ID's.
}

View File

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/join.R
% Please edit documentation in R/join_microorganisms.R
\name{join}
\alias{join}
\alias{inner_join_microorganisms}

View File

@ -19,7 +19,7 @@ key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"),
\arguments{
\item{tbl}{table with antibiotics coloms, like \code{amox} and \code{amcl}.}
\item{col_bactid}{column name of the unique IDs of the microorganisms (should occur in the \code{\link{microorganisms}} dataset). Get your bactid's with the function \code{\link{guess_bactid}}, that takes microorganism names as input.}
\item{col_bactid}{column name of the unique IDs of the microorganisms: \code{bactid}'s. If this column has another class than \code{"bactid"}, values will be coerced using \code{\link{as.bactid}}.}
\item{universal_1, universal_2, universal_3, universal_4, universal_5, universal_6}{column names of \strong{broad-spectrum} antibiotics, case-insensitive}