mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 08:06:12 +01:00
(v0.7.1.9006) new rsi calculations, atc class removal
This commit is contained in:
parent
156d550895
commit
4ff20af123
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 0.7.1.9005
|
||||
Date: 2019-07-01
|
||||
Version: 0.7.1.9006
|
||||
Date: 2019-07-02
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
person(
|
||||
|
4
NEWS.md
4
NEWS.md
@ -1,7 +1,7 @@
|
||||
# AMR 0.7.1.9005
|
||||
# AMR 0.7.1.9006
|
||||
|
||||
### New
|
||||
* Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for `portion_*` functions or `count_*` functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter `only_all_tested` replaces the old `also_single_tested` and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the `portion` and `count` help pages), where the %SI is being determined:
|
||||
* Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for `portion_*` functions or `count_*` functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter `only_all_tested` (**which defaults to `FALSE`**) replaces the old `also_single_tested` and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the `portion` and `count` help pages), where the %SI is being determined:
|
||||
|
||||
```r
|
||||
# -------------------------------------------------------------------------
|
||||
|
2
R/freq.R
2
R/freq.R
@ -318,7 +318,7 @@ freq <- function(x,
|
||||
df <- df %>%
|
||||
ungroup() %>%
|
||||
# do not repeat group labels
|
||||
mutate_at(vars(x.group), funs(ifelse(lag(.) == ., "", .)))
|
||||
mutate_at(vars(x.group), ~(ifelse(lag(.) == ., "", .)))
|
||||
df[1, 1] <- df.topleft
|
||||
colnames(df)[1:2] <- c("group", "item")
|
||||
|
||||
|
@ -30,7 +30,7 @@ globalVariables(c(".",
|
||||
"count.x",
|
||||
"date_lab",
|
||||
"diff.percent",
|
||||
"First",
|
||||
"First name",
|
||||
"first_isolate_row_index",
|
||||
"fullname",
|
||||
"fullname_lower",
|
||||
@ -46,7 +46,7 @@ globalVariables(c(".",
|
||||
"key_ab_other",
|
||||
"kingdom",
|
||||
"lang",
|
||||
"Last",
|
||||
"Last name",
|
||||
"lookup",
|
||||
"mdr",
|
||||
"median",
|
||||
@ -56,8 +56,6 @@ globalVariables(c(".",
|
||||
"mono_count",
|
||||
"more_than_episode_ago",
|
||||
"name",
|
||||
"name",
|
||||
"name",
|
||||
"new",
|
||||
"observations",
|
||||
"observed",
|
||||
|
3
R/mo.R
3
R/mo.R
@ -135,6 +135,7 @@
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @importFrom dplyr %>% pull left_join
|
||||
#' @examples
|
||||
#' \donttest{
|
||||
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||
#' as.mo("sau") # WHONET code
|
||||
#' as.mo("stau")
|
||||
@ -169,7 +170,7 @@
|
||||
#' # All mo_* functions use as.mo() internally too (see ?mo_property):
|
||||
#' mo_genus("E. coli") # returns "Escherichia"
|
||||
#' mo_gramstain("E. coli") # returns "Gram negative"#'
|
||||
#'
|
||||
#' }
|
||||
#' \dontrun{
|
||||
#' df$mo <- as.mo(df$microorganism_name)
|
||||
#'
|
||||
|
@ -36,7 +36,7 @@
|
||||
#' @inheritSection as.rsi Interpretation of S, I and R
|
||||
#' @details \strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
#'
|
||||
#' These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.}
|
||||
#' These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{portion_SI()} is essentially equal to \code{count_SI() / count_all()}. \emph{Low counts can infuence the outcome - the \code{portion} functions may camouflage this, since they only return the portion (albeit being dependent on the \code{minimum} parameter).}
|
||||
#'
|
||||
#' The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
|
||||
#'
|
||||
@ -70,12 +70,12 @@
|
||||
#' -------------------------------------------------------------------------
|
||||
#' }
|
||||
#'
|
||||
#' Please note that for \code{only_all_tested = TRUE} applies that:
|
||||
#' Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
#' \preformatted{
|
||||
#' count_S() + count_I() + count_R() == count_all()
|
||||
#' portion_S() + portion_I() + portion_R() == 1
|
||||
#' }
|
||||
#' and that for \code{only_all_tested = FALSE} applies that:
|
||||
#' and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
#' \preformatted{
|
||||
#' count_S() + count_I() + count_R() >= count_all()
|
||||
#' portion_S() + portion_I() + portion_R() >= 1
|
||||
|
@ -166,7 +166,7 @@ resistance_predict <- function(x,
|
||||
df <- x %>%
|
||||
mutate_at(col_ab, as.rsi) %>%
|
||||
mutate_at(col_ab, droplevels) %>%
|
||||
mutate_at(col_ab, funs(
|
||||
mutate_at(col_ab, ~(
|
||||
if (I_as_S == TRUE) {
|
||||
gsub("I", "S", .)
|
||||
} else {
|
||||
|
12
R/rsi_calc.R
12
R/rsi_calc.R
@ -120,9 +120,15 @@ rsi_calc <- function(...,
|
||||
#numerator <- x %>% filter_all(any_vars(. %in% ab_result)) %>% nrow()
|
||||
if (only_all_tested == TRUE) {
|
||||
# THE NUMBER OF ISOLATES WHERE *ALL* ABx ARE S/I/R
|
||||
x_filtered <- x %>% filter_all(all_vars(!is.na(.)))
|
||||
numerator <- x_filtered %>% filter_all(any_vars(. %in% ab_result)) %>% nrow()
|
||||
denominator <- x_filtered %>% nrow()
|
||||
# x_filtered <- x %>% filter_all(all_vars(!is.na(.)))
|
||||
# numerator <- x_filtered %>% filter_all(any_vars(. %in% ab_result)) %>% nrow()
|
||||
# denominator <- x_filtered %>% nrow()
|
||||
x <- apply(X = x %>% mutate_all(as.integer),
|
||||
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))
|
||||
|
||||
} else {
|
||||
# THE NUMBER OF ISOLATES WHERE *ANY* ABx IS S/I/R
|
||||
other_values <- base::setdiff(c(NA, levels(ab_result)), ab_result)
|
||||
|
@ -78,7 +78,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -78,7 +78,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -232,16 +232,16 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="amr-0719005" class="section level1">
|
||||
<div id="amr-0719006" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#amr-0719005" class="anchor"></a>AMR 0.7.1.9005<small> Unreleased </small>
|
||||
<a href="#amr-0719006" class="anchor"></a>AMR 0.7.1.9006<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="new" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter <code>only_all_tested</code> replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
|
||||
<p>Additional way to calculate co-resistance, i.e. when using multiple antibiotics as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="co"># -------------------------------------------------------------------------</span></a>
|
||||
<a class="sourceLine" id="cb1-2" title="2"><span class="co"># only_all_tested = FALSE only_all_tested = TRUE</span></a>
|
||||
<a class="sourceLine" id="cb1-3" title="3"><span class="co"># Antibiotic Antibiotic ----------------------- -----------------------</span></a>
|
||||
@ -1192,7 +1192,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
<div id="tocnav">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#amr-0719005">0.7.1.9005</a></li>
|
||||
<li><a href="#amr-0719006">0.7.1.9006</a></li>
|
||||
<li><a href="#amr-071">0.7.1</a></li>
|
||||
<li><a href="#amr-070">0.7.0</a></li>
|
||||
<li><a href="#amr-061">0.6.1</a></li>
|
||||
|
@ -80,7 +80,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -406,7 +406,6 @@ The <code><a href='mo_property.html'>mo_property</a></code> functions (like <cod
|
||||
<span class='co'># All mo_* functions use as.mo() internally too (see ?mo_property):</span>
|
||||
<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Escherichia"</span>
|
||||
<span class='fu'><a href='mo_property.html'>mo_gramstain</a></span>(<span class='st'>"E. coli"</span>) <span class='co'># returns "Gram negative"#'</span>
|
||||
|
||||
<span class='co'># }</span><span class='co'># NOT RUN {</span>
|
||||
<span class='no'>df</span>$<span class='no'>mo</span> <span class='kw'><-</span> <span class='fu'>as.mo</span>(<span class='no'>df</span>$<span class='no'>microorganism_name</span>)
|
||||
|
||||
|
@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
</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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -349,10 +349,10 @@ not tested R - - - -
|
||||
not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
</pre>
|
||||
<p>Please note that for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
</pre><p>and that for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
</pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
</pre>
|
||||
|
@ -78,7 +78,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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
</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">0.7.1.9005</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9006</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -319,7 +319,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
||||
<p><strong>Remember that you should filter your table to let it contain only first isolates!</strong> This is needed to exclude duplicates and to reduce selection bias. Use <code><a href='first_isolate.html'>first_isolate</a></code> to determine them in your data set.</p>
|
||||
<p>These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the <code><a href='count.html'>count</a></code> functions to count isolates. <em>Low counts can infuence the outcome - these <code>portion</code> functions may camouflage this, since they only return the portion albeit being dependent on the <code>minimum</code> parameter.</em></p>
|
||||
<p>These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the <code><a href='count.html'>count</a></code> functions to count isolates. The function <code>portion_SI()</code> is essentially equal to <code>count_SI() / count_all()</code>. <em>Low counts can infuence the outcome - the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter).</em></p>
|
||||
<p>The function <code>portion_df</code> takes any variable from <code>data</code> that has an <code>"rsi"</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) and calculates the portions R, I and S. The resulting <em>tidy data</em> (see Source) <code>data.frame</code> will have three rows (S/I/R) and a column for each group and each variable with class <code>"rsi"</code>.</p>
|
||||
<p>The function <code>rsi_df</code> works exactly like <code>portion_df</code>, but adds the number of isolates.</p>
|
||||
|
||||
@ -352,10 +352,10 @@ not tested R - - - -
|
||||
not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
</pre>
|
||||
<p>Please note that for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
</pre><p>and that for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
</pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
</pre>
|
||||
|
@ -145,6 +145,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
}
|
||||
|
||||
\examples{
|
||||
\donttest{
|
||||
# These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||
as.mo("sau") # WHONET code
|
||||
as.mo("stau")
|
||||
@ -179,7 +180,7 @@ as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRA
|
||||
# All mo_* functions use as.mo() internally too (see ?mo_property):
|
||||
mo_genus("E. coli") # returns "Escherichia"
|
||||
mo_gramstain("E. coli") # returns "Gram negative"#'
|
||||
|
||||
}
|
||||
\dontrun{
|
||||
df$mo <- as.mo(df$microorganism_name)
|
||||
|
||||
|
@ -109,12 +109,12 @@ not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Please note that for \code{only_all_tested = TRUE} applies that:
|
||||
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
}
|
||||
and that for \code{only_all_tested = FALSE} applies that:
|
||||
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
|
@ -69,7 +69,7 @@ These functions can be used to calculate the (co-)resistance of microbial isolat
|
||||
\details{
|
||||
\strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
|
||||
These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.}
|
||||
These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{portion_SI()} is essentially equal to \code{count_SI() / count_all()}. \emph{Low counts can infuence the outcome - the \code{portion} functions may camouflage this, since they only return the portion (albeit being dependent on the \code{minimum} parameter).}
|
||||
|
||||
The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
|
||||
|
||||
@ -105,12 +105,12 @@ not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Please note that for \code{only_all_tested = TRUE} applies that:
|
||||
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
}
|
||||
and that for \code{only_all_tested = FALSE} applies that:
|
||||
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
|
@ -238,7 +238,7 @@ test_that("as.mo works", {
|
||||
print(mo_uncertainties())
|
||||
|
||||
# Salmonella (City) are all actually Salmonella enterica spp (City)
|
||||
expect_equal(as.character(suppressMessages(as.mo("Salmonella Goettingen"))),
|
||||
expect_equal(as.character(suppressWarnings(as.mo("Salmonella Goettingen"))),
|
||||
"B_SLMNL_ENT")
|
||||
expect_equal(as.character(as.mo("Salmonella Group A")), "B_SLMNL")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user