mirror of
https://github.com/msberends/AMR.git
synced 2024-12-24 18:46:14 +01:00
(v1.2.0.9024) AMR calculation speed improvement
This commit is contained in:
parent
152ac5bcad
commit
46cf423eab
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 1.2.0.9023
|
||||
Date: 2020-07-02
|
||||
Version: 1.2.0.9024
|
||||
Date: 2020-07-03
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(role = c("aut", "cre"),
|
||||
|
9
NEWS.md
9
NEWS.md
@ -1,5 +1,5 @@
|
||||
# AMR 1.2.0.9023
|
||||
## <small>Last updated: 02-Jul-2020</small>
|
||||
# AMR 1.2.0.9024
|
||||
## <small>Last updated: 03-Jul-2020</small>
|
||||
|
||||
### New
|
||||
* Function `ab_from_text()` to retrieve antimicrobial drug names, doses and forms of administration from clinical texts in e.g. health care records, which also corrects for misspelling since it uses `as.ab()` internally
|
||||
@ -19,7 +19,10 @@
|
||||
* Added Monuril as trade name for fosfomycin
|
||||
|
||||
### Changed
|
||||
* Using unexisting columns in all `count_*()`, `proportion_*()`, `susceptibility()` and `resistance()` functions wil now return an error instead of dropping them silently. Using variables for column names (as well as `dplyr::all_of()`) now works again.
|
||||
* Improvements for `susceptibility()` and `resistance()` and all `count_*()`, `proportion_*()` functions:
|
||||
* 95% speed improvement (!) by using other base R functions for calculation
|
||||
* Using unexisting columns wil now return an error instead of dropping them silently
|
||||
* Using variables for column names (as well as `dplyr::all_of()`) now works again
|
||||
* Improvements for `as.ab()`:
|
||||
* Dramatic improvement of the algorithm behind `as.ab()`, making many more input errors translatable, such as digitalised health care records, using too few or too many vowels or consonants and many more
|
||||
* Added progress bar
|
||||
|
24
R/rsi_calc.R
24
R/rsi_calc.R
@ -101,7 +101,7 @@ rsi_calc <- function(...,
|
||||
if (is.data.frame(x)) {
|
||||
rsi_integrity_check <- character(0)
|
||||
for (i in seq_len(ncol(x))) {
|
||||
# check integrity of columns: force rsi class
|
||||
# check integrity of columns: force <rsi> class
|
||||
if (!is.rsi(x[, i, drop = TRUE])) {
|
||||
rsi_integrity_check <- c(rsi_integrity_check, as.character(x[, i, drop = TRUE]))
|
||||
x[, i] <- suppressWarnings(as.rsi(x[, i, drop = TRUE])) # warning will be given later
|
||||
@ -113,22 +113,16 @@ rsi_calc <- function(...,
|
||||
rsi_integrity_check <- as.rsi(rsi_integrity_check)
|
||||
}
|
||||
|
||||
x_transposed <- as.list(as.data.frame(t(x)))
|
||||
if (only_all_tested == TRUE) {
|
||||
# THE NUMBER OF ISOLATES WHERE *ALL* ABx ARE S/I/R
|
||||
x <- apply(X = as.data.frame(lapply(x, as.integer), stringsAsFactors = FALSE),
|
||||
MARGIN = 1,
|
||||
FUN = base::min)
|
||||
numerator <- sum(as.integer(x) %in% as.integer(ab_result), na.rm = TRUE)
|
||||
denominator <- length(x) - sum(is.na(x))
|
||||
|
||||
# no NAs in any column
|
||||
numerator <- sum(sapply(x_transposed, function(y) !any(is.na(y)) & any(y %in% ab_result, na.rm = TRUE)))
|
||||
denominator <- sum(sapply(x_transposed, function(y) !(any(is.na(y)))))
|
||||
} else {
|
||||
# THE NUMBER OF ISOLATES WHERE *ANY* ABx IS S/I/R
|
||||
# may contain NAs in any column
|
||||
other_values <- base::setdiff(c(NA, levels(ab_result)), ab_result)
|
||||
other_values_filter <- base::apply(x, 1, function(y) {
|
||||
base::all(y %in% other_values) & base::any(is.na(y))
|
||||
})
|
||||
numerator <- sum(as.logical(by(x, seq_len(nrow(x)), function(row) any(unlist(row) %in% ab_result, na.rm = TRUE))))
|
||||
denominator <- nrow(x[!other_values_filter, , drop = FALSE])
|
||||
numerator <- sum(sapply(x_transposed, function(y) any(y %in% ab_result, na.rm = TRUE)))
|
||||
denominator <- sum(sapply(x_transposed, function(y) !(all(y %in% other_values) & any(is.na(y)))))
|
||||
}
|
||||
} else {
|
||||
# x is not a data.frame
|
||||
@ -153,7 +147,7 @@ rsi_calc <- function(...,
|
||||
if (data_vars != "") {
|
||||
data_vars <- paste(" for", data_vars)
|
||||
}
|
||||
warning("Introducing NA: only ", denominator, " results available", data_vars, " (`minimum` was set to ", minimum, ").", call. = FALSE)
|
||||
warning("Introducing NA: only ", denominator, " results available", data_vars, " (`minimum` = ", minimum, ").", call. = FALSE)
|
||||
fraction <- NA
|
||||
} else {
|
||||
fraction <- numerator / denominator
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.gitlab.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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -229,13 +229,13 @@
|
||||
<small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1209023" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.2.0.9023">
|
||||
<a href="#amr-1209023" class="anchor"></a>AMR 1.2.0.9023<small> Unreleased </small>
|
||||
<div id="amr-1209024" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.2.0.9024">
|
||||
<a href="#amr-1209024" class="anchor"></a>AMR 1.2.0.9024<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="last-updated-02-jul-2020" class="section level2">
|
||||
<div id="last-updated-03-jul-2020" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#last-updated-02-jul-2020" class="anchor"></a><small>Last updated: 02-Jul-2020</small>
|
||||
<a href="#last-updated-03-jul-2020" class="anchor"></a><small>Last updated: 03-Jul-2020</small>
|
||||
</h2>
|
||||
<div id="new" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -262,7 +262,13 @@
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changed" class="anchor"></a>Changed</h3>
|
||||
<ul>
|
||||
<li>Using unexisting columns in all <code>count_*()</code>, <code>proportion_*()</code>, <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> functions wil now return an error instead of dropping them silently. Using variables for column names (as well as <code><a href="https://dplyr.tidyverse.org/reference/reexports.html">dplyr::all_of()</a></code>) now works again.</li>
|
||||
<li>Improvements for <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> and all <code>count_*()</code>, <code>proportion_*()</code> functions:
|
||||
<ul>
|
||||
<li>95% speed improvement (!) by using other base R functions for calculation</li>
|
||||
<li>Using unexisting columns wil now return an error instead of dropping them silently</li>
|
||||
<li>Using variables for column names (as well as <code><a href="https://dplyr.tidyverse.org/reference/reexports.html">dplyr::all_of()</a></code>) now works again</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Improvements for <code><a href="../reference/as.ab.html">as.ab()</a></code>:
|
||||
<ul>
|
||||
<li>Dramatic improvement of the algorithm behind <code><a href="../reference/as.ab.html">as.ab()</a></code>, making many more input errors translatable, such as digitalised health care records, using too few or too many vowels or consonants and many more</li>
|
||||
|
@ -10,7 +10,7 @@ articles:
|
||||
WHONET: WHONET.html
|
||||
benchmarks: benchmarks.html
|
||||
resistance_predict: resistance_predict.html
|
||||
last_built: 2020-07-02T19:12Z
|
||||
last_built: 2020-07-03T08:50Z
|
||||
urls:
|
||||
reference: https://msberends.gitlab.io/AMR/reference
|
||||
article: https://msberends.gitlab.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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</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.2.0.9023</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9024</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user