NEWS.md
- logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to TRUE
will take considerably more time than when using FALSE
. At default, it will turn TRUE
when all input elements contain a maximum of three words.
logical to indicate whether a progress bar should be printed, defaults to TRUE
only in interactive mode
arguments passed on to as.ab()
Use this function to determine the antibiotic code of one or more antibiotics. The data set antibiotics will be searched for abbreviations, official names and synonyms (brand names).
-as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...) +as.ab(x, flag_multiple_results = TRUE, info = interactive(), ...) is.ab(x)@@ -259,7 +259,7 @@
logical to indicate whether a progress bar should be printed
a logical to indicate whether a progress bar should be printed, defaults to TRUE
only in interactive mode
language to translate text like "no growth", which defaults to the system language (see get_locale()
)
a logical to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to TRUE
only in interactive mode
other arguments passed on to functions
R/custom_eucast_rules.R
custom_eucast_rules.Rd
Create Custom EUCAST Rules
+Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in eucast_rules()
.
custom_eucast_rules(...)@@ -253,21 +253,97 @@
A list containing the custom rules
This documentation page will be updated shortly. This function is experimental.
+Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the eucast_rules()
function.
..
-It is also possible to define antibiotic groups instead of single antibiotics. The following groups are allowed (case-insensitive): aminoglycosides
, aminopenicillins
, betalactams
, carbapenems
, cephalosporins
, cephalosporins_1st
, cephalosporins_2nd
, cephalosporins_3rd
, cephalosporins_except_caz
, fluoroquinolones
, glycopeptides
, glycopeptides_except_lipo
, lincosamides
, lipoglycopeptides
, macrolides
, oxazolidinones
, penicillins
, polymyxins
, streptogramins
, tetracyclines
, tetracyclines_except_tgc
and ureidopenicillins
.
If you are familiar with the case_when()
function of the dplyr
package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation'. The rule itself is written before the tilde (~
) and the consequence of the rule is written after the tilde:
x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S", + TZP == "R" ~ aminopenicillins == "R") ++ +
These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:
x +#> A set of custom EUCAST rules: +#> +#> 1. If TZP is S then set to S: +#> amoxicillin (AMX), ampicillin (AMP) +#> +#> 2. If TZP is R then set to R: +#> amoxicillin (AMX), ampicillin (AMP) ++ +
The rules (the part before the tilde, in above example TZP == "S"
and TZP == "R"
) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column TZP
must exist. We will create a sample data set and test the rules set:
df <- data.frame(mo = c("E. coli", "K. pneumoniae"), + TZP = "R", + amox = "", + AMP = "") +df +#> mo TZP amox AMP +#> 1 E. coli R +#> 2 K. pneumoniae R + +eucast_rules(df, rules = "custom", custom_rules = x) +#> mo TZP amox AMP +#> 1 E. coli R R R +#> 2 K. pneumoniae R R R ++ + +
There is one exception in variables used for the rules: all column names of the microorganisms data set can also be used, but do not have to exist in the data set. These column names are: mo
, fullname
, kingdom
, phylum
, class
, order
, family
, genus
, species
, subspecies
, rank
, ref
, species_id
, source
, prevalence
and snomed
. Thus, this next example will work as well, despite the fact that the df
data set does not contain a column genus
:
y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S", + TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R") + +eucast_rules(df, rules = "custom", custom_rules = y) +#> mo TZP amox AMP +#> 1 E. coli R +#> 2 K. pneumoniae R R R ++ + +
It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part after the tilde. In above examples, the antibiotic group aminopenicillins
is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule.
aminoglycosides
(amikacin, amikacin/fosfomycin, amphotericin B-high, apramycin, arbekacin, astromicin, bekanamycin, dibekacin, framycetin, gentamicin, gentamicin-high, habekacin, hygromycin, isepamicin, kanamycin, kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin, pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin, streptoduocin, streptomycin, streptomycin-high, tobramycin, tobramycin-high)
aminopenicillins
(amoxicillin, ampicillin)
betalactams
(amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, biapenem, cadazolid, carbenicillin, carindacillin, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, ciclacillin, clometocillin, cloxacillin, dicloxacillin, doripenem, epicillin, ertapenem, flucloxacillin, hetacillin, imipenem, imipenem/EDTA, imipenem/relebactam, latamoxef, lenampicillin, loracarbef, mecillinam (Amdinocillin), meropenem, meropenem/nacubactam, meropenem/vaborbactam, metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, panipenem, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, razupenem, ritipenem, ritipenem acoxil, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, tebipenem, temocillin, ticarcillin, ticarcillin/clavulanic acid)
carbapenems
(biapenem, doripenem, ertapenem, imipenem, imipenem/EDTA, imipenem/relebactam, meropenem, meropenem/nacubactam, meropenem/vaborbactam, panipenem, razupenem, ritipenem, ritipenem acoxil, tebipenem)
cephalosporins
(cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef)
cephalosporins_1st
(cefacetrile, cefadroxil, cefaloridine, cefatrizine, cefazedone, cefazolin, cefroxadine, ceftezole, cephalexin, cephalothin, cephapirin, cephradine)
cephalosporins_2nd
(cefaclor, cefamandole, cefmetazole, cefonicid, ceforanide, cefotetan, cefotiam, cefoxitin, cefoxitin screening, cefprozil, cefuroxime, cefuroxime axetil, loracarbef)
cephalosporins_3rd
(cadazolid, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefetamet, cefetamet pivoxil, cefixime, cefmenoxime, cefodizime, cefoperazone, cefoperazone/sulbactam, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotiam hexetil, cefovecin, cefpimizole, cefpiramide, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefsulodin, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftriaxone, latamoxef)
cephalosporins_except_caz
(cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef)
fluoroquinolones
(ciprofloxacin, enoxacin, fleroxacin, gatifloxacin, gemifloxacin, grepafloxacin, levofloxacin, lomefloxacin, moxifloxacin, norfloxacin, ofloxacin, pazufloxacin, pefloxacin, prulifloxacin, rufloxacin, sparfloxacin, temafloxacin, trovafloxacin)
glycopeptides
(avoparcin, dalbavancin, norvancomycin, oritavancin, ramoplanin, teicoplanin, teicoplanin-macromethod, telavancin, vancomycin, vancomycin-macromethod)
glycopeptides_except_lipo
(avoparcin, norvancomycin, ramoplanin, teicoplanin, teicoplanin-macromethod, vancomycin, vancomycin-macromethod)
lincosamides
(clindamycin, lincomycin, pirlimycin)
lipoglycopeptides
(dalbavancin, oritavancin, telavancin)
macrolides
(azithromycin, clarithromycin, dirithromycin, erythromycin, flurithromycin, josamycin, midecamycin, miocamycin, oleandomycin, rokitamycin, roxithromycin, spiramycin, telithromycin, troleandomycin)
oxazolidinones
(cycloserine, linezolid, tedizolid, thiacetazone)
penicillins
(amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, carbenicillin, carindacillin, ciclacillin, clometocillin, cloxacillin, dicloxacillin, epicillin, flucloxacillin, hetacillin, lenampicillin, mecillinam (Amdinocillin), metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, temocillin, ticarcillin, ticarcillin/clavulanic acid)
polymyxins
(colistin, polymyxin B, polymyxin B/polysorbate 80)
streptogramins
(pristinamycin, quinupristin/dalfopristin)
tetracyclines
(chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline, tigecycline)
tetracyclines_except_tgc
(chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline)
ureidopenicillins
(azlocillin, mezlocillin, piperacillin, piperacillin/tazobactam)
-The lifecycle of this function is experimental. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this AMR
package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.
+The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').
x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R", diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index 867cbede..035f2330 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
print progress
a logical to indicate whether a progress bar should be printed, defaults to TRUE
only in interactive mode
Create Custom EUCAST Rules
Define Custom EUCAST Rules
print progress
a logical to indicate whether a progress bar should be printed, defaults to TRUE
only in interactive mode
A logical vector
This %like%
function:
Is case-insensitive (use %like_case%
for case-sensitive matching)
Supports multiple patterns
Checks if pattern
is a valid regular expression and sets fixed = TRUE
if not, to greatly improve speed (vectorised over pattern
)
Always uses compatibility with Perl unless fixed = TRUE
, to greatly improve speed
These like()
and %like%
functions:
Are case-insensitive (use %like_case%
for case-sensitive matching)
Support multiple patterns
Check if pattern
is a valid regular expression and sets fixed = TRUE
if not, to greatly improve speed (vectorised over pattern
)
Always use compatibility with Perl unless fixed = TRUE
, to greatly improve speed
Using RStudio? The text %like%
can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like Ctrl+Shift+L
or Cmd+Shift+L
(see Tools
> Modify Keyboard Shortcuts...
).
# simple test -a <- "This is a test" +a <- "This is a test" b <- "TEST" a %like% b #> TRUE @@ -317,12 +316,12 @@ The lifecycle of this function is stable#> TRUE FALSE FALSE # get isolates whose name start with 'Ent' or 'ent' -# \donttest{ +example_isolates[which(mo_name() %like% "^ent"), ] + if (require("dplyr")) { example_isolates %>% filter(mo_name() %like% "^ent") } -# }@@ -360,7 +360,7 @@ Ordered factor with levelsCustom guidelines can be set with the custom_mdro_guideline()
function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data. -If you are familiar with
case_when()
of thedplyr
package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation':custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A", +If you are familiar with the
case_when()
function of thedplyr
package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation'. The rule is written before the tilde (~
) and the consequence of the rule is written after the tilde:custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A", ERY == "R" & age > 60 ~ "Elderly Type B")diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index 6097226d..327fa58f 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -82,7 +82,7 @@ @@ -281,7 +281,7 @@Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect.
For example, Staphylococcus pettenkoferi was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (doi: 10.1016/s0732-8893(02)00399-1 ), but it was not before 2007 that a publication in IJSEM followed (doi: 10.1099/ijs.0.64381-0 -). Consequently, the AMR package returns 2007 for
mo_year("S. pettenkoferi")
.Manual additions
+). Consequently, theAMR
package returns 2007 formo_year("S. pettenkoferi")
.Manual additions
For convenience, some entries were added manually:
diff --git a/docs/reference/mo_matching_score.html b/docs/reference/mo_matching_score.html index fc66d1d5..d5bf2a8b 100644 --- a/docs/reference/mo_matching_score.html +++ b/docs/reference/mo_matching_score.html @@ -82,7 +82,7 @@
diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 3e824d6a..1dafa2cc 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ diff --git a/docs/survey.html b/docs/survey.html index 26cd313d..7116c788 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ diff --git a/man/ab_from_text.Rd b/man/ab_from_text.Rd index 387f0298..f66c2dcb 100644 --- a/man/ab_from_text.Rd +++ b/man/ab_from_text.Rd @@ -10,6 +10,7 @@ ab_from_text( collapse = NULL, translate_ab = FALSE, thorough_search = NULL, + info = interactive(), ... ) } @@ -24,6 +25,8 @@ ab_from_text( \item{thorough_search}{logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to \code{TRUE} will take considerably more time than when using \code{FALSE}. At default, it will turn \code{TRUE} when all input elements contain a maximum of three words.} +\item{info}{logical to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode} + \item{...}{arguments passed on to \code{\link[=as.ab]{as.ab()}}} } \value{ diff --git a/man/as.ab.Rd b/man/as.ab.Rd index 36921b3e..8815e37c 100644 --- a/man/as.ab.Rd +++ b/man/as.ab.Rd @@ -6,7 +6,7 @@ \alias{is.ab} \title{Transform Input to an Antibiotic ID} \usage{ -as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...) +as.ab(x, flag_multiple_results = TRUE, info = interactive(), ...) is.ab(x) } @@ -15,7 +15,7 @@ is.ab(x) \item{flag_multiple_results}{logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value.} -\item{info}{logical to indicate whether a progress bar should be printed} +\item{info}{a \link{logical} to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode} \item{...}{arguments passed on to internal functions} } diff --git a/man/as.mo.Rd b/man/as.mo.Rd index 061731b9..05859899 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -17,6 +17,7 @@ as.mo( reference_df = get_mo_source(), ignore_pattern = getOption("AMR_ignore_pattern"), language = get_locale(), + info = interactive(), ... ) @@ -47,6 +48,8 @@ This excludes \emph{Enterococci} at default (who are in group D), use \code{Lanc \item{language}{language to translate text like "no growth", which defaults to the system language (see \code{\link[=get_locale]{get_locale()}})} +\item{info}{a \link{logical} to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to \code{TRUE} only in interactive mode} + \item{...}{other arguments passed on to functions} } \value{ diff --git a/man/custom_eucast_rules.Rd b/man/custom_eucast_rules.Rd index 9fed0904..2a5659eb 100644 --- a/man/custom_eucast_rules.Rd +++ b/man/custom_eucast_rules.Rd @@ -2,30 +2,102 @@ % Please edit documentation in R/custom_eucast_rules.R \name{custom_eucast_rules} \alias{custom_eucast_rules} -\title{Create Custom EUCAST Rules} +\title{Define Custom EUCAST Rules} \usage{ custom_eucast_rules(...) } \arguments{ \item{...}{rules in formula notation, see \emph{Examples}} } +\value{ +A \link{list} containing the custom rules +} \description{ -Create Custom EUCAST Rules +Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in \code{\link[=eucast_rules]{eucast_rules()}}. } \details{ -This documentation page will be updated shortly. \strong{This function is experimental.} +Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the \code{\link[=eucast_rules]{eucast_rules()}} function. } \section{How it works}{ -.. +\subsection{Basics}{ -It is also possible to define antibiotic groups instead of single antibiotics. The following groups are allowed (case-insensitive): \code{aminoglycosides}, \code{aminopenicillins}, \code{betalactams}, \code{carbapenems}, \code{cephalosporins}, \code{cephalosporins_1st}, \code{cephalosporins_2nd}, \code{cephalosporins_3rd}, \code{cephalosporins_except_caz}, \code{fluoroquinolones}, \code{glycopeptides}, \code{glycopeptides_except_lipo}, \code{lincosamides}, \code{lipoglycopeptides}, \code{macrolides}, \code{oxazolidinones}, \code{penicillins}, \code{polymyxins}, \code{streptogramins}, \code{tetracyclines}, \code{tetracyclines_except_tgc} and \code{ureidopenicillins}. +If you are familiar with the \code{\link[dplyr:case_when]{case_when()}} function of the \code{dplyr} package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule itself is written \emph{before} the tilde (\code{~}) and the consequence of the rule is written \emph{after} the tilde:\preformatted{x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S", + TZP == "R" ~ aminopenicillins == "R") } -\section{Experimental Lifecycle}{ +These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:\preformatted{x +#> A set of custom EUCAST rules: +#> +#> 1. If TZP is S then set to S: +#> amoxicillin (AMX), ampicillin (AMP) +#> +#> 2. If TZP is R then set to R: +#> amoxicillin (AMX), ampicillin (AMP) +} -\if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr} -The \link[=lifecycle]{lifecycle} of this function is \strong{experimental}. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this \code{AMR} package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough. +The rules (the part \emph{before} the tilde, in above example \code{TZP == "S"} and \code{TZP == "R"}) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column \code{TZP} must exist. We will create a sample data set and test the rules set:\preformatted{df <- data.frame(mo = c("E. coli", "K. pneumoniae"), + TZP = "R", + amox = "", + AMP = "") +df +#> mo TZP amox AMP +#> 1 E. coli R +#> 2 K. pneumoniae R + +eucast_rules(df, rules = "custom", custom_rules = x) +#> mo TZP amox AMP +#> 1 E. coli R R R +#> 2 K. pneumoniae R R R +} +} + +\subsection{Using taxonomic properties in rules}{ + +There is one exception in variables used for the rules: all column names of the \link{microorganisms} data set can also be used, but do not have to exist in the data set. These column names are: \code{mo}, \code{fullname}, \code{kingdom}, \code{phylum}, \code{class}, \code{order}, \code{family}, \code{genus}, \code{species}, \code{subspecies}, \code{rank}, \code{ref}, \code{species_id}, \code{source}, \code{prevalence} and \code{snomed}. Thus, this next example will work as well, despite the fact that the \code{df} data set does not contain a column \code{genus}:\preformatted{y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S", + TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R") + +eucast_rules(df, rules = "custom", custom_rules = y) +#> mo TZP amox AMP +#> 1 E. coli R +#> 2 K. pneumoniae R R R +} +} + +\subsection{Usage of antibiotic group names}{ + +It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part \emph{after} the tilde. In above examples, the antibiotic group \code{aminopenicillins} is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule. +\itemize{ +\item \code{aminoglycosides}\cr(amikacin, amikacin/fosfomycin, amphotericin B-high, apramycin, arbekacin, astromicin, bekanamycin, dibekacin, framycetin, gentamicin, gentamicin-high, habekacin, hygromycin, isepamicin, kanamycin, kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin, pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin, streptoduocin, streptomycin, streptomycin-high, tobramycin, tobramycin-high) +\item \code{aminopenicillins}\cr(amoxicillin, ampicillin) +\item \code{betalactams}\cr(amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, biapenem, cadazolid, carbenicillin, carindacillin, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, ciclacillin, clometocillin, cloxacillin, dicloxacillin, doripenem, epicillin, ertapenem, flucloxacillin, hetacillin, imipenem, imipenem/EDTA, imipenem/relebactam, latamoxef, lenampicillin, loracarbef, mecillinam (Amdinocillin), meropenem, meropenem/nacubactam, meropenem/vaborbactam, metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, panipenem, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, razupenem, ritipenem, ritipenem acoxil, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, tebipenem, temocillin, ticarcillin, ticarcillin/clavulanic acid) +\item \code{carbapenems}\cr(biapenem, doripenem, ertapenem, imipenem, imipenem/EDTA, imipenem/relebactam, meropenem, meropenem/nacubactam, meropenem/vaborbactam, panipenem, razupenem, ritipenem, ritipenem acoxil, tebipenem) +\item \code{cephalosporins}\cr(cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef) +\item \code{cephalosporins_1st}\cr(cefacetrile, cefadroxil, cefaloridine, cefatrizine, cefazedone, cefazolin, cefroxadine, ceftezole, cephalexin, cephalothin, cephapirin, cephradine) +\item \code{cephalosporins_2nd}\cr(cefaclor, cefamandole, cefmetazole, cefonicid, ceforanide, cefotetan, cefotiam, cefoxitin, cefoxitin screening, cefprozil, cefuroxime, cefuroxime axetil, loracarbef) +\item \code{cephalosporins_3rd}\cr(cadazolid, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefetamet, cefetamet pivoxil, cefixime, cefmenoxime, cefodizime, cefoperazone, cefoperazone/sulbactam, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotiam hexetil, cefovecin, cefpimizole, cefpiramide, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefsulodin, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftriaxone, latamoxef) +\item \code{cephalosporins_except_caz}\cr(cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef) +\item \code{fluoroquinolones}\cr(ciprofloxacin, enoxacin, fleroxacin, gatifloxacin, gemifloxacin, grepafloxacin, levofloxacin, lomefloxacin, moxifloxacin, norfloxacin, ofloxacin, pazufloxacin, pefloxacin, prulifloxacin, rufloxacin, sparfloxacin, temafloxacin, trovafloxacin) +\item \code{glycopeptides}\cr(avoparcin, dalbavancin, norvancomycin, oritavancin, ramoplanin, teicoplanin, teicoplanin-macromethod, telavancin, vancomycin, vancomycin-macromethod) +\item \code{glycopeptides_except_lipo}\cr(avoparcin, norvancomycin, ramoplanin, teicoplanin, teicoplanin-macromethod, vancomycin, vancomycin-macromethod) +\item \code{lincosamides}\cr(clindamycin, lincomycin, pirlimycin) +\item \code{lipoglycopeptides}\cr(dalbavancin, oritavancin, telavancin) +\item \code{macrolides}\cr(azithromycin, clarithromycin, dirithromycin, erythromycin, flurithromycin, josamycin, midecamycin, miocamycin, oleandomycin, rokitamycin, roxithromycin, spiramycin, telithromycin, troleandomycin) +\item \code{oxazolidinones}\cr(cycloserine, linezolid, tedizolid, thiacetazone) +\item \code{penicillins}\cr(amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, carbenicillin, carindacillin, ciclacillin, clometocillin, cloxacillin, dicloxacillin, epicillin, flucloxacillin, hetacillin, lenampicillin, mecillinam (Amdinocillin), metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, temocillin, ticarcillin, ticarcillin/clavulanic acid) +\item \code{polymyxins}\cr(colistin, polymyxin B, polymyxin B/polysorbate 80) +\item \code{streptogramins}\cr(pristinamycin, quinupristin/dalfopristin) +\item \code{tetracyclines}\cr(chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline, tigecycline) +\item \code{tetracyclines_except_tgc}\cr(chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline) +\item \code{ureidopenicillins}\cr(azlocillin, mezlocillin, piperacillin, piperacillin/tazobactam) +} +} +} + +\section{Maturing Lifecycle}{ + +\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr} +The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome \href{https://github.com/msberends/AMR/issues}{to suggest changes at our repository} or \link[=AMR]{write us an email (see section 'Contact Us')}. } \examples{ diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 29a15f75..daf937d0 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -81,7 +81,7 @@ filter_first_weighted_isolate( \item{points_threshold}{points until the comparison of key antibiotics will lead to inclusion of an isolate when \code{type = "points"}, see \emph{Details}} -\item{info}{print progress} +\item{info}{a \link{logical} to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode} \item{include_unknown}{logical to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code \code{"UNKNOWN"}, which defaults to \code{FALSE}. For WHONET users, this means that all records with organism code \code{"con"} (\emph{contamination}) will be excluded at default. Isolates with a microbial ID of \code{NA} will always be excluded as first isolate.} diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index 112b3bf0..1186176d 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -62,7 +62,7 @@ key_antibiotics_equal( \item{points_threshold}{points until the comparison of key antibiotics will lead to inclusion of an isolate when \code{type = "points"}, see \emph{Details}} -\item{info}{print progress} +\item{info}{a \link{logical} to indicate whether a progress bar should be printed, defaults to \code{TRUE} only in interactive mode} } \description{ These function can be used to determine first isolates (see \code{\link[=first_isolate]{first_isolate()}}). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first 'weighted' isolates. diff --git a/man/like.Rd b/man/like.Rd index 9b5b3f3e..217275b5 100755 --- a/man/like.Rd +++ b/man/like.Rd @@ -29,12 +29,12 @@ A \link{logical} vector Convenient wrapper around \code{\link[=grepl]{grepl()}} to match a pattern: \code{x \%like\% pattern}. It always returns a \code{\link{logical}} vector and is always case-insensitive (use \code{x \%like_case\% pattern} for case-sensitive matching). Also, \code{pattern} can be as long as \code{x} to compare items of each index in both vectors, or they both can have the same length to iterate over all cases. } \details{ -This \verb{\%like\%} function: +These \code{\link[=like]{like()}} and \verb{\%like\%} functions: \itemize{ -\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching) -\item Supports multiple patterns -\item Checks if \code{pattern} is a valid regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed (vectorised over \code{pattern}) -\item Always uses compatibility with Perl unless \code{fixed = TRUE}, to greatly improve speed +\item Are case-insensitive (use \verb{\%like_case\%} for case-sensitive matching) +\item Support multiple patterns +\item Check if \code{pattern} is a valid regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed (vectorised over \code{pattern}) +\item Always use compatibility with Perl unless \code{fixed = TRUE}, to greatly improve speed } Using RStudio? The text \verb{\%like\%} can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like \code{Ctrl+Shift+L} or \code{Cmd+Shift+L} (see \code{Tools} > \verb{Modify Keyboard Shortcuts...}). @@ -53,7 +53,6 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ } \examples{ -# simple test a <- "This is a test" b <- "TEST" a \%like\% b @@ -72,13 +71,13 @@ a \%like\% b[1] #> TRUE FALSE FALSE # get isolates whose name start with 'Ent' or 'ent' -\donttest{ +example_isolates[which(mo_name() \%like\% "^ent"), ] + if (require("dplyr")) { example_isolates \%>\% filter(mo_name() \%like\% "^ent") } } -} \seealso{ \code{\link[=grepl]{grepl()}} } diff --git a/man/mdro.Rd b/man/mdro.Rd index a2687610..bb0a06a1 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -119,7 +119,7 @@ Please suggest your own (country-specific) guidelines by letting us know: \url{h Custom guidelines can be set with the \code{\link[=custom_mdro_guideline]{custom_mdro_guideline()}} function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data. -If you are familiar with \code{case_when()} of the \code{dplyr} package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation':\preformatted{custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A", +If you are familiar with the \code{\link[dplyr:case_when]{case_when()}} function of the \code{dplyr} package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule is written \emph{before} the tilde (\code{~}) and the consequence of the rule is written \emph{after} the tilde:\preformatted{custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A", ERY == "R" & age > 60 ~ "Elderly Type B") } diff --git a/man/microorganisms.Rd b/man/microorganisms.Rd index 6bfdca58..74989282 100755 --- a/man/microorganisms.Rd +++ b/man/microorganisms.Rd @@ -46,7 +46,7 @@ A data set containing the microbial taxonomy, last updated in March 2021, of six \details{ Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect. -For example, \emph{Staphylococcus pettenkoferi} was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the AMR package returns 2007 for \code{mo_year("S. pettenkoferi")}. +For example, \emph{Staphylococcus pettenkoferi} was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the \code{AMR} package returns 2007 for \code{mo_year("S. pettenkoferi")}. \subsection{Manual additions}{ For convenience, some entries were added manually: