mirror of
https://github.com/msberends/AMR.git
synced 2024-12-24 19:26:12 +01:00
(v1.7.1.9016) only_treatable ab selectors
This commit is contained in:
parent
625a6fb304
commit
b228eb1536
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.7.1.9015
|
||||
Date: 2021-07-07
|
||||
Version: 1.7.1.9016
|
||||
Date: 2021-07-08
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
7
NEWS.md
7
NEWS.md
@ -1,11 +1,12 @@
|
||||
# `AMR` 1.7.1.9015
|
||||
## <small>Last updated: 7 July 2021</small>
|
||||
# `AMR` 1.7.1.9016
|
||||
## <small>Last updated: 8 July 2021</small>
|
||||
|
||||
### Changed
|
||||
* Antibiotic class selectors (see `ab_class()`)
|
||||
* They now finally also work in R-3.0 and R-3.1, supporting every version of R since 2013
|
||||
* They now also work in R-3.0 and R-3.1, supporting every version of R since 2013
|
||||
* Added more selectors: `aminopenicillins()`, `lincosamides()`, `lipoglycopeptides()`, `polymyxins()`, `quinolones()`, `streptogramins()` and `ureidopenicillins()`
|
||||
* Fix for using selectors multiple times in one call (e.g., using them in `dplyr::filter()` and immediately after in `dplyr::select()`)
|
||||
* Added argument `only_treatable`, which defaults to `TRUE` and will exclude drugs that are only for laboratory tests and not for treating patients (such as imipenem/EDTA and gentamicin-high)
|
||||
* Fix for duplicate ATC codes in the `antibiotics` data set
|
||||
* Added `ggplot2::autoplot()` generic for classes `<mic>`, `<disk>`, `<rsi>` and `<resistance_predict>`
|
||||
* Fix to prevent introducing `NA`s for old MO codes when running `as.mo()` on them
|
||||
|
@ -29,6 +29,7 @@
|
||||
#' @inheritSection lifecycle Stable Lifecycle
|
||||
#' @param ab_class an antimicrobial class, such as `"carbapenems"`. The columns `group`, `atc_group1` and `atc_group2` of the [antibiotics] data set will be searched (case-insensitive) for this value.
|
||||
#' @param only_rsi_columns a [logical] to indicate whether only columns of class `<rsi>` must be selected (defaults to `FALSE`), see [as.rsi()]
|
||||
#' @param only_treatable a [logical] to indicate whether agents that are only for laboratory tests should be excluded (defaults to `TRUE`), such as gentamicin-high (`GEH`) and imipenem/EDTA (`IPE`)
|
||||
#' @details
|
||||
#' These functions can be used in data set calls for selecting columns and filtering rows. They are heavily inspired by the [Tidyverse selection helpers][tidyselect::language] such as [`everything()`][tidyselect::everything()], but also work in base \R and not only in `dplyr` verbs. Nonetheless, they are very convenient to use with `dplyr` functions such as [`select()`][dplyr::select()], [`filter()`][dplyr::filter()] and [`summarise()`][dplyr::summarise()], see *Examples*.
|
||||
#'
|
||||
@ -123,17 +124,20 @@
|
||||
#' }
|
||||
#' }
|
||||
ab_class <- function(ab_class,
|
||||
only_rsi_columns = FALSE) {
|
||||
only_rsi_columns = FALSE,
|
||||
only_treatable = TRUE) {
|
||||
meet_criteria(ab_class, allow_class = "character", has_length = 1, allow_NULL = TRUE)
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
ab_selector(NULL, only_rsi_columns = only_rsi_columns, ab_class = ab_class)
|
||||
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
|
||||
ab_selector(NULL, only_rsi_columns = only_rsi_columns, ab_class = ab_class, only_treatable = only_treatable)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
aminoglycosides <- function(only_rsi_columns = FALSE) {
|
||||
aminoglycosides <- function(only_rsi_columns = FALSE, only_treatable = TRUE) {
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
ab_selector("aminoglycosides", only_rsi_columns = only_rsi_columns)
|
||||
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
|
||||
ab_selector("aminoglycosides", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@ -145,16 +149,18 @@ aminopenicillins <- function(only_rsi_columns = FALSE) {
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
betalactams <- function(only_rsi_columns = FALSE) {
|
||||
betalactams <- function(only_rsi_columns = FALSE, only_treatable = TRUE) {
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
ab_selector("betalactams", only_rsi_columns = only_rsi_columns)
|
||||
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
|
||||
ab_selector("betalactams", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
carbapenems <- function(only_rsi_columns = FALSE) {
|
||||
carbapenems <- function(only_rsi_columns = FALSE, only_treatable = TRUE) {
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
ab_selector("carbapenems", only_rsi_columns = only_rsi_columns)
|
||||
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
|
||||
ab_selector("carbapenems", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@ -250,9 +256,10 @@ penicillins <- function(only_rsi_columns = FALSE) {
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
#' @export
|
||||
polymyxins <- function(only_rsi_columns = FALSE) {
|
||||
polymyxins <- function(only_rsi_columns = FALSE, only_treatable = TRUE) {
|
||||
meet_criteria(only_rsi_columns, allow_class = "logical", has_length = 1)
|
||||
ab_selector("polymyxins", only_rsi_columns = only_rsi_columns)
|
||||
meet_criteria(only_treatable, allow_class = "logical", has_length = 1)
|
||||
ab_selector("polymyxins", only_rsi_columns = only_rsi_columns, only_treatable = only_treatable)
|
||||
}
|
||||
|
||||
#' @rdname antibiotic_class_selectors
|
||||
@ -285,6 +292,7 @@ ureidopenicillins <- function(only_rsi_columns = FALSE) {
|
||||
|
||||
ab_selector <- function(function_name,
|
||||
only_rsi_columns,
|
||||
only_treatable,
|
||||
ab_class = NULL) {
|
||||
# get_current_data() has to run each time, for cases where e.g., filter() and select() are used in same call
|
||||
# but it only takes a couple of milliseconds
|
||||
@ -292,6 +300,23 @@ ab_selector <- function(function_name,
|
||||
# to improve speed, get_column_abx() will only run once when e.g. in a select or group call
|
||||
ab_in_data <- get_column_abx(vars_df, info = FALSE, only_rsi_columns = only_rsi_columns, sort = FALSE)
|
||||
|
||||
# untreatable drugs
|
||||
untreatable <- antibiotics[which(antibiotics$name %like% "-high|EDTA|polysorbate"), "ab", drop = TRUE]
|
||||
if (only_treatable == TRUE & any(untreatable %in% names(ab_in_data))) {
|
||||
if (message_not_thrown_before(paste0("ab_class.untreatable.", function_name), entire_session = TRUE)) {
|
||||
warning_("Some agents in `", function_name, "()` were ignored since they cannot be used for treating patients: ",
|
||||
vector_and(ab_name(names(ab_in_data)[names(ab_in_data) %in% untreatable],
|
||||
language = NULL,
|
||||
tolower = TRUE),
|
||||
quotes = FALSE,
|
||||
sort = TRUE), ". They can be included using `", function_name, "(only_treatable = FALSE)`. ",
|
||||
"This warning will be shown once per session.",
|
||||
call = FALSE)
|
||||
remember_thrown_message(paste0("ab_class.untreatable.", function_name), entire_session = TRUE)
|
||||
}
|
||||
ab_in_data <- ab_in_data[!names(ab_in_data) %in% untreatable]
|
||||
}
|
||||
|
||||
if (length(ab_in_data) == 0) {
|
||||
message_("No antimicrobial agents found in the data.")
|
||||
return(NULL)
|
||||
|
@ -81,7 +81,7 @@ bug_drug_combinations <- function(x,
|
||||
unique_mo <- sort(unique(x[, col_mo, drop = TRUE]))
|
||||
|
||||
# select only groups and antibiotics
|
||||
if (inherits(x.bak, "grouped_df")) {
|
||||
if (is_null_or_grouped_tbl(x.bak)) {
|
||||
data_has_groups <- TRUE
|
||||
groups <- setdiff(names(attributes(x.bak)$groups), ".rows")
|
||||
x <- x[, c(groups, col_mo, colnames(x)[vapply(FUN.VALUE = logical(1), x, is.rsi)]), drop = FALSE]
|
||||
|
4
R/mo.R
4
R/mo.R
@ -469,11 +469,11 @@ exec_as.mo <- function(x,
|
||||
x <- strip_whitespace(x, dyslexia_mode)
|
||||
# translate 'unknown' names back to English
|
||||
if (any(x %like% "unbekannt|onbekend|desconocid|sconosciut|iconnu|desconhecid", na.rm = TRUE)) {
|
||||
trns <- subset(TRANSLATIONS, pattern %like% "unknown" | affect_mo_name == TRUE)
|
||||
trns <- subset(TRANSLATIONS, pattern %like% "unknown")
|
||||
langs <- LANGUAGES_SUPPORTED[LANGUAGES_SUPPORTED != "en"]
|
||||
for (l in langs) {
|
||||
for (i in seq_len(nrow(trns))) {
|
||||
if (!is.na(trns[i, l, drop = TRUE]) && trns[i, l, drop = TRUE] %unlike% "\\\\1") {
|
||||
if (!is.na(trns[i, l, drop = TRUE])) {
|
||||
x <- gsub(pattern = trns[i, l, drop = TRUE],
|
||||
replacement = trns$pattern[i],
|
||||
x = x,
|
||||
|
@ -228,7 +228,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
|
||||
translate_ab <- get_translate_ab(translate_ab)
|
||||
|
||||
# select only groups and antibiotics
|
||||
if (inherits(data, "grouped_df")) {
|
||||
if (is_null_or_grouped_tbl(data)) {
|
||||
data_has_groups <- TRUE
|
||||
groups <- setdiff(names(attributes(data)$groups), ".rows")
|
||||
data <- data[, c(groups, colnames(data)[vapply(FUN.VALUE = logical(1), data, is.rsi)]), drop = FALSE]
|
||||
|
BIN
R/sysdata.rda
BIN
R/sysdata.rda
Binary file not shown.
3
R/zzz.R
3
R/zzz.R
@ -38,7 +38,7 @@ if (utf8_supported && !is_latex) {
|
||||
pkg_env$info_icon <- "i"
|
||||
}
|
||||
|
||||
.onLoad <- function(libname, pkgname) {
|
||||
.onLoad <- function(...) {
|
||||
# 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:
|
||||
@ -86,7 +86,6 @@ if (utf8_supported && !is_latex) {
|
||||
assign(x = "INTRINSIC_R", value = create_intr_resistance(), envir = asNamespace("AMR"))
|
||||
}
|
||||
|
||||
|
||||
# Helper functions --------------------------------------------------------
|
||||
|
||||
create_AB_lookup <- function() {
|
||||
|
Binary file not shown.
@ -70,6 +70,8 @@ TRANSLATIONS <- utils::read.delim(file = "data-raw/translations.tsv",
|
||||
# for checking input in `language` argument in e.g. mo_*() and ab_*() functions
|
||||
LANGUAGES_SUPPORTED <- sort(c("en", colnames(TRANSLATIONS)[nchar(colnames(TRANSLATIONS)) == 2]))
|
||||
|
||||
# EXAMPLE_ISOLATES <- readRDS("data-raw/example_isolates.rds")
|
||||
|
||||
# vectors of CoNS and CoPS, improves speed in as.mo()
|
||||
create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
|
||||
# Determination of which staphylococcal species are CoNS/CoPS according to:
|
||||
@ -147,6 +149,7 @@ DEFINED_AB_GROUPS <- DEFINED_AB_GROUPS[!DEFINED_AB_GROUPS %in% globalenv_before_
|
||||
usethis::use_data(EUCAST_RULES_DF,
|
||||
TRANSLATIONS,
|
||||
LANGUAGES_SUPPORTED,
|
||||
# EXAMPLE_ISOLATES,
|
||||
MO_CONS,
|
||||
MO_COPS,
|
||||
AMINOGLYCOSIDES,
|
||||
|
BIN
data-raw/example_isolates.rds
Normal file
BIN
data-raw/example_isolates.rds
Normal file
Binary file not shown.
@ -16,19 +16,20 @@ unknown genus TRUE TRUE FALSE TRUE unbekannte Gattung onbekend geslacht género
|
||||
unknown species TRUE TRUE FALSE TRUE unbekannte Art onbekende soort especie desconocida specie sconosciute espèce inconnue espécies desconhecida
|
||||
unknown subspecies TRUE TRUE FALSE TRUE unbekannte Unterart onbekende ondersoort subespecie desconocida sottospecie sconosciute sous-espèce inconnue subespécies desconhecida
|
||||
unknown rank TRUE TRUE FALSE TRUE unbekannter Rang onbekende rang rango desconocido grado sconosciuto rang inconnu classificação desconhecido
|
||||
CoNS FALSE TRUE FALSE TRUE KNS CNS SCN
|
||||
CoPS FALSE TRUE FALSE TRUE KPS CPS SCP
|
||||
Gram-negative TRUE TRUE FALSE TRUE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo
|
||||
Gram-positive TRUE TRUE FALSE TRUE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo
|
||||
^Bacteria$ TRUE TRUE FALSE TRUE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias
|
||||
^Fungi$ TRUE TRUE FALSE TRUE Pilze Schimmels Hongos Funghi Champignons Fungos
|
||||
^Yeasts$ TRUE TRUE FALSE TRUE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
||||
^Protozoa$ TRUE TRUE FALSE TRUE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
||||
biogroup TRUE TRUE FALSE TRUE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
||||
biotype TRUE TRUE FALSE TRUE Biotyp biotipo biotipo biótipo
|
||||
vegetative TRUE TRUE FALSE TRUE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
||||
([([ ]*?)group TRUE TRUE FALSE TRUE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
||||
([([ ]*?)Group TRUE TRUE FALSE TRUE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
|
||||
group TRUE TRUE FALSE TRUE Gruppe groep grupo gruppo groupe grupo
|
||||
CoNS FALSE TRUE FALSE FALSE KNS CNS SCN
|
||||
CoPS FALSE TRUE FALSE FALSE KPS CPS SCP
|
||||
Gram-negative TRUE TRUE FALSE FALSE Gramnegativ Gram-negatief Gram negativo Gram negativo Gram négatif Gram negativo
|
||||
Gram-positive TRUE TRUE FALSE FALSE Grampositiv Gram-positief Gram positivo Gram positivo Gram positif Gram positivo
|
||||
^Bacteria$ TRUE TRUE FALSE FALSE Bakterien Bacteriën Bacterias Batteri Bactéries Bactérias
|
||||
^Fungi$ TRUE TRUE FALSE FALSE Pilze Schimmels Hongos Funghi Champignons Fungos
|
||||
^Yeasts$ TRUE TRUE FALSE FALSE Hefen Gisten Levaduras Lieviti Levures Leveduras
|
||||
^Protozoa$ TRUE TRUE FALSE FALSE Protozoen Protozoën Protozoarios Protozoi Protozoaires Protozoários
|
||||
biogroup TRUE TRUE FALSE FALSE Biogruppe biogroep biogrupo biogruppo biogroupe biogrupo
|
||||
biotype TRUE TRUE FALSE FALSE Biotyp biotipo biotipo biótipo
|
||||
vegetative TRUE TRUE FALSE FALSE vegetativ vegetatief vegetativo vegetativo végétatif vegetativo
|
||||
([([ ]*?)group TRUE TRUE FALSE FALSE \\1Gruppe \\1groep \\1grupo \\1gruppo \\1groupe \\1grupo
|
||||
([([ ]*?)Group TRUE TRUE FALSE FALSE \\1Gruppe \\1Groep \\1Grupo \\1Gruppo \\1Groupe \\1Grupo
|
||||
no .*growth TRUE FALSE FALSE FALSE keine? .*wachstum geen .*groei no .*crecimientonon sem .*crescimento pas .*croissance sem .*crescimento
|
||||
no|not TRUE FALSE FALSE FALSE keine? geen|niet no|sin sem non sem
|
||||
Susceptible TRUE FALSE FALSE FALSE Empfindlich Gevoelig Susceptible
|
||||
|
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -39,7 +39,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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<div class="page-header toc-ignore">
|
||||
<h1 data-toc-skip>Data sets for download / own use</h1>
|
||||
|
||||
<h4 class="date">07 July 2021</h4>
|
||||
<h4 class="date">08 July 2021</h4>
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/datasets.Rmd"><code>vignettes/datasets.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>datasets.Rmd</code></div>
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -42,7 +42,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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,12 +236,12 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1719015" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.7.1.9015">
|
||||
<a href="#amr-1719015" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9015</h1>
|
||||
<div id="last-updated-7-july-2021" class="section level2">
|
||||
<div id="amr-1719016" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.7.1.9016">
|
||||
<a href="#amr-1719016" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.7.1.9016</h1>
|
||||
<div id="last-updated-8-july-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-7-july-2021" class="anchor"></a><small>Last updated: 7 July 2021</small>
|
||||
<a href="#last-updated-8-july-2021" class="anchor"></a><small>Last updated: 8 July 2021</small>
|
||||
</h2>
|
||||
<div id="changed" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -249,10 +249,11 @@
|
||||
<ul>
|
||||
<li>Antibiotic class selectors (see <code><a href="../reference/antibiotic_class_selectors.html">ab_class()</a></code>)
|
||||
<ul>
|
||||
<li>They now finally also work in R-3.0 and R-3.1, supporting every version of R since 2013</li>
|
||||
<li>They now also work in R-3.0 and R-3.1, supporting every version of R since 2013</li>
|
||||
<li>Added more selectors: <code><a href="../reference/antibiotic_class_selectors.html">aminopenicillins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">lincosamides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">lipoglycopeptides()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">polymyxins()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">quinolones()</a></code>, <code><a href="../reference/antibiotic_class_selectors.html">streptogramins()</a></code> and <code><a href="../reference/antibiotic_class_selectors.html">ureidopenicillins()</a></code>
|
||||
</li>
|
||||
<li>Fix for using selectors multiple times in one call (e.g., using them in <code><a href="https://dplyr.tidyverse.org/reference/filter.html">dplyr::filter()</a></code> and immediately after in <code><a href="https://dplyr.tidyverse.org/reference/select.html">dplyr::select()</a></code>)</li>
|
||||
<li>Added argument <code>only_treatable</code>, which defaults to <code>TRUE</code> and will exclude drugs that are only for laboratory tests and not for treating patients (such as imipenem/EDTA and gentamicin-high)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Fix for duplicate ATC codes in the <code>antibiotics</code> data set</li>
|
||||
|
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-07-07T18:31Z
|
||||
last_built: 2021-07-08T20:22Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -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.7.1.9014</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -242,15 +242,15 @@
|
||||
<p>These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.</p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ab_class</span><span class='op'>(</span><span class='va'>ab_class</span>, only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<pre class="usage"><span class='fu'>ab_class</span><span class='op'>(</span><span class='va'>ab_class</span>, only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>, only_treatable <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>aminoglycosides</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='fu'>aminoglycosides</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>, only_treatable <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>aminopenicillins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>betalactams</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='fu'>betalactams</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>, only_treatable <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>carbapenems</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='fu'>carbapenems</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>, only_treatable <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>cephalosporins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
@ -278,7 +278,7 @@
|
||||
|
||||
<span class='fu'>penicillins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>polymyxins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
<span class='fu'>polymyxins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span>, only_treatable <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
|
||||
|
||||
<span class='fu'>streptogramins</span><span class='op'>(</span>only_rsi_columns <span class='op'>=</span> <span class='cn'>FALSE</span><span class='op'>)</span>
|
||||
|
||||
@ -299,6 +299,10 @@
|
||||
<th>only_rsi_columns</th>
|
||||
<td><p>a <a href='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether only columns of class <code><rsi></code> must be selected (defaults to <code>FALSE</code>), see <code><a href='as.rsi.html'>as.rsi()</a></code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>only_treatable</th>
|
||||
<td><p>a <a href='https://rdrr.io/r/base/logical.html'>logical</a> to indicate whether agents that are only for laboratory tests should be excluded (defaults to <code>TRUE</code>), such as gentamicin-high (<code>GEH</code>) and imipenem/EDTA (<code>IPE</code>)</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.7.1.9015</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9016</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -28,20 +28,17 @@ expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli"))
|
||||
expect_equal(mo_phylum("Escherichia coli"), "Proteobacteria")
|
||||
expect_equal(mo_class("Escherichia coli"), "Gammaproteobacteria")
|
||||
expect_equal(mo_order("Escherichia coli"), "Enterobacterales")
|
||||
|
||||
# S3 class for taxonomic names
|
||||
expect_inherits(mo_family("Escherichia coli"), "taxonomic_name")
|
||||
expect_equal(as.character(mo_family("Escherichia coli")), "Enterobacteriaceae")
|
||||
expect_equal(as.character(mo_fullname("Escherichia coli")), "Escherichia coli")
|
||||
expect_equal(as.character(mo_genus("Escherichia coli")), "Escherichia")
|
||||
expect_equal(as.character(mo_name("Escherichia coli")), "Escherichia coli")
|
||||
expect_equal(as.character(mo_shortname("Escherichia coli")), "E. coli")
|
||||
expect_equal(as.character(mo_shortname("Escherichia")), "Escherichia")
|
||||
expect_equal(as.character(mo_shortname("Staphylococcus aureus")), "S. aureus")
|
||||
expect_equal(as.character(mo_shortname("Staphylococcus aureus", Becker = TRUE)), "S. aureus")
|
||||
expect_equal(as.character(mo_shortname("Staphylococcus aureus", Becker = "all", language = "en")), "CoPS")
|
||||
expect_equal(as.character(mo_shortname("Streptococcus agalactiae")), "S. agalactiae")
|
||||
expect_equal(as.character(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE)), "GBS")
|
||||
expect_equal(mo_family("Escherichia coli"), "Enterobacteriaceae")
|
||||
expect_equal(mo_fullname("Escherichia coli"), "Escherichia coli")
|
||||
expect_equal(mo_genus("Escherichia coli"), "Escherichia")
|
||||
expect_equal(mo_name("Escherichia coli"), "Escherichia coli")
|
||||
expect_equal(mo_shortname("Escherichia coli"), "E. coli")
|
||||
expect_equal(mo_shortname("Escherichia"), "Escherichia")
|
||||
expect_equal(mo_shortname("Staphylococcus aureus"), "S. aureus")
|
||||
expect_equal(mo_shortname("Staphylococcus aureus", Becker = TRUE), "S. aureus")
|
||||
expect_equal(mo_shortname("Staphylococcus aureus", Becker = "all", language = "en"), "CoPS")
|
||||
expect_equal(mo_shortname("Streptococcus agalactiae"), "S. agalactiae")
|
||||
expect_equal(mo_shortname("Streptococcus agalactiae", Lancefield = TRUE), "GBS")
|
||||
|
||||
expect_equal(mo_species("Escherichia coli"), "coli")
|
||||
expect_equal(mo_subspecies("Escherichia coli"), "")
|
||||
@ -68,7 +65,7 @@ expect_true(mo_url("Escherichia coli") %like% "lpsn.dsmz.de")
|
||||
|
||||
# test integrity
|
||||
MOs <- microorganisms
|
||||
expect_identical(MOs$fullname, as.character(mo_fullname(MOs$fullname, language = "en")))
|
||||
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
|
||||
|
||||
# check languages
|
||||
expect_equal(mo_type("Escherichia coli", language = "de"), "Bakterien")
|
||||
@ -84,7 +81,7 @@ expect_stdout(print(mo_gramstain("Escherichia coli", language = "fr")))
|
||||
|
||||
expect_error(mo_gramstain("Escherichia coli", language = "UNKNOWN"))
|
||||
dutch <- mo_name(microorganisms$fullname, language = "nl") # should be transformable to English again
|
||||
expect_identical(as.character(mo_name(dutch, language = NULL)), microorganisms$fullname) # gigantic test - will run ALL names
|
||||
expect_identical(mo_name(dutch, language = NULL), microorganisms$fullname) # gigantic test - will run ALL names
|
||||
|
||||
# manual property function
|
||||
expect_error(mo_property("Escherichia coli", property = c("tsn", "fullname")))
|
||||
@ -120,7 +117,7 @@ expect_equal(mo_is_intrinsic_resistant(c("Escherichia coli", "Staphylococcus aur
|
||||
"vanco"),
|
||||
c(TRUE, FALSE, FALSE))
|
||||
# with reference data
|
||||
expect_equal(as.character(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI"))),
|
||||
expect_equal(mo_name("test", reference_df = data.frame(col1 = "test", mo = "B_ESCHR_COLI")),
|
||||
"Escherichia coli")
|
||||
if (AMR:::pkg_is_available("dplyr")) {
|
||||
expect_equal(example_isolates %>% filter(mo_is_gram_negative()) %>% nrow(),
|
||||
|
@ -27,15 +27,15 @@
|
||||
\alias{ureidopenicillins}
|
||||
\title{Antibiotic Class Selectors}
|
||||
\usage{
|
||||
ab_class(ab_class, only_rsi_columns = FALSE)
|
||||
ab_class(ab_class, only_rsi_columns = FALSE, only_treatable = TRUE)
|
||||
|
||||
aminoglycosides(only_rsi_columns = FALSE)
|
||||
aminoglycosides(only_rsi_columns = FALSE, only_treatable = TRUE)
|
||||
|
||||
aminopenicillins(only_rsi_columns = FALSE)
|
||||
|
||||
betalactams(only_rsi_columns = FALSE)
|
||||
betalactams(only_rsi_columns = FALSE, only_treatable = TRUE)
|
||||
|
||||
carbapenems(only_rsi_columns = FALSE)
|
||||
carbapenems(only_rsi_columns = FALSE, only_treatable = TRUE)
|
||||
|
||||
cephalosporins(only_rsi_columns = FALSE)
|
||||
|
||||
@ -63,7 +63,7 @@ oxazolidinones(only_rsi_columns = FALSE)
|
||||
|
||||
penicillins(only_rsi_columns = FALSE)
|
||||
|
||||
polymyxins(only_rsi_columns = FALSE)
|
||||
polymyxins(only_rsi_columns = FALSE, only_treatable = TRUE)
|
||||
|
||||
streptogramins(only_rsi_columns = FALSE)
|
||||
|
||||
@ -77,6 +77,8 @@ ureidopenicillins(only_rsi_columns = FALSE)
|
||||
\item{ab_class}{an antimicrobial class, such as \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
|
||||
|
||||
\item{only_rsi_columns}{a \link{logical} to indicate whether only columns of class \verb{<rsi>} must be selected (defaults to \code{FALSE}), see \code{\link[=as.rsi]{as.rsi()}}}
|
||||
|
||||
\item{only_treatable}{a \link{logical} to indicate whether agents that are only for laboratory tests should be excluded (defaults to \code{TRUE}), such as gentamicin-high (\code{GEH}) and imipenem/EDTA (\code{IPE})}
|
||||
}
|
||||
\description{
|
||||
These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
|
||||
|
Loading…
Reference in New Issue
Block a user