mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 06:06:12 +01:00
(v1.3.0.9034) eucast_rules summary fix
This commit is contained in:
parent
36ec8b0d81
commit
68e6e1e329
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.3.0.9033
|
||||
Date: 2020-09-28
|
||||
Version: 1.3.0.9034
|
||||
Date: 2020-09-29
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
4
NEWS.md
4
NEWS.md
@ -1,5 +1,5 @@
|
||||
# AMR 1.3.0.9033
|
||||
## <small>Last updated: 28 September 2020</small>
|
||||
# AMR 1.3.0.9034
|
||||
## <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!
|
||||
|
||||
|
@ -94,7 +94,7 @@ atc_online_property <- function(atc_code,
|
||||
}
|
||||
|
||||
if (!has_internet()) {
|
||||
message("There appears to be no internet connection.")
|
||||
message("There appears to be no internet connection, returning NA.")
|
||||
return(rep(NA, length(atc_code)))
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,6 @@ eucast_rules <- function(x,
|
||||
all_betalactams <- c(aminopenicillins, cephalosporins, carbapenems, ureidopenicillins, AMC, OXA, FLC, PEN)
|
||||
# nolint end
|
||||
|
||||
|
||||
# Some helper functions ---------------------------------------------------
|
||||
get_antibiotic_columns <- function(x, df) {
|
||||
x <- trimws(unlist(strsplit(x, ",", fixed = TRUE)))
|
||||
@ -547,6 +546,8 @@ eucast_rules <- function(x,
|
||||
suppressWarnings(as.rsi(x))
|
||||
}
|
||||
|
||||
# Preparing the data ------------------------------------------------------
|
||||
|
||||
verbose_info <- data.frame(rowid = character(0),
|
||||
col = character(0),
|
||||
mo_fullname = character(0),
|
||||
@ -884,18 +885,16 @@ eucast_rules <- function(x,
|
||||
# Print overview ----------------------------------------------------------
|
||||
if (info == TRUE) {
|
||||
|
||||
rownames(verbose_info) <- NULL
|
||||
affected <- x.bak[which(x.bak$`.rowid` %in% x$`.rowid`), , drop = FALSE]
|
||||
rows_affected <- as.integer(rownames(affected))
|
||||
verbose_info <- verbose_info %pm>%
|
||||
pm_left_join(data.frame(row = rows_affected,
|
||||
rowid = affected[, ".rowid", drop = TRUE],
|
||||
stringsAsFactors = FALSE),
|
||||
by = "rowid") %pm>%
|
||||
pm_select(-rowid) %pm>%
|
||||
verbose_info <- x.bak %pm>%
|
||||
pm_mutate(row = pm_row_number()) %pm>%
|
||||
pm_select(`.rowid`, row) %pm>%
|
||||
pm_right_join(verbose_info,
|
||||
by = c(".rowid" = "rowid")) %pm>%
|
||||
pm_select(-`.rowid`) %pm>%
|
||||
pm_select(row, pm_everything()) %pm>%
|
||||
pm_filter(!is.na(new)) %pm>%
|
||||
pm_arrange(row, rule_group, rule_name, col)
|
||||
rownames(verbose_info) <- NULL
|
||||
|
||||
if (verbose == TRUE) {
|
||||
wouldve <- "would have "
|
||||
@ -904,15 +903,17 @@ eucast_rules <- function(x,
|
||||
}
|
||||
|
||||
cat(paste0("\n", font_grey(strrep("-", 0.95 * options()$width)), "\n"))
|
||||
cat(font_bold(paste("The rules", paste0(wouldve, "affected"),
|
||||
formatnr(pm_n_distinct(verbose_info$row)),
|
||||
cat(paste0("The rules ", paste0(wouldve, "affected "),
|
||||
font_bold(formatnr(pm_n_distinct(verbose_info$row)),
|
||||
"out of", formatnr(nrow(x.bak)),
|
||||
"rows, making a total of", formatnr(nrow(verbose_info)), "edits\n")))
|
||||
"rows"),
|
||||
", making a total of ",
|
||||
font_bold(formatnr(nrow(verbose_info)), "edits\n")))
|
||||
|
||||
total_n_added <- verbose_info %pm>% pm_filter(is.na(old)) %pm>% nrow()
|
||||
total_n_changed <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% nrow()
|
||||
total_n_added <- verbose_info %pm>% pm_filter(is.na(old)) %pm>% nrow()
|
||||
total_n_changed <- verbose_info %pm>% pm_filter(!is.na(old)) %pm>% nrow()
|
||||
|
||||
# print added values
|
||||
# print added values
|
||||
if (total_n_added == 0) {
|
||||
colour <- cat # is function
|
||||
} else {
|
||||
|
6
R/rsi.R
6
R/rsi.R
@ -657,7 +657,7 @@ exec_as.rsi <- function(method,
|
||||
pm_filter(uti == FALSE) %pm>% # 'uti' is a column in rsi_translation
|
||||
pm_arrange(pm_desc(nchar(mo)))
|
||||
}
|
||||
get_record <- get_record[1L, ]
|
||||
get_record <- get_record[1L, , drop = FALSE]
|
||||
|
||||
if (NROW(get_record) > 0) {
|
||||
if (is.na(x[i])) {
|
||||
@ -670,7 +670,7 @@ exec_as.rsi <- function(method,
|
||||
isTRUE(conserve_capped_values) & mic_input %like% "^>[0-9]" ~ "R",
|
||||
# start interpreting: EUCAST uses <= S and > R, CLSI uses <=S and >= R
|
||||
isTRUE(which(levels(mic_input) == mic_input) <= which(levels(mic_S) == mic_S)) ~ "S",
|
||||
guideline_coerced %like% "ECUAST" &
|
||||
guideline_coerced %like% "EUCAST" &
|
||||
isTRUE(which(levels(mic_input) == mic_input) > which(levels(mic_R) == mic_R)) ~ "R",
|
||||
guideline_coerced %like% "CLSI" &
|
||||
isTRUE(which(levels(mic_input) == mic_input) >= which(levels(mic_R) == mic_R)) ~ "R",
|
||||
@ -681,7 +681,7 @@ exec_as.rsi <- function(method,
|
||||
} else if (method == "disk") {
|
||||
new_rsi[i] <- quick_case_when(isTRUE(as.double(x[i]) >= as.double(get_record$breakpoint_S)) ~ "S",
|
||||
# start interpreting: EUCAST uses >= S and < R, CLSI uses >=S and <= R
|
||||
guideline_coerced %like% "ECUAST" &
|
||||
guideline_coerced %like% "EUCAST" &
|
||||
isTRUE(as.double(x[i]) < as.double(get_record$breakpoint_R)) ~ "R",
|
||||
guideline_coerced %like% "CLSI" &
|
||||
isTRUE(as.double(x[i]) <= as.double(get_record$breakpoint_R)) ~ "R",
|
||||
|
@ -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.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,13 +236,13 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1309033" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.3.0.9033">
|
||||
<a href="#amr-1309033" class="anchor"></a>AMR 1.3.0.9033<small> Unreleased </small>
|
||||
<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>
|
||||
</h1>
|
||||
<div id="last-updated-28-september-2020" class="section level2">
|
||||
<div id="last-updated-29-september-2020" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-28-september-2020" class="anchor"></a><small>Last updated: 28 September 2020</small>
|
||||
<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="new" class="section level3">
|
||||
|
@ -2,7 +2,7 @@ pandoc: 2.7.3
|
||||
pkgdown: 1.5.1.9000
|
||||
pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f
|
||||
articles: []
|
||||
last_built: 2020-09-28T09:00Z
|
||||
last_built: 2020-09-29T08:40Z
|
||||
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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
|
||||
</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.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -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.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</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.3.0.9033</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.3.0.9034</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
32
tests/testthat/test-atc_online.R
Normal file
32
tests/testthat/test-atc_online.R
Normal file
@ -0,0 +1,32 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Analysis #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://github.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2018-2020 Berends MS, Luz CF et al. #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# #
|
||||
# We created this package for both routine data analysis and academic #
|
||||
# research and it was publicly released in the hope that it will be #
|
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
||||
# Visit our website for more info: https://msberends.github.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
context("atc_online.R")
|
||||
|
||||
test_that("atc_online works", {
|
||||
skip_on_cran()
|
||||
skip_if_not(curl::has_internet())
|
||||
|
||||
expect_gte(length(atc_online_groups(ab_atc("AMX"))), 1)
|
||||
expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "O"), 1.5)
|
||||
expect_equal(atc_online_ddd(ab_atc("AMX"), administration = "P"), 3)
|
||||
expect_warning(atc_online_ddd(ab_atc("Novobiocin"), administration = "P"))
|
||||
})
|
@ -97,6 +97,12 @@ test_that("mic2rsi works", {
|
||||
guideline = "EUCAST")),
|
||||
"I")
|
||||
|
||||
# cutoffs at MIC = 8
|
||||
expect_equal(as.rsi(as.mic(2), "E. coli", "ampicillin", guideline = "EUCAST 2020"),
|
||||
as.rsi("S"))
|
||||
expect_equal(as.rsi(as.mic(32), "E. coli", "ampicillin", guideline = "EUCAST 2020"),
|
||||
as.rsi("R"))
|
||||
|
||||
expect_true(example_isolates %>%
|
||||
mutate(amox_mic = as.mic(2)) %>%
|
||||
select(mo, amox_mic) %>%
|
||||
|
Loading…
Reference in New Issue
Block a user