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

AI improvements

This commit is contained in:
2018-12-07 12:04:55 +01:00
parent 87ad6da745
commit 8e8a9cd190
19 changed files with 199 additions and 140 deletions

View File

@ -7,13 +7,13 @@
\alias{guess_mo}
\title{Transform to microorganism ID}
\usage{
as.mo(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = FALSE,
as.mo(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
reference_df = NULL)
is.mo(x)
guess_mo(x, Becker = FALSE, Lancefield = FALSE,
allow_uncertain = FALSE, reference_df = NULL)
allow_uncertain = TRUE, reference_df = NULL)
}
\arguments{
\item{x}{a character vector or a \code{data.frame} with one or two columns}
@ -26,7 +26,7 @@ guess_mo(x, Becker = FALSE, Lancefield = 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{allow_uncertain}{a logical to indicate whether empty results should be checked for only a part of the input string. When results are found, a warning will be given about the uncertainty and the result.}
\item{allow_uncertain}{a logical to indicate whether the input should be checked for less possible results, see Details}
\item{reference_df}{a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid \code{mo} as found in the \code{\link{microorganisms}} data set.}
}
@ -39,11 +39,11 @@ Use this function to determine a valid microorganism ID (\code{mo}). Determinati
\details{
A microbial ID from this package (class: \code{mo}) typically looks like these examples:\cr
\preformatted{
Code Full name
--------------- --------------------------------------
B_KLBSL Klebsiella
B_KLBSL_PNE Klebsiella pneumoniae
B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
Code Full name
--------------- --------------------------------------
B_KLBSL Klebsiella
B_KLBSL_PNE Klebsiella pneumoniae
B_KLBSL_PNE_RHI Klebsiella pneumoniae rhinoscleromatis
| | | |
| | | |
| | | ----> subspecies, a 3-4 letter acronym
@ -62,7 +62,7 @@ This function uses Artificial Intelligence (AI) to help getting fast and logical
\item{Breakdown of input values: from here it starts to breakdown input values to find possible matches}
}
A couple of effects because of these rules
A couple of effects because of these rules:
\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}
@ -71,6 +71,13 @@ A couple of effects because of these rules
}
This means that looking up human pathogenic microorganisms takes less time than looking up human \strong{non}-pathogenic microorganisms.
When using \code{allow_uncertain = TRUE} (which is the default setting), it will use additional rules if all previous AI rules failed to get valid results. Examples:
\itemize{
\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_STRPTC_GRB}) needs review.}
\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.}
\item{\code{"D. spartina"}. This is the abbreviation of an old taxonomic name: \emph{Didymosphaeria spartinae} (the last "e" was missing from the input). This fungus was renamed to \emph{Leptosphaeria obiones}, so a warning will be thrown that this result (\code{F_LPTSP_OBI}) needs review.}
}
\code{guess_mo} is an alias of \code{as.mo}.
}
\section{ITIS}{
@ -100,6 +107,7 @@ as.mo("staaur")
as.mo("S. aureus")
as.mo("S aureus")
as.mo("Staphylococcus aureus")
as.mo("Staphylococcus aureus (MRSA)")
as.mo("MRSA") # Methicillin Resistant S. aureus
as.mo("VISA") # Vancomycin Intermediate S. aureus
as.mo("VRSA") # Vancomycin Resistant S. aureus

View File

@ -36,8 +36,12 @@ plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies
freq(rsi_data) # frequency table with informative header
# fastest way to transform all columns with already valid AB results to class `rsi`:
# using dplyr's mutate
library(dplyr)
septic_patients \%>\%
mutate_at(vars(peni:rifa), as.rsi)
# fastest way to transform all columns with already valid AB results to class `rsi`:
septic_patients \%>\%
mutate_if(is.rsi.eligible,
as.rsi)

View File

@ -57,7 +57,7 @@ interpretive_reading(...)
\item{verbose}{a logical to indicate whether extensive info should be returned as a \code{data.frame} with info about which rows and columns are effected}
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, oxac, peni, pipe, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic, see Details}
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, oxac, peni, pipe, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic, see Antibiotics}
\item{col_bactid}{deprecated, use \code{col_mo} instead.}
@ -69,11 +69,10 @@ The input of \code{tbl}, possibly with edited values of antibiotics. Or, if \cod
\description{
Apply susceptibility rules as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}. This includes (1) expert rules, (2) intrinsic resistance and (3) inferred resistance as defined in their breakpoint tables.
}
\details{
To define antibiotics column names, input a text or use \code{NA} to skip a column (e.g. \code{tica = NA}). Non-existing columns will anyway be skipped with a warning. See the Antibiotics section for an explanation of the abbreviations.
}
\section{Antibiotics}{
To define antibiotics column names, input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning.
Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code})
\strong{amcl}: amoxicillin+clavulanic acid (\emph{J01CR02}),

