1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-24 19:26:12 +01:00

(v1.3.0.9035) mdro() for EUCAST 3.2, examples cleanup

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-09-29 23:35:46 +02:00
parent 68e6e1e329
commit 4e0374af29
94 changed files with 1143 additions and 1165 deletions

View File

@ -63,5 +63,5 @@ jobs:
shell: Rscript {0}
- name: Test coverage
run: covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/resistance_predict.R", "R/aa_helper_pm_functions.R", "R/zzz.R"), quiet = FALSE)
run: covr::codecov(line_exclusions = list("R/atc_online.R", "R/mo_source.R", "R/resistance_predict.R", "R/aa_helper_functions.R", "R/aa_helper_pm_functions.R", "R/zzz.R"), quiet = FALSE)
shell: Rscript {0}

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 1.3.0.9034
Version: 1.3.0.9035
Date: 2020-09-29
Title: Antimicrobial Resistance Analysis
Authors@R: c(

View File

@ -193,12 +193,6 @@ export(n_rsi)
export(p_symbol)
export(pca)
export(penicillins)
export(portion_I)
export(portion_IR)
export(portion_R)
export(portion_S)
export(portion_SI)
export(portion_df)
export(proportion_I)
export(proportion_IR)
export(proportion_R)

View File

@ -1,10 +1,13 @@
# AMR 1.3.0.9034
# AMR 1.3.0.9035
## <small>Last updated: 29 September 2020</small>
Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!
### Breaking
* Removed functions `portion_R()`, `portion_S()` and `portion_I()` that were deprecated since version 0.9.0 (November 2019) and were replaced with `proportion_R()`, `proportion_S()` and `proportion_I()`.
### New
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the parameters `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2.
* Support for 'EUCAST Expert Rules' / 'EUCAST Intrinsic Resistance and Unusual Phenotypes' version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the `eucast_rules()` function can now correct for more than 180 different antibiotics and the `mdro()` function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The `eucast_rules()` function consequently gained the parameters `version_breakpoints` (at the moment defaults to v10.0, 2020) and `version_expertrules` (at the moment defaults to v3.2, 2020). The `example_isolates` data set now also reflects the change from v3.1 to v3.2. The `mdro()` function now accepts `guideline == "EUCAST3.1"` and `guideline == "EUCAST3.2"`.
* A new vignette and website page with info about all our public and freely available data sets, that can be downloaded as flat files or in formats for use in R, SPSS, SAS, Stata and Excel: https://msberends.github.io/AMR/articles/datasets.html
* Data set `intrinsic_resistant`. This data set contains all bug-drug combinations where the 'bug' is intrinsic resistant to the 'drug' according to the latest EUCAST insights. It contains just two columns: `microorganism` and `antibiotic`.

View File

@ -33,8 +33,7 @@
#' @inheritSection AMR Reference data publicly available
#' @inheritSection AMR Read more on our website!
#' @examples
#' \dontrun{
#' library(dplyr)
#' if (require("dplyr")) {
#'
#' # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
#' example_isolates %>%
@ -57,9 +56,9 @@
#' format()
#'
#'
#' data.frame(irrelevant = "value",
#' data.frame(some_column = "some_value",
#' J01CA01 = "S") %>% # ATC code of ampicillin
#' select(penicillins()) # the 'J01CA01' column will be selected
#' select(penicillins()) # only the 'J01CA01' column will be selected
#'
#' }
ab_class <- function(ab_class) {

View File

@ -127,7 +127,7 @@ age <- function(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE) {
#' # same:
#' age_groups(ages, c(1, 2, 4, 6, 13, 17))
#'
#' \dontrun{
#' \donttest{
#' # resistance of ciprofloxacine per age group
#' library(dplyr)
#' example_isolates %>%

View File

@ -60,17 +60,14 @@
#' @inheritSection AMR Read more on our website!
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
#' @examples
#' \dontrun{
#' \donttest{
#' # oral DDD (Defined Daily Dose) of amoxicillin
#' atc_online_property("J01CA04", "DDD", "O")
#'
#' # parenteral DDD (Defined Daily Dose) of amoxicillin
#' atc_online_property("J01CA04", "DDD", "P")
#'
#' atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
#' # [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
#' # [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
#' # [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
#' # [4] "Penicillins with extended spectrum"
#' }
atc_online_property <- function(atc_code,
property,

View File

@ -32,14 +32,7 @@
#' @examples
#' availability(example_isolates)
#'
#' \dontrun{
#' library(dplyr)
#' example_isolates %>% availability()
#'
#' example_isolates %>%
#' select_if(is.rsi) %>%
#' availability()
#'
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%
#' select_if(is.rsi) %>%

View File

@ -26,7 +26,7 @@
#' @inheritParams eucast_rules
#' @param combine_IR logical to indicate whether values R and I should be summed
#' @param add_ab_group logical to indicate where the group of the antimicrobials must be included as a first column
#' @param remove_intrinsic_resistant logical to indicate that rows with 100% resistance for all tested antimicrobials must be removed from the table
#' @param remove_intrinsic_resistant logical to indicate that rows and columns with 100% resistance for all tested antimicrobials must be removed from the table
#' @param FUN the function to call on the `mo` column to transform the microorganism IDs, defaults to [mo_shortname()]
#' @param translate_ab a character of length 1 containing column names of the [antibiotics] data set
#' @param ... arguments passed on to `FUN`
@ -45,10 +45,10 @@
#' format(x, translate_ab = "name (atc)")
#'
#' # Use FUN to change to transformation of microorganism codes
#' x <- bug_drug_combinations(example_isolates,
#' bug_drug_combinations(example_isolates,
#' FUN = mo_gramstain)
#'
#' x <- bug_drug_combinations(example_isolates,
#' bug_drug_combinations(example_isolates,
#' FUN = function(x) ifelse(x == as.mo("E. coli"),
#' "E. coli",
#' "Others"))
@ -183,7 +183,6 @@ format.bug_drug_combinations <- function(x,
y <- y %pm>%
pm_left_join(mo_group, by = "ab")
}
y <<- y
y <- y %pm>%
pm_distinct(ab, .keep_all = TRUE) %pm>%
pm_select(-mo, -txt) %pm>%
@ -205,12 +204,19 @@ format.bug_drug_combinations <- function(x,
y <- y %pm>%
pm_select(-ab_group) %pm>%
pm_rename("Drug" = ab_txt)
colnames(y)[1] <- translate_AMR(colnames(y)[1], language = get_locale(), only_unknown = FALSE)
colnames(y)[1] <- translate_AMR(colnames(y)[1], language, only_unknown = FALSE)
} else {
y <- y %pm>%
pm_rename("Group" = ab_group,
"Drug" = ab_txt)
colnames(y)[1:2] <- translate_AMR(colnames(y)[1:2], language = get_locale(), only_unknown = FALSE)
}
if (!is.null(language)) {
colnames(y) <- translate_AMR(colnames(y), language, only_unknown = FALSE)
}
if (remove_intrinsic_resistant == TRUE) {
y <- y[, !sapply(y, function(col) all(col %like% "100", na.rm = TRUE) & !any(is.na(col))), drop = FALSE]
}
rownames(y) <- NULL

View File

@ -24,46 +24,6 @@
#' These functions are so-called '[Deprecated]'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
#' @inheritSection lifecycle Retired lifecycle
#' @inheritSection AMR Read more on our website!
#' @export
#' @keywords internal
#' @name AMR-deprecated
#' @export
portion_R <- function(...) {
.Deprecated("resistance()", package = "AMR")
proportion_R(...)
}
#' @rdname AMR-deprecated
#' @export
portion_IR <- function(...) {
.Deprecated("proportion_IR()", package = "AMR")
proportion_IR(...)
}
#' @rdname AMR-deprecated
#' @export
portion_I <- function(...) {
.Deprecated("proportion_I()", package = "AMR")
proportion_I(...)
}
#' @rdname AMR-deprecated
#' @export
portion_SI <- function(...) {
.Deprecated("susceptibility()", package = "AMR")
proportion_SI(...)
}
#' @rdname AMR-deprecated
#' @export
portion_S <- function(...) {
.Deprecated("proportion_S()", package = "AMR")
proportion_S(...)
}
#' @rdname AMR-deprecated
#' @export
portion_df <- function(...) {
.Deprecated("proportion_df()", package = "AMR")
proportion_df(...)
}
# @export

View File

@ -33,7 +33,7 @@
#' @seealso [as.rsi()]
#' @inheritSection AMR Read more on our website!
#' @examples
#' \dontrun{
#' \donttest{
#' # transform existing disk zones to the `disk` class
#' library(dplyr)
#' df <- data.frame(microorganism = "E. coli",
@ -41,8 +41,9 @@
#' CIP = 14,
#' GEN = 18,
#' TOB = 16)
#' df <- df %>% mutate_at(vars(AMP:TOB), as.disk)
#' df
#' df[, 2:5] <- lapply(df[, 2:5], as.disk)
#' # same with dplyr:
#' # df %>% mutate(across(AMP:TOB, as.disk))
#'
#' # interpret disk values, see ?as.rsi
#' as.rsi(x = as.disk(18),

View File

@ -67,23 +67,18 @@ EUCAST_VERSION_EXPERT_RULES <- list("3.1" = list(version_txt = "v3.1",
#'
#' The following antibiotics are used for the functions [eucast_rules()] and [mdro()]. These are shown below in the format 'name (`antimicrobial ID`, [ATC code](https://www.whocc.no/atc/structure_and_principles/))', sorted alphabetically:
#'
#' `r create_ab_documentation(c("AMC", "AMK", "AMP", "AMX", "ATM", "AVO", "AZL", "AZM", "BAM", "BPR", "CAC", "CAP", "CAT", "CAZ", "CCV", "CDR", "CDZ", "CEC", "CED", "CEI", "CEP", "CFM", "CFM1", "CFP", "CFR", "CFS", "CHL", "CID", "CIP", "CLI", "CLR", "CMX", "CMZ", "CND", "COL", "CPD", "CPM", "CPO", "CPR", "CPT", "CRB", "CRD", "CRN", "CRO", "CSL", "CTB", "CTF", "CTL", "CTT", "CTX", "CTZ", "CXM", "CYC", "CZD", "CZO", "CZX", "DAL", "DAP", "DIR", "DIT", "DIZ", "DKB", "DOR", "DOX", "ENX", "EPC", "ERY", "ETH", "ETP", "FEP", "FLC", "FLE", "FLR1", "FOS", "FOX", "FOX1", "FUS", "GAT", "GEH", "GEM", "GEN", "GRX", "HAP", "HET", "INH", "IPM", "ISE", "JOS", "KAN", "LEX", "LIN", "LNZ", "LOM", "LOR", "LTM", "LVX", "MAN", "MCM", "MEC", "MEM", "MEV", "MEZ", "MFX", "MID", "MNO", "MTM", "NAL", "NEO", "NET", "NIT", "NOR", "NOV", "NVA", "OFX", "OLE", "ORI", "OXA", "PAZ", "PEF", "PEN", "PHN", "PIP", "PLB", "PME", "PRI", "PRL", "PRU", "PVM", "PZA", "QDA", "RAM", "RFL", "RFP", "RIB", "RID", "RIF", "ROK", "RST", "RXT", "SAM", "SBC", "SDI", "SDM", "SIS", "SLF", "SLF1", "SLF10", "SLF11", "SLF12", "SLF13", "SLF2", "SLF3", "SLF4", "SLF5", "SLF6", "SLF7", "SLF8", "SLF9", "SLT1", "SLT2", "SLT3", "SLT4", "SLT5", "SMX", "SPI", "SPX", "STH", "STR", "STR1", "SUD", "SUT", "SXT", "SZO", "TAL", "TCC", "TCM", "TCY", "TEC", "TEM", "TGC", "THA", "TIC", "TLT", "TLV", "TMP", "TMX", "TOB", "TRL", "TVA", "TZD", "TZP", "VAN"))`
#' `r create_ab_documentation(c("AMC", "AMK", "AMP", "AMX", "ATM", "AVO", "AZL", "AZM", "BAM", "BPR", "CAC", "CAP", "CAT", "CAZ", "CCV", "CDR", "CDZ", "CEC", "CED", "CEI", "CEP", "CFM", "CFM1", "CFP", "CFR", "CFS", "CHL", "CID", "CIP", "CLI", "CLR", "CMX", "CMZ", "CND", "COL", "CPD", "CPM", "CPO", "CPR", "CPT", "CRB", "CRD", "CRN", "CRO", "CSL", "CTB", "CTF", "CTL", "CTT", "CTX", "CTZ", "CXM", "CYC", "CZD", "CZO", "CZX", "DAL", "DAP", "DIR", "DIT", "DIZ", "DKB", "DOR", "DOX", "ENX", "EPC", "ERV", "ERY", "ETH", "ETP", "FDX", "FEP", "FLC", "FLE", "FLR1", "FOS", "FOX", "FOX1", "FUS", "GAT", "GEH", "GEM", "GEN", "GRX", "HAP", "HET", "INH", "IPM", "ISE", "JOS", "KAN", "LEX", "LIN", "LNZ", "LOM", "LOR", "LTM", "LVX", "MAN", "MCM", "MEC", "MEM", "MEV", "MEZ", "MFX", "MID", "MNO", "MTM", "MTR", "NAL", "NEO", "NET", "NIT", "NOR", "NOV", "NVA", "OFX", "OLE", "OMC", "ORI", "OXA", "PAZ", "PEF", "PEN", "PHN", "PIP", "PLB", "PME", "PRI", "PRL", "PRU", "PVM", "PZA", "QDA", "RAM", "RFL", "RFP", "RIB", "RID", "RIF", "ROK", "RST", "RXT", "SAM", "SBC", "SDI", "SDM", "SIS", "SLF", "SLF1", "SLF10", "SLF11", "SLF12", "SLF13", "SLF2", "SLF3", "SLF4", "SLF5", "SLF6", "SLF7", "SLF8", "SLF9", "SLT1", "SLT2", "SLT3", "SLT4", "SLT5", "SMX", "SPI", "SPT", "SPX", "STH", "STR", "STR1", "SUD", "SUT", "SXT", "SZO", "TAL", "TCC", "TCM", "TCY", "TEC", "TEM", "TGC", "THA", "TIC", "TLT", "TLV", "TMP", "TMX", "TOB", "TRL", "TVA", "TZD", "TZP", "VAN"))`
#' @aliases EUCAST
#' @rdname eucast_rules
#' @export
#' @return The input of `x`, possibly with edited values of antibiotics. Or, if `verbose = TRUE`, a [data.frame] with all original and new values of the affected bug-drug combinations.
#' @source
#' - EUCAST Expert Rules. Version 2.0, 2012. \cr
#' Leclercq et al. **EUCAST expert rules in antimicrobial susceptibility testing.** *Clin Microbiol Infect.* 2013;19(2):141-60. \cr
#' <https://doi.org/10.1111/j.1469-0691.2011.03703.x>
#' - EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. \cr
#' <https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf>
#' - EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. \cr
#' <https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf>
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. \cr
#' <https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsx>
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. \cr
#' <https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_10.0_Breakpoint_Tables.xlsx>
#' - EUCAST Expert Rules. Version 2.0, 2012.\cr
#' Leclercq et al. **EUCAST expert rules in antimicrobial susceptibility testing.** *Clin Microbiol Infect.* 2013;19(2):141-60. [(link)](https://doi.org/10.1111/j.1469-0691.2011.03703.x)
#' - EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf)
#' - EUCAST Intrinsic Resistance and Unusual Phenotypes. Version 3.2, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf)
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsx)
#' - EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 10.0, 2020. [(link)](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_10.0_Breakpoint_Tables.xlsx)
#' @inheritSection AMR Reference data publicly available
#' @inheritSection AMR Read more on our website!
#' @examples

View File

@ -33,12 +33,14 @@
#' @seealso [antibiotic_class_selectors()] for the `select()` equivalent.
#' @export
#' @examples
#' \dontrun{
#' library(dplyr)
#' filter_aminoglycosides(example_isolates)
#'
#' \donttest{
#' if (require("dplyr")) {
#'
#' # filter on isolates that have any result for any aminoglycoside
#' example_isolates %>% filter_ab_class("aminoglycoside")
#' example_isolates %>% filter_aminoglycosides()
#' example_isolates %>% filter_ab_class("aminoglycoside")
#'
#' # this is essentially the same as (but without determination of column names):
#' example_isolates %>%
@ -68,6 +70,7 @@
#' example_isolates %>% filter_carbapenems("R", "all")
#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
#' }
#' }
filter_ab_class <- function(x,
ab_class,
result = NULL,

View File

@ -46,9 +46,10 @@
#'
#' All isolates with a microbial ID of `NA` will be excluded as first isolate.
#'
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to one of:
#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to either:
#' ```
#' x %>% filter(first_isolate(., ...))
#' x[first_isolate(x, ...), ]
#' x %>% filter(first_isolate(x, ...))
#' ```
#' The function [filter_first_weighted_isolate()] is essentially equal to:
#' ```
@ -81,13 +82,23 @@
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' \dontrun{
#' library(dplyr)
#' # basic filtering on first isolates
#' example_isolates[first_isolate(example_isolates), ]
#'
#' \donttest{
#' if (require("dplyr")) {
#' # Filter on first isolates:
#' example_isolates %>%
#' mutate(first_isolate = first_isolate(.)) %>%
#' filter(first_isolate == TRUE)
#'
#' # Short-hand versions:
#' example_isolates %>%
#' filter_first_isolate()
#'
#' example_isolates %>%
#' filter_first_weighted_isolate()
#'
#' # Now let's see if first isolates matter:
#' A <- example_isolates %>%
#' group_by(hospital_id) %>%
@ -104,26 +115,7 @@
#' # B is more reliable because every isolate is counted only once.
#' # Gentamicin resistance in hospital D appears to be 3.7% higher than
#' # when you (erroneously) would have used all isolates for analysis.
#'
#'
#' ## OTHER EXAMPLES:
#'
#' # Short-hand versions:
#' example_isolates %>%
#' filter_first_isolate()
#'
#' example_isolates %>%
#' filter_first_weighted_isolate()
#'
#'
#' # set key antibiotics to a new variable
#' x$keyab <- key_antibiotics(x)
#'
#' x$first_isolate <- first_isolate(x)
#'
#' x$first_isolate_weighed <- first_isolate(x, col_keyantibiotics = 'keyab')
#'
#' x$first_blood_isolate <- first_isolate(x, specimen_group = "Blood")
#' }
#' }
first_isolate <- function(x,
col_date = NULL,

View File

@ -60,8 +60,7 @@
#' # See ?example_isolates.
#'
#' # See ?pca for more info about Principal Component Analysis (PCA).
#' \dontrun{
#' library(dplyr)
#' if (require("dplyr")) {
#' pca_model <- example_isolates %>%
#' filter(mo_genus(mo) == "Staphylococcus") %>%
#' group_by(species = mo_shortname(mo)) %>%

View File

@ -102,14 +102,14 @@
#'
#' }
#'
#' \dontrun{
#' \donttest{
#'
#' # resistance of ciprofloxacine per age group
#' example_isolates %>%
#' mutate(first_isolate = first_isolate(.)) %>%
#' filter(first_isolate == TRUE,
#' mo == as.mo("E. coli")) %>%
#' # `age_group` is also a function of this package:
#' # `age_groups` is also a function of this AMR package:
#' group_by(age_group = age_groups(age)) %>%
#' select(age_group,
#' CIP) %>%
@ -118,7 +118,8 @@
#' # for colourblind mode, use divergent colours from the viridis package:
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi() + scale_fill_viridis_d()
#' ggplot_rsi() +
#' scale_fill_viridis_d()
#' # a shorter version which also adjusts data label colours:
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%

View File

@ -39,9 +39,11 @@
#' left_join_microorganisms(as.mo("K. pneumoniae"))
#' left_join_microorganisms("B_KLBSL_PNE")
#'
#' \dontrun{
#' library(dplyr)
#' example_isolates %>% left_join_microorganisms()
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' left_join_microorganisms() %>%
#' colnames()
#'
#' df <- data.frame(date = seq(from = as.Date("2018-01-01"),
#' to = as.Date("2018-01-07"),
@ -53,6 +55,7 @@
#' df_joined <- left_join_microorganisms(df, "bacteria")
#' colnames(df_joined)
#' }
#' }
inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
check_dataset_integrity()
check_groups_before_join(x, "inner_join_microorganisms")

View File

@ -73,8 +73,19 @@
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' \dontrun{
#' library(dplyr)
#' # output of the `key_antibiotics` function could be like this:
#' strainA <- "SSSRR.S.R..S"
#' strainB <- "SSSIRSSSRSSS"
#'
#' # can those strings can be compared with:
#' key_antibiotics_equal(strainA, strainB)
#' # TRUE, because I is ignored (as well as missing values)
#'
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
#' # FALSE, because I is not ignored and so the 4th value differs
#'
#' \donttest{
#' if (require("dplyr")) {
#' # set key antibiotics to a new variable
#' my_patients <- example_isolates %>%
#' mutate(keyab = key_antibiotics(.)) %>%
@ -89,16 +100,7 @@
#' sum(my_patients$first_regular, na.rm = TRUE)
#' sum(my_patients$first_weighted, na.rm = TRUE)
#' }
#'
#' # output of the `key_antibiotics` function could be like this:
#' strainA <- "SSSRR.S.R..S"
#' strainB <- "SSSIRSSSRSSS"
#'
#' key_antibiotics_equal(strainA, strainB)
#' # TRUE, because I is ignored (as well as missing values)
#'
#' key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
#' # FALSE, because I is not ignored and so the 4th value differs
#' }
key_antibiotics <- function(x,
col_mo = NULL,
universal_1 = guess_ab_col(x, "amoxicillin"),

View File

@ -57,11 +57,12 @@
#' #> TRUE TRUE TRUE
#'
#' # get isolates whose name start with 'Ent' or 'ent'
#' \dontrun{
#' library(dplyr)
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo_name(mo) %like% "^ent")
#' }
#' }
like <- function(x, pattern, ignore.case = TRUE) {
# set to fixed if no regex found
fixed <- !any(is_possibly_regex(pattern))

272
R/mdro.R
View File

@ -27,7 +27,7 @@
#' @param info a logical to indicate whether progress should be printed to the console
#' @inheritParams eucast_rules
#' @param pct_required_classes minimal required percentage of antimicrobial classes that must be available per isolate, rounded down. For example, with the default guideline, 17 antimicrobial classes must be available for *S. aureus*. Setting this `pct_required_classes` argument to `0.5` (default) means that for every *S. aureus* isolate at least 8 different classes must be available. Any lower number of available classes will return `NA` for that isolate.
#' @param combine_SI a logical to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the [mdro()] function, it follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using `combine_SI = FALSE`, resistance is considered when isolates are R or I.
#' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so resistance is only considered when isolates are R, not I. As this is the default behaviour of the [mdro()] function, it follows the redefinition by EUCAST about the interpretation of I (increased exposure) in 2019, see section 'Interpretation of S, I and R' below. When using `combine_SI = FALSE`, resistance is considered when isolates are R or I.
#' @param verbose a logical to turn Verbose mode on and off (default is off). In Verbose mode, the function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.
#' @inheritSection eucast_rules Antibiotics
#' @details
@ -37,8 +37,10 @@
#'
#' - `guideline = "CMI2012"`\cr
#' Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) ([link](https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext))
#' - `guideline = "EUCAST"`\cr
#' The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" ([link](http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf))
#' - `guideline = "EUCAST3.2"` (or simply `guideline = "EUCAST"`)\cr
#' The European international guideline - EUCAST Expert Rules Version 3.2 "Intrinsic Resistance and Unusual Phenotypes" ([link](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf))
#' - `guideline = "EUCAST3.1"`\cr
#' The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" ([link](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf))
#' - `guideline = "TB"`\cr
#' The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" ([link](https://www.who.int/tb/publications/pmdt_companionhandbook/en/))
#' - `guideline = "MRGN"`\cr
@ -48,7 +50,7 @@
#'
#' Please suggest your own (country-specific) guidelines by letting us know: <https://github.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.
#' **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 R and S/I
#' @return
#' - CMI 2012 paper - function [mdr_cmi2012()] or [mdro()]:\cr
@ -66,19 +68,20 @@
#' @source
#' Please see *Details* for the list of publications used for this function.
#' @examples
#' \dontrun{
#' library(dplyr)
#' library(cleaner)
#' mdro(example_isolates, guideline = "EUCAST")
#'
#' \donttest{
#' if (require("dplyr")) {
#' example_isolates %>%
#' mdro() %>%
#' freq()
#' table()
#'
#' example_isolates %>%
#' mutate(EUCAST = eucast_exceptional_phenotypes(.),
#' BRMO = brmo(.),
#' MRGN = mrgn(.))
#' }
#' }
mdro <- function(x,
guideline = "CMI2012",
col_mo = NULL,
@ -90,12 +93,12 @@ mdro <- function(x,
check_dataset_integrity()
if (verbose == TRUE & interactive()) {
if (interactive() & verbose == TRUE & info == TRUE) {
txt <- paste0("WARNING: In Verbose mode, the mdro() function does not return the MDRO results, but instead returns a data set in logbook form with extensive info about which isolates would be MDRO-positive, or why they are not.",
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- mdro(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
showQuestion <- import_fn("showQuestion", "rstudioapi")
showQuestion <- import_fn("showQuestion", "rstudioapi", error_on_fail = FALSE)
if (!is.null(showQuestion)) {
q_continue <- showQuestion("Using verbose = TRUE with mdro()", txt)
} else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
@ -124,19 +127,25 @@ mdro <- function(x,
}
stop_ifnot(length(guideline) == 1, "`guideline` must be of length 1")
guideline.bak <- guideline
guideline <- tolower(gsub("[^a-zA-Z0-9.]+", "", guideline))
if (is.null(guideline)) {
# default to the paper by Magiorakos et al. (2012)
guideline <- "cmi2012"
}
if (tolower(guideline) == "nl") {
guideline <- "BRMO"
if (guideline == "eucast") {
# turn into latest EUCAST guideline
guideline <- "eucast3.2"
}
if (tolower(guideline) == "de") {
guideline <- "MRGN"
if (guideline == "nl") {
guideline <- "brmo"
}
stop_ifnot(tolower(guideline) %in% c("brmo", "mrgn", "eucast", "tb", "cmi2012"),
"invalid guideline: ", guideline)
guideline <- list(code = tolower(guideline))
if (guideline == "de") {
guideline <- "mrgn"
}
stop_ifnot(guideline %in% c("brmo", "mrgn", "eucast3.1", "eucast3.2", "tb", "cmi2012"),
"invalid guideline: ", guideline.bak)
guideline <- list(code = guideline)
# try to find columns based on type
# -- mo
@ -158,16 +167,22 @@ mdro <- function(x,
guideline$version <- "N/A"
guideline$source <- "Clinical Microbiology and Infection 18:3, 2012. DOI: 10.1111/j.1469-0691.2011.03570.x"
} else if (guideline$code == "eucast") {
} else if (guideline$code == "eucast3.2") {
guideline$name <- "EUCAST Expert Rules, \"Intrinsic Resistance and Unusual Phenotypes\""
guideline$author <- "EUCAST (European Committee on Antimicrobial Susceptibility Testing)"
guideline$version <- "3.2, 2020"
guideline$source <- "https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf"
} else if (guideline$code == "eucast3.1") {
guideline$name <- "EUCAST Expert Rules, \"Intrinsic Resistance and Exceptional Phenotypes Tables\""
guideline$author <- "EUCAST (European Committee on Antimicrobial Susceptibility Testing)"
guideline$version <- "3.1"
guideline$source <- "http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf"
guideline$version <- "3.1, 2016"
guideline$source <- "https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf"
} else if (guideline$code == "tb") {
guideline$name <- "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis"
guideline$author <- "WHO (World Health Organization)"
guideline$version <- "WHO/HTM/TB/2014.11"
guideline$version <- "WHO/HTM/TB/2014.11, 2014"
guideline$source <- "https://www.who.int/tb/publications/pmdt_companionhandbook/en/"
# support per country:
@ -306,6 +321,33 @@ mdro <- function(x,
verbose = verbose,
info = info,
...)
} else if (guideline$code == "eucast3.2") {
cols_ab <- get_column_abx(x = x,
soft_dependencies = c("AMP",
"AMX",
"CIP",
"DAL",
"DAP",
"ERV",
"FDX",
"GEN",
"LNZ",
"MEM",
"MTR",
"OMC",
"ORI",
"PEN",
"QDA",
"RIF",
"TEC",
"TGC",
"TLV",
"TOB",
"TZD",
"VAN"),
info = info,
verbose = verbose,
...)
} else if (guideline$code == "tb") {
cols_ab <- get_column_abx(x = x,
soft_dependencies = c("CAP",
@ -344,41 +386,88 @@ mdro <- function(x,
ATM <- cols_ab["ATM"]
AZL <- cols_ab["AZL"]
AZM <- cols_ab["AZM"]
BPR <- cols_ab["BPR"]
CAC <- cols_ab["CAC"]
CAT <- cols_ab["CAT"]
CAZ <- cols_ab["CAZ"]
CCV <- cols_ab["CCV"]
CDR <- cols_ab["CDR"]
CDZ <- cols_ab["CDZ"]
CEC <- cols_ab["CEC"]
CED <- cols_ab["CED"]
CEI <- cols_ab["CEI"]
CEP <- cols_ab["CEP"]
CFM <- cols_ab["CFM"]
CFM1 <- cols_ab["CFM1"]
CFP <- cols_ab["CFP"]
CFR <- cols_ab["CFR"]
CFS <- cols_ab["CFS"]
CHL <- cols_ab["CHL"]
CID <- cols_ab["CID"]
CIP <- cols_ab["CIP"]
CLI <- cols_ab["CLI"]
CLR <- cols_ab["CLR"]
CMX <- cols_ab["CMX"]
CMZ <- cols_ab["CMZ"]
CND <- cols_ab["CND"]
COL <- cols_ab["COL"]
CPD <- cols_ab["CPD"]
CPM <- cols_ab["CPM"]
CPO <- cols_ab["CPO"]
CPR <- cols_ab["CPR"]
CPT <- cols_ab["CPT"]
CRD <- cols_ab["CRD"]
CRO <- cols_ab["CRO"]
CSL <- cols_ab["CSL"]
CTB <- cols_ab["CTB"]
CTF <- cols_ab["CTF"]
CTL <- cols_ab["CTL"]
CTT <- cols_ab["CTT"]
CTX <- cols_ab["CTX"]
CTZ <- cols_ab["CTZ"]
CXM <- cols_ab["CXM"]
CZD <- cols_ab["CZD"]
CZO <- cols_ab["CZO"]
CZX <- cols_ab["CZX"]
DAL <- cols_ab["DAL"]
DAP <- cols_ab["DAP"]
DIT <- cols_ab["DIT"]
DIZ <- cols_ab["DIZ"]
DOR <- cols_ab["DOR"]
DOX <- cols_ab["DOX"]
ENX <- cols_ab["ENX"]
ERV <- cols_ab["ERV"]
ERY <- cols_ab["ERY"]
ETP <- cols_ab["ETP"]
FDX <- cols_ab["FDX"]
FEP <- cols_ab["FEP"]
FLC <- cols_ab["FLC"]
FLE <- cols_ab["FLE"]
FOS <- cols_ab["FOS"]
FOX <- cols_ab["FOX"]
FUS <- cols_ab["FUS"]
GAT <- cols_ab["GAT"]
GEH <- cols_ab["GEH"]
GEM <- cols_ab["GEM"]
GEN <- cols_ab["GEN"]
GRX <- cols_ab["GRX"]
HAP <- cols_ab["HAP"]
IPM <- cols_ab["IPM"]
KAN <- cols_ab["KAN"]
LEX <- cols_ab["LEX"]
LIN <- cols_ab["LIN"]
LNZ <- cols_ab["LNZ"]
LOM <- cols_ab["LOM"]
LOR <- cols_ab["LOR"]
LTM <- cols_ab["LTM"]
LVX <- cols_ab["LVX"]
MAN <- cols_ab["MAN"]
MEM <- cols_ab["MEM"]
MEV <- cols_ab["MEV"]
MEZ <- cols_ab["MEZ"]
MTR <- cols_ab["MTR"]
MFX <- cols_ab["MFX"]
MNO <- cols_ab["MNO"]
MTR <- cols_ab["MTR"]
NAL <- cols_ab["NAL"]
NEO <- cols_ab["NEO"]
NET <- cols_ab["NET"]
@ -386,17 +475,25 @@ mdro <- function(x,
NOR <- cols_ab["NOR"]
NOV <- cols_ab["NOV"]
OFX <- cols_ab["OFX"]
OMC <- cols_ab["OMC"]
ORI <- cols_ab["ORI"]
OXA <- cols_ab["OXA"]
PAZ <- cols_ab["PAZ"]
PEF <- cols_ab["PEF"]
PEN <- cols_ab["PEN"]
PIP <- cols_ab["PIP"]
PLB <- cols_ab["PLB"]
PRI <- cols_ab["PRI"]
PRU <- cols_ab["PRU"]
QDA <- cols_ab["QDA"]
RFL <- cols_ab["RFL"]
RID <- cols_ab["RID"]
RIF <- cols_ab["RIF"]
RXT <- cols_ab["RXT"]
SAM <- cols_ab["SAM"]
SIS <- cols_ab["SIS"]
SPT <- cols_ab["SPT"]
SPX <- cols_ab["SPX"]
STH <- cols_ab["STH"]
SXT <- cols_ab["SXT"]
TCC <- cols_ab["TCC"]
@ -406,7 +503,10 @@ mdro <- function(x,
TIC <- cols_ab["TIC"]
TLV <- cols_ab["TLV"]
TMP <- cols_ab["TMP"]
TMX <- cols_ab["TMX"]
TOB <- cols_ab["TOB"]
TVA <- cols_ab["TVA"]
TZD <- cols_ab["TZD"]
TZP <- cols_ab["TZP"]
VAN <- cols_ab["VAN"]
# additional for TB
@ -453,10 +553,12 @@ mdro <- function(x,
# antibiotic classes
aminoglycosides <- c(TOB, GEN)
cephalosporins <- c(FEP, CTX, FOX, CED, CAZ, CRO, CXM, CZO)
cephalosporins_3rd <- c(CTX, CRO, CAZ)
carbapenems <- c(ETP, IPM, MEM)
fluoroquinolones <- c(OFX, CIP, LVX, MFX)
cephalosporins <- c(CDZ, CAC, CEC, CFR, RID, MAN, CTZ, CZD, CZO, CDR, DIT, FEP, CAT, CFM, CMX, CMZ, DIZ, CID, CFP, CSL, CND, CTX, CTT, CTF, FOX, CPM, CPO, CPD, CPR, CRD, CFS, CPT, CAZ, CCV, CTL, CTB, CZX, BPR, CFM1, CEI, CRO, CXM, LEX, CEP, HAP, CED, LTM, LOR)
cephalosporins_1st <- c(CAC, CFR, RID, CTZ, CZD, CZO, CRD, CTL, LEX, CEP, HAP, CED)
cephalosporins_2nd <- c(CEC, MAN, CMZ, CID, CND, CTT, CTF, FOX, CPR, CXM, LOR)
cephalosporins_3rd <- c(CDZ, CDR, DIT, CAT, CFM, CMX, DIZ, CFP, CSL, CTX, CPM, CPD, CFS, CAZ, CCV, CTB, CZX, CRO, LTM)
carbapenems <- c(DOR, ETP, IPM, MEM, MEV)
fluoroquinolones <- c(CIP, ENX, FLE, GAT, GEM, GRX, LVX, LOM, MFX, NOR, OFX, PAZ, PEF, PRU, RFL, SPX, TMX, TVA)
# helper function for editing the table
trans_tbl <- function(to, rows, cols, any_all) {
@ -749,33 +851,33 @@ mdro <- function(x,
}
if (guideline$code == "eucast") {
# EUCAST ------------------------------------------------------------------
if (guideline$code == "eucast3.1") {
# EUCAST 3.1 --------------------------------------------------------------
# Table 5
trans_tbl(3,
which(x$order == "Enterobacterales"
| x$fullname %like% "^Pseudomonas aeruginosa"
| (x$genus == "Pseudomonas" & x$species == "aeruginosa")
| x$genus == "Acinetobacter"),
COL,
"all")
trans_tbl(3,
which(x$fullname %like% "^Salmonella Typhi"),
which(x$genus == "Salmonella" & x$species == "Typhi"),
c(carbapenems, fluoroquinolones),
"any")
trans_tbl(3,
which(x$fullname %like% "^Haemophilus influenzae"),
which(x$genus == "Haemophilus" & x$species == "influenzae"),
c(cephalosporins_3rd, carbapenems, fluoroquinolones),
"any")
trans_tbl(3,
which(x$fullname %like% "^Moraxella catarrhalis"),
which(x$genus == "Moraxella" & x$species == "catarrhalis"),
c(cephalosporins_3rd, fluoroquinolones),
"any")
trans_tbl(3,
which(x$fullname %like% "^Neisseria meningitidis"),
which(x$genus == "Neisseria" & x$species == "meningitidis"),
c(cephalosporins_3rd, fluoroquinolones),
"any")
trans_tbl(3,
which(x$fullname %like% "^Neisseria gonorrhoeae"),
which(x$genus == "Neisseria" & x$species == "gonorrhoeae"),
AZM,
"any")
# Table 6
@ -788,7 +890,7 @@ mdro <- function(x,
c(VAN, TEC, DAP, LNZ, QDA, TGC),
"any")
trans_tbl(3,
which(x$fullname %like% "^Streptococcus pneumoniae"),
which(x$genus == "Streptococcus" & x$species == "pneumoniae"),
c(carbapenems, VAN, TEC, DAP, LNZ, QDA, TGC, RIF),
"any")
trans_tbl(3, # Sr. groups A/B/C/G
@ -800,7 +902,7 @@ mdro <- function(x,
c(DAP, LNZ, TGC, TEC),
"any")
trans_tbl(3,
which(x$fullname %like% "^Enterococcus faecalis"),
which(x$genus == "Enterococcus" & x$species == "faecalis"),
c(AMP, AMX),
"any")
# Table 7
@ -809,11 +911,84 @@ mdro <- function(x,
MTR,
"any")
trans_tbl(3,
which(x$fullname %like% "^Clostridium difficile"),
which(x$genus == "Clostridium" & x$species == "difficile"),
c(MTR, VAN),
"any")
}
if (guideline$code == "eucast3.2") {
# EUCAST 3.2 --------------------------------------------------------------
# Table 6
trans_tbl(3,
which((x$order == "Enterobacterales" &
!x$family == "Morganellaceae" &
!(x$genus == "Serratia" & x$species == "marcescens"))
| (x$genus == "Pseudomonas" & x$species == "aeruginosa")
| x$genus == "Acinetobacter"),
COL,
"all")
trans_tbl(3,
which(x$genus == "Salmonella" & x$species == "Typhi"),
c(carbapenems),
"any")
trans_tbl(3,
which(x$genus == "Haemophilus" & x$species == "influenzae"),
c(cephalosporins_3rd, carbapenems, fluoroquinolones),
"any")
trans_tbl(3,
which(x$genus == "Moraxella" & x$species == "catarrhalis"),
c(cephalosporins_3rd, fluoroquinolones),
"any")
trans_tbl(3,
which(x$genus == "Neisseria" & x$species == "meningitidis"),
c(cephalosporins_3rd, fluoroquinolones),
"any")
trans_tbl(3,
which(x$genus == "Neisseria" & x$species == "gonorrhoeae"),
SPT,
"any")
# Table 7
trans_tbl(3,
which(x$genus == "Staphylococcus" & x$species == "aureus"),
c(VAN, TEC, TLV, DAL, ORI, DAP, LNZ, TZD, QDA, TGC, ERV, OMC),
"any")
trans_tbl(3,
which(x$mo %in% MO_CONS), # coagulase-negative Staphylococcus
c( VAN, TLV, DAL, ORI, DAP, LNZ, TZD, QDA, TGC, ERV, OMC),
"any")
trans_tbl(3,
which(x$genus == "Corynebacterium"),
c(VAN, TEC, TLV, DAL, ORI, DAP, LNZ, TZD, QDA, TGC),
"any")
trans_tbl(3,
which(x$genus == "Streptococcus" & x$species == "pneumoniae"),
c(carbapenems, VAN, TEC, TLV, DAL, ORI, DAP, LNZ, TZD, QDA, TGC, ERV, OMC, RIF),
"any")
streps <- MO_lookup[which(MO_lookup$genus == "Streptococcus"), "mo", drop = TRUE]
streps_ABCG <- streps[as.mo(streps, Lancefield = TRUE) %in% c("B_STRPT_GRPA", "B_STRPT_GRPB", "B_STRPT_GRPC", "B_STRPT_GRPG")]
trans_tbl(3, # Sr. groups A/B/C/G
which(x$mo %in% streps_ABCG),
c(PEN, cephalosporins, VAN, TEC, TLV, DAL, ORI, DAP, LNZ, TZD, QDA, TGC, ERV, OMC),
"any")
trans_tbl(3,
which(x$genus == "Enterococcus"),
c(DAP, LNZ, TGC, ERV, OMC, TEC),
"any")
trans_tbl(3,
which(x$genus == "Enterococcus" & x$species == "faecalis"),
c(AMP, AMX),
"any")
# Table 8
trans_tbl(3,
which(x$genus == "Bacteroides"),
MTR,
"any")
trans_tbl(3,
which(x$genus == "Clostridium" & x$species == "difficile"),
c(MTR, VAN, FDX),
"any")
}
if (guideline$code == "mrgn") {
# Germany -----------------------------------------------------------------
CTX_or_CAZ <- CTX %or% CAZ
@ -828,7 +1003,7 @@ mdro <- function(x,
# Table 1
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
x$fullname %like% "^Acinetobacter baumannii") &
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
x[, PIP] == "R" &
x[, CTX_or_CAZ] == "R" &
x[, IPM_or_MEM] == "S" &
@ -836,7 +1011,7 @@ mdro <- function(x,
"MDRO"] <- 2 # 2 = 3MRGN
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
x$fullname %like% "^Acinetobacter baumannii") &
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
x[, PIP] == "R" &
x[, CTX_or_CAZ] == "R" &
x[, IPM_or_MEM] == "R" &
@ -844,18 +1019,18 @@ mdro <- function(x,
"MDRO"] <- 3 # 3 = 4MRGN, overwrites 3MRGN if applicable
x[which((x$order == "Enterobacterales" | # following in fact the old Enterobacteriaceae classification
x$fullname %like% "^Acinetobacter baumannii") &
(x$genus == "Acinetobacter" & x$species == "baumannii")) &
x[, IPM] == "R" | x[, MEM] == "R"),
"MDRO"] <- 3 # 3 = 4MRGN, always when imipenem or meropenem is R
x[which(x$fullname %like% "^Pseudomonas aeruginosa" &
x[which(x$genus == "Pseudomonas" & x$species == "aeruginosa" &
(x[, PIP] == "S") +
(x[, CTX_or_CAZ] == "S") +
(x[, IPM_or_MEM] == "S") +
(x[, CIP] == "S") == 1),
"MDRO"] <- 2 # 2 = 3MRGN, if only 1 group is S
x[which((x$fullname %like% "^Pseudomonas aeruginosa") &
x[which((x$genus == "Pseudomonas" & x$species == "aeruginosa") &
x[, PIP] == "R" &
x[, CTX_or_CAZ] == "R" &
x[, IPM_or_MEM] == "R" &
@ -903,7 +1078,7 @@ mdro <- function(x,
"all")
trans_tbl(3,
which(x$fullname %like% "^Stenotrophomonas maltophilia"),
which(x$genus == "Stenotrophomonas" & x$species == "maltophilia"),
SXT,
"all")
@ -922,20 +1097,20 @@ mdro <- function(x,
x$psae <- 0
}
x[which(
x$fullname %like% "Pseudomonas aeruginosa"
x$genus == "Pseudomonas" & x$species == "aeruginosa"
& x$psae >= 3), "MDRO"] <- 3
# Table 3
trans_tbl(3,
which(x$fullname %like% "Streptococcus pneumoniae"),
which(x$genus == "Streptococcus" & x$species == "pneumoniae"),
PEN,
"all")
trans_tbl(3,
which(x$fullname %like% "Streptococcus pneumoniae"),
which(x$genus == "Streptococcus" & x$species == "pneumoniae"),
VAN,
"all")
trans_tbl(3,
which(x$fullname %like% "Enterococcus faecium"),
which(x$genus == "Enterococcus" & x$species == "faecium"),
c(PEN, VAN),
"all")
}
@ -1086,7 +1261,6 @@ mdr_cmi2012 <- function(x, guideline = "CMI2012", ...) {
mdro(x = x, guideline = "CMI2012", ...)
}
#' @rdname mdro
#' @export
eucast_exceptional_phenotypes <- function(x, guideline = "EUCAST", ...) {

61
R/mo.R
View File

@ -93,14 +93,7 @@
#'
#' ## Microbial prevalence of pathogens in humans
#'
#' The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the `prevalence` columns in the [microorganisms] and [microorganisms.old] data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence.
#'
#' Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Klebsiella*, *Pseudomonas* and *Legionella*.
#'
#' Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Aspergillus*, *Bacteroides*, *Candida*, *Capnocytophaga*, *Chryseobacterium*, *Cryptococcus*, *Elisabethkingia*, *Flavobacterium*, *Fusobacterium*, *Giardia*, *Leptotrichia*, *Mycoplasma*, *Prevotella*, *Rhodotorula*, *Treponema*, *Trichophyton* or *Ureaplasma*. This group consequently contains all less common and rare human pathogens.
#'
#' Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans.
#'
#' The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the `prevalence` columns in the [microorganisms] and [microorganisms.old] data sets. The grouping into human pathogenic prevalence is explained in the section *Matching score for microorganisms* below.
#' @inheritSection mo_matching_score Matching score for microorganisms
#' @inheritSection catalogue_of_life Catalogue of Life
# (source as a section here, so it can be inherited by other man pages:)
@ -152,25 +145,6 @@
#' # All mo_* functions use as.mo() internally too (see ?mo_property):
#' mo_genus("E. coli") # returns "Escherichia"
#' mo_gramstain("E. coli") # returns "Gram negative"
#'
#' }
#' \dontrun{
#' df$mo <- as.mo(df$microorganism_name)
#'
#' # the select function of the Tidyverse is also supported:
#' library(dplyr)
#' df$mo <- df %>%
#' select(microorganism_name) %>%
#' as.mo()
#'
#' # and can even contain 2 columns, which is convenient
#' # for genus/species combinations:
#' df$mo <- df %>%
#' select(genus, species) %>%
#' as.mo()
#' # although this works easier and does the same:
#' df <- df %>%
#' mutate(mo = as.mo(paste(genus, species)))
#' }
as.mo <- function(x,
Becker = FALSE,
@ -1439,45 +1413,26 @@ exec_as.mo <- function(x,
# Becker ----
if (Becker == TRUE | Becker == "all") {
# See Source. It's this figure:
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4187637/figure/F3/
MOs_staph <- MO_lookup[which(MO_lookup$genus == "Staphylococcus"), ]
CoNS <- MOs_staph[which(MOs_staph$species %in% c("arlettae", "auricularis", "capitis",
"caprae", "carnosus", "chromogenes", "cohnii", "condimenti",
"devriesei", "epidermidis", "equorum", "felis",
"fleurettii", "gallinarum", "haemolyticus",
"hominis", "jettensis", "kloosii", "lentus",
"lugdunensis", "massiliensis", "microti",
"muscae", "nepalensis", "pasteuri", "petrasii",
"pettenkoferi", "piscifermentans", "rostri",
"saccharolyticus", "saprophyticus", "sciuri",
"stepanovicii", "simulans", "succinus",
"vitulinus", "warneri", "xylosus")
| (MOs_staph$species == "schleiferi" & MOs_staph$subspecies %in% c("schleiferi", ""))),
property]
CoPS <- MOs_staph[which(MOs_staph$species %in% c("simiae", "agnetis",
"delphini", "lutrae",
"hyicus", "intermedius",
"pseudintermedius", "pseudointermedius",
"schweitzeri", "argenteus")
| (MOs_staph$species == "schleiferi" & MOs_staph$subspecies == "coagulans")),
property]
# warn when species found that are not in Becker (2014, PMID 25278577) and Becker (2019, PMID 30872103)
post_Becker <- c("argensis", "caeli", "cornubiensis", "edaphicus")
if (any(x %in% MOs_staph[which(MOs_staph$species %in% post_Becker), property])) {
if (any(x %in% MO_lookup[which(MO_lookup$species %in% post_Becker), property])) {
warning("Becker ", font_italic("et al."), " (2014, 2019) does not contain these species named after their publication: ",
font_italic(paste("S.",
sort(mo_species(unique(x[x %in% MOs_staph[which(MOs_staph$species %in% post_Becker), property]]))),
sort(mo_species(unique(x[x %in% MO_lookup[which(MO_lookup$species %in% post_Becker), property]]))),
collapse = ", ")),
".",
call. = FALSE,
immediate. = TRUE)
}
# 'MO_CONS' and 'MO_COPS' are <mo> vectors created in R/zzz.R
CoNS <- MO_lookup[which(MO_lookup$mo %in% MO_CONS), property, drop = TRUE]
x[x %in% CoNS] <- lookup(mo == "B_STPHY_CONS", uncertainty = -1)
CoPS <- MO_lookup[which(MO_lookup$mo %in% MO_COPS), property, drop = TRUE]
x[x %in% CoPS] <- lookup(mo == "B_STPHY_COPS", uncertainty = -1)
if (Becker == "all") {
x[x %in% lookup(fullname %like_case% "^Staphylococcus aureus", n = Inf)] <- lookup(mo == "B_STPHY_COPS", uncertainty = -1)
}

View File

@ -32,21 +32,22 @@
#' where:
#'
#' * \eqn{x} is the user input;
#' * \eqn{n} is a taxonomic name (genus, species and subspecies) as found in [`microorganisms$fullname`][microorganisms];
#' * \eqn{l_{n}}{l_n} is the length of \eqn{n};
#' * \eqn{\operatorname{lev}}{lev} is the [Levenshtein distance function](https://en.wikipedia.org/wiki/Levenshtein_distance);
#' * \eqn{p_{n}}{p_n} is the human pathogenic prevalence of \eqn{n}, categorised into group \eqn{1}, \eqn{2} and \eqn{3} (see *Details* in `?as.mo`), meaning that \eqn{p = \{1, 2 , 3\}}{p = {1, 2, 3}};
#' * \eqn{k_{n}}{k_n} is the kingdom index of \eqn{n}, set as follows: Bacteria = \eqn{1}, Fungi = \eqn{2}, Protozoa = \eqn{3}, Archaea = \eqn{4}, and all others = \eqn{5}, meaning that \eqn{k = \{1, 2 , 3, 4, 5\}}{k = {1, 2, 3, 4, 5}}.
#' * \eqn{n} is a taxonomic name (genus, species, and subspecies);
#' * \eqn{l_n}{l_n} is the length of \eqn{n};
#' * lev is the [Levenshtein distance function](https://en.wikipedia.org/wiki/Levenshtein_distance), which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};
#' * \eqn{p_n}{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
#' * \eqn{k_n}{p_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.
#'
#' This means that the user input `x = "E. coli"` gets for *Escherichia coli* a matching score of `r percentage(mo_matching_score("E. coli", "Escherichia coli"), 1)` and for *Entamoeba coli* a matching score of `r percentage(mo_matching_score("E. coli", "Entamoeba coli"), 1)`.
#' The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. **Group 1** (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is *Enterococcus*, *Staphylococcus* or *Streptococcus*. This group consequently contains all common Gram-negative bacteria, such as *Pseudomonas* and *Legionella* and all species within the order Enterobacterales. **Group 2** consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is *Absidia*, *Acremonium*, *Actinotignum*, *Alternaria*, *Anaerosalibacter*, *Apophysomyces*, *Arachnia*, *Aspergillus*, *Aureobacterium*, *Aureobasidium*, *Bacteroides*, *Basidiobolus*, *Beauveria*, *Blastocystis*, *Branhamella*, *Calymmatobacterium*, *Candida*, *Capnocytophaga*, *Catabacter*, *Chaetomium*, *Chryseobacterium*, *Chryseomonas*, *Chrysonilia*, *Cladophialophora*, *Cladosporium*, *Conidiobolus*, *Cryptococcus*, *Curvularia*, *Exophiala*, *Exserohilum*, *Flavobacterium*, *Fonsecaea*, *Fusarium*, *Fusobacterium*, *Hendersonula*, *Hypomyces*, *Koserella*, *Lelliottia*, *Leptosphaeria*, *Leptotrichia*, *Malassezia*, *Malbranchea*, *Mortierella*, *Mucor*, *Mycocentrospora*, *Mycoplasma*, *Nectria*, *Ochroconis*, *Oidiodendron*, *Phoma*, *Piedraia*, *Pithomyces*, *Pityrosporum*, *Prevotella*,\\*Pseudallescheria*, *Rhizomucor*, *Rhizopus*, *Rhodotorula*, *Scolecobasidium*, *Scopulariopsis*, *Scytalidium*,*Sporobolomyces*, *Stachybotrys*, *Stomatococcus*, *Treponema*, *Trichoderma*, *Trichophyton*, *Trichosporon*, *Tritirachium* or *Ureaplasma*. **Group 3** consists of all other microorganisms.
#'
#' All matches are sorted descending on their matching score and for all user input values, the top match will be returned.
#' All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., `"E. coli"` will return the microbial ID of *Escherichia coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Escherichia coli"), 3)`}, a highly prevalent microorganism found in humans) and not *Entamoeba coli* (\eqn{m = `r round(mo_matching_score("E. coli", "Entamoeba coli"), 3)`}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
#' @export
#' @examples
#' as.mo("E. coli")
#' mo_uncertainties()
#'
#' mo_matching_score("E. coli", "Escherichia coli")
#' mo_matching_score(x = "E. coli",
#' n = c("Escherichia coli", "Entamoeba coli"))
mo_matching_score <- function(x, n) {
# n is always a taxonomically valid full name
levenshtein <- double(length = length(x))

View File

@ -25,6 +25,7 @@
#' @inheritSection lifecycle Questioning lifecycle
#' @param p p value
#' @param emptychar text to show when `p > 0.1`
#' @details **NOTE**: this function will be moved to the `cleaner` package when a new version is being published on CRAN.
#' @return Text
#' @inheritSection AMR Read more on our website!
#' @export

View File

@ -36,9 +36,10 @@
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' \dontrun{
#' \donttest{
#'
#' if (require("dplyr")) {
#' # calculate the resistance per group first
#' library(dplyr)
#' resistance_data <- example_isolates %>%
#' group_by(order = mo_order(mo), # group on anything, like order
#' genus = mo_genus(mo)) %>% # and genus as we do here
@ -53,6 +54,7 @@
#' biplot(pca_result)
#' ggplot_pca(pca_result) # a new and convenient plot function
#' }
#' }
pca <- function(x,
...,
retx = TRUE,

View File

@ -157,15 +157,6 @@
#' group_by(hospital_id) %>%
#' proportion_df(translate = FALSE)
#' }
#'
#' \dontrun{
#' # calculate current empiric combination therapy of Helicobacter gastritis:
#' my_table %>%
#' filter(first_isolate == TRUE,
#' genus == "Helicobacter") %>%
#' summarise(p = susceptibility(AMX, MTR), # amoxicillin with metronidazole
#' n = count_all(AMX, MTR))
#' }
resistance <- function(...,
minimum = 30,
as_percent = FALSE,

View File

@ -84,9 +84,7 @@
#' }
#'
#' # create nice plots with ggplot2 yourself
#' \dontrun{
#' library(dplyr)
#' library(ggplot2)
#' if (require("dplyr") & require("ggplot2")) {
#'
#' data <- example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%

50
R/rsi.R
View File

@ -106,10 +106,20 @@
#' NIT = as.mic(32))
#' as.rsi(df)
#'
#' \dontrun{
#' # for single values
#' as.rsi(x = as.mic(2),
#' mo = as.mo("S. pneumoniae"),
#' ab = "AMP",
#' guideline = "EUCAST")
#'
#' as.rsi(x = as.disk(18),
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
#' ab = "ampicillin", # and `ab` with as.ab()
#' guideline = "EUCAST")
#'
#' \donttest{
#' # the dplyr way
#' library(dplyr)
#' if (require("dplyr")) {
#' df %>% mutate_if(is.mic, as.rsi)
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
#' df %>% mutate(across(where(is.mic), as.rsi))
@ -134,18 +144,6 @@
#' mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
#' }
#'
#' # for single values
#' as.rsi(x = as.mic(2),
#' mo = as.mo("S. pneumoniae"),
#' ab = "AMP",
#' guideline = "EUCAST")
#'
#' as.rsi(x = as.disk(18),
#' mo = "Strep pneu", # `mo` will be coerced with as.mo()
#' ab = "ampicillin", # and `ab` with as.ab()
#' guideline = "EUCAST")
#'
#'
#' # For CLEANING existing R/SI values ------------------------------------
#'
#' as.rsi(c("S", "I", "R", "A", "B", "C"))
@ -156,8 +154,8 @@
#' plot(rsi_data) # for percentages
#' barplot(rsi_data) # for frequencies
#'
#' \dontrun{
#' library(dplyr)
#' # the dplyr way
#' if (require("dplyr")) {
#' example_isolates %>%
#' mutate_at(vars(PEN:RIF), as.rsi)
#' # same:
@ -171,10 +169,7 @@
#' # note: from dplyr 1.0.0 on, this will be:
#' # example_isolates %>%
#' # mutate(across(is.rsi.eligible, as.rsi))
#'
#' # default threshold of `is.rsi.eligible` is 5%.
#' is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid
#' is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
#' }
#' }
as.rsi <- function(x, ...) {
UseMethod("as.rsi")
@ -430,13 +425,6 @@ as.rsi.data.frame <- function(x,
conserve_capped_values = FALSE,
add_intrinsic_resistance = FALSE) {
# try to find columns based on type
# -- mo
if (is.null(col_mo)) {
col_mo <- search_type_in_df(x = x, type = "mo")
stop_if(is.null(col_mo), "`col_mo` must be set")
}
# -- UTIs
col_uti <- uti
if (is.null(col_uti)) {
@ -517,6 +505,14 @@ as.rsi.data.frame <- function(x,
types[types == "" & sapply(x[, ab_cols], all_valid_disks)] <- "disk"
types[types == "" & !sapply(x[, ab_cols], is.rsi)] <- "rsi"
if (any(types %in% c("mic", "disk"), na.rm = TRUE)) {
# now we need an mo column - try to find columns based on type
if (is.null(col_mo)) {
col_mo <- search_type_in_df(x = x, type = "mo")
stop_if(is.null(col_mo), "`col_mo` must be set")
}
}
for (i in seq_len(length(ab_cols))) {
if (types[i] == "mic") {
x[, ab_cols[i]] <- as.rsi.mic(x = x %pm>% pm_pull(ab_cols[i]),

View File

@ -188,9 +188,9 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
translate_ab <- get_translate_ab(translate_ab)
# select only groups and antibiotics
if (pm_has_groups(data)) {
if (inherits(data, "grouped_df")) {
data_has_groups <- TRUE
groups <- setdiff(names(pm_get_group_details(data)), ".rows")
groups <- setdiff(names(attributes(data)$groups), ".rows")
data <- data[, c(groups, colnames(data)[sapply(data, is.rsi)]), drop = FALSE]
} else {
data_has_groups <- FALSE

Binary file not shown.

51
R/zzz.R
View File

@ -36,8 +36,17 @@
value = sort(c("en", unique(translations_file$lang))),
envir = asNamespace("AMR"))
# support for tibble headers (type_sum) and tibble columns content (pillar_shaft) without the need to depend on other packages
# this was suggested by the developers of the vctrs package:
assign(x = "MO_CONS",
value = create_species_cons_cops("CoNS"),
envir = asNamespace("AMR"))
assign(x = "MO_COPS",
value = create_species_cons_cops("CoPS"),
envir = asNamespace("AMR"))
# Support for tibble headers (type_sum) and tibble columns content (pillar_shaft)
# without the need to depend on other packages. This was suggested by the
# developers of the vctrs package:
# https://github.com/r-lib/vctrs/blob/05968ce8e669f73213e3e894b5f4424af4f46316/R/register-s3.R
s3_register("pillar::pillar_shaft", "ab")
s3_register("tibble::type_sum", "ab")
@ -49,10 +58,10 @@
s3_register("tibble::type_sum", "mic")
s3_register("pillar::pillar_shaft", "disk")
s3_register("tibble::type_sum", "disk")
# support for frequency tables from the cleaner package
# Support for frequency tables from the cleaner package
s3_register("cleaner::freq", "mo")
s3_register("cleaner::freq", "rsi")
# support from skim from the skimr package
# Support from skim() from the skimr package
s3_register("skimr::get_skimmers", "mo")
s3_register("skimr::get_skimmers", "rsi")
s3_register("skimr::get_skimmers", "mic")
@ -60,6 +69,7 @@
}
.onAttach <- function(...) {
# show notice in 10% of cases in interactive session
if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(getOption("AMR_silentstart", FALSE)))) {
return()
}
@ -69,6 +79,39 @@
"\n[ prevent his notice with suppressPackageStartupMessages(library(AMR)) or use options(AMR_silentstart = TRUE) ]")
}
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
# Determination of which staphylococcal species are CoNS/CoPS according to Becker et al.:
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4187637/figure/F3/
# returns class <mo>
MO_staph <- AMR::microorganisms
MO_staph <- MO_staph[which(MO_staph$genus == "Staphylococcus"), , drop = FALSE]
if (type == "CoNS") {
MO_staph[which(MO_staph$species %in% c("coagulase-negative",
"arlettae", "auricularis", "capitis",
"caprae", "carnosus", "chromogenes", "cohnii", "condimenti",
"devriesei", "epidermidis", "equorum", "felis",
"fleurettii", "gallinarum", "haemolyticus",
"hominis", "jettensis", "kloosii", "lentus",
"lugdunensis", "massiliensis", "microti",
"muscae", "nepalensis", "pasteuri", "petrasii",
"pettenkoferi", "piscifermentans", "rostri",
"saccharolyticus", "saprophyticus", "sciuri",
"stepanovicii", "simulans", "succinus",
"vitulinus", "warneri", "xylosus")
| (MO_staph$species == "schleiferi" & MO_staph$subspecies %in% c("schleiferi", ""))),
"mo", drop = TRUE]
} else if (type == "CoPS") {
MO_staph[which(MO_staph$species %in% c("coagulase-positive",
"simiae", "agnetis",
"delphini", "lutrae",
"hyicus", "intermedius",
"pseudintermedius", "pseudointermedius",
"schweitzeri", "argenteus")
| (MO_staph$species == "schleiferi" & MO_staph$subspecies == "coagulans")),
"mo", drop = TRUE]
}
}
create_AB_lookup <- function() {
AB_lookup <- AMR::antibiotics
AB_lookup$generalised_name <- generalise_antibiotic_name(AB_lookup$name)

View File

@ -184,13 +184,13 @@ reference:
- "`skewness`"
- "`p_symbol`"
- title: "Other: deprecated functions"
desc: >
These functions are deprecated, meaning that they will still
work but show a warning with every use and will be removed
in a future version.
contents:
- "`AMR-deprecated`"
# - title: "Other: deprecated functions"
# desc: >
# These functions are deprecated, meaning that they will still
# work but show a warning with every use and will be removed
# in a future version.
# contents:
# - "`AMR-deprecated`"
authors:
Matthijs S. Berends:

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.github.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -43,7 +43,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -236,20 +236,27 @@
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="amr-1309034" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9034">
<a href="#amr-1309034" class="anchor"></a>AMR 1.3.0.9034<small> Unreleased </small>
<div id="amr-1309035" class="section level1">
<h1 class="page-header" data-toc-text="1.3.0.9035">
<a href="#amr-1309035" class="anchor"></a>AMR 1.3.0.9035<small> Unreleased </small>
</h1>
<div id="last-updated-29-september-2020" class="section level2">
<h2 class="hasAnchor">
<a href="#last-updated-29-september-2020" class="anchor"></a><small>Last updated: 29 September 2020</small>
</h2>
<p>Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly!</p>
<div id="breaking" class="section level3">
<h3 class="hasAnchor">
<a href="#breaking" class="anchor"></a>Breaking</h3>
<ul>
<li>Removed functions <code>portion_R()</code>, <code>portion_S()</code> and <code>portion_I()</code> that were deprecated since version 0.9.0 (November 2019) and were replaced with <code><a href="../reference/proportion.html">proportion_R()</a></code>, <code><a href="../reference/proportion.html">proportion_S()</a></code> and <code><a href="../reference/proportion.html">proportion_I()</a></code>.</li>
</ul>
</div>
<div id="new" class="section level3">
<h3 class="hasAnchor">
<a href="#new" class="anchor"></a>New</h3>
<ul>
<li><p>Support for EUCAST Expert Rules / EUCAST Intrinsic Resistance and Unusual Phenotypes version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can now correct for more than 180 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function consequently gained the parameters <code>version_breakpoints</code> (at the moment defaults to v10.0, 2020) and <code>version_expertrules</code> (at the moment defaults to v3.2, 2020). The <code>example_isolates</code> data set now also reflects the change from v3.1 to v3.2.</p></li>
<li><p>Support for EUCAST Expert Rules / EUCAST Intrinsic Resistance and Unusual Phenotypes version 3.2 of May 2020. With this addition to the previously implemented version 3.1 of 2016, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can now correct for more than 180 different antibiotics and the <code><a href="../reference/mdro.html">mdro()</a></code> function can determine multidrug resistance based on more than 150 different antibiotics. All previously implemented versions of the EUCAST rules are now maintained and kept available in this package. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function consequently gained the parameters <code>version_breakpoints</code> (at the moment defaults to v10.0, 2020) and <code>version_expertrules</code> (at the moment defaults to v3.2, 2020). The <code>example_isolates</code> data set now also reflects the change from v3.1 to v3.2. The <code><a href="../reference/mdro.html">mdro()</a></code> function now accepts <code>guideline == "EUCAST3.1"</code> and <code>guideline == "EUCAST3.2"</code>.</p></li>
<li><p>A new vignette and website page with info about all our public and freely available data sets, that can be downloaded as flat files or in formats for use in R, SPSS, SAS, Stata and Excel: <a href="https://msberends.github.io/AMR/articles/datasets.html" class="uri">https://msberends.github.io/AMR/articles/datasets.html</a></p></li>
<li>
<p>Data set <code>intrinsic_resistant</code>. This data set contains all bug-drug combinations where the bug is intrinsic resistant to the drug according to the latest EUCAST insights. It contains just two columns: <code>microorganism</code> and <code>antibiotic</code>.</p>
@ -430,9 +437,9 @@
<h1 class="page-header" data-toc-text="1.2.0">
<a href="#amr-120" class="anchor"></a>AMR 1.2.0<small> 2020-05-28 </small>
</h1>
<div id="breaking" class="section level3">
<div id="breaking-1" class="section level3">
<h3 class="hasAnchor">
<a href="#breaking" class="anchor"></a>Breaking</h3>
<a href="#breaking-1" class="anchor"></a>Breaking</h3>
<ul>
<li>
<p>Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.</p>
@ -640,9 +647,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h1 class="page-header" data-toc-text="0.9.0">
<a href="#amr-090" class="anchor"></a>AMR 0.9.0<small> 2019-11-29 </small>
</h1>
<div id="breaking-1" class="section level3">
<div id="breaking-2" class="section level3">
<h3 class="hasAnchor">
<a href="#breaking-1" class="anchor"></a>Breaking</h3>
<a href="#breaking-2" class="anchor"></a>Breaking</h3>
<ul>
<li>Adopted Adeolu <em>et al.</em> (2016), <a href="https://www.ncbi.nlm.nih.gov/pubmed/27620848">PMID 27620848</a> for the <code>microorganisms</code> data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like <em>Morganellaceae</em> and <em>Yersiniaceae</em>). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with <code><a href="../reference/mdro.html">mdro()</a></code> will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
<ul>
@ -748,9 +755,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h1 class="page-header" data-toc-text="0.8.0">
<a href="#amr-080" class="anchor"></a>AMR 0.8.0<small> 2019-10-15 </small>
</h1>
<div id="breaking-2" class="section level3">
<div id="breaking-3" class="section level3">
<h3 class="hasAnchor">
<a href="#breaking-2" class="anchor"></a>Breaking</h3>
<a href="#breaking-3" class="anchor"></a>Breaking</h3>
<ul>
<li>
<p>Determination of first isolates now <strong>excludes</strong> all unknown microorganisms at default, i.e. microbial code <code>"UNKNOWN"</code>. They can be included with the new parameter <code>include_unknown</code>:</p>
@ -889,7 +896,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>The <code>antibiotics</code> data set is now sorted by name and all cephalosporins now have their generation between brackets</li>
<li>Speed improvement for <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> which is now 30 times faster for antibiotic abbreviations</li>
<li>Improved <code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code> to be more reliable and to support 5th generation cephalosporins</li>
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code><a href="../reference/AMR-deprecated.html">portion_R()</a></code> instead of <code><a href="../reference/AMR-deprecated.html">portion_IR()</a></code>, to comply with EUCAST insights</li>
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code>portion_R()</code> instead of <code>portion_IR()</code>, to comply with EUCAST insights</li>
<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> parameter to remove empty values</li>
<li>Renamed function <code>p.symbol()</code> to <code><a href="../reference/p_symbol.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
<li>Using negative values for <code>x</code> in <code><a href="../reference/age_groups.html">age_groups()</a></code> will now introduce <code>NA</code>s and not return an error anymore</li>
@ -919,7 +926,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<a href="#new-6" class="anchor"></a>New</h4>
<ul>
<li>
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code><a href="../reference/AMR-deprecated.html">portion_df()</a></code> to immediately show resistance percentages and number of available isolates:</p>
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
<div class="sourceCode" id="cb18"><pre class="downlit">
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="kw">AMX</span>, <span class="kw">CIP</span>) <span class="op">%&gt;%</span>
@ -964,7 +971,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<h4 class="hasAnchor">
<a href="#changed-6" class="anchor"></a>Changed</h4>
<ul>
<li>Column names of output <code><a href="../reference/count.html">count_df()</a></code> and <code><a href="../reference/AMR-deprecated.html">portion_df()</a></code> are now lowercase</li>
<li>Column names of output <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> are now lowercase</li>
<li>Fixed bug in translation of microorganism names</li>
<li>Fixed bug in determining taxonomic kingdoms</li>
<li>Algorithm improvements for <code><a href="../reference/as.ab.html">as.ab()</a></code> and <code><a href="../reference/as.mo.html">as.mo()</a></code> to understand even more severely misspelled input</li>
@ -1041,7 +1048,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<li>Improved intelligence of looking up antibiotic columns in a data set using <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code>
</li>
<li>Added ~5,000 more old taxonomic names to the <code>microorganisms.old</code> data set, which leads to better results finding when using the <code><a href="../reference/as.mo.html">as.mo()</a></code> function</li>
<li>This package now honours the new EUCAST insight (2019) that S and I are but classified as susceptible, where I is defined as increased exposure and not intermediate anymore. For functions like <code><a href="../reference/AMR-deprecated.html">portion_df()</a></code> and <code><a href="../reference/count.html">count_df()</a></code> this means that their new parameter <code>combine_SI</code> is TRUE at default. Our plotting function <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> also reflects this change since it uses <code><a href="../reference/count.html">count_df()</a></code> internally.</li>
<li>This package now honours the new EUCAST insight (2019) that S and I are but classified as susceptible, where I is defined as increased exposure and not intermediate anymore. For functions like <code>portion_df()</code> and <code><a href="../reference/count.html">count_df()</a></code> this means that their new parameter <code>combine_SI</code> is TRUE at default. Our plotting function <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> also reflects this change since it uses <code><a href="../reference/count.html">count_df()</a></code> internally.</li>
<li>The <code><a href="../reference/age.html">age()</a></code> function gained a new parameter <code>exact</code> to determine ages with decimals</li>
<li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code><a href="../reference/as.rsi.html">rsi()</a></code>
</li>
@ -1595,9 +1602,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
<span class="co"># which is the same as:</span>
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu"><a href="../reference/count.html">count_IR</a></span>(<span class="kw">amox</span>, <span class="kw">cipr</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(<span class="kw">amcl</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(<span class="kw">amcl</span>, <span class="kw">gent</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(<span class="kw">amcl</span>, <span class="kw">gent</span>, <span class="kw">pita</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu">portion_S</span>(<span class="kw">amcl</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu">portion_S</span>(<span class="kw">amcl</span>, <span class="kw">gent</span>)
<span class="kw">septic_patients</span> <span class="op">%&gt;%</span> <span class="fu">portion_S</span>(<span class="kw">amcl</span>, <span class="kw">gent</span>, <span class="kw">pita</span>)
</pre></div>
</li>
<li><p>Edited <code>ggplot_rsi</code> and <code>geom_rsi</code> so they can cope with <code>count_df</code>. The new <code>fun</code> parameter has value <code>portion_df</code> at default, but can be set to <code>count_df</code>.</p></li>

View File

@ -2,7 +2,7 @@ pandoc: 2.7.3
pkgdown: 1.5.1.9000
pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f
articles: []
last_built: 2020-09-29T08:40Z
last_built: 2020-09-29T21:35Z
urls:
reference: https://msberends.github.io/AMR/reference
article: https://msberends.github.io/AMR/articles

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -315,7 +315,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='co'># same:</span>
<span class='fu'>age_groups</span>(<span class='kw'>ages</span>, <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>1</span>, <span class='fl'>2</span>, <span class='fl'>4</span>, <span class='fl'>6</span>, <span class='fl'>13</span>, <span class='fl'>17</span>))
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># \donttest{</span>
<span class='co'># resistance of ciprofloxacine per age group</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
@ -324,7 +324,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(age_group = <span class='fu'>age_groups</span>(<span class='kw'>age</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>age_group</span>, <span class='kw'>CIP</span>) <span class='op'>%&gt;%</span>
<span class='fu'><a href='ggplot_rsi.html'>ggplot_rsi</a></span>(x = <span class='st'>"age_group"</span>, minimum = <span class='fl'>0</span>)
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="Antibiotic class selectors — antibiotic_class_selectors" />
<meta property="og:description" content="Use these selection helpers inside any function that allows Tidyverse selection helpers, like dplyr::select() or tidyr::pivot_longer(). They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -298,8 +298,7 @@
<div class='dont-index'><p><code><a href='filter_ab_class.html'>filter_ab_class()</a></code> for the <code><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter()</a></code> equivalent.</p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<pre class="examples"><span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='co'># this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
@ -322,11 +321,12 @@
<span class='fu'><a href='https://rdrr.io/r/base/format.html'>format</a></span>()
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(irrelevant = <span class='st'>"value"</span>,
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(some_column = <span class='st'>"some_value"</span>,
J01CA01 = <span class='st'>"S"</span>) <span class='op'>%&gt;%</span> <span class='co'># ATC code of ampicillin</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='fu'>penicillins</span>()) <span class='co'># the 'J01CA01' column will be selected</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='fu'>penicillins</span>()) <span class='co'># only the 'J01CA01' column will be selected</span>
}</pre>
}
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -282,7 +282,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<div class='dont-index'><p><code><a href='as.rsi.html'>as.rsi()</a></code></p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<pre class="examples"><span class='co'># \donttest{</span>
<span class='co'># transform existing disk zones to the `disk` class</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>df</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(microorganism = <span class='st'>"E. coli"</span>,
@ -290,8 +290,9 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
CIP = <span class='fl'>14</span>,
GEN = <span class='fl'>18</span>,
TOB = <span class='fl'>16</span>)
<span class='kw'>df</span> <span class='op'>&lt;-</span> <span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.disk</span>)
<span class='kw'>df</span>
<span class='kw'>df</span>[, <span class='fl'>2</span><span class='op'>:</span><span class='fl'>5</span>] <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/lapply.html'>lapply</a></span>(<span class='kw'>df</span>[, <span class='fl'>2</span><span class='op'>:</span><span class='fl'>5</span>], <span class='kw'>as.disk</span>)
<span class='co'># same with dplyr:</span>
<span class='co'># df %&gt;% mutate(across(AMP:TOB, as.disk))</span>
<span class='co'># interpret disk values, see ?as.rsi</span>
<span class='fu'><a href='as.rsi.html'>as.rsi</a></span>(x = <span class='fu'>as.disk</span>(<span class='fl'>18</span>),
@ -300,7 +301,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
guideline = <span class='st'>"EUCAST"</span>)
<span class='fu'><a href='as.rsi.html'>as.rsi</a></span>(<span class='kw'>df</span>)
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -361,10 +361,7 @@
<h3>Microbial prevalence of pathogens in humans</h3>
<p>The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the <code>prevalence</code> columns in the <a href='microorganisms.html'>microorganisms</a> and <a href='microorganisms.old.html'>microorganisms.old</a> data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence.</p>
<p>Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Klebsiella</em>, <em>Pseudomonas</em> and <em>Legionella</em>.</p>
<p>Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is <em>Aspergillus</em>, <em>Bacteroides</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Chryseobacterium</em>, <em>Cryptococcus</em>, <em>Elisabethkingia</em>, <em>Flavobacterium</em>, <em>Fusobacterium</em>, <em>Giardia</em>, <em>Leptotrichia</em>, <em>Mycoplasma</em>, <em>Prevotella</em>, <em>Rhodotorula</em>, <em>Treponema</em>, <em>Trichophyton</em> or <em>Ureaplasma</em>. This group consequently contains all less common and rare human pathogens.</p>
<p>Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans.</p>
<p>The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the <code>prevalence</code> columns in the <a href='microorganisms.html'>microorganisms</a> and <a href='microorganisms.old.html'>microorganisms.old</a> data sets. The grouping into human pathogenic prevalence is explained in the section <em>Matching score for microorganisms</em> below.</p>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
@ -392,15 +389,15 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li>
<li><p>\(n\) is a taxonomic name (genus, species and subspecies) as found in <code><a href='microorganisms.html'>microorganisms$fullname</a></code>;</p></li>
<li><p>\(l_{n}\) is the length of \(n\);</p></li>
<li><p>\(\operatorname{lev}\) is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>;</p></li>
<li><p>\(p_{n}\) is the human pathogenic prevalence of \(n\), categorised into group \(1\), \(2\) and \(3\) (see <em>Details</em> in <code>?as.mo</code>), meaning that \(p = \{1, 2 , 3\}\);</p></li>
<li><p>\(k_{n}\) is the kingdom index of \(n\), set as follows: Bacteria = \(1\), Fungi = \(2\), Protozoa = \(3\), Archaea = \(4\), and all others = \(5\), meaning that \(k = \{1, 2 , 3, 4, 5\}\).</p></li>
<li><p>\(n\) is a taxonomic name (genus, species, and subspecies);</p></li>
<li><p>\(l_n\) is the length of \(n\);</p></li>
<li><p>lev is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>, which counts any insertion, deletion and substitution as 1 that is needed to change \(x\) into \(n\);</p></li>
<li><p>\(p_n\) is the human pathogenic prevalence group of \(n\), as described below;</p></li>
<li><p>\(k_n\) is the taxonomic kingdom of \(n\), set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.</p></li>
</ul>
<p>This means that the user input <code>x = "E. coli"</code> gets for <em>Escherichia coli</em> a matching score of 68.8% and for <em>Entamoeba coli</em> a matching score of 7.9%.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned.</p>
<p>The grouping into human pathogenic prevalence (\(p\)) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. <strong>Group 1</strong> (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Pseudomonas</em> and <em>Legionella</em> and all species within the order Enterobacterales. <strong>Group 2</strong> consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is <em>Absidia</em>, <em>Acremonium</em>, <em>Actinotignum</em>, <em>Alternaria</em>, <em>Anaerosalibacter</em>, <em>Apophysomyces</em>, <em>Arachnia</em>, <em>Aspergillus</em>, <em>Aureobacterium</em>, <em>Aureobasidium</em>, <em>Bacteroides</em>, <em>Basidiobolus</em>, <em>Beauveria</em>, <em>Blastocystis</em>, <em>Branhamella</em>, <em>Calymmatobacterium</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Catabacter</em>, <em>Chaetomium</em>, <em>Chryseobacterium</em>, <em>Chryseomonas</em>, <em>Chrysonilia</em>, <em>Cladophialophora</em>, <em>Cladosporium</em>, <em>Conidiobolus</em>, <em>Cryptococcus</em>, <em>Curvularia</em>, <em>Exophiala</em>, <em>Exserohilum</em>, <em>Flavobacterium</em>, <em>Fonsecaea</em>, <em>Fusarium</em>, <em>Fusobacterium</em>, <em>Hendersonula</em>, <em>Hypomyces</em>, <em>Koserella</em>, <em>Lelliottia</em>, <em>Leptosphaeria</em>, <em>Leptotrichia</em>, <em>Malassezia</em>, <em>Malbranchea</em>, <em>Mortierella</em>, <em>Mucor</em>, <em>Mycocentrospora</em>, <em>Mycoplasma</em>, <em>Nectria</em>, <em>Ochroconis</em>, <em>Oidiodendron</em>, <em>Phoma</em>, <em>Piedraia</em>, <em>Pithomyces</em>, <em>Pityrosporum</em>, <em>Prevotella</em>,\<em>Pseudallescheria</em>, <em>Rhizomucor</em>, <em>Rhizopus</em>, <em>Rhodotorula</em>, <em>Scolecobasidium</em>, <em>Scopulariopsis</em>, <em>Scytalidium</em>,<em>Sporobolomyces</em>, <em>Stachybotrys</em>, <em>Stomatococcus</em>, <em>Treponema</em>, <em>Trichoderma</em>, <em>Trichophyton</em>, <em>Trichosporon</em>, <em>Tritirachium</em> or <em>Ureaplasma</em>. <strong>Group 3</strong> consists of all other microorganisms.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., <code>"E. coli"</code> will return the microbial ID of <em>Escherichia coli</em> (\(m = 0.688\), a highly prevalent microorganism found in humans) and not <em>Entamoeba coli</em> (\(m = 0.079\), a less prevalent microorganism in humans), although the latter would alphabetically come first.</p>
<h2 class="hasAnchor" id="catalogue-of-life"><a class="anchor" href="#catalogue-of-life"></a>Catalogue of Life</h2>
@ -459,26 +456,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
<span class='co'># All mo_* functions use as.mo() internally too (see ?mo_property):</span>
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Escherichia"</span>
<span class='fu'><a href='mo_property.html'>mo_gramstain</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Gram negative"</span>
<span class='co'># }</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='kw'>df</span><span class='op'>$</span><span class='kw'>mo</span> <span class='op'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='kw'>df</span><span class='op'>$</span><span class='kw'>microorganism_name</span>)
<span class='co'># the select function of the Tidyverse is also supported:</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>df</span><span class='op'>$</span><span class='kw'>mo</span> <span class='op'>&lt;-</span> <span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>microorganism_name</span>) <span class='op'>%&gt;%</span>
<span class='fu'>as.mo</span>()
<span class='co'># and can even contain 2 columns, which is convenient</span>
<span class='co'># for genus/species combinations:</span>
<span class='kw'>df</span><span class='op'>$</span><span class='kw'>mo</span> <span class='op'>&lt;-</span> <span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>genus</span>, <span class='kw'>species</span>) <span class='op'>%&gt;%</span>
<span class='fu'>as.mo</span>()
<span class='co'># although this works easier and does the same:</span>
<span class='kw'>df</span> <span class='op'>&lt;-</span> <span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(mo = <span class='fu'>as.mo</span>(<span class='fu'><a href='https://rdrr.io/r/base/paste.html'>paste</a></span>(<span class='kw'>genus</span>, <span class='kw'>species</span>)))
}
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -424,34 +424,6 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
NIT = <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>32</span>))
<span class='fu'>as.rsi</span>(<span class='kw'>df</span>)
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># the dplyr way</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='kw'>is.mic</span>, <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='fu'>function</span>(<span class='kw'>x</span>) <span class='fu'><a href='as.mic.html'>is.mic</a></span>(<span class='kw'>x</span>) <span class='op'>|</span> <span class='fu'><a href='as.disk.html'>is.disk</a></span>(<span class='kw'>x</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='fu'>where</span>(<span class='kw'>is.mic</span>), <span class='kw'>as.rsi</span>))
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>, mo = <span class='st'>"E. coli"</span>)
<span class='co'># to include information about urinary tract infections (UTI)</span>
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(mo = <span class='st'>"E. coli"</span>,
NIT = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"&lt;= 2"</span>, <span class='fl'>32</span>),
from_the_bladder = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>TRUE</span>, <span class='fl'>FALSE</span>)) <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>(uti = <span class='st'>"from_the_bladder"</span>)
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(mo = <span class='st'>"E. coli"</span>,
NIT = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"&lt;= 2"</span>, <span class='fl'>32</span>),
specimen = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"urine"</span>, <span class='st'>"blood"</span>)) <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>() <span class='co'># automatically determines urine isolates</span>
<span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>NIT</span>), <span class='kw'>as.rsi</span>, mo = <span class='st'>"E. coli"</span>, uti = <span class='fl'>TRUE</span>)
}
<span class='co'># for single values</span>
<span class='fu'>as.rsi</span>(x = <span class='fu'><a href='as.mic.html'>as.mic</a></span>(<span class='fl'>2</span>),
mo = <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"S. pneumoniae"</span>),
@ -463,6 +435,32 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
ab = <span class='st'>"ampicillin"</span>, <span class='co'># and `ab` with as.ab()</span>
guideline = <span class='st'>"EUCAST"</span>)
<span class='co'># \donttest{</span>
<span class='co'># the dplyr way</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='kw'>is.mic</span>, <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='fu'>function</span>(<span class='kw'>x</span>) <span class='fu'><a href='as.mic.html'>is.mic</a></span>(<span class='kw'>x</span>) <span class='op'>|</span> <span class='fu'><a href='as.disk.html'>is.disk</a></span>(<span class='kw'>x</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='fu'>where</span>(<span class='kw'>is.mic</span>), <span class='kw'>as.rsi</span>))
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>)
<span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>TOB</span>), <span class='kw'>as.rsi</span>, mo = <span class='st'>"E. coli"</span>)
<span class='co'># to include information about urinary tract infections (UTI)</span>
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(mo = <span class='st'>"E. coli"</span>,
NIT = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"&lt;= 2"</span>, <span class='fl'>32</span>),
from_the_bladder = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='fl'>TRUE</span>, <span class='fl'>FALSE</span>)) <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>(uti = <span class='st'>"from_the_bladder"</span>)
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(mo = <span class='st'>"E. coli"</span>,
NIT = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"&lt;= 2"</span>, <span class='fl'>32</span>),
specimen = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"urine"</span>, <span class='st'>"blood"</span>)) <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>() <span class='co'># automatically determines urine isolates</span>
<span class='kw'>df</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>AMP</span><span class='op'>:</span><span class='kw'>NIT</span>), <span class='kw'>as.rsi</span>, mo = <span class='st'>"E. coli"</span>, uti = <span class='fl'>TRUE</span>)
}
<span class='co'># For CLEANING existing R/SI values ------------------------------------</span>
@ -473,26 +471,23 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'><a href='plot.html'>plot</a></span>(<span class='kw'>rsi_data</span>) <span class='co'># for percentages</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/barplot.html'>barplot</a></span>(<span class='kw'>rsi_data</span>) <span class='co'># for frequencies</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># the dplyr way</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='kw'>PEN</span><span class='op'>:</span><span class='kw'>RIF</span>), <span class='kw'>as.rsi</span>)
<span class='co'># same: </span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># same: </span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>as.rsi</span>(<span class='kw'>PEN</span><span class='op'>:</span><span class='kw'>RIF</span>)
<span class='co'># fastest way to transform all columns with already valid AMR results to class `rsi`:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># fastest way to transform all columns with already valid AMR results to class `rsi`:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='kw'>is.rsi.eligible</span>, <span class='kw'>as.rsi</span>)
<span class='co'># note: from dplyr 1.0.0 on, this will be: </span>
<span class='co'># example_isolates %&gt;%</span>
<span class='co'># mutate(across(is.rsi.eligible, as.rsi))</span>
<span class='co'># default threshold of `is.rsi.eligible` is 5%.</span>
<span class='fu'>is.rsi.eligible</span>(<span class='kw'>WHONET</span><span class='op'>$</span><span class='kw'>`First name`</span>) <span class='co'># fails, &gt;80% is invalid</span>
<span class='fu'>is.rsi.eligible</span>(<span class='kw'>WHONET</span><span class='op'>$</span><span class='kw'>`First name`</span>, threshold = <span class='fl'>0.99</span>) <span class='co'># succeeds</span>
<span class='co'># note: from dplyr 1.0.0 on, this will be: </span>
<span class='co'># example_isolates %&gt;%</span>
<span class='co'># mutate(across(is.rsi.eligible, as.rsi))</span>
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -327,18 +327,15 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<p>On our website <a href='https://msberends.github.io/AMR'>https://msberends.github.io/AMR</a> you can find <a href='https://msberends.github.io/AMR/articles/AMR.html'>a comprehensive tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.github.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.github.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>. As we would like to better understand the backgrounds and needs of our users, please <a href='https://msberends.github.io/AMR/survey.html'>participate in our survey</a>!</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<pre class="examples"><span class='co'># \donttest{</span>
<span class='co'># oral DDD (Defined Daily Dose) of amoxicillin</span>
<span class='fu'>atc_online_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"O"</span>)
<span class='co'># parenteral DDD (Defined Daily Dose) of amoxicillin</span>
<span class='fu'>atc_online_property</span>(<span class='st'>"J01CA04"</span>, <span class='st'>"DDD"</span>, <span class='st'>"P"</span>)
<span class='fu'>atc_online_property</span>(<span class='st'>"J01CA04"</span>, property = <span class='st'>"groups"</span>) <span class='co'># search hierarchical groups of amoxicillin</span>
<span class='co'># [1] "ANTIINFECTIVES FOR SYSTEMIC USE"</span>
<span class='co'># [2] "ANTIBACTERIALS FOR SYSTEMIC USE"</span>
<span class='co'># [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"</span>
<span class='co'># [4] "Penicillins with extended spectrum"</span>
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -279,15 +279,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='fu'>availability</span>(<span class='kw'>example_isolates</span>)
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>availability</span>()
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select_all.html'>select_if</a></span>(<span class='kw'>is.rsi</span>) <span class='op'>%&gt;%</span>
<span class='fu'>availability</span>()
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='kw'>mo</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select_all.html'>select_if</a></span>(<span class='kw'>is.rsi</span>) <span class='op'>%&gt;%</span>
<span class='fu'>availability</span>()

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9028</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -304,7 +304,7 @@
</tr>
<tr>
<th>remove_intrinsic_resistant</th>
<td><p>logical to indicate that rows with 100% resistance for all tested antimicrobials must be removed from the table</p></td>
<td><p>logical to indicate that rows and columns with 100% resistance for all tested antimicrobials must be removed from the table</p></td>
</tr>
<tr>
<th>decimal.mark</th>
@ -348,10 +348,10 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='fu'><a href='https://rdrr.io/r/base/format.html'>format</a></span>(<span class='kw'>x</span>, translate_ab = <span class='st'>"name (atc)"</span>)
<span class='co'># Use FUN to change to transformation of microorganism codes</span>
<span class='kw'>x</span> <span class='op'>&lt;-</span> <span class='fu'>bug_drug_combinations</span>(<span class='kw'>example_isolates</span>,
<span class='fu'>bug_drug_combinations</span>(<span class='kw'>example_isolates</span>,
FUN = <span class='kw'>mo_gramstain</span>)
<span class='kw'>x</span> <span class='op'>&lt;-</span> <span class='fu'>bug_drug_combinations</span>(<span class='kw'>example_isolates</span>,
<span class='fu'>bug_drug_combinations</span>(<span class='kw'>example_isolates</span>,
FUN = <span class='fu'>function</span>(<span class='kw'>x</span>) <span class='fu'><a href='https://rdrr.io/r/base/ifelse.html'>ifelse</a></span>(<span class='kw'>x</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>),
<span class='st'>"E. coli"</span>,
<span class='st'>"Others"</span>))

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="Filter isolates on result in antimicrobial class — filter_ab_class" />
<meta property="og:description" content="Filter isolates on results in specific antimicrobial classes. This makes it easy to filter on isolates that were tested for e.g. any aminoglycoside, or to filter on carbapenem-resistant isolates without the need to specify the drugs." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -310,41 +310,45 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<div class='dont-index'><p><code><a href='antibiotic_class_selectors.html'>antibiotic_class_selectors()</a></code> for the <code><a href='https://dplyr.tidyverse.org/reference/select.html'>select()</a></code> equivalent.</p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<pre class="examples"><span class='fu'>filter_aminoglycosides</span>(<span class='kw'>example_isolates</span>)
<span class='co'># filter on isolates that have any result for any aminoglycoside</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_ab_class</span>(<span class='st'>"aminoglycoside"</span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>()
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='co'># this is essentially the same as (but without determination of column names):</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># filter on isolates that have any result for any aminoglycoside</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>()
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_ab_class</span>(<span class='st'>"aminoglycoside"</span>)
<span class='co'># this is essentially the same as (but without determination of column names):</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter_all.html'>filter_at</a></span>(.vars = <span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"GEN"</span>, <span class='st'>"TOB"</span>, <span class='st'>"AMK"</span>, <span class='st'>"KAN"</span>)),
.vars_predicate = <span class='fu'><a href='https://dplyr.tidyverse.org/reference/all_vars.html'>any_vars</a></span>(<span class='kw'>.</span> <span class='op'>%in%</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"S"</span>, <span class='st'>"I"</span>, <span class='st'>"R"</span>)))
<span class='co'># filter on isolates that show resistance to ANY aminoglycoside</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"any"</span>)
<span class='co'># filter on isolates that show resistance to ANY aminoglycoside</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"any"</span>)
<span class='co'># filter on isolates that show resistance to ALL aminoglycosides</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='co'># filter on isolates that show resistance to ALL aminoglycosides</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># any aminoglycoside and any fluoroquinolone</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># any aminoglycoside and any fluoroquinolone</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>) <span class='op'>%&gt;%</span>
<span class='fu'>filter_fluoroquinolones</span>(<span class='st'>"R"</span>)
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># all aminoglycosides and all fluoroquinolones</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># all aminoglycosides and all fluoroquinolones</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>) <span class='op'>%&gt;%</span>
<span class='fu'>filter_fluoroquinolones</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_carbapenems</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='fu'><a href='antibiotic_class_selectors.html'>carbapenems</a></span>(), <span class='op'>~</span><span class='kw'>.</span> <span class='op'>==</span> <span class='st'>"R"</span>))
}</pre>
<span class='co'># with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>filter_carbapenems</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span>(<span class='fu'><a href='antibiotic_class_selectors.html'>carbapenems</a></span>(), <span class='op'>~</span><span class='kw'>.</span> <span class='op'>==</span> <span class='st'>"R"</span>))
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -369,7 +369,8 @@
<p><strong>WHY THIS IS SO IMPORTANT</strong> <br />
To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode <a href='https://www.ncbi.nlm.nih.gov/pubmed/17304462'>(ref)</a>. If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all <em>S. aureus</em> isolates would be overestimated, because you included this MRSA more than once. It would be <a href='https://en.wikipedia.org/wiki/Selection_bias'>selection bias</a>.</p>
<p>All isolates with a microbial ID of <code>NA</code> will be excluded as first isolate.</p>
<p>The functions <code>filter_first_isolate()</code> and <code>filter_first_weighted_isolate()</code> are helper functions to quickly filter on first isolates. The function <code>filter_first_isolate()</code> is essentially equal to one of:</p><pre> <span class='kw'>x</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'>first_isolate</span>(<span class='kw'>.</span>, <span class='kw'>...</span>))
<p>The functions <code>filter_first_isolate()</code> and <code>filter_first_weighted_isolate()</code> are helper functions to quickly filter on first isolates. The function <code>filter_first_isolate()</code> is essentially equal to either:</p><pre> <span class='kw'>x</span>[<span class='fu'>first_isolate</span>(<span class='kw'>x</span>, <span class='kw'>...</span>), ]
<span class='kw'>x</span> <span class='op'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'>first_isolate</span>(<span class='kw'>x</span>, <span class='kw'>...</span>))
</pre>
<p>The function <code>filter_first_weighted_isolate()</code> is essentially equal to:</p><pre> <span class='kw'>x</span> <span class='op'>%&gt;%</span>
@ -411,50 +412,41 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='co'># Filter on first isolates:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># basic filtering on first isolates</span>
<span class='kw'>example_isolates</span>[<span class='fu'>first_isolate</span>(<span class='kw'>example_isolates</span>), ]
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='co'># Filter on first isolates:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(first_isolate = <span class='fu'>first_isolate</span>(<span class='kw'>.</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='kw'>first_isolate</span> <span class='op'>==</span> <span class='fl'>TRUE</span>)
<span class='co'># Now let's see if first isolates matter:</span>
<span class='kw'>A</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># Short-hand versions:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_first_isolate</span>()
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_first_weighted_isolate</span>()
<span class='co'># Now let's see if first isolates matter:</span>
<span class='kw'>A</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>hospital_id</span>) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(count = <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='kw'>GEN</span>), <span class='co'># gentamicin availability</span>
resistance = <span class='fu'><a href='proportion.html'>resistance</a></span>(<span class='kw'>GEN</span>)) <span class='co'># gentamicin resistance</span>
<span class='kw'>B</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='kw'>B</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_first_weighted_isolate</span>() <span class='op'>%&gt;%</span> <span class='co'># the 1st isolate filter</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>hospital_id</span>) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(count = <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='kw'>GEN</span>), <span class='co'># gentamicin availability</span>
resistance = <span class='fu'><a href='proportion.html'>resistance</a></span>(<span class='kw'>GEN</span>)) <span class='co'># gentamicin resistance</span>
<span class='co'># Have a look at A and B.</span>
<span class='co'># B is more reliable because every isolate is counted only once.</span>
<span class='co'># Gentamicin resistance in hospital D appears to be 3.7% higher than</span>
<span class='co'># when you (erroneously) would have used all isolates for analysis.</span>
<span class='co'>## OTHER EXAMPLES:</span>
<span class='co'># Short-hand versions:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_first_isolate</span>()
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>filter_first_weighted_isolate</span>()
<span class='co'># set key antibiotics to a new variable</span>
<span class='kw'>x</span><span class='op'>$</span><span class='kw'>keyab</span> <span class='op'>&lt;-</span> <span class='fu'><a href='key_antibiotics.html'>key_antibiotics</a></span>(<span class='kw'>x</span>)
<span class='kw'>x</span><span class='op'>$</span><span class='kw'>first_isolate</span> <span class='op'>&lt;-</span> <span class='fu'>first_isolate</span>(<span class='kw'>x</span>)
<span class='kw'>x</span><span class='op'>$</span><span class='kw'>first_isolate_weighed</span> <span class='op'>&lt;-</span> <span class='fu'>first_isolate</span>(<span class='kw'>x</span>, col_keyantibiotics = <span class='st'>'keyab'</span>)
<span class='kw'>x</span><span class='op'>$</span><span class='kw'>first_blood_isolate</span> <span class='op'>&lt;-</span> <span class='fu'>first_isolate</span>(<span class='kw'>x</span>, specimen_group = <span class='st'>"Blood"</span>)
<span class='co'># Have a look at A and B.</span>
<span class='co'># B is more reliable because every isolate is counted only once.</span>
<span class='co'># Gentamicin resistance in hospital D appears to be 3.7% higher than</span>
<span class='co'># when you (erroneously) would have used all isolates for analysis.</span>
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="PCA biplot with ggplot2 — ggplot_pca" />
<meta property="og:description" content="Produces a ggplot2 variant of a so-called biplot for PCA (principal component analysis), but is more flexible and more appealing than the base R biplot() function." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -395,8 +395,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
<span class='co'># See ?example_isolates.</span>
<span class='co'># See ?pca for more info about Principal Component Analysis (PCA).</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>pca_model</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='kw'>mo</span>) <span class='op'>==</span> <span class='st'>"Staphylococcus"</span>) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(species = <span class='fu'><a href='mo_property.html'>mo_shortname</a></span>(<span class='kw'>mo</span>)) <span class='op'>%&gt;%</span>
@ -414,7 +413,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_colour_viridis_d</a></span>() <span class='op'>+</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(title = <span class='st'>"Title here"</span>)
}
}</pre>
}
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -467,14 +467,14 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
}
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># \donttest{</span>
<span class='co'># resistance of ciprofloxacine per age group</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(first_isolate = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='kw'>first_isolate</span> <span class='op'>==</span> <span class='fl'>TRUE</span>,
<span class='kw'>mo</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='op'>%&gt;%</span>
<span class='co'># `age_group` is also a function of this package:</span>
<span class='co'># `age_groups` is also a function of this AMR package:</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(age_group = <span class='fu'><a href='age_groups.html'>age_groups</a></span>(<span class='kw'>age</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>age_group</span>,
<span class='kw'>CIP</span>) <span class='op'>%&gt;%</span>
@ -483,7 +483,8 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
<span class='co'># for colourblind mode, use divergent colours from the viridis package:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>AMX</span>, <span class='kw'>NIT</span>, <span class='kw'>FOS</span>, <span class='kw'>TMP</span>, <span class='kw'>CIP</span>) <span class='op'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>() <span class='op'>+</span> <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>()
<span class='fu'>ggplot_rsi</span>() <span class='op'>+</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>()
<span class='co'># a shorter version which also adjusts data label colours:</span>
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='kw'>AMX</span>, <span class='kw'>NIT</span>, <span class='kw'>FOS</span>, <span class='kw'>TMP</span>, <span class='kw'>CIP</span>) <span class='op'>%&gt;%</span>
@ -500,7 +501,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
title = <span class='st'>"AMR of Anti-UTI Drugs Per Hospital"</span>,
x.title = <span class='st'>"Hospital"</span>,
datalabels = <span class='fl'>FALSE</span>)
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -634,25 +634,6 @@
</td>
<td><p>Symbol of a p-value</p></td>
</tr>
</tbody><tbody>
<tr>
<th colspan="2">
<h2 id="section-other-deprecated-functions" class="hasAnchor"><a href="#section-other-deprecated-functions" class="anchor"></a>Other: deprecated functions</h2>
<p class="section-desc"><p>These functions are deprecated, meaning that they will still work but show a warning with every use and will be removed in a future version.</p></p>
</th>
</tr>
</tbody><tbody>
<tr>
<td>
<p><code><a href="AMR-deprecated.html">portion_R()</a></code> <code><a href="AMR-deprecated.html">portion_IR()</a></code> <code><a href="AMR-deprecated.html">portion_I()</a></code> <code><a href="AMR-deprecated.html">portion_SI()</a></code> <code><a href="AMR-deprecated.html">portion_S()</a></code> <code><a href="AMR-deprecated.html">portion_df()</a></code> </p>
</td>
<td><p>Deprecated functions</p></td>
</tr>
</tbody>
</table>
</div>

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9032</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -296,20 +296,23 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<pre class="examples"><span class='fu'>left_join_microorganisms</span>(<span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"K. pneumoniae"</span>))
<span class='fu'>left_join_microorganisms</span>(<span class='st'>"B_KLBSL_PNE"</span>)
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span> <span class='fu'>left_join_microorganisms</span>()
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'>left_join_microorganisms</span>() <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>colnames</a></span>()
<span class='kw'>df</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(date = <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span>(from = <span class='fu'><a href='https://rdrr.io/r/base/as.Date.html'>as.Date</a></span>(<span class='st'>"2018-01-01"</span>),
<span class='kw'>df</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(date = <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span>(from = <span class='fu'><a href='https://rdrr.io/r/base/as.Date.html'>as.Date</a></span>(<span class='st'>"2018-01-01"</span>),
to = <span class='fu'><a href='https://rdrr.io/r/base/as.Date.html'>as.Date</a></span>(<span class='st'>"2018-01-07"</span>),
by = <span class='fl'>1</span>),
bacteria = <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"S. aureus"</span>, <span class='st'>"MRSA"</span>, <span class='st'>"MSSA"</span>, <span class='st'>"STAAUR"</span>,
<span class='st'>"E. coli"</span>, <span class='st'>"E. coli"</span>, <span class='st'>"E. coli"</span>)),
stringsAsFactors = <span class='fl'>FALSE</span>)
<span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>colnames</a></span>(<span class='kw'>df</span>)
<span class='kw'>df_joined</span> <span class='op'>&lt;-</span> <span class='fu'>left_join_microorganisms</span>(<span class='kw'>df</span>, <span class='st'>"bacteria"</span>)
<span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>colnames</a></span>(<span class='kw'>df_joined</span>)
<span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>colnames</a></span>(<span class='kw'>df</span>)
<span class='kw'>df_joined</span> <span class='op'>&lt;-</span> <span class='fu'>left_join_microorganisms</span>(<span class='kw'>df</span>, <span class='st'>"bacteria"</span>)
<span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>colnames</a></span>(<span class='kw'>df_joined</span>)
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="Key antibiotics for first weighted isolates — key_antibiotics" />
<meta property="og:description" content="These function can be used to determine first isolates (see first_isolate()). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -395,10 +395,21 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='co'># set key antibiotics to a new variable</span>
<span class='kw'>my_patients</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># output of the `key_antibiotics` function could be like this:</span>
<span class='kw'>strainA</span> <span class='op'>&lt;-</span> <span class='st'>"SSSRR.S.R..S"</span>
<span class='kw'>strainB</span> <span class='op'>&lt;-</span> <span class='st'>"SSSIRSSSRSSS"</span>
<span class='co'># can those strings can be compared with:</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>)
<span class='co'># TRUE, because I is ignored (as well as missing values)</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>, ignore_I = <span class='fl'>FALSE</span>)
<span class='co'># FALSE, because I is not ignored and so the 4th value differs</span>
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='co'># set key antibiotics to a new variable</span>
<span class='kw'>my_patients</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(keyab = <span class='fu'>key_antibiotics</span>(<span class='kw'>.</span>)) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(
<span class='co'># now calculate first isolates</span>
@ -407,20 +418,12 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
first_weighted = <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='kw'>.</span>, col_keyantibiotics = <span class='st'>"keyab"</span>)
)
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_regular</span>, na.rm = <span class='fl'>TRUE</span>)
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_weighted</span>, na.rm = <span class='fl'>TRUE</span>)
<span class='co'># Check the difference, in this data set it results in 7% more isolates:</span>
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_regular</span>, na.rm = <span class='fl'>TRUE</span>)
<span class='fu'><a href='https://rdrr.io/r/base/sum.html'>sum</a></span>(<span class='kw'>my_patients</span><span class='op'>$</span><span class='kw'>first_weighted</span>, na.rm = <span class='fl'>TRUE</span>)
}
<span class='co'># output of the `key_antibiotics` function could be like this:</span>
<span class='kw'>strainA</span> <span class='op'>&lt;-</span> <span class='st'>"SSSRR.S.R..S"</span>
<span class='kw'>strainB</span> <span class='op'>&lt;-</span> <span class='st'>"SSSIRSSSRSSS"</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>)
<span class='co'># TRUE, because I is ignored (as well as missing values)</span>
<span class='fu'>key_antibiotics_equal</span>(<span class='kw'>strainA</span>, <span class='kw'>strainB</span>, ignore_I = <span class='fl'>FALSE</span>)
<span class='co'># FALSE, because I is not ignored and so the 4th value differs</span></pre>
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -313,11 +313,12 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<span class='co'>#&gt; TRUE TRUE TRUE</span>
<span class='co'># get isolates whose name start with 'Ent' or 'ent'</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_name</a></span>(<span class='kw'>mo</span>) <span class='op'>%like%</span> <span class='st'>"^ent"</span>)
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

