mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 09:11:51 +02:00
(v1.3.0.9014) as.mo() speed improvement
This commit is contained in:
@ -12,10 +12,10 @@ A \code{\link{data.frame}} with 500 observations and 53 variables:
|
||||
\item \code{Organism}\cr Name of the microorganism. Before analysis, you should transform this to a valid microbial class, using \code{\link[=as.mo]{as.mo()}}.
|
||||
\item \code{Country}\cr Country of origin
|
||||
\item \code{Laboratory}\cr Name of laboratory
|
||||
\item \verb{Last name}\cr Last name of patient
|
||||
\item \verb{First name}\cr Initial of patient
|
||||
\item \code{Sex}\cr Gender of patient
|
||||
\item \code{Age}\cr Age of patient
|
||||
\item \verb{Last name}\cr Fictitious last name of patient
|
||||
\item \verb{First name}\cr Fictitious initial of patient
|
||||
\item \code{Sex}\cr Fictitious gender of patient
|
||||
\item \code{Age}\cr Fictitious age of patient
|
||||
\item \verb{Age category}\cr Age group, can also be looked up using \code{\link[=age_groups]{age_groups()}}
|
||||
\item \verb{Date of admission}\cr Date of hospital admission
|
||||
\item \verb{Specimen date}\cr Date when specimen was received at laboratory
|
||||
@ -39,7 +39,7 @@ A \code{\link{data.frame}} with 500 observations and 53 variables:
|
||||
WHONET
|
||||
}
|
||||
\description{
|
||||
This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \link{example_isolates} data set.
|
||||
This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are based on our \link{example_isolates} data set. All patient names are created using online surname generators and are only in place for practice purposes.
|
||||
}
|
||||
\section{Reference data publicly available}{
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
\alias{ab_ddd}
|
||||
\alias{ab_info}
|
||||
\alias{ab_url}
|
||||
\title{Property of an antibiotic}
|
||||
\title{Get properties of an antibiotic}
|
||||
\usage{
|
||||
ab_name(x, language = get_locale(), tolower = FALSE, ...)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
\alias{as.ab}
|
||||
\alias{ab}
|
||||
\alias{is.ab}
|
||||
\title{Transform to antibiotic ID}
|
||||
\title{Transform input to an antibiotic ID}
|
||||
\usage{
|
||||
as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...)
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
\alias{as.disk}
|
||||
\alias{disk}
|
||||
\alias{is.disk}
|
||||
\title{Class 'disk'}
|
||||
\title{Transform input to disk diffusion diameters}
|
||||
\usage{
|
||||
as.disk(x, na.rm = FALSE)
|
||||
|
||||
@ -19,7 +19,7 @@ is.disk(x)
|
||||
An \code{\link{integer}} with additional new class \code{\link{disk}}
|
||||
}
|
||||
\description{
|
||||
This transforms a vector to a new class \code{\link{disk}}, which is a growth zone size (around an antibiotic disk) in millimetres between 6 and 50.
|
||||
This transforms a vector to a new class \code{\link{disk}}, which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50.
|
||||
}
|
||||
\details{
|
||||
Interpret disk values as RSI values with \code{\link[=as.rsi]{as.rsi()}}. It supports guidelines from EUCAST and CLSI.
|
||||
|
@ -4,7 +4,7 @@
|
||||
\alias{as.mic}
|
||||
\alias{mic}
|
||||
\alias{is.mic}
|
||||
\title{Class 'mic'}
|
||||
\title{Transform input to minimum inhibitory concentrations}
|
||||
\usage{
|
||||
as.mic(x, na.rm = FALSE)
|
||||
|
||||
@ -19,7 +19,7 @@ is.mic(x)
|
||||
Ordered \code{\link{factor}} with new class \code{\link{mic}}
|
||||
}
|
||||
\description{
|
||||
This transforms a vector to a new class \code{\link{mic}}, which is an ordered \code{\link{factor}} with valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning.
|
||||
This transforms a vector to a new class \code{\link{mic}}, which is an ordered \code{\link{factor}} with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as \code{NA} with a warning.
|
||||
}
|
||||
\details{
|
||||
To interpret MIC values as RSI values, use \code{\link[=as.rsi]{as.rsi()}} on MIC values. It supports guidelines from EUCAST and CLSI.
|
||||
|
15
man/as.mo.Rd
15
man/as.mo.Rd
@ -7,7 +7,7 @@
|
||||
\alias{mo_failures}
|
||||
\alias{mo_uncertainties}
|
||||
\alias{mo_renamed}
|
||||
\title{Transform to microorganism ID}
|
||||
\title{Transform input to a microorganism ID}
|
||||
\usage{
|
||||
as.mo(
|
||||
x,
|
||||
@ -15,6 +15,7 @@ as.mo(
|
||||
Lancefield = FALSE,
|
||||
allow_uncertain = TRUE,
|
||||
reference_df = get_mo_source(),
|
||||
ignore_pattern = getOption("AMR_ignore_pattern"),
|
||||
...
|
||||
)
|
||||
|
||||
@ -41,6 +42,8 @@ This excludes \emph{Enterococci} at default (who are in group D), use \code{Lanc
|
||||
|
||||
\item{reference_df}{a \code{\link{data.frame}} to be used for extra reference when translating \code{x} to a valid \code{\link{mo}}. See \code{\link[=set_mo_source]{set_mo_source()}} and \code{\link[=get_mo_source]{get_mo_source()}} to automate the usage of your own codes (e.g. used in your analysis or organisation).}
|
||||
|
||||
\item{ignore_pattern}{a regular expression (case-insensitive) of which all matches in \code{x} must return \code{NA}. This can be convenient to exclude known non-relevant input and can also be set with the option \code{AMR_ignore_pattern}, e.g. \code{options(AMR_ignore_pattern = "(not reported|contaminated flora)")}.}
|
||||
|
||||
\item{...}{other parameters passed on to functions}
|
||||
}
|
||||
\value{
|
||||
@ -52,17 +55,17 @@ Use this function to determine a valid microorganism ID (\code{\link{mo}}). Dete
|
||||
\details{
|
||||
\subsection{General info}{
|
||||
|
||||
A microorganism ID from this package (class: \code{\link{mo}}) typically looks like these examples:\preformatted{ Code Full name
|
||||
A microorganism ID from this package (class: \code{\link{mo}}) is human readable and typically looks like these examples:\preformatted{ Code Full name
|
||||
--------------- --------------------------------------
|
||||
B_KLBSL Klebsiella
|
||||
B_KLBSL_PNMN Klebsiella pneumoniae
|
||||
B_KLBSL_PNMN_RHNS Klebsiella pneumoniae rhinoscleromatis
|
||||
| | | |
|
||||
| | | |
|
||||
| | | ---> subspecies, a 4-5 letter acronym
|
||||
| | ----> species, a 4-5 letter acronym
|
||||
| ----> genus, a 5-7 letter acronym
|
||||
----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
|
||||
| | | \\---> subspecies, a 4-5 letter acronym
|
||||
| | \\----> species, a 4-5 letter acronym
|
||||
| \\----> genus, a 5-7 letter acronym
|
||||
\\----> taxonomic kingdom: A (Archaea), AN (Animalia), B (Bacteria),
|
||||
C (Chromista), F (Fungi), P (Protozoa)
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
\alias{as.rsi.mic}
|
||||
\alias{as.rsi.disk}
|
||||
\alias{as.rsi.data.frame}
|
||||
\title{Class 'rsi'}
|
||||
\title{Interpret MIC and disk, or clean raw R/SI data}
|
||||
\usage{
|
||||
as.rsi(x, ...)
|
||||
|
||||
|
@ -33,8 +33,6 @@ atc_online_ddd(atc_code, ...)
|
||||
}
|
||||
\description{
|
||||
Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic) like name, defined daily dose (DDD) or standard unit.
|
||||
|
||||
\strong{This function requires an internet connection.}
|
||||
}
|
||||
\details{
|
||||
Options for parameter \code{administration}:
|
||||
@ -62,11 +60,15 @@ Abbreviations of return values when using \code{property = "U"} (unit):
|
||||
\item \code{"mmol"} = millimole
|
||||
\item \code{"ml"} = milliliter (e.g. eyedrops)
|
||||
}
|
||||
}
|
||||
\section{Questioning lifecycle}{
|
||||
|
||||
\if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:5px} \cr}
|
||||
The \link[=lifecycle]{lifecycle} of this function is \strong{questioning}. This function might be no longer be optimal approach, or is it questionable whether this function should be in this \code{AMR} package at all.
|
||||
\strong{N.B. This function requires an internet connection and only works if the following packages are installed: \code{curl}, \code{rvest}, \code{xml2}.}
|
||||
}
|
||||
\section{Stable lifecycle}{
|
||||
|
||||
\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr}
|
||||
The \link[=lifecycle]{lifecycle} of this function is \strong{stable}. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.
|
||||
|
||||
If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
|
@ -62,8 +62,6 @@ Determine antimicrobial resistance (AMR) of all bug-drug combinations in your da
|
||||
}
|
||||
\details{
|
||||
The function \code{\link[=format]{format()}} calculates the resistance per bug-drug combination. Use \code{combine_IR = FALSE} (default) to test R vs. S+I and \code{combine_IR = TRUE} to test R+I vs. S.
|
||||
|
||||
The language of the output can be overwritten with \code{options(AMR_locale)}, please see \link{translate}.
|
||||
}
|
||||
\section{Stable lifecycle}{
|
||||
|
||||
|
@ -31,7 +31,7 @@ Convenient wrapper around \code{\link[=grep]{grep()}} to match a pattern: \code{
|
||||
\details{
|
||||
The \verb{\%like\%} function:
|
||||
\itemize{
|
||||
\item Is case insensitive (use \verb{\%like_case\%} for case-sensitive matching)
|
||||
\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching)
|
||||
\item Supports multiple patterns
|
||||
\item Checks if \code{pattern} is a regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed
|
||||
\item Tries again with \code{perl = TRUE} if regex fails
|
||||
@ -75,5 +75,5 @@ example_isolates \%>\%
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
\code{\link[base:grep]{base::grep()}}
|
||||
\code{\link[=grep]{grep()}}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
\docType{data}
|
||||
\name{microorganisms.codes}
|
||||
\alias{microorganisms.codes}
|
||||
\title{Translation table with 5,583 common microorganism codes}
|
||||
\title{Data set with 5,583 common microorganism codes}
|
||||
\format{
|
||||
A \code{\link{data.frame}} with 5,583 observations and 2 variables:
|
||||
\itemize{
|
||||
|
@ -25,7 +25,7 @@
|
||||
\alias{mo_synonyms}
|
||||
\alias{mo_info}
|
||||
\alias{mo_url}
|
||||
\title{Property of a microorganism}
|
||||
\title{Get properties of a microorganism}
|
||||
\usage{
|
||||
mo_name(x, language = get_locale(), ...)
|
||||
|
||||
@ -78,9 +78,9 @@ mo_property(x, property = "fullname", language = get_locale(), ...)
|
||||
\arguments{
|
||||
\item{x}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}}
|
||||
|
||||
\item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can also be set with \code{getOption("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
|
||||
\item{language}{language of the returned text, defaults to system language (see \code{\link[=get_locale]{get_locale()}}) and can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}, see \link{translate}. Use \code{language = NULL} or \code{language = ""} to prevent translation.}
|
||||
|
||||
\item{...}{other parameters passed on to \code{\link[=as.mo]{as.mo()}}}
|
||||
\item{...}{other parameters passed on to \code{\link[=as.mo]{as.mo()}}, such as 'allow_uncertain' and 'ignore_pattern'}
|
||||
|
||||
\item{open}{browse the URL using \code{\link[utils:browseURL]{utils::browseURL()}}}
|
||||
|
||||
@ -96,7 +96,7 @@ mo_property(x, property = "fullname", language = get_locale(), ...)
|
||||
}
|
||||
}
|
||||
\description{
|
||||
Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with \code{\link[=as.mo]{as.mo()}}, which makes it possible to use microbial abbreviations, codes and names as input. Please see \emph{Examples}.
|
||||
Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with \code{\link[=as.mo]{as.mo()}}, which makes it possible to use microbial abbreviations, codes and names as input. Please see \emph{Examples}.
|
||||
}
|
||||
\details{
|
||||
All functions will return the most recently known taxonomic property according to the Catalogue of Life, except for \code{\link[=mo_ref]{mo_ref()}}, \code{\link[=mo_authors]{mo_authors()}} and \code{\link[=mo_year]{mo_year()}}. Please refer to this example, knowing that \emph{Escherichia blattae} was renamed to \emph{Shimwellia blattae} in 2010:
|
||||
|
@ -11,15 +11,13 @@ get_locale()
|
||||
For language-dependent output of AMR functions, like \code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}} and \code{\link[=ab_name]{ab_name()}}.
|
||||
}
|
||||
\details{
|
||||
Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: \url{https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv}.
|
||||
Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: \url{https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv}. This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_property()}} functions (\code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.).
|
||||
|
||||
Currently supported languages are (besides English): Dutch, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.
|
||||
Currently supported languages are: Dutch, English, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.
|
||||
|
||||
Please suggest your own translations \href{https://github.com/msberends/AMR/issues/new?title=Translations}{by creating a new issue on our repository}.
|
||||
|
||||
This file will be read by all functions where a translated output can be desired, like all \code{\link[=mo_property]{mo_property()}} functions (\code{\link[=mo_name]{mo_name()}}, \code{\link[=mo_gramstain]{mo_gramstain()}}, \code{\link[=mo_type]{mo_type()}}, etc.).
|
||||
|
||||
The system language will be used at default, if that language is supported. The system language can be overwritten with \code{Sys.setenv(AMR_locale = yourlanguage)}.
|
||||
The system language will be used at default (as returned by \code{\link[=Sys.getlocale]{Sys.getlocale()}}), if that language is supported. The language to be used can be overwritten by setting the option \code{AMR_locale}, e.g. \code{options(AMR_locale = "de")}.
|
||||
}
|
||||
\section{Stable lifecycle}{
|
||||
|
||||
|
Reference in New Issue
Block a user