View File

@ -40,125 +40,125 @@ eucast_exceptional_phenotypes(tbl, country = "EUCAST", ...)
\item{info}{print progress}
\item{amcl}{column name of an antibiotic, see Details}
\item{amcl}{column name of an antibiotic, see Antibiotics}
\item{amik}{column name of an antibiotic, see Details}
\item{amik}{column name of an antibiotic, see Antibiotics}
\item{amox}{column name of an antibiotic, see Details}
\item{amox}{column name of an antibiotic, see Antibiotics}
\item{ampi}{column name of an antibiotic, see Details}
\item{ampi}{column name of an antibiotic, see Antibiotics}
\item{azit}{column name of an antibiotic, see Details}
\item{azit}{column name of an antibiotic, see Antibiotics}
\item{aztr}{column name of an antibiotic, see Details}
\item{aztr}{column name of an antibiotic, see Antibiotics}
\item{cefa}{column name of an antibiotic, see Details}
\item{cefa}{column name of an antibiotic, see Antibiotics}
\item{cfra}{column name of an antibiotic, see Details}
\item{cfra}{column name of an antibiotic, see Antibiotics}
\item{cfep}{column name of an antibiotic, see Details}
\item{cfep}{column name of an antibiotic, see Antibiotics}
\item{cfot}{column name of an antibiotic, see Details}
\item{cfot}{column name of an antibiotic, see Antibiotics}
\item{cfox}{column name of an antibiotic, see Details}
\item{cfox}{column name of an antibiotic, see Antibiotics}
\item{cfta}{column name of an antibiotic, see Details}
\item{cfta}{column name of an antibiotic, see Antibiotics}
\item{cftr}{column name of an antibiotic, see Details}
\item{cftr}{column name of an antibiotic, see Antibiotics}
\item{cfur}{column name of an antibiotic, see Details}
\item{cfur}{column name of an antibiotic, see Antibiotics}
\item{chlo}{column name of an antibiotic, see Details}
\item{chlo}{column name of an antibiotic, see Antibiotics}
\item{cipr}{column name of an antibiotic, see Details}
\item{cipr}{column name of an antibiotic, see Antibiotics}
\item{clar}{column name of an antibiotic, see Details}
\item{clar}{column name of an antibiotic, see Antibiotics}
\item{clin}{column name of an antibiotic, see Details}
\item{clin}{column name of an antibiotic, see Antibiotics}
\item{clox}{column name of an antibiotic, see Details}
\item{clox}{column name of an antibiotic, see Antibiotics}
\item{coli}{column name of an antibiotic, see Details}
\item{coli}{column name of an antibiotic, see Antibiotics}
\item{czol}{column name of an antibiotic, see Details}
\item{czol}{column name of an antibiotic, see Antibiotics}
\item{dapt}{column name of an antibiotic, see Details}
\item{dapt}{column name of an antibiotic, see Antibiotics}
\item{doxy}{column name of an antibiotic, see Details}
\item{doxy}{column name of an antibiotic, see Antibiotics}
\item{erta}{column name of an antibiotic, see Details}
\item{erta}{column name of an antibiotic, see Antibiotics}
\item{eryt}{column name of an antibiotic, see Details}
\item{eryt}{column name of an antibiotic, see Antibiotics}
\item{fosf}{column name of an antibiotic, see Details}
\item{fosf}{column name of an antibiotic, see Antibiotics}
\item{fusi}{column name of an antibiotic, see Details}
\item{fusi}{column name of an antibiotic, see Antibiotics}
\item{gent}{column name of an antibiotic, see Details}
\item{gent}{column name of an antibiotic, see Antibiotics}
\item{imip}{column name of an antibiotic, see Details}
\item{imip}{column name of an antibiotic, see Antibiotics}
\item{kana}{column name of an antibiotic, see Details}
\item{kana}{column name of an antibiotic, see Antibiotics}
\item{levo}{column name of an antibiotic, see Details}
\item{levo}{column name of an antibiotic, see Antibiotics}
\item{linc}{column name of an antibiotic, see Details}
\item{linc}{column name of an antibiotic, see Antibiotics}
\item{line}{column name of an antibiotic, see Details}
\item{line}{column name of an antibiotic, see Antibiotics}
\item{mero}{column name of an antibiotic, see Details}
\item{mero}{column name of an antibiotic, see Antibiotics}
\item{metr}{column name of an antibiotic. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
\item{metr}{column name of an antibiotic, see Antibiotics}
\item{mino}{column name of an antibiotic, see Details}
\item{mino}{column name of an antibiotic, see Antibiotics}
\item{moxi}{column name of an antibiotic, see Details}
\item{moxi}{column name of an antibiotic, see Antibiotics}
\item{nali}{column name of an antibiotic, see Details}
\item{nali}{column name of an antibiotic, see Antibiotics}
\item{neom}{column name of an antibiotic, see Details}
\item{neom}{column name of an antibiotic, see Antibiotics}
\item{neti}{column name of an antibiotic, see Details}
\item{neti}{column name of an antibiotic, see Antibiotics}
\item{nitr}{column name of an antibiotic, see Details}
\item{nitr}{column name of an antibiotic, see Antibiotics}
\item{novo}{column name of an antibiotic, see Details}
\item{novo}{column name of an antibiotic, see Antibiotics}
\item{norf}{column name of an antibiotic, see Details}
\item{norf}{column name of an antibiotic, see Antibiotics}
\item{oflo}{column name of an antibiotic, see Details}
\item{oflo}{column name of an antibiotic, see Antibiotics}
\item{peni}{column name of an antibiotic, see Details}
\item{peni}{column name of an antibiotic, see Antibiotics}
\item{pipe}{column name of an antibiotic, see Details}
\item{pipe}{column name of an antibiotic, see Antibiotics}
\item{pita}{column name of an antibiotic, see Details}
\item{pita}{column name of an antibiotic, see Antibiotics}
\item{poly}{column name of an antibiotic, see Details}
\item{poly}{column name of an antibiotic, see Antibiotics}
\item{qida}{column name of an antibiotic, see Details}
\item{qida}{column name of an antibiotic, see Antibiotics}
\item{rifa}{column name of an antibiotic, see Details}
\item{rifa}{column name of an antibiotic, see Antibiotics}
\item{roxi}{column name of an antibiotic, see Details}
\item{roxi}{column name of an antibiotic, see Antibiotics}
\item{siso}{column name of an antibiotic, see Details}
\item{siso}{column name of an antibiotic, see Antibiotics}
\item{teic}{column name of an antibiotic, see Details}
\item{teic}{column name of an antibiotic, see Antibiotics}
\item{tetr}{column name of an antibiotic, see Details}
\item{tetr}{column name of an antibiotic, see Antibiotics}
\item{tica}{column name of an antibiotic, see Details}
\item{tica}{column name of an antibiotic, see Antibiotics}
\item{tige}{column name of an antibiotic, see Details}
\item{tige}{column name of an antibiotic, see Antibiotics}
\item{tobr}{column name of an antibiotic, see Details}
\item{tobr}{column name of an antibiotic, see Antibiotics}
\item{trim}{column name of an antibiotic, see Details}
\item{trim}{column name of an antibiotic, see Antibiotics}
\item{trsu}{column name of an antibiotic, see Details}
\item{trsu}{column name of an antibiotic, see Antibiotics}
\item{vanc}{column name of an antibiotic, see Details}
\item{vanc}{column name of an antibiotic, see Antibiotics}
\item{col_bactid}{deprecated, use \code{col_mo} instead.}
@ -175,6 +175,8 @@ When \code{country} will be left blank, guidelines will be taken from EUCAST Exp
}
\section{Antibiotics}{
To define antibiotics column names, input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning.
Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code})
\strong{amcl}: amoxicillin+clavulanic acid (\emph{J01CR02}),