File diff suppressed because one or more lines are too long

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -265,21 +265,22 @@
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li>
<li><p>\(n\) is a taxonomic name (genus, species and subspecies) as found in <code><a href='microorganisms.html'>microorganisms$fullname</a></code>;</p></li>
<li><p>\(l_{n}\) is the length of \(n\);</p></li>
<li><p>\(\operatorname{lev}\) is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>;</p></li>
<li><p>\(p_{n}\) is the human pathogenic prevalence of \(n\), categorised into group \(1\), \(2\) and \(3\) (see <em>Details</em> in <code><a href='as.mo.html'>?as.mo</a></code>), meaning that \(p = \{1, 2 , 3\}\);</p></li>
<li><p>\(k_{n}\) is the kingdom index of \(n\), set as follows: Bacteria = \(1\), Fungi = \(2\), Protozoa = \(3\), Archaea = \(4\), and all others = \(5\), meaning that \(k = \{1, 2 , 3, 4, 5\}\).</p></li>
<li><p>\(n\) is a taxonomic name (genus, species, and subspecies);</p></li>
<li><p>\(l_n\) is the length of \(n\);</p></li>
<li><p>lev is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>, which counts any insertion, deletion and substitution as 1 that is needed to change \(x\) into \(n\);</p></li>
<li><p>\(p_n\) is the human pathogenic prevalence group of \(n\), as described below;</p></li>
<li><p>\(k_n\) is the taxonomic kingdom of \(n\), set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.</p></li>
</ul>
<p>This means that the user input <code>x = "E. coli"</code> gets for <em>Escherichia coli</em> a matching score of 68.8% and for <em>Entamoeba coli</em> a matching score of 7.9%.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned.</p>
<p>The grouping into human pathogenic prevalence (\(p\)) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. <strong>Group 1</strong> (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Pseudomonas</em> and <em>Legionella</em> and all species within the order Enterobacterales. <strong>Group 2</strong> consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is <em>Absidia</em>, <em>Acremonium</em>, <em>Actinotignum</em>, <em>Alternaria</em>, <em>Anaerosalibacter</em>, <em>Apophysomyces</em>, <em>Arachnia</em>, <em>Aspergillus</em>, <em>Aureobacterium</em>, <em>Aureobasidium</em>, <em>Bacteroides</em>, <em>Basidiobolus</em>, <em>Beauveria</em>, <em>Blastocystis</em>, <em>Branhamella</em>, <em>Calymmatobacterium</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Catabacter</em>, <em>Chaetomium</em>, <em>Chryseobacterium</em>, <em>Chryseomonas</em>, <em>Chrysonilia</em>, <em>Cladophialophora</em>, <em>Cladosporium</em>, <em>Conidiobolus</em>, <em>Cryptococcus</em>, <em>Curvularia</em>, <em>Exophiala</em>, <em>Exserohilum</em>, <em>Flavobacterium</em>, <em>Fonsecaea</em>, <em>Fusarium</em>, <em>Fusobacterium</em>, <em>Hendersonula</em>, <em>Hypomyces</em>, <em>Koserella</em>, <em>Lelliottia</em>, <em>Leptosphaeria</em>, <em>Leptotrichia</em>, <em>Malassezia</em>, <em>Malbranchea</em>, <em>Mortierella</em>, <em>Mucor</em>, <em>Mycocentrospora</em>, <em>Mycoplasma</em>, <em>Nectria</em>, <em>Ochroconis</em>, <em>Oidiodendron</em>, <em>Phoma</em>, <em>Piedraia</em>, <em>Pithomyces</em>, <em>Pityrosporum</em>, <em>Prevotella</em>,\<em>Pseudallescheria</em>, <em>Rhizomucor</em>, <em>Rhizopus</em>, <em>Rhodotorula</em>, <em>Scolecobasidium</em>, <em>Scopulariopsis</em>, <em>Scytalidium</em>,<em>Sporobolomyces</em>, <em>Stachybotrys</em>, <em>Stomatococcus</em>, <em>Treponema</em>, <em>Trichoderma</em>, <em>Trichophyton</em>, <em>Trichosporon</em>, <em>Tritirachium</em> or <em>Ureaplasma</em>. <strong>Group 3</strong> consists of all other microorganisms.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., <code>"E. coli"</code> will return the microbial ID of <em>Escherichia coli</em> (\(m = 0.688\), a highly prevalent microorganism found in humans) and not <em>Entamoeba coli</em> (\(m = 0.079\), a less prevalent microorganism in humans), although the latter would alphabetically come first.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)
<span class='fu'><a href='as.mo.html'>mo_uncertainties</a></span>()
<span class='fu'>mo_matching_score</span>(<span class='st'>"E. coli"</span>, <span class='st'>"Escherichia coli"</span>)
<span class='fu'>mo_matching_score</span>(x = <span class='st'>"E. coli"</span>,
n = <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"Escherichia coli"</span>, <span class='st'>"Entamoeba coli"</span>))
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -354,15 +354,15 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
<p>$$m_{(x, n)} = \frac{l_{n} - 0.5 \cdot \min \begin{cases}l_{n} \\ \operatorname{lev}(x, n)\end{cases}}{l_{n} \cdot p_{n} \cdot k_{n}}$$</p>
<p>where:</p><ul>
<li><p>\(x\) is the user input;</p></li>
<li><p>\(n\) is a taxonomic name (genus, species and subspecies) as found in <code><a href='microorganisms.html'>microorganisms$fullname</a></code>;</p></li>
<li><p>\(l_{n}\) is the length of \(n\);</p></li>
<li><p>\(\operatorname{lev}\) is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>;</p></li>
<li><p>\(p_{n}\) is the human pathogenic prevalence of \(n\), categorised into group \(1\), \(2\) and \(3\) (see <em>Details</em> in <code><a href='as.mo.html'>?as.mo</a></code>), meaning that \(p = \{1, 2 , 3\}\);</p></li>
<li><p>\(k_{n}\) is the kingdom index of \(n\), set as follows: Bacteria = \(1\), Fungi = \(2\), Protozoa = \(3\), Archaea = \(4\), and all others = \(5\), meaning that \(k = \{1, 2 , 3, 4, 5\}\).</p></li>
<li><p>\(n\) is a taxonomic name (genus, species, and subspecies);</p></li>
<li><p>\(l_n\) is the length of \(n\);</p></li>
<li><p>lev is the <a href='https://en.wikipedia.org/wiki/Levenshtein_distance'>Levenshtein distance function</a>, which counts any insertion, deletion and substitution as 1 that is needed to change \(x\) into \(n\);</p></li>
<li><p>\(p_n\) is the human pathogenic prevalence group of \(n\), as described below;</p></li>
<li><p>\(k_n\) is the taxonomic kingdom of \(n\), set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.</p></li>
</ul>
<p>This means that the user input <code>x = "E. coli"</code> gets for <em>Escherichia coli</em> a matching score of 68.8% and for <em>Entamoeba coli</em> a matching score of 7.9%.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned.</p>
<p>The grouping into human pathogenic prevalence (\(p\)) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. <strong>Group 1</strong> (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Pseudomonas</em> and <em>Legionella</em> and all species within the order Enterobacterales. <strong>Group 2</strong> consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is <em>Absidia</em>, <em>Acremonium</em>, <em>Actinotignum</em>, <em>Alternaria</em>, <em>Anaerosalibacter</em>, <em>Apophysomyces</em>, <em>Arachnia</em>, <em>Aspergillus</em>, <em>Aureobacterium</em>, <em>Aureobasidium</em>, <em>Bacteroides</em>, <em>Basidiobolus</em>, <em>Beauveria</em>, <em>Blastocystis</em>, <em>Branhamella</em>, <em>Calymmatobacterium</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Catabacter</em>, <em>Chaetomium</em>, <em>Chryseobacterium</em>, <em>Chryseomonas</em>, <em>Chrysonilia</em>, <em>Cladophialophora</em>, <em>Cladosporium</em>, <em>Conidiobolus</em>, <em>Cryptococcus</em>, <em>Curvularia</em>, <em>Exophiala</em>, <em>Exserohilum</em>, <em>Flavobacterium</em>, <em>Fonsecaea</em>, <em>Fusarium</em>, <em>Fusobacterium</em>, <em>Hendersonula</em>, <em>Hypomyces</em>, <em>Koserella</em>, <em>Lelliottia</em>, <em>Leptosphaeria</em>, <em>Leptotrichia</em>, <em>Malassezia</em>, <em>Malbranchea</em>, <em>Mortierella</em>, <em>Mucor</em>, <em>Mycocentrospora</em>, <em>Mycoplasma</em>, <em>Nectria</em>, <em>Ochroconis</em>, <em>Oidiodendron</em>, <em>Phoma</em>, <em>Piedraia</em>, <em>Pithomyces</em>, <em>Pityrosporum</em>, <em>Prevotella</em>,\<em>Pseudallescheria</em>, <em>Rhizomucor</em>, <em>Rhizopus</em>, <em>Rhodotorula</em>, <em>Scolecobasidium</em>, <em>Scopulariopsis</em>, <em>Scytalidium</em>,<em>Sporobolomyces</em>, <em>Stachybotrys</em>, <em>Stomatococcus</em>, <em>Treponema</em>, <em>Trichoderma</em>, <em>Trichophyton</em>, <em>Trichosporon</em>, <em>Tritirachium</em> or <em>Ureaplasma</em>. <strong>Group 3</strong> consists of all other microorganisms.</p>
<p>All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., <code>"E. coli"</code> will return the microbial ID of <em>Escherichia coli</em> (\(m = 0.688\), a highly prevalent microorganism found in humans) and not <em>Entamoeba coli</em> (\(m = 0.079\), a less prevalent microorganism in humans), although the latter would alphabetically come first.</p>
<h2 class="hasAnchor" id="catalogue-of-life"><a class="anchor" href="#catalogue-of-life"></a>Catalogue of Life</h2>

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="Symbol of a p-value — p_symbol" />
<meta property="og:description" content="Return the symbol related to the p-value: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1. Values above p = 1 will return NA." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -260,6 +260,9 @@
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>Text</p>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p><strong>NOTE</strong>: this function will be moved to the <code>cleaner</code> package when a new version is being published on CRAN.</p>
<h2 class="hasAnchor" id="questioning-lifecycle"><a class="anchor" href="#questioning-lifecycle"></a>Questioning lifecycle</h2>

View File

@ -50,7 +50,7 @@
<meta property="og:title" content="Principal Component Analysis (for AMR) — pca" />
<meta property="og:description" content="Performs a principal component analysis (PCA) based on a data set with automatic determination for afterwards plotting the groups and labels, and automatic filtering on only suitable (i.e. non-empty and numeric) variables." />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg" />
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" />
@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9015</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -322,23 +322,26 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing<
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># calculate the resistance per group first</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='kw'>resistance_data</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='co'># \donttest{</span>
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>)) {
<span class='co'># calculate the resistance per group first </span>
<span class='kw'>resistance_data</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(order = <span class='fu'><a href='mo_property.html'>mo_order</a></span>(<span class='kw'>mo</span>), <span class='co'># group on anything, like order</span>
genus = <span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='kw'>mo</span>)) <span class='op'>%&gt;%</span> <span class='co'># and genus as we do here</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise_all.html'>summarise_if</a></span>(<span class='kw'>is.rsi</span>, <span class='kw'>resistance</span>) <span class='co'># then get resistance of all drugs</span>
<span class='co'># now conduct PCA for certain antimicrobial agents</span>
<span class='kw'>pca_result</span> <span class='op'>&lt;-</span> <span class='kw'>resistance_data</span> <span class='op'>%&gt;%</span>
<span class='co'># now conduct PCA for certain antimicrobial agents</span>
<span class='kw'>pca_result</span> <span class='op'>&lt;-</span> <span class='kw'>resistance_data</span> <span class='op'>%&gt;%</span>
<span class='fu'>pca</span>(<span class='kw'>AMC</span>, <span class='kw'>CXM</span>, <span class='kw'>CTX</span>, <span class='kw'>CAZ</span>, <span class='kw'>GEN</span>, <span class='kw'>TOB</span>, <span class='kw'>TMP</span>, <span class='kw'>SXT</span>)
<span class='kw'>pca_result</span>
<span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span>(<span class='kw'>pca_result</span>)
<span class='fu'><a href='https://rdrr.io/r/stats/biplot.html'>biplot</a></span>(<span class='kw'>pca_result</span>)
<span class='fu'><a href='ggplot_pca.html'>ggplot_pca</a></span>(<span class='kw'>pca_result</span>) <span class='co'># a new and convenient plot function</span>
}</pre>
<span class='kw'>pca_result</span>
<span class='fu'><a href='https://rdrr.io/r/base/summary.html'>summary</a></span>(<span class='kw'>pca_result</span>)
<span class='fu'><a href='https://rdrr.io/r/stats/biplot.html'>biplot</a></span>(<span class='kw'>pca_result</span>)
<span class='fu'><a href='ggplot_pca.html'>ggplot_pca</a></span>(<span class='kw'>pca_result</span>) <span class='co'># a new and convenient plot function</span>
}
<span class='co'># }</span>
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top">

