mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 04:42:09 +02:00
(v0.9.0) v0.9.0
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
#' [count_resistant()] should be used to count resistant isolates, [count_susceptible()] should be used to count susceptible isolates.
|
||||
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with [as.rsi()] if needed.
|
||||
#' @inheritParams proportion
|
||||
#' @inheritSection as.rsi Interpretation of S, I and R
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @details These functions are meant to count isolates. Use the [resistance()]/[susceptibility()] functions to calculate microbial resistance/susceptibility.
|
||||
#'
|
||||
#' The function [count_resistant()] is equal to the function [count_R()]. The function [count_susceptible()] is equal to the function [count_SI()].
|
||||
|
4
R/freq.R
4
R/freq.R
@ -46,8 +46,8 @@ freq.mo <- function(x, ...) {
|
||||
decimal.mark = "."),
|
||||
" (", percentage(sum(grams == "Gram-positive", na.rm = TRUE) / length(grams), digits = digits),
|
||||
")"),
|
||||
`Nr of genera` = n_distinct(mo_genus(x_noNA, language = NULL)),
|
||||
`Nr of species` = n_distinct(paste(mo_genus(x_noNA, language = NULL),
|
||||
`No of genera` = n_distinct(mo_genus(x_noNA, language = NULL)),
|
||||
`No of species` = n_distinct(paste(mo_genus(x_noNA, language = NULL),
|
||||
mo_species(x_noNA, language = NULL)))))
|
||||
}
|
||||
|
||||
|
12
R/like.R
12
R/like.R
@ -22,7 +22,9 @@
|
||||
#' Pattern Matching
|
||||
#'
|
||||
#' Convenient wrapper around [base::grep()] to match a pattern: `a %like% b`. It always returns a [`logical`] vector and is always case-insensitive (use `a %like_case% b` for case-sensitive matching). Also, `pattern` (*b*) can be as long as `x` (*a*) to compare items of each index in both vectors, or can both have the same length to iterate over all cases.
|
||||
#' @inheritParams base::grepl
|
||||
#' @param x a character vector where matches are sought, or an object which can be coerced by [as.character()] to a character vector.
|
||||
#' @param pattern a character string containing a regular expression (or [`character`] string for `fixed = TRUE`) to be matched in the given character vector. Coerced by [as.character()] to a character string if possible. If a [`character`] vector of length 2 or more is supplied, the first element is used with a warning.
|
||||
#' @param ignore.case if `FALSE`, the pattern matching is *case sensitive* and if `TRUE`, case is ignored during matching.
|
||||
#' @return A [`logical`] vector
|
||||
#' @name like
|
||||
#' @rdname like
|
||||
@ -83,10 +85,12 @@ like <- function(x, pattern, ignore.case = TRUE) {
|
||||
as.integer(x) %in% base::grep(pattern, levels(x), ignore.case = ignore.case)
|
||||
} else {
|
||||
tryCatch(base::grepl(pattern, x, ignore.case = ignore.case),
|
||||
error = function(e) ifelse(test = grepl("Invalid regexp", e$message),
|
||||
error = function(e) ifelse(grepl("Invalid regexp", e$message),
|
||||
# try with perl = TRUE:
|
||||
yes = return(base::grepl(pattern, x, ignore.case = ignore.case, perl = TRUE)),
|
||||
no = stop(e$message)))
|
||||
return(base::grepl(pattern = pattern, x = x,
|
||||
ignore.case = ignore.case, perl = TRUE)),
|
||||
# stop otherwise
|
||||
stop(e$message)))
|
||||
}
|
||||
}
|
||||
|
||||
|
2
R/mdro.R
2
R/mdro.R
@ -48,7 +48,7 @@
|
||||
#' Please suggest your own (country-specific) guidelines by letting us know: <https://gitlab.com/msberends/AMR/issues/new>.
|
||||
#'
|
||||
#' **Note:** Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named order Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu *et al.* in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this [mdro()] function makes sure that results from before 2016 and after 2016 are identical.
|
||||
#' @inheritSection as.rsi Interpretation of S, I and R
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @return
|
||||
#' - CMI 2012 paper - function [mdr_cmi2012()] or [mdro()]:\cr
|
||||
#' Ordered [`factor`] with levels `Negative` < `Multi-drug-resistant (MDR)` < `Extensively drug-resistant (XDR)` < `Pandrug-resistant (PDR)`
|
||||
|
@ -33,7 +33,7 @@
|
||||
#' @inheritParams ab_property
|
||||
#' @param combine_SI a logical to indicate whether all values of S and I must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter `combine_IR`, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. Default is `TRUE`.
|
||||
#' @param combine_IR a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. I+R (susceptible vs. non-susceptible). This is outdated, see parameter `combine_SI`.
|
||||
#' @inheritSection as.rsi Interpretation of S, I and R
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @details
|
||||
#' The function [resistance()] is equal to the function [proportion_R()]. The function [susceptibility()] is equal to the function [proportion_SI()].
|
||||
#'
|
||||
|
@ -35,7 +35,7 @@
|
||||
#' @param main title of the plot
|
||||
#' @param ribbon a logical to indicate whether a ribbon should be shown (default) or error bars
|
||||
#' @param ... parameters passed on to functions
|
||||
#' @inheritSection as.rsi Interpretation of S, I and R
|
||||
#' @inheritSection as.rsi Interpretation of R and S/I
|
||||
#' @inheritParams first_isolate
|
||||
#' @inheritParams graphics::plot
|
||||
#' @details Valid options for the statistical model (parameter `model`) are:
|
||||
|
17
R/rsi.R
17
R/rsi.R
@ -21,7 +21,7 @@
|
||||
|
||||
#' Class 'rsi'
|
||||
#'
|
||||
#' Interpret MIC values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Invalid antimicrobial interpretations will be translated as `NA` with a warning.
|
||||
#' Interpret MIC values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class [`rsi`], which is an ordered factor with levels `S < I < R`. Invalid antimicrobial interpretations will be translated as `NA` with a warning.
|
||||
#' @rdname as.rsi
|
||||
#' @param x vector of values (for class [`mic`]: an MIC value in mg/L, for class [`disk`]: a disk diffusion radius in millimeters)
|
||||
#' @param mo a microorganism code, generated with [as.mo()]
|
||||
@ -35,14 +35,15 @@
|
||||
#' After using [as.rsi()], you can use [eucast_rules()] to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.
|
||||
#'
|
||||
#' The function [is.rsi.eligible()] returns `TRUE` when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and `FALSE` otherwise. The threshold of 5% can be set with the `threshold` parameter.
|
||||
#' @section Interpretation of S, I and R:
|
||||
#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<http://www.eucast.org/newsiandr/>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
#' @section Interpretation of R and S/I:
|
||||
#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (<http://www.eucast.org/newsiandr/>). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
#'
|
||||
#' - **S** - Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
|
||||
#' - **I** - Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
|
||||
#' - **R** - Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.
|
||||
#'
|
||||
#' Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
|
||||
#' - **R = Resistant**\cr
|
||||
#' A microorganism is categorised as *Resistant* when there is a high likelihood of therapeutic failure even when there is increased exposure. Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
|
||||
#' - **S = Susceptible**\cr
|
||||
#' A microorganism is categorised as *Susceptible, standard dosing regimen*, when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
|
||||
#' - **I = Increased exposure, but still susceptible**\cr
|
||||
#' A microorganism is categorised as *Susceptible, Increased exposure* when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
|
||||
#'
|
||||
#' This AMR package honours this new insight. Use [susceptibility()] (equal to [proportion_SI()]) to determine antimicrobial susceptibility and [count_susceptible()] (equal to [count_SI()]) to count susceptible isolates.
|
||||
#' @return Ordered factor with new class [`rsi`]
|
||||
|
Reference in New Issue
Block a user