mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 04:46:11 +01:00
(v1.6.0.9022) unit test fix
This commit is contained in:
parent
29dbfa2f49
commit
655b813e99
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.6.0.9021
|
Version: 1.6.0.9022
|
||||||
Date: 2021-05-12
|
Date: 2021-05-13
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(role = c("aut", "cre"),
|
person(role = c("aut", "cre"),
|
||||||
|
4
NEWS.md
4
NEWS.md
@ -1,5 +1,5 @@
|
|||||||
# `AMR` 1.6.0.9021
|
# `AMR` 1.6.0.9022
|
||||||
## <small>Last updated: 12 May 2021</small>
|
## <small>Last updated: 13 May 2021</small>
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
* Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()`
|
||||||
|
@ -240,7 +240,13 @@ eucast_rules <- function(x,
|
|||||||
cat(font_subtle(" (no changes)\n"))
|
cat(font_subtle(" (no changes)\n"))
|
||||||
} else {
|
} else {
|
||||||
# opening
|
# opening
|
||||||
cat(font_grey(" ("))
|
if (n_added > 0 & n_changed == 0) {
|
||||||
|
cat(font_green(" ("))
|
||||||
|
} else if (n_added == 0 & n_changed > 0) {
|
||||||
|
cat(font_blue(" ("))
|
||||||
|
} else {
|
||||||
|
cat(font_grey(" ("))
|
||||||
|
}
|
||||||
# additions
|
# additions
|
||||||
if (n_added > 0) {
|
if (n_added > 0) {
|
||||||
if (n_added == 1) {
|
if (n_added == 1) {
|
||||||
@ -262,7 +268,13 @@ eucast_rules <- function(x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# closing
|
# closing
|
||||||
cat(font_grey(")\n"))
|
if (n_added > 0 & n_changed == 0) {
|
||||||
|
cat(font_green(")\n"))
|
||||||
|
} else if (n_added == 0 & n_changed > 0) {
|
||||||
|
cat(font_blue(")\n"))
|
||||||
|
} else {
|
||||||
|
cat(font_grey(")\n"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
warned <<- FALSE
|
warned <<- FALSE
|
||||||
}
|
}
|
||||||
@ -398,7 +410,7 @@ eucast_rules <- function(x,
|
|||||||
paste0(x, collapse = "")
|
paste0(x, collapse = "")
|
||||||
})
|
})
|
||||||
|
|
||||||
# save original [table], with the new .rowid column
|
# save original table, with the new .rowid column
|
||||||
x.bak <- x
|
x.bak <- x
|
||||||
# keep only unique rows for MO and ABx
|
# keep only unique rows for MO and ABx
|
||||||
x <- x %pm>%
|
x <- x %pm>%
|
||||||
@ -413,7 +425,7 @@ eucast_rules <- function(x,
|
|||||||
# join to microorganisms data set
|
# join to microorganisms data set
|
||||||
x <- left_join_microorganisms(x, by = col_mo, suffix = c("_oldcols", ""))
|
x <- left_join_microorganisms(x, by = col_mo, suffix = c("_oldcols", ""))
|
||||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||||
x$genus_species <- paste(x$genus, x$species)
|
x$genus_species <- trimws(paste(x$genus, x$species))
|
||||||
if (info == TRUE & NROW(x) > 10000) {
|
if (info == TRUE & NROW(x) > 10000) {
|
||||||
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
message_(" OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
@ -902,21 +914,23 @@ eucast_rules <- function(x,
|
|||||||
cat(paste0(font_grey(strrep("-", 0.95 * options()$width)), "\n"))
|
cat(paste0(font_grey(strrep("-", 0.95 * options()$width)), "\n"))
|
||||||
|
|
||||||
if (verbose == FALSE & total_n_added + total_n_changed > 0) {
|
if (verbose == FALSE & total_n_added + total_n_changed > 0) {
|
||||||
cat("\n", word_wrap("Use ", font_bold("eucast_rules(..., verbose = TRUE)"), " (on your original data) to get a [data.frame] with all specified edits instead."), "\n\n", sep = "")
|
cat("\n", word_wrap("Use ", font_bold("eucast_rules(..., verbose = TRUE)"), " (on your original data) to get a data.frame with all specified edits instead."), "\n\n", sep = "")
|
||||||
} else if (verbose == TRUE) {
|
} else if (verbose == TRUE) {
|
||||||
cat("\n", word_wrap("Used 'Verbose mode' (", font_bold("verbose = TRUE"), "), which returns a [data.frame] with all specified edits.\nUse ", font_bold("verbose = FALSE"), " to apply the rules on your data."), "\n\n", sep = "")
|
cat("\n", word_wrap("Used 'Verbose mode' (", font_bold("verbose = TRUE"), "), which returns a data.frame with all specified edits.\nUse ", font_bold("verbose = FALSE"), " to apply the rules on your data."), "\n\n", sep = "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length(warn_lacking_rsi_class) > 0) {
|
if (length(warn_lacking_rsi_class) > 0) {
|
||||||
warn_lacking_rsi_class <- unique(warn_lacking_rsi_class)
|
warn_lacking_rsi_class <- unique(warn_lacking_rsi_class)
|
||||||
|
# take order from original data set
|
||||||
|
warn_lacking_rsi_class <- warn_lacking_rsi_class[order(colnames(x.bak))]
|
||||||
|
warn_lacking_rsi_class <- warn_lacking_rsi_class[!is.na(warn_lacking_rsi_class)]
|
||||||
warning_("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
warning_("Not all columns with antimicrobial results are of class <rsi>. Transform them on beforehand, with e.g.:\n",
|
||||||
" ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
" - ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
||||||
" ", x_deparsed, " %>% mutate(across((is.rsi.eligible), as.rsi))\n",
|
|
||||||
" ", x_deparsed, " %>% as.rsi(", ifelse(length(warn_lacking_rsi_class) == 1,
|
|
||||||
warn_lacking_rsi_class,
|
warn_lacking_rsi_class,
|
||||||
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])),
|
paste0(warn_lacking_rsi_class[1], ":", warn_lacking_rsi_class[length(warn_lacking_rsi_class)])), ")\n",
|
||||||
")",
|
" - ", x_deparsed, " %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||||
|
" - ", x_deparsed, " %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||||
call = FALSE)
|
call = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -936,7 +950,7 @@ eucast_rules <- function(x,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# helper function for editing the [table] ----
|
# helper function for editing the table ----
|
||||||
edit_rsi <- function(x,
|
edit_rsi <- function(x,
|
||||||
to,
|
to,
|
||||||
rule,
|
rule,
|
||||||
@ -961,7 +975,7 @@ edit_rsi <- function(x,
|
|||||||
}
|
}
|
||||||
txt_warning <- function() {
|
txt_warning <- function() {
|
||||||
if (warned == FALSE) {
|
if (warned == FALSE) {
|
||||||
if (info == TRUE) cat("", font_yellow_bg(font_black(" WARNING ")))
|
if (info == TRUE) cat(" ", font_rsi_I_bg(" WARNING "), sep = "")
|
||||||
}
|
}
|
||||||
warned <<- TRUE
|
warned <<- TRUE
|
||||||
}
|
}
|
||||||
@ -975,20 +989,22 @@ edit_rsi <- function(x,
|
|||||||
# insert into original table
|
# insert into original table
|
||||||
new_edits[rows, cols] <- to,
|
new_edits[rows, cols] <- to,
|
||||||
warning = function(w) {
|
warning = function(w) {
|
||||||
if (w$message %like% "invalid [factor] level") {
|
if (w$message %like% "invalid factor level") {
|
||||||
xyz <- vapply(FUN.VALUE = logical(1), cols, function(col) {
|
xyz <- vapply(FUN.VALUE = logical(1), cols, function(col) {
|
||||||
new_edits[, col] <<- factor(x = as.character(pm_pull(new_edits, col)),
|
new_edits[, col] <<- factor(x = as.character(pm_pull(new_edits, col)),
|
||||||
levels = unique(c(to, levels(pm_pull(new_edits, col)))))
|
levels = unique(c(to, levels(pm_pull(new_edits, col)))))
|
||||||
TRUE
|
TRUE
|
||||||
})
|
})
|
||||||
suppressWarnings(new_edits[rows, cols] <<- to)
|
suppressWarnings(new_edits[rows, cols] <<- to)
|
||||||
warning_('Value "', to, '" added to the [factor] levels of column(s) `', paste(cols, collapse = "`, `"), "` because this value was not an existing [factor] level. A better way is to use as.rsi() on beforehand on antimicrobial columns to guarantee the right structure.", call = FALSE)
|
warning_("Value \"", to, "\" added to the factor levels of column", ifelse(length(cols) == 1, "", "s"),
|
||||||
|
" ", vector_and(cols, quotes = "`", sort = FALSE),
|
||||||
|
" because this value was not an existing factor level.",
|
||||||
|
call = FALSE)
|
||||||
txt_warning()
|
txt_warning()
|
||||||
warned <- FALSE
|
warned <- FALSE
|
||||||
} else {
|
} else {
|
||||||
warning_(w$message, call = FALSE)
|
warning_(w$message, call = FALSE)
|
||||||
txt_warning()
|
txt_warning()
|
||||||
cat("\n") # txt_warning() does not append a "\n" on itself
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
|
@ -105,7 +105,7 @@ semi_join_microorganisms <- function(x, by = NULL, ...) {
|
|||||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
|
||||||
join_microorganisms(type = "semi_join", x = x, by = by, suffix = suffix, ...)
|
join_microorganisms(type = "semi_join", x = x, by = by, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname join
|
#' @rdname join
|
||||||
@ -114,7 +114,7 @@ anti_join_microorganisms <- function(x, by = NULL, ...) {
|
|||||||
meet_criteria(x, allow_class = c("data.frame", "character"))
|
meet_criteria(x, allow_class = c("data.frame", "character"))
|
||||||
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
meet_criteria(by, allow_class = "character", allow_NULL = TRUE)
|
||||||
|
|
||||||
join_microorganisms(type = "anti_join", x = x, by = by, suffix = suffix, ...)
|
join_microorganisms(type = "anti_join", x = x, by = by, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
join_microorganisms <- function(type, x, by, suffix, ...) {
|
join_microorganisms <- function(type, x, by, suffix, ...) {
|
||||||
@ -126,8 +126,12 @@ join_microorganisms <- function(type, x, by, suffix, ...) {
|
|||||||
}
|
}
|
||||||
if (is.null(by)) {
|
if (is.null(by)) {
|
||||||
by <- search_type_in_df(x, "mo", info = FALSE)
|
by <- search_type_in_df(x, "mo", info = FALSE)
|
||||||
stop_if(is.null(by), "cannot join - no column with microorganism names or codes found")
|
if (is.null(by) && NCOL(x) == 1) {
|
||||||
# message_('Joining, by = "', by, '"', add_fn = font_black, as_note = FALSE) # message same as dplyr::join functions
|
by <- colnames(x)[1L]
|
||||||
|
} else {
|
||||||
|
stop_if(is.null(by), "no column with microorganism names or codes found, set this column with `by`", call = -2)
|
||||||
|
}
|
||||||
|
message_('Joining, by = "', by, '"', add_fn = font_black, as_note = FALSE) # message same as dplyr::join functions
|
||||||
}
|
}
|
||||||
if (!all(x[, by, drop = TRUE] %in% MO_lookup$mo, na.rm = TRUE)) {
|
if (!all(x[, by, drop = TRUE] %in% MO_lookup$mo, na.rm = TRUE)) {
|
||||||
x$join.mo <- as.mo(x[, by, drop = TRUE])
|
x$join.mo <- as.mo(x[, by, drop = TRUE])
|
||||||
@ -166,7 +170,7 @@ join_microorganisms <- function(type, x, by, suffix, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type %like% "full|left|right|inner" && NROW(joined) > NROW(x)) {
|
if (type %like% "full|left|right|inner" && NROW(joined) > NROW(x)) {
|
||||||
warning_("The newly joined tbl contains ", nrow(joined) - nrow(x), " rows more that its original.", call = FALSE)
|
warning_("The newly joined data set contains ", nrow(joined) - nrow(x), " rows more than the number of rows of `x`.", call = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
joined
|
joined
|
||||||
|
4
R/rsi.R
4
R/rsi.R
@ -135,7 +135,7 @@
|
|||||||
#' if (require("dplyr")) {
|
#' if (require("dplyr")) {
|
||||||
#' df %>% mutate_if(is.mic, as.rsi)
|
#' df %>% mutate_if(is.mic, as.rsi)
|
||||||
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
#' df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
||||||
#' df %>% mutate(across((is.mic), as.rsi))
|
#' df %>% mutate(across(where(is.mic), as.rsi))
|
||||||
#' df %>% mutate_at(vars(AMP:TOB), as.rsi)
|
#' df %>% mutate_at(vars(AMP:TOB), as.rsi)
|
||||||
#' df %>% mutate(across(AMP:TOB, as.rsi))
|
#' df %>% mutate(across(AMP:TOB, as.rsi))
|
||||||
#'
|
#'
|
||||||
@ -181,7 +181,7 @@
|
|||||||
#'
|
#'
|
||||||
#' # note: from dplyr 1.0.0 on, this will be:
|
#' # note: from dplyr 1.0.0 on, this will be:
|
||||||
#' # example_isolates %>%
|
#' # example_isolates %>%
|
||||||
#' # mutate(across((is.rsi.eligible), as.rsi))
|
#' # mutate(across(where(is.rsi.eligible), as.rsi))
|
||||||
#' }
|
#' }
|
||||||
#' }
|
#' }
|
||||||
as.rsi <- function(x, ...) {
|
as.rsi <- function(x, ...) {
|
||||||
|
@ -150,7 +150,7 @@ rsi_calc <- function(...,
|
|||||||
if (message_not_thrown_before("rsi_calc")) {
|
if (message_not_thrown_before("rsi_calc")) {
|
||||||
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
warning_("Increase speed by transforming to class <rsi> on beforehand:\n",
|
||||||
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
" your_data %>% mutate_if(is.rsi.eligible, as.rsi)\n",
|
||||||
" your_data %>% mutate(across((is.rsi.eligible), as.rsi))",
|
" your_data %>% mutate(across(where(is.rsi.eligible), as.rsi))",
|
||||||
call = FALSE)
|
call = FALSE)
|
||||||
remember_thrown_message("rsi_calc")
|
remember_thrown_message("rsi_calc")
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -236,12 +236,12 @@
|
|||||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="amr-1609021" class="section level1">
|
<div id="amr-1609022" class="section level1">
|
||||||
<h1 class="page-header" data-toc-text="1.6.0.9021">
|
<h1 class="page-header" data-toc-text="1.6.0.9022">
|
||||||
<a href="#amr-1609021" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9021</h1>
|
<a href="#amr-1609022" class="anchor"></a><small> Unreleased </small><code>AMR</code> 1.6.0.9022</h1>
|
||||||
<div id="last-updated-12-may-2021" class="section level2">
|
<div id="last-updated-13-may-2021" class="section level2">
|
||||||
<h2 class="hasAnchor">
|
<h2 class="hasAnchor">
|
||||||
<a href="#last-updated-12-may-2021" class="anchor"></a><small>Last updated: 12 May 2021</small>
|
<a href="#last-updated-13-may-2021" class="anchor"></a><small>Last updated: 13 May 2021</small>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="new" class="section level3">
|
<div id="new" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
@ -346,7 +346,7 @@
|
|||||||
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
<span class="co">#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"</span></code></pre></div>
|
||||||
</li>
|
</li>
|
||||||
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
<li><p>Support for custom MDRO guidelines, using the new <code><a href="../reference/mdro.html">custom_mdro_guideline()</a></code> function, please see <code><a href="../reference/mdro.html">mdro()</a></code> for additional info</p></li>
|
||||||
<li><p><code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
<li><p><code>ggplot()</code> generics for classes <code><mic></code> and <code><disk></code></p></li>
|
||||||
<li>
|
<li>
|
||||||
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
<p>Function <code><a href="../reference/mo_property.html">mo_is_yeast()</a></code>, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:</p>
|
||||||
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
|
||||||
@ -403,7 +403,7 @@
|
|||||||
<li>Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent</li>
|
<li>Plotting of MIC and disk diffusion values now support interpretation colouring if you supply the microorganism and antimicrobial agent</li>
|
||||||
<li>All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)</li>
|
<li>All colours were updated to colour-blind friendly versions for values R, S and I for all plot methods (also applies to tibble printing)</li>
|
||||||
<li>Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see <code>translate</code>)</li>
|
<li>Interpretation of MIC and disk diffusion values to R/SI will now be translated if the system language is German, Dutch or Spanish (see <code>translate</code>)</li>
|
||||||
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot()</a></code> on any vector of MIC and disk diffusion values</li>
|
<li>Plotting is now possible with base R using <code><a href="../reference/plot.html">plot()</a></code> and with ggplot2 using <code>ggplot()</code> on any vector of MIC and disk diffusion values</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the <code>microorganisms</code> data set</li>
|
<li>Updated SNOMED codes to US Edition of SNOMED CT from 1 September 2020 and added the source to the help page of the <code>microorganisms</code> data set</li>
|
||||||
|
@ -12,7 +12,7 @@ articles:
|
|||||||
datasets: datasets.html
|
datasets: datasets.html
|
||||||
resistance_predict: resistance_predict.html
|
resistance_predict: resistance_predict.html
|
||||||
welcome_to_AMR: welcome_to_AMR.html
|
welcome_to_AMR: welcome_to_AMR.html
|
||||||
last_built: 2021-05-12T16:13Z
|
last_built: 2021-05-13T13:55Z
|
||||||
urls:
|
urls:
|
||||||
reference: https://msberends.github.io/AMR//reference
|
reference: https://msberends.github.io/AMR//reference
|
||||||
article: https://msberends.github.io/AMR//articles
|
article: https://msberends.github.io/AMR//articles
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
|||||||
<span class='kw'>if</span> <span class='op'>(</span><span class='kw'><a href='https://rdrr.io/r/base/library.html'>require</a></span><span class='op'>(</span><span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span><span class='op'>)</span><span class='op'>)</span> <span class='op'>{</span>
|
<span class='kw'>if</span> <span class='op'>(</span><span class='kw'><a href='https://rdrr.io/r/base/library.html'>require</a></span><span class='op'>(</span><span class='st'><a href='https://dplyr.tidyverse.org'>"dplyr"</a></span><span class='op'>)</span><span class='op'>)</span> <span class='op'>{</span>
|
||||||
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span><span class='op'>(</span><span class='va'>is.mic</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span><span class='op'>(</span><span class='va'>is.mic</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
||||||
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span><span class='op'>(</span><span class='kw'>function</span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span> <span class='fu'><a href='as.mic.html'>is.mic</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span> <span class='op'>|</span> <span class='fu'><a href='as.disk.html'>is.disk</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span><span class='op'>(</span><span class='kw'>function</span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span> <span class='fu'><a href='as.mic.html'>is.mic</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span> <span class='op'>|</span> <span class='fu'><a href='as.disk.html'>is.disk</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
||||||
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='op'>(</span><span class='va'>is.mic</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span><span class='op'>)</span>
|
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='fu'>where</span><span class='op'>(</span><span class='va'>is.mic</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span><span class='op'>(</span><span class='va'>AMP</span><span class='op'>:</span><span class='va'>TOB</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span><span class='op'>(</span><span class='va'>AMP</span><span class='op'>:</span><span class='va'>TOB</span><span class='op'>)</span>, <span class='va'>as.rsi</span><span class='op'>)</span>
|
||||||
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='va'>AMP</span><span class='op'>:</span><span class='va'>TOB</span>, <span class='va'>as.rsi</span><span class='op'>)</span><span class='op'>)</span>
|
<span class='va'>df</span> <span class='op'>%>%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span><span class='op'>(</span><span class='fu'><a href='https://dplyr.tidyverse.org/reference/across.html'>across</a></span><span class='op'>(</span><span class='va'>AMP</span><span class='op'>:</span><span class='va'>TOB</span>, <span class='va'>as.rsi</span><span class='op'>)</span><span class='op'>)</span>
|
||||||
|
|
||||||
@ -498,7 +498,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>stable</s
|
|||||||
|
|
||||||
<span class='co'># note: from dplyr 1.0.0 on, this will be: </span>
|
<span class='co'># note: from dplyr 1.0.0 on, this will be: </span>
|
||||||
<span class='co'># example_isolates %>%</span>
|
<span class='co'># example_isolates %>%</span>
|
||||||
<span class='co'># mutate(across((is.rsi.eligible), as.rsi))</span>
|
<span class='co'># mutate(across(where(is.rsi.eligible), as.rsi))</span>
|
||||||
<span class='op'>}</span>
|
<span class='op'>}</span>
|
||||||
<span class='co'># }</span>
|
<span class='co'># }</span>
|
||||||
</pre>
|
</pre>
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<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.6.0.9021</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9022</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ as.rsi(x = as.disk(18),
|
|||||||
if (require("dplyr")) {
|
if (require("dplyr")) {
|
||||||
df \%>\% mutate_if(is.mic, as.rsi)
|
df \%>\% mutate_if(is.mic, as.rsi)
|
||||||
df \%>\% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
df \%>\% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
|
||||||
df \%>\% mutate(across((is.mic), as.rsi))
|
df \%>\% mutate(across(where(is.mic), as.rsi))
|
||||||
df \%>\% mutate_at(vars(AMP:TOB), as.rsi)
|
df \%>\% mutate_at(vars(AMP:TOB), as.rsi)
|
||||||
df \%>\% mutate(across(AMP:TOB, as.rsi))
|
df \%>\% mutate(across(AMP:TOB, as.rsi))
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ if (require("dplyr")) {
|
|||||||
|
|
||||||
# note: from dplyr 1.0.0 on, this will be:
|
# note: from dplyr 1.0.0 on, this will be:
|
||||||
# example_isolates \%>\%
|
# example_isolates \%>\%
|
||||||
# mutate(across((is.rsi.eligible), as.rsi))
|
# mutate(across(where(is.rsi.eligible), as.rsi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,17 +77,18 @@ test_that("EUCAST rules work", {
|
|||||||
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
|
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
|
||||||
|
|
||||||
# piperacillin must be R in Enterobacteriaceae when tica is R
|
# piperacillin must be R in Enterobacteriaceae when tica is R
|
||||||
library(dplyr, warn.conflicts = FALSE)
|
if (require("dplyr")) {
|
||||||
expect_equal(suppressWarnings(
|
expect_equal(suppressWarnings(
|
||||||
example_isolates %>%
|
example_isolates %>%
|
||||||
filter(mo_family(mo) == "Enterobacteriaceae") %>%
|
filter(mo_family(mo) == "Enterobacteriaceae") %>%
|
||||||
mutate(TIC = as.rsi("R"),
|
mutate(TIC = as.rsi("R"),
|
||||||
PIP = as.rsi("S")) %>%
|
PIP = as.rsi("S")) %>%
|
||||||
eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE) %>%
|
eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE) %>%
|
||||||
pull(PIP) %>%
|
pull(PIP) %>%
|
||||||
unique() %>%
|
unique() %>%
|
||||||
as.character()),
|
as.character()),
|
||||||
"R")
|
"R")
|
||||||
|
}
|
||||||
|
|
||||||
# Azithromycin and Clarythromycin must be equal to Erythromycin
|
# Azithromycin and Clarythromycin must be equal to Erythromycin
|
||||||
a <- suppressWarnings(as.rsi(eucast_rules(data.frame(mo = example_isolates$mo,
|
a <- suppressWarnings(as.rsi(eucast_rules(data.frame(mo = example_isolates$mo,
|
||||||
@ -114,7 +115,9 @@ test_that("EUCAST rules work", {
|
|||||||
"S")
|
"S")
|
||||||
|
|
||||||
# also test norf
|
# also test norf
|
||||||
expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE)))
|
if (require("dplyr")) {
|
||||||
|
expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE)))
|
||||||
|
}
|
||||||
|
|
||||||
# check verbose output
|
# check verbose output
|
||||||
expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE, rules = "all", info = TRUE)))
|
expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE, rules = "all", info = TRUE)))
|
||||||
|
Loading…
Reference in New Issue
Block a user