View File

@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -464,15 +464,6 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>hospital_id</span>) <span class='op'>%&gt;%</span>
<span class='fu'>proportion_df</span>(translate = <span class='fl'>FALSE</span>)
}
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span>
<span class='kw'>my_table</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='kw'>first_isolate</span> <span class='op'>==</span> <span class='fl'>TRUE</span>,
<span class='kw'>genus</span> <span class='op'>==</span> <span class='st'>"Helicobacter"</span>) <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(p = <span class='fu'>susceptibility</span>(<span class='kw'>AMX</span>, <span class='kw'>MTR</span>), <span class='co'># amoxicillin with metronidazole</span>
n = <span class='fu'><a href='count.html'>count_all</a></span>(<span class='kw'>AMX</span>, <span class='kw'>MTR</span>))
}
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

View File

@ -82,7 +82,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9026</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>
@ -418,9 +418,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
}
<span class='co'># create nice plots with ggplot2 yourself</span>
<span class='co'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='https://dplyr.tidyverse.org'>dplyr</a></span>)
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='kw'><a href='http://ggplot2.tidyverse.org'>ggplot2</a></span>)
<span class='co'>if</span> (<span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span>) <span class='op'>&amp;</span> <span class='fu'><a href='https://rdrr.io/r/base/library.html'>require</a></span>(<span class='st'><a href='http://ggplot2.tidyverse.org'>"ggplot2"</a></span>)) {
<span class='kw'>data</span> <span class='op'>&lt;-</span> <span class='kw'>example_isolates</span> <span class='op'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='kw'>mo</span> <span class='op'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='op'>%&gt;%</span>

View File

@ -3,9 +3,6 @@
<url>
<loc>https://msberends.github.io/AMR/index.html</loc>
</url>
<url>
<loc>https://msberends.github.io/AMR/reference/AMR-deprecated.html</loc>
</url>
<url>
<loc>https://msberends.github.io/AMR/reference/AMR.html</loc>
</url>

View File

@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9035</span>
</span>
</div>

View File

@ -1,39 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/deprecated.R
\name{AMR-deprecated}
\alias{AMR-deprecated}
\alias{portion_R}
\alias{portion_IR}
\alias{portion_I}
\alias{portion_SI}
\alias{portion_S}
\alias{portion_df}
\title{Deprecated functions}
\usage{
portion_R(...)
portion_IR(...)
portion_I(...)
portion_SI(...)
portion_S(...)
portion_df(...)
}
\description{
These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
}
\section{Retired lifecycle}{
\if{html}{\figure{lifecycle_retired.svg}{options: style=margin-bottom:5px} \cr}
The \link[=lifecycle]{lifecycle} of this function is \strong{retired}. A retired function is no longer under active development, and (if appropiate) a better alternative is available. No new arguments will be added, and only the most critical bugs will be fixed. In a future version, this function will be removed.
}
\section{Read more on our website!}{
On our website \url{https://msberends.github.io/AMR} you can find \href{https://msberends.github.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.github.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.github.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. As we would like to better understand the backgrounds and needs of our users, please \href{https://msberends.github.io/AMR/survey.html}{participate in our survey}!
}
\keyword{internal}

View File

@ -68,7 +68,7 @@ age_groups(ages, "children")
# same:
age_groups(ages, c(1, 2, 4, 6, 13, 17))
\dontrun{
\donttest{
# resistance of ciprofloxacine per age group
library(dplyr)
example_isolates \%>\%

View File

@ -68,8 +68,7 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
}
\examples{
\dontrun{
library(dplyr)
if (require("dplyr")) {
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
example_isolates \%>\%
@ -92,9 +91,9 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
format()
data.frame(irrelevant = "value",
data.frame(some_column = "some_value",
J01CA01 = "S") \%>\% # ATC code of ampicillin
select(penicillins()) # the 'J01CA01' column will be selected
select(penicillins()) # only the 'J01CA01' column will be selected
}
}

View File

@ -38,7 +38,7 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
}
\examples{
\dontrun{
\donttest{
# transform existing disk zones to the `disk` class
library(dplyr)
df <- data.frame(microorganism = "E. coli",
@ -46,8 +46,9 @@ df <- data.frame(microorganism = "E. coli",
CIP = 14,
GEN = 18,
TOB = 16)
df <- df \%>\% mutate_at(vars(AMP:TOB), as.disk)
df
df[, 2:5] <- lapply(df[, 2:5], as.disk)
# same with dplyr:
# df \%>\% mutate(across(AMP:TOB, as.disk))
# interpret disk values, see ?as.rsi
as.rsi(x = as.disk(18),

View File

@ -117,13 +117,7 @@ There are three helper functions that can be run after using the \code{\link[=as
\subsection{Microbial prevalence of pathogens in humans}{
The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the \code{prevalence} columns in the \link{microorganisms} and \link{microorganisms.old} data sets. The grouping into prevalence groups is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence.
Group 1 (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Klebsiella}, \emph{Pseudomonas} and \emph{Legionella}.
Group 2 consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \emph{Aspergillus}, \emph{Bacteroides}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Chryseobacterium}, \emph{Cryptococcus}, \emph{Elisabethkingia}, \emph{Flavobacterium}, \emph{Fusobacterium}, \emph{Giardia}, \emph{Leptotrichia}, \emph{Mycoplasma}, \emph{Prevotella}, \emph{Rhodotorula}, \emph{Treponema}, \emph{Trichophyton} or \emph{Ureaplasma}. This group consequently contains all less common and rare human pathogens.
Group 3 (least prevalent microorganisms) consists of all other microorganisms. This group contains microorganisms most probably not found in humans.
The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the \code{prevalence} columns in the \link{microorganisms} and \link{microorganisms.old} data sets. The grouping into human pathogenic prevalence is explained in the section \emph{Matching score for microorganisms} below.
}
}
\section{Source}{
@ -153,16 +147,16 @@ With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\li
where:
\itemize{
\item \eqn{x} is the user input;
\item \eqn{n} is a taxonomic name (genus, species and subspecies) as found in \code{\link[=microorganisms]{microorganisms$fullname}};
\item \eqn{l_{n}}{l_n} is the length of \eqn{n};
\item \eqn{\operatorname{lev}}{lev} is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function};
\item \eqn{p_{n}}{p_n} is the human pathogenic prevalence of \eqn{n}, categorised into group \eqn{1}, \eqn{2} and \eqn{3} (see \emph{Details} in \code{?as.mo}), meaning that \eqn{p = \{1, 2 , 3\}}{p = {1, 2, 3}};
\item \eqn{k_{n}}{k_n} is the kingdom index of \eqn{n}, set as follows: Bacteria = \eqn{1}, Fungi = \eqn{2}, Protozoa = \eqn{3}, Archaea = \eqn{4}, and all others = \eqn{5}, meaning that \eqn{k = \{1, 2 , 3, 4, 5\}}{k = {1, 2, 3, 4, 5}}.
\item \eqn{n} is a taxonomic name (genus, species, and subspecies);
\item \eqn{l_n}{l_n} is the length of \eqn{n};
\item lev is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function}, which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};
\item \eqn{p_n}{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
\item \eqn{k_n}{p_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.
}
This means that the user input \code{x = "E. coli"} gets for \emph{Escherichia coli} a matching score of 68.8\% and for \emph{Entamoeba coli} a matching score of 7.9\%.
The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. \strong{Group 1} (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Pseudomonas} and \emph{Legionella} and all species within the order Enterobacterales. \strong{Group 2} consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \emph{Absidia}, \emph{Acremonium}, \emph{Actinotignum}, \emph{Alternaria}, \emph{Anaerosalibacter}, \emph{Apophysomyces}, \emph{Arachnia}, \emph{Aspergillus}, \emph{Aureobacterium}, \emph{Aureobasidium}, \emph{Bacteroides}, \emph{Basidiobolus}, \emph{Beauveria}, \emph{Blastocystis}, \emph{Branhamella}, \emph{Calymmatobacterium}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Catabacter}, \emph{Chaetomium}, \emph{Chryseobacterium}, \emph{Chryseomonas}, \emph{Chrysonilia}, \emph{Cladophialophora}, \emph{Cladosporium}, \emph{Conidiobolus}, \emph{Cryptococcus}, \emph{Curvularia}, \emph{Exophiala}, \emph{Exserohilum}, \emph{Flavobacterium}, \emph{Fonsecaea}, \emph{Fusarium}, \emph{Fusobacterium}, \emph{Hendersonula}, \emph{Hypomyces}, \emph{Koserella}, \emph{Lelliottia}, \emph{Leptosphaeria}, \emph{Leptotrichia}, \emph{Malassezia}, \emph{Malbranchea}, \emph{Mortierella}, \emph{Mucor}, \emph{Mycocentrospora}, \emph{Mycoplasma}, \emph{Nectria}, \emph{Ochroconis}, \emph{Oidiodendron}, \emph{Phoma}, \emph{Piedraia}, \emph{Pithomyces}, \emph{Pityrosporum}, \emph{Prevotella},\\\emph{Pseudallescheria}, \emph{Rhizomucor}, \emph{Rhizopus}, \emph{Rhodotorula}, \emph{Scolecobasidium}, \emph{Scopulariopsis}, \emph{Scytalidium},\emph{Sporobolomyces}, \emph{Stachybotrys}, \emph{Stomatococcus}, \emph{Treponema}, \emph{Trichoderma}, \emph{Trichophyton}, \emph{Trichosporon}, \emph{Tritirachium} or \emph{Ureaplasma}. \strong{Group 3} consists of all other microorganisms.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., \code{"E. coli"} will return the microbial ID of \emph{Escherichia coli} (\eqn{m = 0.688}, a highly prevalent microorganism found in humans) and not \emph{Entamoeba coli} (\eqn{m = 0.079}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
}
\section{Catalogue of Life}{
@ -219,25 +213,6 @@ as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA
# All mo_* functions use as.mo() internally too (see ?mo_property):
mo_genus("E. coli") # returns "Escherichia"
mo_gramstain("E. coli") # returns "Gram negative"
}
\dontrun{
df$mo <- as.mo(df$microorganism_name)
# the select function of the Tidyverse is also supported:
library(dplyr)
df$mo <- df \%>\%
select(microorganism_name) \%>\%
as.mo()
# and can even contain 2 columns, which is convenient
# for genus/species combinations:
df$mo <- df \%>\%
select(genus, species) \%>\%
as.mo()
# although this works easier and does the same:
df <- df \%>\%
mutate(mo = as.mo(paste(genus, species)))
}
}
\seealso{

View File

@ -167,34 +167,6 @@ df <- data.frame(microorganism = "E. coli",
NIT = as.mic(32))
as.rsi(df)
\dontrun{
# the dplyr way
library(dplyr)
df \%>\% mutate_if(is.mic, as.rsi)
df \%>\% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
df \%>\% mutate(across(where(is.mic), as.rsi))
df \%>\% mutate_at(vars(AMP:TOB), as.rsi)
df \%>\% mutate(across(AMP:TOB), as.rsi)
df \%>\%
mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli")
# to include information about urinary tract infections (UTI)
data.frame(mo = "E. coli",
NIT = c("<= 2", 32),
from_the_bladder = c(TRUE, FALSE)) \%>\%
as.rsi(uti = "from_the_bladder")
data.frame(mo = "E. coli",
NIT = c("<= 2", 32),
specimen = c("urine", "blood")) \%>\%
as.rsi() # automatically determines urine isolates
df \%>\%
mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
}
# for single values
as.rsi(x = as.mic(2),
mo = as.mo("S. pneumoniae"),
@ -206,6 +178,32 @@ as.rsi(x = as.disk(18),
ab = "ampicillin", # and `ab` with as.ab()
guideline = "EUCAST")
\donttest{
# the dplyr way
if (require("dplyr")) {
df \%>\% mutate_if(is.mic, as.rsi)
df \%>\% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
df \%>\% mutate(across(where(is.mic), as.rsi))
df \%>\% mutate_at(vars(AMP:TOB), as.rsi)
df \%>\% mutate(across(AMP:TOB), as.rsi)
df \%>\%
mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli")
# to include information about urinary tract infections (UTI)
data.frame(mo = "E. coli",
NIT = c("<= 2", 32),
from_the_bladder = c(TRUE, FALSE)) \%>\%
as.rsi(uti = "from_the_bladder")
data.frame(mo = "E. coli",
NIT = c("<= 2", 32),
specimen = c("urine", "blood")) \%>\%
as.rsi() # automatically determines urine isolates
df \%>\%
mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
}
# For CLEANING existing R/SI values ------------------------------------
@ -216,25 +214,22 @@ is.rsi(rsi_data)
plot(rsi_data) # for percentages
barplot(rsi_data) # for frequencies
\dontrun{
library(dplyr)
example_isolates \%>\%
# the dplyr way
if (require("dplyr")) {
example_isolates \%>\%
mutate_at(vars(PEN:RIF), as.rsi)
# same:
example_isolates \%>\%
# same:
example_isolates \%>\%
as.rsi(PEN:RIF)
# fastest way to transform all columns with already valid AMR results to class `rsi`:
example_isolates \%>\%
# fastest way to transform all columns with already valid AMR results to class `rsi`:
example_isolates \%>\%
mutate_if(is.rsi.eligible, as.rsi)
# note: from dplyr 1.0.0 on, this will be:
# example_isolates \%>\%
# mutate(across(is.rsi.eligible, as.rsi))
# default threshold of `is.rsi.eligible` is 5\%.
is.rsi.eligible(WHONET$`First name`) # fails, >80\% is invalid
is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
# note: from dplyr 1.0.0 on, this will be:
# example_isolates \%>\%
# mutate(across(is.rsi.eligible, as.rsi))
}
}
}
\seealso{

View File

@ -80,16 +80,13 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
}
\examples{
\dontrun{
\donttest{
# oral DDD (Defined Daily Dose) of amoxicillin
atc_online_property("J01CA04", "DDD", "O")
# parenteral DDD (Defined Daily Dose) of amoxicillin
atc_online_property("J01CA04", "DDD", "P")
atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
# [1] "ANTIINFECTIVES FOR SYSTEMIC USE"
# [2] "ANTIBACTERIALS FOR SYSTEMIC USE"
# [3] "BETA-LACTAM ANTIBACTERIALS, PENICILLINS"
# [4] "Penicillins with extended spectrum"
}
}

View File

@ -36,15 +36,8 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
\examples{
availability(example_isolates)
\dontrun{
library(dplyr)
example_isolates \%>\% availability()
example_isolates \%>\%
select_if(is.rsi) \%>\%
availability()
example_isolates \%>\%
if (require("dplyr")) {
example_isolates \%>\%
filter(mo == as.mo("E. coli")) \%>\%
select_if(is.rsi) \%>\%
availability()

View File

@ -45,7 +45,7 @@ bug_drug_combinations(x, col_mo = NULL, FUN = mo_shortname, ...)
\item{add_ab_group}{logical to indicate where the group of the antimicrobials must be included as a first column}
\item{remove_intrinsic_resistant}{logical to indicate that rows with 100\% resistance for all tested antimicrobials must be removed from the table}
\item{remove_intrinsic_resistant}{logical to indicate that rows and columns with 100\% resistance for all tested antimicrobials must be removed from the table}
\item{decimal.mark}{the character to be used to indicate the numeric
decimal point.}
@ -83,10 +83,10 @@ x
format(x, translate_ab = "name (atc)")
# Use FUN to change to transformation of microorganism codes
x <- bug_drug_combinations(example_isolates,
bug_drug_combinations(example_isolates,
FUN = mo_gramstain)
x <- bug_drug_combinations(example_isolates,
bug_drug_combinations(example_isolates,
FUN = function(x) ifelse(x == as.mo("E. coli"),
"E. coli",
"Others"))

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -71,40 +71,43 @@ If the unlying code needs breaking changes, they will occur gradually. For examp
}
\examples{
\dontrun{
library(dplyr)
filter_aminoglycosides(example_isolates)
# filter on isolates that have any result for any aminoglycoside
example_isolates \%>\% filter_ab_class("aminoglycoside")
example_isolates \%>\% filter_aminoglycosides()
\donttest{
if (require("dplyr")) {
# this is essentially the same as (but without determination of column names):
example_isolates \%>\%
# filter on isolates that have any result for any aminoglycoside
example_isolates \%>\% filter_aminoglycosides()
example_isolates \%>\% filter_ab_class("aminoglycoside")
# this is essentially the same as (but without determination of column names):
example_isolates \%>\%
filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")),
.vars_predicate = any_vars(. \%in\% c("S", "I", "R")))
# filter on isolates that show resistance to ANY aminoglycoside
example_isolates \%>\% filter_aminoglycosides("R", "any")
# filter on isolates that show resistance to ANY aminoglycoside
example_isolates \%>\% filter_aminoglycosides("R", "any")
# filter on isolates that show resistance to ALL aminoglycosides
example_isolates \%>\% filter_aminoglycosides("R", "all")
# filter on isolates that show resistance to ALL aminoglycosides
example_isolates \%>\% filter_aminoglycosides("R", "all")
# filter on isolates that show resistance to
# any aminoglycoside and any fluoroquinolone
example_isolates \%>\%
# filter on isolates that show resistance to
# any aminoglycoside and any fluoroquinolone
example_isolates \%>\%
filter_aminoglycosides("R") \%>\%
filter_fluoroquinolones("R")
# filter on isolates that show resistance to
# all aminoglycosides and all fluoroquinolones
example_isolates \%>\%
# filter on isolates that show resistance to
# all aminoglycosides and all fluoroquinolones
example_isolates \%>\%
filter_aminoglycosides("R", "all") \%>\%
filter_fluoroquinolones("R", "all")
# with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
example_isolates \%>\% filter_carbapenems("R", "all")
example_isolates \%>\% filter(across(carbapenems(), ~. == "R"))
# with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
example_isolates \%>\% filter_carbapenems("R", "all")
example_isolates \%>\% filter(across(carbapenems(), ~. == "R"))
}
}
}
\seealso{

View File

@ -98,7 +98,8 @@ To conduct an analysis of antimicrobial resistance, you should only include the
All isolates with a microbial ID of \code{NA} will be excluded as first isolate.
The functions \code{\link[=filter_first_isolate]{filter_first_isolate()}} and \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} are helper functions to quickly filter on first isolates. The function \code{\link[=filter_first_isolate]{filter_first_isolate()}} is essentially equal to one of:\preformatted{ x \%>\% filter(first_isolate(., ...))
The functions \code{\link[=filter_first_isolate]{filter_first_isolate()}} and \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} are helper functions to quickly filter on first isolates. The function \code{\link[=filter_first_isolate]{filter_first_isolate()}} is essentially equal to either:\preformatted{ x[first_isolate(x, ...), ]
x \%>\% filter(first_isolate(x, ...))
}
The function \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} is essentially equal to:\preformatted{ x \%>\%
@ -139,49 +140,40 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
\dontrun{
library(dplyr)
# Filter on first isolates:
example_isolates \%>\%
# basic filtering on first isolates
example_isolates[first_isolate(example_isolates), ]
\donttest{
if (require("dplyr")) {
# Filter on first isolates:
example_isolates \%>\%
mutate(first_isolate = first_isolate(.)) \%>\%
filter(first_isolate == TRUE)
# Now let's see if first isolates matter:
A <- example_isolates \%>\%
# Short-hand versions:
example_isolates \%>\%
filter_first_isolate()
example_isolates \%>\%
filter_first_weighted_isolate()
# Now let's see if first isolates matter:
A <- example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(count = n_rsi(GEN), # gentamicin availability
resistance = resistance(GEN)) # gentamicin resistance
B <- example_isolates \%>\%
B <- example_isolates \%>\%
filter_first_weighted_isolate() \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
summarise(count = n_rsi(GEN), # gentamicin availability
resistance = resistance(GEN)) # gentamicin resistance
# Have a look at A and B.
# B is more reliable because every isolate is counted only once.
# Gentamicin resistance in hospital D appears to be 3.7\% higher than
# when you (erroneously) would have used all isolates for analysis.
## OTHER EXAMPLES:
# Short-hand versions:
example_isolates \%>\%
filter_first_isolate()
example_isolates \%>\%
filter_first_weighted_isolate()
# set key antibiotics to a new variable
x$keyab <- key_antibiotics(x)
x$first_isolate <- first_isolate(x)
x$first_isolate_weighed <- first_isolate(x, col_keyantibiotics = 'keyab')
x$first_blood_isolate <- first_isolate(x, specimen_group = "Blood")
# Have a look at A and B.
# B is more reliable because every isolate is counted only once.
# Gentamicin resistance in hospital D appears to be 3.7\% higher than
# when you (erroneously) would have used all isolates for analysis.
}
}
}
\seealso{

View File

@ -118,8 +118,7 @@ The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unly
# See ?example_isolates.
# See ?pca for more info about Principal Component Analysis (PCA).
\dontrun{
library(dplyr)
if (require("dplyr")) {
pca_model <- example_isolates \%>\%
filter(mo_genus(mo) == "Staphylococcus") \%>\%
group_by(species = mo_shortname(mo)) \%>\%

View File

@ -193,14 +193,14 @@ if (require("ggplot2") & require("dplyr")) {
}
\dontrun{
\donttest{
# resistance of ciprofloxacine per age group
example_isolates \%>\%
mutate(first_isolate = first_isolate(.)) \%>\%
filter(first_isolate == TRUE,
mo == as.mo("E. coli")) \%>\%
# `age_group` is also a function of this package:
# `age_groups` is also a function of this AMR package:
group_by(age_group = age_groups(age)) \%>\%
select(age_group,
CIP) \%>\%
@ -209,7 +209,8 @@ example_isolates \%>\%
# for colourblind mode, use divergent colours from the viridis package:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi() + scale_fill_viridis_d()
ggplot_rsi() +
scale_fill_viridis_d()
# a shorter version which also adjusts data label colours:
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%

View File

@ -57,18 +57,21 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
left_join_microorganisms(as.mo("K. pneumoniae"))
left_join_microorganisms("B_KLBSL_PNE")
\dontrun{
library(dplyr)
example_isolates \%>\% left_join_microorganisms()
\donttest{
if (require("dplyr")) {
example_isolates \%>\%
left_join_microorganisms() \%>\%
colnames()
df <- data.frame(date = seq(from = as.Date("2018-01-01"),
df <- data.frame(date = seq(from = as.Date("2018-01-01"),
to = as.Date("2018-01-07"),
by = 1),
bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR",
"E. coli", "E. coli", "E. coli")),
stringsAsFactors = FALSE)
colnames(df)
df_joined <- left_join_microorganisms(df, "bacteria")
colnames(df_joined)
colnames(df)
df_joined <- left_join_microorganisms(df, "bacteria")
colnames(df_joined)
}
}
}

View File

@ -136,10 +136,21 @@ On our website \url{https://msberends.github.io/AMR} you can find \href{https://
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
\dontrun{
library(dplyr)
# set key antibiotics to a new variable
my_patients <- example_isolates \%>\%
# output of the `key_antibiotics` function could be like this:
strainA <- "SSSRR.S.R..S"
strainB <- "SSSIRSSSRSSS"
# can those strings can be compared with:
key_antibiotics_equal(strainA, strainB)
# TRUE, because I is ignored (as well as missing values)
key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
# FALSE, because I is not ignored and so the 4th value differs
\donttest{
if (require("dplyr")) {
# set key antibiotics to a new variable
my_patients <- example_isolates \%>\%
mutate(keyab = key_antibiotics(.)) \%>\%
mutate(
# now calculate first isolates
@ -148,20 +159,11 @@ my_patients <- example_isolates \%>\%
first_weighted = first_isolate(., col_keyantibiotics = "keyab")
)
# Check the difference, in this data set it results in 7\% more isolates:
sum(my_patients$first_regular, na.rm = TRUE)
sum(my_patients$first_weighted, na.rm = TRUE)
# Check the difference, in this data set it results in 7\% more isolates:
sum(my_patients$first_regular, na.rm = TRUE)
sum(my_patients$first_weighted, na.rm = TRUE)
}
}
# output of the `key_antibiotics` function could be like this:
strainA <- "SSSRR.S.R..S"
strainB <- "SSSIRSSSRSSS"
key_antibiotics_equal(strainA, strainB)
# TRUE, because I is ignored (as well as missing values)
key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
# FALSE, because I is not ignored and so the 4th value differs
}
\seealso{
\code{\link[=first_isolate]{first_isolate()}}

View File

@ -68,12 +68,13 @@ a \%like\% b
#> TRUE TRUE TRUE
# get isolates whose name start with 'Ent' or 'ent'
\dontrun{
library(dplyr)
example_isolates \%>\%
\donttest{
if (require("dplyr")) {
example_isolates \%>\%
filter(mo_name(mo) \%like\% "^ent")
}
}
}
\seealso{
\code{\link[=grep]{grep()}}
}

File diff suppressed because one or more lines are too long

View File

@ -23,21 +23,22 @@ With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\li
where:
\itemize{
\item \eqn{x} is the user input;
\item \eqn{n} is a taxonomic name (genus, species and subspecies) as found in \code{\link[=microorganisms]{microorganisms$fullname}};
\item \eqn{l_{n}}{l_n} is the length of \eqn{n};
\item \eqn{\operatorname{lev}}{lev} is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function};
\item \eqn{p_{n}}{p_n} is the human pathogenic prevalence of \eqn{n}, categorised into group \eqn{1}, \eqn{2} and \eqn{3} (see \emph{Details} in \code{?as.mo}), meaning that \eqn{p = \{1, 2 , 3\}}{p = {1, 2, 3}};
\item \eqn{k_{n}}{k_n} is the kingdom index of \eqn{n}, set as follows: Bacteria = \eqn{1}, Fungi = \eqn{2}, Protozoa = \eqn{3}, Archaea = \eqn{4}, and all others = \eqn{5}, meaning that \eqn{k = \{1, 2 , 3, 4, 5\}}{k = {1, 2, 3, 4, 5}}.
\item \eqn{n} is a taxonomic name (genus, species, and subspecies);
\item \eqn{l_n}{l_n} is the length of \eqn{n};
\item lev is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function}, which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};
\item \eqn{p_n}{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
\item \eqn{k_n}{p_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.
}
This means that the user input \code{x = "E. coli"} gets for \emph{Escherichia coli} a matching score of 68.8\% and for \emph{Entamoeba coli} a matching score of 7.9\%.
The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. \strong{Group 1} (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Pseudomonas} and \emph{Legionella} and all species within the order Enterobacterales. \strong{Group 2} consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \emph{Absidia}, \emph{Acremonium}, \emph{Actinotignum}, \emph{Alternaria}, \emph{Anaerosalibacter}, \emph{Apophysomyces}, \emph{Arachnia}, \emph{Aspergillus}, \emph{Aureobacterium}, \emph{Aureobasidium}, \emph{Bacteroides}, \emph{Basidiobolus}, \emph{Beauveria}, \emph{Blastocystis}, \emph{Branhamella}, \emph{Calymmatobacterium}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Catabacter}, \emph{Chaetomium}, \emph{Chryseobacterium}, \emph{Chryseomonas}, \emph{Chrysonilia}, \emph{Cladophialophora}, \emph{Cladosporium}, \emph{Conidiobolus}, \emph{Cryptococcus}, \emph{Curvularia}, \emph{Exophiala}, \emph{Exserohilum}, \emph{Flavobacterium}, \emph{Fonsecaea}, \emph{Fusarium}, \emph{Fusobacterium}, \emph{Hendersonula}, \emph{Hypomyces}, \emph{Koserella}, \emph{Lelliottia}, \emph{Leptosphaeria}, \emph{Leptotrichia}, \emph{Malassezia}, \emph{Malbranchea}, \emph{Mortierella}, \emph{Mucor}, \emph{Mycocentrospora}, \emph{Mycoplasma}, \emph{Nectria}, \emph{Ochroconis}, \emph{Oidiodendron}, \emph{Phoma}, \emph{Piedraia}, \emph{Pithomyces}, \emph{Pityrosporum}, \emph{Prevotella},\\\emph{Pseudallescheria}, \emph{Rhizomucor}, \emph{Rhizopus}, \emph{Rhodotorula}, \emph{Scolecobasidium}, \emph{Scopulariopsis}, \emph{Scytalidium},\emph{Sporobolomyces}, \emph{Stachybotrys}, \emph{Stomatococcus}, \emph{Treponema}, \emph{Trichoderma}, \emph{Trichophyton}, \emph{Trichosporon}, \emph{Tritirachium} or \emph{Ureaplasma}. \strong{Group 3} consists of all other microorganisms.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., \code{"E. coli"} will return the microbial ID of \emph{Escherichia coli} (\eqn{m = 0.688}, a highly prevalent microorganism found in humans) and not \emph{Entamoeba coli} (\eqn{m = 0.079}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
}
\examples{
as.mo("E. coli")
mo_uncertainties()
mo_matching_score("E. coli", "Escherichia coli")
mo_matching_score(x = "E. coli",
n = c("Escherichia coli", "Entamoeba coli"))
}

View File

@ -133,16 +133,16 @@ With ambiguous user input in \code{\link[=as.mo]{as.mo()}} and all the \code{\li
where:
\itemize{
\item \eqn{x} is the user input;
\item \eqn{n} is a taxonomic name (genus, species and subspecies) as found in \code{\link[=microorganisms]{microorganisms$fullname}};
\item \eqn{l_{n}}{l_n} is the length of \eqn{n};
\item \eqn{\operatorname{lev}}{lev} is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function};
\item \eqn{p_{n}}{p_n} is the human pathogenic prevalence of \eqn{n}, categorised into group \eqn{1}, \eqn{2} and \eqn{3} (see \emph{Details} in \code{?as.mo}), meaning that \eqn{p = \{1, 2 , 3\}}{p = {1, 2, 3}};
\item \eqn{k_{n}}{k_n} is the kingdom index of \eqn{n}, set as follows: Bacteria = \eqn{1}, Fungi = \eqn{2}, Protozoa = \eqn{3}, Archaea = \eqn{4}, and all others = \eqn{5}, meaning that \eqn{k = \{1, 2 , 3, 4, 5\}}{k = {1, 2, 3, 4, 5}}.
\item \eqn{n} is a taxonomic name (genus, species, and subspecies);
\item \eqn{l_n}{l_n} is the length of \eqn{n};
\item lev is the \href{https://en.wikipedia.org/wiki/Levenshtein_distance}{Levenshtein distance function}, which counts any insertion, deletion and substitution as 1 that is needed to change \eqn{x} into \eqn{n};
\item \eqn{p_n}{p_n} is the human pathogenic prevalence group of \eqn{n}, as described below;
\item \eqn{k_n}{p_n} is the taxonomic kingdom of \eqn{n}, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.
}
This means that the user input \code{x = "E. coli"} gets for \emph{Escherichia coli} a matching score of 68.8\% and for \emph{Entamoeba coli} a matching score of 7.9\%.
The grouping into human pathogenic prevalence (\eqn{p}) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence. \strong{Group 1} (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is \emph{Enterococcus}, \emph{Staphylococcus} or \emph{Streptococcus}. This group consequently contains all common Gram-negative bacteria, such as \emph{Pseudomonas} and \emph{Legionella} and all species within the order Enterobacterales. \strong{Group 2} consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is \emph{Absidia}, \emph{Acremonium}, \emph{Actinotignum}, \emph{Alternaria}, \emph{Anaerosalibacter}, \emph{Apophysomyces}, \emph{Arachnia}, \emph{Aspergillus}, \emph{Aureobacterium}, \emph{Aureobasidium}, \emph{Bacteroides}, \emph{Basidiobolus}, \emph{Beauveria}, \emph{Blastocystis}, \emph{Branhamella}, \emph{Calymmatobacterium}, \emph{Candida}, \emph{Capnocytophaga}, \emph{Catabacter}, \emph{Chaetomium}, \emph{Chryseobacterium}, \emph{Chryseomonas}, \emph{Chrysonilia}, \emph{Cladophialophora}, \emph{Cladosporium}, \emph{Conidiobolus}, \emph{Cryptococcus}, \emph{Curvularia}, \emph{Exophiala}, \emph{Exserohilum}, \emph{Flavobacterium}, \emph{Fonsecaea}, \emph{Fusarium}, \emph{Fusobacterium}, \emph{Hendersonula}, \emph{Hypomyces}, \emph{Koserella}, \emph{Lelliottia}, \emph{Leptosphaeria}, \emph{Leptotrichia}, \emph{Malassezia}, \emph{Malbranchea}, \emph{Mortierella}, \emph{Mucor}, \emph{Mycocentrospora}, \emph{Mycoplasma}, \emph{Nectria}, \emph{Ochroconis}, \emph{Oidiodendron}, \emph{Phoma}, \emph{Piedraia}, \emph{Pithomyces}, \emph{Pityrosporum}, \emph{Prevotella},\\\emph{Pseudallescheria}, \emph{Rhizomucor}, \emph{Rhizopus}, \emph{Rhodotorula}, \emph{Scolecobasidium}, \emph{Scopulariopsis}, \emph{Scytalidium},\emph{Sporobolomyces}, \emph{Stachybotrys}, \emph{Stomatococcus}, \emph{Treponema}, \emph{Trichoderma}, \emph{Trichophyton}, \emph{Trichosporon}, \emph{Tritirachium} or \emph{Ureaplasma}. \strong{Group 3} consists of all other microorganisms.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned.
All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., \code{"E. coli"} will return the microbial ID of \emph{Escherichia coli} (\eqn{m = 0.688}, a highly prevalent microorganism found in humans) and not \emph{Entamoeba coli} (\eqn{m = 0.079}, a less prevalent microorganism in humans), although the latter would alphabetically come first.
}
\section{Catalogue of Life}{

View File

@ -17,6 +17,9 @@ Text
\description{
Return the symbol related to the p-value: 0 '\verb{***}' 0.001 '\verb{**}' 0.01 '\code{*}' 0.05 '\code{.}' 0.1 ' ' 1. Values above \code{p = 1} will return \code{NA}.
}
\details{
\strong{NOTE}: this function will be moved to the \code{cleaner} package when a new version is being published on CRAN.
}
\section{Questioning lifecycle}{
\if{html}{\figure{lifecycle_questioning.svg}{options: style=margin-bottom:5px} \cr}

View File

@ -69,21 +69,23 @@ The \link[=lifecycle]{lifecycle} of this function is \strong{maturing}. The unly
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
\dontrun{
# calculate the resistance per group first
library(dplyr)
resistance_data <- example_isolates \%>\%
\donttest{
if (require("dplyr")) {
# calculate the resistance per group first
resistance_data <- example_isolates \%>\%
group_by(order = mo_order(mo), # group on anything, like order
genus = mo_genus(mo)) \%>\% # and genus as we do here
summarise_if(is.rsi, resistance) # then get resistance of all drugs
# now conduct PCA for certain antimicrobial agents
pca_result <- resistance_data \%>\%
# now conduct PCA for certain antimicrobial agents
pca_result <- resistance_data \%>\%
pca(AMC, CXM, CTX, CAZ, GEN, TOB, TMP, SXT)
pca_result
summary(pca_result)
biplot(pca_result)
ggplot_pca(pca_result) # a new and convenient plot function
pca_result
summary(pca_result)
biplot(pca_result)
ggplot_pca(pca_result) # a new and convenient plot function
}
}
}

View File

@ -218,15 +218,6 @@ if (require("dplyr")) {
group_by(hospital_id) \%>\%
proportion_df(translate = FALSE)
}
\dontrun{
# calculate current empiric combination therapy of Helicobacter gastritis:
my_table \%>\%
filter(first_isolate == TRUE,
genus == "Helicobacter") \%>\%
summarise(p = susceptibility(AMX, MTR), # amoxicillin with metronidazole
n = count_all(AMX, MTR))
}
}
\seealso{
\code{\link[=count]{count()}} to count resistant and susceptible isolates.

View File

@ -150,9 +150,7 @@ if (require("dplyr")) {
}
# create nice plots with ggplot2 yourself
\dontrun{
library(dplyr)
library(ggplot2)
if (require("dplyr") & require("ggplot2")) {
data <- example_isolates \%>\%
filter(mo == as.mo("E. coli")) \%>\%

View File

@ -66,6 +66,8 @@ test_that("creation of data sets is valid", {
expect_true(all(c("fullname", "fullname_new", "ref", "prevalence",
"fullname_lower", "g_species") %in% colnames(olddf)))
expect_s3_class(create_species_cons_cops("CoNS"), "mo")
})
test_that("CoL version info works", {

View File

@ -31,14 +31,16 @@ test_that("mdro works", {
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
outcome <- suppressWarnings(mdro(example_isolates))
outcome <- mdro(example_isolates, "eucast3.1", info = TRUE)
outcome <- eucast_exceptional_phenotypes(example_isolates, info = TRUE)
# check class
expect_equal(outcome %>% class(), c("ordered", "factor"))
expect_equal(class(outcome), c("ordered", "factor"))
outcome <- mdro(example_isolates, "nl", info = TRUE)
# check class
expect_equal(outcome %>% class(), c("ordered", "factor"))
expect_equal(class(outcome), c("ordered", "factor"))
library(dplyr)
# example_isolates should have these finding using Dutch guidelines
expect_equal(outcome %>% cleaner::freq() %>% pull(count),
c(1969, 25, 6)) # 1969 neg, 25 unconfirmed, 6 pos

View File

@ -84,18 +84,20 @@ test_that("mic2rsi works", {
skip_on_cran()
# S. pneumoniae/ampicillin in EUCAST 2020: 0.5-2 ug/ml (R is only > 2)
expect_equal(as.character(
as.rsi(x = as.mic(0.125),
as.rsi(x = as.mic(c(0.125, 0.5, 1, 2, 4)),
mo = "B_STRPT_PNMN",
ab = "AMP",
guideline = "EUCAST 2020")),
c("S", "S", "I", "I", "R"))
# S. pneumoniae/amoxicillin in CLSI 2019: 2-8 ug/ml (R is 8 and > 8)
expect_equal(as.character(
as.rsi(x = as.mic(c(1, 2, 4, 8, 16)),
mo = "B_STRPT_PNMN",
ab = "AMX",
guideline = "EUCAST")),
"S")
expect_equal(as.character(
as.rsi(x = as.mic(4),
mo = "B_STRPT_PNMN",
ab = "AMX",
guideline = "EUCAST")),
"I")
guideline = "CLSI 2019")),
c("S", "S", "I", "R", "R"))
# cutoffs at MIC = 8
expect_equal(as.rsi(as.mic(2), "E. coli", "ampicillin", guideline = "EUCAST 2020"),