1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 07:26:13 +01:00

as.rsi warning, site update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-02-09 22:16:24 +01:00
parent ed30312048
commit c56b179857
73 changed files with 735 additions and 421 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 0.5.0.9017 Version: 0.5.0.9017
Date: 2019-02-08 Date: 2019-02-09
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person( person(

View File

@ -87,6 +87,7 @@
* New colours for `scale_rsi_colours()` * New colours for `scale_rsi_colours()`
* Summaries of class `mo` will now return the top 3 and the unique count, e.g. using `summary(mo)` * Summaries of class `mo` will now return the top 3 and the unique count, e.g. using `summary(mo)`
* Small text updates to summaries of class `rsi` and `mic` * Small text updates to summaries of class `rsi` and `mic`
* Function `as.rsi()` now gives a warning when inputting MIC values
* Frequency tables (`freq()` function): * Frequency tables (`freq()` function):
* Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes: * Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
```r ```r

View File

@ -30,11 +30,17 @@
#' @param year_max highest year to use in the prediction model, defaults to 10 years after today #' @param year_max highest year to use in the prediction model, defaults to 10 years after today
#' @param year_every unit of sequence between lowest year found in the data and \code{year_max} #' @param year_every unit of sequence between lowest year found in the data and \code{year_max}
#' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model. #' @param minimum minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.
#' @param model the statistical model of choice. Valid values are \code{"binomial"} (or \code{"binom"} or \code{"logit"}) or \code{"loglin"} (or \code{"poisson"}) or \code{"linear"} (or \code{"lin"}). #' @param model the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.
#' @param I_as_R a logical to indicate whether values \code{I} should be treated as \code{R} #' @param I_as_R a logical to indicate whether values \code{I} should be treated as \code{R}
#' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}. #' @param preserve_measurements a logical to indicate whether predictions of years that are actually available in the data should be overwritten by the original data. The standard errors of those years will be \code{NA}.
#' @param info a logical to indicate whether textual analysis should be printed with the name and \code{\link{summary}} of the statistical model. #' @param info a logical to indicate whether textual analysis should be printed with the name and \code{\link{summary}} of the statistical model.
#' @param main title of the plot #' @param main title of the plot
#' @details Valid options for the statistical model are:
#' \itemize{
#' \item{\code{"binomial"} or \code{"binom"} or \code{"logit"}: a generalised linear regression model with binomial distribution}
#' \item{\code{"loglin"} or \code{"poisson"}: a generalised log-linear regression model with poisson distribution}
#' \item{\code{"lin"} or \code{"linear"}: a linear regression model}
#' }
#' @return \code{data.frame} with extra class \code{"resistance_predict"} with columns: #' @return \code{data.frame} with extra class \code{"resistance_predict"} with columns:
#' \itemize{ #' \itemize{
#' \item{\code{year}} #' \item{\code{year}}
@ -306,7 +312,9 @@ plot.resistance_predict <- function(x, main = paste("Resistance prediction of",
ylab = paste0("Percentage (", ylab, ")"), ylab = paste0("Percentage (", ylab, ")"),
xlab = "Year", xlab = "Year",
main = main, main = main,
sub = paste0("(model: ", attributes(x)$model_title, ")")) sub = paste0("(n = ", sum(x$observations, na.rm = TRUE),
", model: ", attributes(x)$model_title, ")"),
cex.sub = 0.75)
axis(side = 2, at = seq(0, 1, 0.1), labels = paste0(0:10 * 10, "%")) axis(side = 2, at = seq(0, 1, 0.1), labels = paste0(0:10 * 10, "%"))
@ -332,12 +340,13 @@ ggplot_rsi_predict <- function(x, main = paste("Resistance prediction of", attri
} }
suppressWarnings( suppressWarnings(
ggplot2::ggplot(x, ggplot2::aes(x = year, y = value)) + ggplot2::ggplot(x, ggplot2::aes(x = year, y = value)) +
ggplot2::geom_col() + ggplot2::geom_point(size = 2) +
ggplot2::geom_errorbar(ggplot2::aes(ymin = se_min, ymax = se_max)) + ggplot2::geom_errorbar(ggplot2::aes(ymin = se_min, ymax = se_max), na.rm = TRUE, width = 0.5) +
scale_y_percent() + scale_y_percent(limits = c(0, 1)) +
ggplot2::labs(title = main, ggplot2::labs(title = main,
y = paste0("Percentage (", ylab, ")"), y = paste0("Percentage (", ylab, ")"),
x = "Year", x = "Year",
caption = paste0("(model: ", attributes(x)$model_title, ")")) caption = paste0("(n = ", sum(x$observations, na.rm = TRUE),
", model: ", attributes(x)$model_title, ")"))
) )
} }

11
R/rsi.R
View File

@ -64,6 +64,9 @@ as.rsi <- function(x) {
} else if (identical(levels(x), c("S", "I", "R"))) { } else if (identical(levels(x), c("S", "I", "R"))) {
structure(x, class = c('rsi', 'ordered', 'factor')) structure(x, class = c('rsi', 'ordered', 'factor'))
} else { } else {
if (mic_like(x) > 0.5) {
warning("`as.rsi` is intended to clean antimicrobial interpretations - not to interpret MIC values.", call. = FALSE)
}
x <- x %>% unlist() x <- x %>% unlist()
x.bak <- x x.bak <- x
@ -103,6 +106,14 @@ as.rsi <- function(x) {
} }
} }
mic_like <- function(x) {
mic <- x %>%
gsub("[^0-9.,]+", "", .) %>%
unique()
mic_valid <- suppressWarnings(as.mic(mic))
sum(!is.na(mic_valid)) / length(mic)
}
#' @rdname as.rsi #' @rdname as.rsi
#' @export #' @export
is.rsi <- function(x) { is.rsi <- function(x) {

View File

@ -54,7 +54,7 @@ This is the latest **development version**. Although it may contain bugfixes and
Development Test | Result | Reference Development Test | Result | Reference
--- | :---: | --- --- | :---: | ---
All functions checked on Linux | [![pipeline status](https://gitlab.com/msberends/AMR/badges/master/pipeline.svg)](https://gitlab.com/msberends/AMR/commits/master) | GitLab CI [[ref 1]](https://gitlab.com/msberends/AMR/pipelines) All functions checked on Linux | [![pipeline status](https://gitlab.com/msberends/AMR/badges/master/pipeline.svg)](https://gitlab.com/msberends/AMR/commits/master) | GitLab CI [[ref 1]](https://gitlab.com/msberends/AMR)
All functions checked on Windows | [![AppVeyor_Build](https://ci.appveyor.com/api/projects/status/gitlab/msberends/AMR?branch=master&svg=true)](https://ci.appveyor.com/project/msberends/amr-svxon) | Appveyor Systems Inc. [[ref 2]](https://ci.appveyor.com/project/msberends/amr-svxon) All functions checked on Windows | [![AppVeyor_Build](https://ci.appveyor.com/api/projects/status/gitlab/msberends/AMR?branch=master&svg=true)](https://ci.appveyor.com/project/msberends/amr-svxon) | Appveyor Systems Inc. [[ref 2]](https://ci.appveyor.com/project/msberends/amr-svxon)
Percentage of syntax lines checked | [![Code_Coverage](https://codecov.io/gl/msberends/AMR/branch/master/graph/badge.svg)](https://codecov.io/gl/msberends/AMR) | Codecov LLC [[ref 3]](https://codecov.io/gl/msberends/AMR) Percentage of syntax lines checked | [![Code_Coverage](https://codecov.io/gl/msberends/AMR/branch/master/graph/badge.svg)](https://codecov.io/gl/msberends/AMR) | Codecov LLC [[ref 3]](https://codecov.io/gl/msberends/AMR)

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to conduct AMR analysis</h1> <h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div> <div class="hidden name"><code>AMR.Rmd</code></div>
@ -194,7 +194,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 08 February 2019.</p> <p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">RMarkdown</a>. However, the methodology remains unchanged. This page was generated on 09 February 2019.</p>
<div id="introduction" class="section level1"> <div id="introduction" class="section level1">
<h1 class="hasAnchor"> <h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1> <a href="#introduction" class="anchor"></a>Introduction</h1>
@ -210,21 +210,21 @@
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">2019-02-08</td> <td align="center">2019-02-09</td>
<td align="center">abcd</td> <td align="center">abcd</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2019-02-08</td> <td align="center">2019-02-09</td>
<td align="center">abcd</td> <td align="center">abcd</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">2019-02-08</td> <td align="center">2019-02-09</td>
<td align="center">efgh</td> <td align="center">efgh</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">R</td> <td align="center">R</td>
@ -313,70 +313,70 @@
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">2010-10-06</td> <td align="center">2012-10-05</td>
<td align="center">F7</td> <td align="center">F3</td>
<td align="center">Hospital D</td> <td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td> <td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">M</td> <td align="center">M</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2015-07-29</td> <td align="center">2012-11-18</td>
<td align="center">T1</td> <td align="center">X7</td>
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">Escherichia coli</td> <td align="center">Escherichia coli</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">F</td> <td align="center">F</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">2017-10-20</td> <td align="center">2012-04-27</td>
<td align="center">P2</td> <td align="center">K2</td>
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td> <td align="center">Escherichia coli</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2014-09-03</td>
<td align="center">M6</td>
<td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2015-09-13</td>
<td align="center">R4</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td> <td align="center">F</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2010-02-07</td> <td align="center">2011-09-19</td>
<td align="center">Z6</td> <td align="center">D6</td>
<td align="center">Hospital A</td> <td align="center">Hospital B</td>
<td align="center">Klebsiella pneumoniae</td> <td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">I</td> <td align="center">I</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">F</td> <td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2012-06-26</td>
<td align="center">V4</td>
<td align="center">Hospital A</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2016-02-08</td>
<td align="center">S2</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -396,8 +396,8 @@
# #
# Item Count Percent Cum. Count Cum. Percent # Item Count Percent Cum. Count Cum. Percent
# --- ----- ------ -------- ----------- ------------- # --- ----- ------ -------- ----------- -------------
# 1 M 2,551 51.0% 2,551 51.0% # 1 M 2,565 51.3% 2,565 51.3%
# 2 F 2,449 49.0% 5,000 100.0%</code></pre> # 2 F 2,435 48.7% 5,000 100.0%</code></pre>
<p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didnt already know.</p> <p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didnt already know.</p>
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p> <p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a> <div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a>
@ -428,10 +428,10 @@
<a class="sourceLine" id="cb14-19" data-line-number="19"><span class="co"># Kingella kingae (no changes)</span></a> <a class="sourceLine" id="cb14-19" data-line-number="19"><span class="co"># Kingella kingae (no changes)</span></a>
<a class="sourceLine" id="cb14-20" data-line-number="20"><span class="co"># </span></a> <a class="sourceLine" id="cb14-20" data-line-number="20"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-21" data-line-number="21"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a> <a class="sourceLine" id="cb14-21" data-line-number="21"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb14-22" data-line-number="22"><span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (345 changes)</span></a> <a class="sourceLine" id="cb14-22" data-line-number="22"><span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (306 changes)</span></a>
<a class="sourceLine" id="cb14-23" data-line-number="23"><span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a> <a class="sourceLine" id="cb14-23" data-line-number="23"><span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-24" data-line-number="24"><span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a> <a class="sourceLine" id="cb14-24" data-line-number="24"><span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-25" data-line-number="25"><span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (673 changes)</span></a> <a class="sourceLine" id="cb14-25" data-line-number="25"><span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (681 changes)</span></a>
<a class="sourceLine" id="cb14-26" data-line-number="26"><span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a> <a class="sourceLine" id="cb14-26" data-line-number="26"><span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
<a class="sourceLine" id="cb14-27" data-line-number="27"><span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a> <a class="sourceLine" id="cb14-27" data-line-number="27"><span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
<a class="sourceLine" id="cb14-28" data-line-number="28"><span class="co"># Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a> <a class="sourceLine" id="cb14-28" data-line-number="28"><span class="co"># Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
@ -447,9 +447,9 @@
<a class="sourceLine" id="cb14-38" data-line-number="38"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a> <a class="sourceLine" id="cb14-38" data-line-number="38"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-39" data-line-number="39"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a> <a class="sourceLine" id="cb14-39" data-line-number="39"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
<a class="sourceLine" id="cb14-40" data-line-number="40"><span class="co"># </span></a> <a class="sourceLine" id="cb14-40" data-line-number="40"><span class="co"># </span></a>
<a class="sourceLine" id="cb14-41" data-line-number="41"><span class="co"># =&gt; EUCAST rules affected 1,814 out of 5,000 rows</span></a> <a class="sourceLine" id="cb14-41" data-line-number="41"><span class="co"># =&gt; EUCAST rules affected 1,796 out of 5,000 rows</span></a>
<a class="sourceLine" id="cb14-42" data-line-number="42"><span class="co"># -&gt; added 0 test results</span></a> <a class="sourceLine" id="cb14-42" data-line-number="42"><span class="co"># -&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb14-43" data-line-number="43"><span class="co"># -&gt; changed 1,018 test results (0 to S; 0 to I; 1,018 to R)</span></a></code></pre></div> <a class="sourceLine" id="cb14-43" data-line-number="43"><span class="co"># -&gt; changed 987 test results (0 to S; 0 to I; 987 to R)</span></a></code></pre></div>
</div> </div>
<div id="adding-new-variables" class="section level1"> <div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor"> <h1 class="hasAnchor">
@ -474,8 +474,8 @@
<a class="sourceLine" id="cb16-3" data-line-number="3"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a> <a class="sourceLine" id="cb16-3" data-line-number="3"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb16-4" data-line-number="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a> <a class="sourceLine" id="cb16-4" data-line-number="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb16-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a> <a class="sourceLine" id="cb16-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb16-6" data-line-number="6"><span class="co"># =&gt; Found 2,939 first isolates (58.8% of total)</span></a></code></pre></div> <a class="sourceLine" id="cb16-6" data-line-number="6"><span class="co"># =&gt; Found 2,948 first isolates (59.0% of total)</span></a></code></pre></div>
<p>So only 58.8% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p> <p>So only 59% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div> <a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
<p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p> <p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p>
@ -501,63 +501,85 @@
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-04-03</td> <td align="center">2010-05-12</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2</td> <td align="center">2</td>
<td align="center">2010-10-31</td> <td align="center">2010-05-12</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">3</td> <td align="center">3</td>
<td align="center">2010-11-12</td> <td align="center">2010-07-18</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">4</td> <td align="center">4</td>
<td align="center">2010-11-21</td> <td align="center">2011-01-18</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">5</td> <td align="center">5</td>
<td align="center">2010-12-01</td> <td align="center">2011-11-20</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2011-12-03</td>
<td align="center">B4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2012-09-09</td>
<td align="center">B4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">6</td> <td align="center">8</td>
<td align="center">2011-10-22</td> <td align="center">2013-01-24</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">I</td> <td align="center">I</td>
@ -566,52 +588,30 @@
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td>
<td align="center">2012-03-22</td>
<td align="center">C3</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2012-05-14</td>
<td align="center">C3</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2012-10-26</td> <td align="center">2013-04-25</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">10</td> <td align="center">10</td>
<td align="center">2013-06-13</td> <td align="center">2014-02-01</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">TRUE</td>
<td align="center">FALSE</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Only 3 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p> <p>Only 4 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>If a column exists with a name like key(…)ab the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p> <p>If a column exists with a name like key(…)ab the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb19-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb19-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -622,7 +622,7 @@
<a class="sourceLine" id="cb19-7" data-line-number="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a> <a class="sourceLine" id="cb19-7" data-line-number="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb19-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a> <a class="sourceLine" id="cb19-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
<a class="sourceLine" id="cb19-9" data-line-number="9"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a> <a class="sourceLine" id="cb19-9" data-line-number="9"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># =&gt; Found 4,387 first weighted isolates (87.7% of total)</span></a></code></pre></div> <a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># =&gt; Found 4,405 first weighted isolates (88.1% of total)</span></a></code></pre></div>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="center">isolate</th> <th align="center">isolate</th>
@ -639,11 +639,11 @@
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-04-03</td> <td align="center">2010-05-12</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
@ -651,46 +651,70 @@
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2</td> <td align="center">2</td>
<td align="center">2010-10-31</td> <td align="center">2010-05-12</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">3</td> <td align="center">3</td>
<td align="center">2010-11-12</td> <td align="center">2010-07-18</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">4</td> <td align="center">4</td>
<td align="center">2010-11-21</td> <td align="center">2011-01-18</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FALSE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">5</td> <td align="center">5</td>
<td align="center">2010-12-01</td> <td align="center">2011-11-20</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2011-12-03</td>
<td align="center">B4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2012-09-09</td>
<td align="center">B4</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -698,9 +722,9 @@
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">6</td> <td align="center">8</td>
<td align="center">2011-10-22</td> <td align="center">2013-01-24</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">I</td> <td align="center">I</td>
@ -710,60 +734,36 @@
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td>
<td align="center">2012-03-22</td>
<td align="center">C3</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2012-05-14</td>
<td align="center">C3</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2012-10-26</td> <td align="center">2013-04-25</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">10</td> <td align="center">10</td>
<td align="center">2013-06-13</td> <td align="center">2014-02-01</td>
<td align="center">C3</td> <td align="center">B4</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">TRUE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Instead of 3, now 9 isolates are flagged. In total, 87.7% of all isolates are marked first weighted - 29% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p> <p>Instead of 4, now 9 isolates are flagged. In total, 88.1% of all isolates are marked first weighted - 29.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p> <p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb20-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div> <a class="sourceLine" id="cb20-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
<p>So we end up with 4,387 isolates for analysis.</p> <p>So we end up with 4,405 isolates for analysis.</p>
<p>We can remove unneeded columns:</p> <p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div> <a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div>
@ -788,28 +788,12 @@
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td>1</td>
<td align="center">2010-10-06</td>
<td align="center">F7</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNE</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram negative</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>2</td> <td>2</td>
<td align="center">2015-07-29</td> <td align="center">2012-11-18</td>
<td align="center">T1</td> <td align="center">X7</td>
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -819,68 +803,84 @@
<td align="center">coli</td> <td align="center">coli</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="even">
<td>3</td> <td>3</td>
<td align="center">2017-10-20</td> <td align="center">2012-04-27</td>
<td align="center">P2</td> <td align="center">K2</td>
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">B_STPHY_AUR</td> <td align="center">B_ESCHR_COL</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">F</td> <td align="center">M</td>
<td align="center">Gram negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>4</td>
<td align="center">2014-09-03</td>
<td align="center">M6</td>
<td align="center">Hospital A</td>
<td align="center">B_STRPTC_PNE</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Staphylococcus</td> <td align="center">Streptococcus</td>
<td align="center">aureus</td> <td align="center">pneumoniae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td>4</td> <td>5</td>
<td align="center">2010-02-07</td> <td align="center">2015-09-13</td>
<td align="center">Z6</td> <td align="center">R4</td>
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">B_KLBSL_PNE</td> <td align="center">B_ESCHR_COL</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">R</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">F</td> <td align="center">F</td>
<td align="center">Gram negative</td> <td align="center">Gram negative</td>
<td align="center">Klebsiella</td> <td align="center">Escherichia</td>
<td align="center">pneumoniae</td> <td align="center">coli</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td>6</td> <td>6</td>
<td align="center">2016-02-08</td> <td align="center">2011-09-19</td>
<td align="center">S2</td> <td align="center">D6</td>
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td> <td align="center">B_STRPTC_PNE</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">M</td>
<td align="center">F</td> <td align="center">Gram positive</td>
<td align="center">Gram negative</td> <td align="center">Streptococcus</td>
<td align="center">Escherichia</td> <td align="center">pneumoniae</td>
<td align="center">coli</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td>9</td> <td>7</td>
<td align="center">2016-10-31</td> <td align="center">2013-01-13</td>
<td align="center">H3</td> <td align="center">Q3</td>
<td align="center">Hospital C</td> <td align="center">Hospital A</td>
<td align="center">B_STPHY_AUR</td> <td align="center">B_STRPTC_PNE</td>
<td align="center">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">M</td> <td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Staphylococcus</td> <td align="center">Streptococcus</td>
<td align="center">aureus</td> <td align="center">pneumoniae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
</tbody> </tbody>
@ -900,9 +900,9 @@
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" data-line-number="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/paste">paste</a></span>(data_1st<span class="op">$</span>genus, data_1st<span class="op">$</span>species))</a></code></pre></div> <div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" data-line-number="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/paste">paste</a></span>(data_1st<span class="op">$</span>genus, data_1st<span class="op">$</span>species))</a></code></pre></div>
<p>Or can be used like the <code>dplyr</code> way, which is easier readable:</p> <p>Or can be used like the <code>dplyr</code> way, which is easier readable:</p>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div> <div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (4,387 x 13)</strong><br> <p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (4,405 x 13)</strong><br>
Columns: 2<br> Columns: 2<br>
Length: 4,387 (of which NA: 0 = 0.00%)<br> Length: 4,405 (of which NA: 0 = 0.00%)<br>
Unique: 4</p> Unique: 4</p>
<p>Shortest: 16<br> <p>Shortest: 16<br>
Longest: 24</p> Longest: 24</p>
@ -919,33 +919,33 @@ Longest: 24</p>
<tr class="odd"> <tr class="odd">
<td align="left">1</td> <td align="left">1</td>
<td align="left">Escherichia coli</td> <td align="left">Escherichia coli</td>
<td align="right">2,129</td> <td align="right">2,160</td>
<td align="right">48.5%</td> <td align="right">49.0%</td>
<td align="right">2,129</td> <td align="right">2,160</td>
<td align="right">48.5%</td> <td align="right">49.0%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">Staphylococcus aureus</td> <td align="left">Staphylococcus aureus</td>
<td align="right">1,098</td> <td align="right">1,109</td>
<td align="right">25.0%</td> <td align="right">25.2%</td>
<td align="right">3,227</td> <td align="right">3,269</td>
<td align="right">73.6%</td> <td align="right">74.2%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td> <td align="left">Streptococcus pneumoniae</td>
<td align="right">688</td> <td align="right">690</td>
<td align="right">15.7%</td> <td align="right">15.7%</td>
<td align="right">3,915</td> <td align="right">3,959</td>
<td align="right">89.2%</td> <td align="right">89.9%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">4</td> <td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td> <td align="left">Klebsiella pneumoniae</td>
<td align="right">472</td> <td align="right">446</td>
<td align="right">10.8%</td> <td align="right">10.1%</td>
<td align="right">4,387</td> <td align="right">4,405</td>
<td align="right">100.0%</td> <td align="right">100.0%</td>
</tr> </tr>
</tbody> </tbody>
@ -956,7 +956,7 @@ Longest: 24</p>
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2> <a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
<p>The functions <code>portion_R</code>, <code>portion_RI</code>, <code>portion_I</code>, <code>portion_IS</code> and <code>portion_S</code> can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:</p> <p>The functions <code>portion_R</code>, <code>portion_RI</code>, <code>portion_I</code>, <code>portion_IS</code> and <code>portion_S</code> can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:</p>
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_IR</a></span>(amox)</a> <div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_IR</a></span>(amox)</a>
<a class="sourceLine" id="cb25-2" data-line-number="2"><span class="co"># [1] 0.4700251</span></a></code></pre></div> <a class="sourceLine" id="cb25-2" data-line-number="2"><span class="co"># [1] 0.4719637</span></a></code></pre></div>
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p> <p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb26-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%&gt;%</span><span class="st"> </span></a> <a class="sourceLine" id="cb26-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -969,19 +969,19 @@ Longest: 24</p>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">0.4544765</td> <td align="center">0.4711316</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">0.4920107</td> <td align="center">0.4910714</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">Hospital C</td> <td align="center">Hospital C</td>
<td align="center">0.4686567</td> <td align="center">0.4597701</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Hospital D</td> <td align="center">Hospital D</td>
<td align="center">0.4570792</td> <td align="center">0.4488698</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -999,23 +999,23 @@ Longest: 24</p>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">Hospital A</td> <td align="center">Hospital A</td>
<td align="center">0.4544765</td> <td align="center">0.4711316</td>
<td align="center">1318</td> <td align="center">1299</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Hospital B</td> <td align="center">Hospital B</td>
<td align="center">0.4920107</td> <td align="center">0.4910714</td>
<td align="center">1502</td> <td align="center">1568</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">Hospital C</td> <td align="center">Hospital C</td>
<td align="center">0.4686567</td> <td align="center">0.4597701</td>
<td align="center">670</td> <td align="center">609</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Hospital D</td> <td align="center">Hospital D</td>
<td align="center">0.4570792</td> <td align="center">0.4488698</td>
<td align="center">897</td> <td align="center">929</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -1035,27 +1035,27 @@ Longest: 24</p>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">Escherichia</td> <td align="center">Escherichia</td>
<td align="center">0.7491780</td> <td align="center">0.7407407</td>
<td align="center">0.9074683</td> <td align="center">0.9000000</td>
<td align="center">0.9798027</td> <td align="center">0.9763889</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Klebsiella</td> <td align="center">Klebsiella</td>
<td align="center">0.7521186</td> <td align="center">0.7533632</td>
<td align="center">0.9067797</td> <td align="center">0.9147982</td>
<td align="center">0.9745763</td> <td align="center">0.9843049</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">Staphylococcus</td> <td align="center">Staphylococcus</td>
<td align="center">0.7349727</td> <td align="center">0.7303877</td>
<td align="center">0.9171220</td> <td align="center">0.9305681</td>
<td align="center">0.9708561</td> <td align="center">0.9819657</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">Streptococcus</td> <td align="center">Streptococcus</td>
<td align="center">0.7398256</td> <td align="center">0.7173913</td>
<td align="center">0.0000000</td> <td align="center">0.0000000</td>
<td align="center">0.7398256</td> <td align="center">0.7173913</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to apply EUCAST rules</h1> <h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div> <div class="hidden name"><code>EUCAST.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to use the <em>G</em>-test</h1> <h1>How to use the <em>G</em>-test</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>G_test.Rmd</code></div> <div class="hidden name"><code>G_test.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to predict antimicrobial resistance</h1> <h1>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>Predict.Rmd</code></div> <div class="hidden name"><code>Predict.Rmd</code></div>
@ -194,10 +194,166 @@
<p><em>(will be available soon)</em></p> <div id="needed-r-packages" class="section level2">
<h2 class="hasAnchor">
<a href="#needed-r-packages" class="anchor"></a>Needed R packages</h2>
<p>As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the <a href="https://www.tidyverse.org">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org"><code>ggplot2</code></a> by <a href="https://www.linkedin.com/in/hadleywickham/">Dr Hadley Wickham</a>. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.</p>
<p>Our <code>AMR</code> package depends on these packages and even extends their use and functions.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr)</a>
<a class="sourceLine" id="cb1-2" data-line-number="2"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(ggplot2)</a>
<a class="sourceLine" id="cb1-3" data-line-number="3"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(AMR)</a>
<a class="sourceLine" id="cb1-4" data-line-number="4"></a>
<a class="sourceLine" id="cb1-5" data-line-number="5"><span class="co"># (if not yet installed, install with:)</span></a>
<a class="sourceLine" id="cb1-6" data-line-number="6"><span class="co"># install.packages(c("tidyverse", "AMR"))</span></a></code></pre></div>
</div>
<div id="prediction-analysis" class="section level2">
<h2 class="hasAnchor">
<a href="#prediction-analysis" class="anchor"></a>Prediction analysis</h2>
<p>Our package contains a function <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <a href="./articles/AMR.html">other AMR analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
<p>It is basically as easy as:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1"><span class="co"># resistance prediction of piperacillin/tazobactam (pita):</span></a>
<a class="sourceLine" id="cb2-2" data-line-number="2"><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">tbl =</span> septic_patients, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a>
<a class="sourceLine" id="cb2-3" data-line-number="3"></a>
<a class="sourceLine" id="cb2-4" data-line-number="4"><span class="co"># or:</span></a>
<a class="sourceLine" id="cb2-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-6" data-line-number="6"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a>
<a class="sourceLine" id="cb2-7" data-line-number="7"></a>
<a class="sourceLine" id="cb2-8" data-line-number="8"><span class="co"># to bind it to object 'predict_pita' for example:</span></a>
<a class="sourceLine" id="cb2-9" data-line-number="9">predict_pita &lt;-<span class="st"> </span>septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-10" data-line-number="10"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a></code></pre></div>
<pre><code># NOTE: Using column `date` as input for `col_date`.
#
# Logistic regression model (logit) with binomial distribution
# ------------------------------------------------------------
#
# Call:
# glm(formula = df_matrix ~ year, family = binomial)
#
# Deviance Residuals:
# Min 1Q Median 3Q Max
# -2.9224 -1.3120 0.0170 0.7586 3.1932
#
# Coefficients:
# Estimate Std. Error z value Pr(&gt;|z|)
# (Intercept) -222.92857 45.93922 -4.853 1.22e-06 ***
# year 0.10994 0.02284 4.814 1.48e-06 ***
# ---
# Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#
# (Dispersion parameter for binomial family taken to be 1)
#
# Null deviance: 59.794 on 14 degrees of freedom
# Residual deviance: 35.191 on 13 degrees of freedom
# AIC: 93.464
#
# Number of Fisher Scoring iterations: 4</code></pre>
<p>The function will look for a data column itself if <code>col_date</code> is not set. The result is nothing more than a <code>data.frame</code>, containing the years, number of observations, actual observed resistance, the estimated resistance and the standard error below and above the estimation:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">predict_pita</a>
<a class="sourceLine" id="cb4-2" data-line-number="2"><span class="co"># year value se_min se_max observations observed estimated</span></a>
<a class="sourceLine" id="cb4-3" data-line-number="3"><span class="co"># 1 2003 0.06250000 NA NA 32 0.06250000 0.06177594</span></a>
<a class="sourceLine" id="cb4-4" data-line-number="4"><span class="co"># 2 2004 0.08536585 NA NA 82 0.08536585 0.06846343</span></a>
<a class="sourceLine" id="cb4-5" data-line-number="5"><span class="co"># 3 2005 0.10000000 NA NA 60 0.10000000 0.07581637</span></a>
<a class="sourceLine" id="cb4-6" data-line-number="6"><span class="co"># 4 2006 0.05084746 NA NA 59 0.05084746 0.08388789</span></a>
<a class="sourceLine" id="cb4-7" data-line-number="7"><span class="co"># 5 2007 0.12121212 NA NA 66 0.12121212 0.09273250</span></a>
<a class="sourceLine" id="cb4-8" data-line-number="8"><span class="co"># 6 2008 0.04166667 NA NA 72 0.04166667 0.10240539</span></a>
<a class="sourceLine" id="cb4-9" data-line-number="9"><span class="co"># 7 2009 0.01639344 NA NA 61 0.01639344 0.11296163</span></a>
<a class="sourceLine" id="cb4-10" data-line-number="10"><span class="co"># 8 2010 0.09433962 NA NA 53 0.09433962 0.12445516</span></a>
<a class="sourceLine" id="cb4-11" data-line-number="11"><span class="co"># 9 2011 0.18279570 NA NA 93 0.18279570 0.13693759</span></a>
<a class="sourceLine" id="cb4-12" data-line-number="12"><span class="co"># 10 2012 0.30769231 NA NA 65 0.30769231 0.15045682</span></a>
<a class="sourceLine" id="cb4-13" data-line-number="13"><span class="co"># 11 2013 0.08620690 NA NA 58 0.08620690 0.16505550</span></a>
<a class="sourceLine" id="cb4-14" data-line-number="14"><span class="co"># 12 2014 0.15254237 NA NA 59 0.15254237 0.18076926</span></a>
<a class="sourceLine" id="cb4-15" data-line-number="15"><span class="co"># 13 2015 0.27272727 NA NA 55 0.27272727 0.19762493</span></a>
<a class="sourceLine" id="cb4-16" data-line-number="16"><span class="co"># 14 2016 0.25000000 NA NA 84 0.25000000 0.21563859</span></a>
<a class="sourceLine" id="cb4-17" data-line-number="17"><span class="co"># 15 2017 0.16279070 NA NA 86 0.16279070 0.23481370</span></a>
<a class="sourceLine" id="cb4-18" data-line-number="18"><span class="co"># 16 2018 0.25513926 0.2228376 0.2874409 NA NA 0.25513926</span></a>
<a class="sourceLine" id="cb4-19" data-line-number="19"><span class="co"># 17 2019 0.27658825 0.2386811 0.3144954 NA NA 0.27658825</span></a>
<a class="sourceLine" id="cb4-20" data-line-number="20"><span class="co"># 18 2020 0.29911630 0.2551715 0.3430611 NA NA 0.29911630</span></a>
<a class="sourceLine" id="cb4-21" data-line-number="21"><span class="co"># 19 2021 0.32266085 0.2723340 0.3729877 NA NA 0.32266085</span></a>
<a class="sourceLine" id="cb4-22" data-line-number="22"><span class="co"># 20 2022 0.34714076 0.2901847 0.4040968 NA NA 0.34714076</span></a>
<a class="sourceLine" id="cb4-23" data-line-number="23"><span class="co"># 21 2023 0.37245666 0.3087318 0.4361815 NA NA 0.37245666</span></a>
<a class="sourceLine" id="cb4-24" data-line-number="24"><span class="co"># 22 2024 0.39849187 0.3279750 0.4690088 NA NA 0.39849187</span></a>
<a class="sourceLine" id="cb4-25" data-line-number="25"><span class="co"># 23 2025 0.42511415 0.3479042 0.5023241 NA NA 0.42511415</span></a>
<a class="sourceLine" id="cb4-26" data-line-number="26"><span class="co"># 24 2026 0.45217796 0.3684992 0.5358568 NA NA 0.45217796</span></a>
<a class="sourceLine" id="cb4-27" data-line-number="27"><span class="co"># 25 2027 0.47952757 0.3897276 0.5693275 NA NA 0.47952757</span></a>
<a class="sourceLine" id="cb4-28" data-line-number="28"><span class="co"># 26 2028 0.50700045 0.4115444 0.6024565 NA NA 0.50700045</span></a>
<a class="sourceLine" id="cb4-29" data-line-number="29"><span class="co"># 27 2029 0.53443111 0.4338908 0.6349714 NA NA 0.53443111</span></a></code></pre></div>
<p>The function <code>plot</code> is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/plot">plot</a></span>(predict_pita)</a></code></pre></div>
<p><img src="Predict_files/figure-html/unnamed-chunk-4-1.png" width="720"></p>
<p>We also support the <code>ggplot2</code> package with the function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code>:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(ggplot2)</a>
<a class="sourceLine" id="cb6-2" data-line-number="2"><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>(predict_pita)</a>
<a class="sourceLine" id="cb6-3" data-line-number="3"><span class="co"># Warning: Removed 15 rows containing missing values (geom_errorbar).</span></a></code></pre></div>
<p><img src="Predict_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
<div id="choosing-the-right-model" class="section level3">
<h3 class="hasAnchor">
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb7-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb7-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb7-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/plot">plot</a></span>()</a>
<a class="sourceLine" id="cb7-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<p><img src="Predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
<p>Vancomycin resistance could be 100% in ten years, but might also stay around 0%.</p>
<p>You can define the model with the <code>model</code> parameter. The default model is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.</p>
<p>Valid values are:</p>
<table class="table">
<colgroup>
<col width="32%">
<col width="25%">
<col width="42%">
</colgroup>
<thead><tr class="header">
<th>Input values</th>
<th>Function used by R</th>
<th>Type of model</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>
<code>"binomial"</code> or <code>"binom"</code> or <code>"logit"</code>
</td>
<td><code><a href="https://www.rdocumentation.org/packages/stats/topics/glm">glm(..., family = binomial)</a></code></td>
<td>Generalised linear model with binomial distribution</td>
</tr>
<tr class="even">
<td>
<code>"loglin"</code> or <code>"poisson"</code>
</td>
<td><code><a href="https://www.rdocumentation.org/packages/stats/topics/glm">glm(..., family = poisson)</a></code></td>
<td>Generalised linear model with poisson distribution</td>
</tr>
<tr class="odd">
<td>
<code>"lin"</code> or <code>"linear"</code>
</td>
<td><code><a href="https://www.rdocumentation.org/packages/stats/topics/lm">lm()</a></code></td>
<td>Linear model</td>
</tr>
</tbody>
</table>
<p>For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on observed years:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/plot">plot</a></span>()</a>
<a class="sourceLine" id="cb8-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<p><img src="Predict_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
<p>This seems more likely, doesnt it?</p>
</div>
</div>
</div> </div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#needed-r-packages">Needed R packages</a></li>
<li><a href="#prediction-analysis">Prediction analysis</a></li>
</ul>
</div>
</div> </div>
</div> </div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to work with WHONET data</h1> <h1>How to work with WHONET data</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>WHONET.Rmd</code></div> <div class="hidden name"><code>WHONET.Rmd</code></div>
@ -227,10 +227,10 @@
<p><strong>Frequency table of <code>mo</code> from a <code>data.frame</code> (500 x 54)</strong><br> <p><strong>Frequency table of <code>mo</code> from a <code>data.frame</code> (500 x 54)</strong><br>
Class: <code>mo</code> (<code>character</code>)<br> Class: <code>mo</code> (<code>character</code>)<br>
Length: 500 (of which NA: 0 = 0.00%)<br> Length: 500 (of which NA: 0 = 0.00%)<br>
Unique: 56</p> Unique: 39</p>
<p>Families: 14<br> <p>Families: 9<br>
Genera: 23<br> Genera: 16<br>
Species: 51</p> Species: 36</p>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="left"></th> <th align="left"></th>
@ -244,86 +244,86 @@ Species: 51</p>
<tr class="odd"> <tr class="odd">
<td align="left">1</td> <td align="left">1</td>
<td align="left">B_ESCHR_COL</td> <td align="left">B_ESCHR_COL</td>
<td align="right">127</td> <td align="right">245</td>
<td align="right">25.4%</td> <td align="right">49.0%</td>
<td align="right">127</td> <td align="right">245</td>
<td align="right">25.4%</td> <td align="right">49.0%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">B_STPHY_CNS</td> <td align="left">B_STPHY_CNS</td>
<td align="right">80</td> <td align="right">74</td>
<td align="right">16.0%</td> <td align="right">14.8%</td>
<td align="right">207</td> <td align="right">319</td>
<td align="right">41.4%</td> <td align="right">63.8%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">B_STPHY_AUR</td> <td align="left">B_STPHY_EPI</td>
<td align="right">50</td> <td align="right">38</td>
<td align="right">10.0%</td> <td align="right">7.6%</td>
<td align="right">257</td> <td align="right">357</td>
<td align="right">51.4%</td> <td align="right">71.4%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">4</td> <td align="left">4</td>
<td align="left">B_STPHY_EPI</td>
<td align="right">37</td>
<td align="right">7.4%</td>
<td align="right">294</td>
<td align="right">58.8%</td>
</tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">B_STRPTC_PNE</td> <td align="left">B_STRPTC_PNE</td>
<td align="right">31</td> <td align="right">31</td>
<td align="right">6.2%</td> <td align="right">6.2%</td>
<td align="right">325</td>
<td align="right">65.0%</td>
</tr>
<tr class="even">
<td align="left">6</td>
<td align="left">B_STPHY_HOM</td>
<td align="right">23</td>
<td align="right">4.6%</td>
<td align="right">348</td>
<td align="right">69.6%</td>
</tr>
<tr class="odd">
<td align="left">7</td>
<td align="left">B_PROTS_MIR</td>
<td align="right">13</td>
<td align="right">2.6%</td>
<td align="right">361</td>
<td align="right">72.2%</td>
</tr>
<tr class="even">
<td align="left">8</td>
<td align="left">B_KLBSL_PNE</td>
<td align="right">11</td>
<td align="right">2.2%</td>
<td align="right">372</td>
<td align="right">74.4%</td>
</tr>
<tr class="odd">
<td align="left">9</td>
<td align="left">B_PDMNS_AER</td>
<td align="right">8</td>
<td align="right">1.6%</td>
<td align="right">380</td>
<td align="right">76.0%</td>
</tr>
<tr class="even">
<td align="left">10</td>
<td align="left">B_STPHY_CAP</td>
<td align="right">8</td>
<td align="right">1.6%</td>
<td align="right">388</td> <td align="right">388</td>
<td align="right">77.6%</td> <td align="right">77.6%</td>
</tr> </tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">B_STPHY_HOM</td>
<td align="right">21</td>
<td align="right">4.2%</td>
<td align="right">409</td>
<td align="right">81.8%</td>
</tr>
<tr class="even">
<td align="left">6</td>
<td align="left">B_PROTS_MIR</td>
<td align="right">9</td>
<td align="right">1.8%</td>
<td align="right">418</td>
<td align="right">83.6%</td>
</tr>
<tr class="odd">
<td align="left">7</td>
<td align="left">B_ENTRC_IUM</td>
<td align="right">8</td>
<td align="right">1.6%</td>
<td align="right">426</td>
<td align="right">85.2%</td>
</tr>
<tr class="even">
<td align="left">8</td>
<td align="left">B_STPHY_CAP</td>
<td align="right">8</td>
<td align="right">1.6%</td>
<td align="right">434</td>
<td align="right">86.8%</td>
</tr>
<tr class="odd">
<td align="left">9</td>
<td align="left">B_ENTRB_CLO</td>
<td align="right">5</td>
<td align="right">1.0%</td>
<td align="right">439</td>
<td align="right">87.8%</td>
</tr>
<tr class="even">
<td align="left">10</td>
<td align="left">B_ENTRC</td>
<td align="right">4</td>
<td align="right">0.8%</td>
<td align="right">443</td>
<td align="right">88.6%</td>
</tr>
</tbody> </tbody>
</table> </table>
<p>(omitted 46 entries, n = 112 [22.4%])</p> <p>(omitted 29 entries, n = 57 [11.4%])</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"></a> <div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"></a>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co"># our transformed antibiotic columns</span></a> <a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co"># our transformed antibiotic columns</span></a>
<a class="sourceLine" id="cb5-3" data-line-number="3"><span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span></a> <a class="sourceLine" id="cb5-3" data-line-number="3"><span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span></a>
@ -331,9 +331,9 @@ Species: 51</p>
<p><strong>Frequency table of <code>AMC_ND2</code> from a <code>data.frame</code> (500 x 54)</strong><br> <p><strong>Frequency table of <code>AMC_ND2</code> from a <code>data.frame</code> (500 x 54)</strong><br>
Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br> Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br>
Levels: S &lt; I &lt; R<br> Levels: S &lt; I &lt; R<br>
Length: 500 (of which NA: 41 = 8.20%)<br> Length: 500 (of which NA: 19 = 3.80%)<br>
Unique: 3</p> Unique: 3</p>
<p>%IR: 28.98% (ratio S : IR = 1.0 : 0.4)</p> <p>%IR: 25.99% (ratio S : IR = 1.0 : 0.4)</p>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="left"></th> <th align="left"></th>
@ -347,25 +347,25 @@ Unique: 3</p>
<tr class="odd"> <tr class="odd">
<td align="left">1</td> <td align="left">1</td>
<td align="left">S</td> <td align="left">S</td>
<td align="right">326</td> <td align="right">356</td>
<td align="right">71.0%</td> <td align="right">74.0%</td>
<td align="right">326</td> <td align="right">356</td>
<td align="right">71.0%</td> <td align="right">74.0%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">R</td> <td align="left">R</td>
<td align="right">111</td> <td align="right">103</td>
<td align="right">24.2%</td> <td align="right">21.4%</td>
<td align="right">437</td> <td align="right">459</td>
<td align="right">95.2%</td> <td align="right">95.4%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">I</td> <td align="left">I</td>
<td align="right">22</td> <td align="right">22</td>
<td align="right">4.8%</td> <td align="right">4.6%</td>
<td align="right">459</td> <td align="right">481</td>
<td align="right">100.0%</td> <td align="right">100.0%</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to get properties of an antibiotic</h1> <h1>How to get properties of an antibiotic</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>ab_property.Rmd</code></div> <div class="hidden name"><code>ab_property.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>Benchmarks</h1> <h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div> <div class="hidden name"><code>benchmarks.Rmd</code></div>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to create frequency tables</h1> <h1>How to create frequency tables</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>freq.Rmd</code></div> <div class="hidden name"><code>freq.Rmd</code></div>
@ -595,9 +595,9 @@ Unique: 4</p>
<p><strong>Frequency table of <code>amox</code> from a <code>data.frame</code> (2,000 x 49)</strong><br> <p><strong>Frequency table of <code>amox</code> from a <code>data.frame</code> (2,000 x 49)</strong><br>
Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br> Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br>
Levels: S &lt; I &lt; R<br> Levels: S &lt; I &lt; R<br>
Length: 2,000 (of which NA: 828 = 41.40%)<br> Length: 2,000 (of which NA: 771 = 38.55%)<br>
Unique: 3</p> Unique: 3</p>
<p>%IR: 58.53% (ratio S : IR = 1.0 : 1.4)</p> <p>%IR: 55.82% (ratio S : IR = 1.0 : 1.3)</p>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="left"></th> <th align="left"></th>
@ -612,24 +612,24 @@ Unique: 3</p>
<td align="left">1</td> <td align="left">1</td>
<td align="left">R</td> <td align="left">R</td>
<td align="right">683</td> <td align="right">683</td>
<td align="right">58.3%</td> <td align="right">55.6%</td>
<td align="right">683</td> <td align="right">683</td>
<td align="right">58.3%</td> <td align="right">55.6%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">S</td> <td align="left">S</td>
<td align="right">486</td> <td align="right">543</td>
<td align="right">41.5%</td> <td align="right">44.2%</td>
<td align="right">1,169</td> <td align="right">1,226</td>
<td align="right">99.7%</td> <td align="right">99.8%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">I</td> <td align="left">I</td>
<td align="right">3</td> <td align="right">3</td>
<td align="right">0.3%</td> <td align="right">0.2%</td>
<td align="right">1,172</td> <td align="right">1,229</td>
<td align="right">100.0%</td> <td align="right">100.0%</td>
</tr> </tr>
</tbody> </tbody>
@ -726,9 +726,9 @@ Median: 31 July 2009 (47.39%)</p>
<p><strong>Frequency table of <code>amox</code> from a <code>data.frame</code> (2,000 x 49)</strong><br> <p><strong>Frequency table of <code>amox</code> from a <code>data.frame</code> (2,000 x 49)</strong><br>
Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br> Class: <code>factor</code> &gt; <code>ordered</code> &gt; <code>rsi</code> (<code>numeric</code>)<br>
Levels: S &lt; I &lt; R<br> Levels: S &lt; I &lt; R<br>
Length: 2,828 (of which NA: 828 = 29.28%)<br> Length: 2,771 (of which NA: 771 = 27.82%)<br>
Unique: 4</p> Unique: 4</p>
<p>%IR: 34.30% (ratio S : IR = 1.0 : 1.4)</p> <p>%IR: 34.30% (ratio S : IR = 1.0 : 1.3)</p>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="left"></th> <th align="left"></th>
@ -742,24 +742,24 @@ Unique: 4</p>
<tr class="odd"> <tr class="odd">
<td align="left">1</td> <td align="left">1</td>
<td align="left">(NA)</td> <td align="left">(NA)</td>
<td align="right">828</td> <td align="right">771</td>
<td align="right">41.4%</td> <td align="right">38.6%</td>
<td align="right">828</td> <td align="right">771</td>
<td align="right">41.4%</td> <td align="right">38.6%</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="left">2</td> <td align="left">2</td>
<td align="left">R</td> <td align="left">R</td>
<td align="right">683</td> <td align="right">683</td>
<td align="right">34.2%</td> <td align="right">34.2%</td>
<td align="right">1,511</td> <td align="right">1,454</td>
<td align="right">75.6%</td> <td align="right">72.7%</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="left">3</td> <td align="left">3</td>
<td align="left">S</td> <td align="left">S</td>
<td align="right">486</td> <td align="right">543</td>
<td align="right">24.3%</td> <td align="right">27.2%</td>
<td align="right">1,997</td> <td align="right">1,997</td>
<td align="right">99.9%</td> <td align="right">99.9%</td>
</tr> </tr>

View File

@ -40,7 +40,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>
@ -185,7 +185,7 @@
<h1>How to get properties of a microorganism</h1> <h1>How to get properties of a microorganism</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">08 February 2019</h4> <h4 class="date">09 February 2019</h4>
<div class="hidden name"><code>mo_property.Rmd</code></div> <div class="hidden name"><code>mo_property.Rmd</code></div>

BIN
docs/cover_r4ds.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

View File

@ -21,6 +21,16 @@
# ==================================================================== # # ==================================================================== #
*/ */
/* R for Data Science (r4ds) */
#r4ds a {
display: inline;
}
#r4ds * {
text-align: center;
display: block;
margin: 0 auto;
}
/* class for footer */ /* class for footer */
.footer_logo { .footer_logo {
float: right; float: right;

View File

@ -34,6 +34,16 @@ $( document ).ready(function() {
window.location.replace(url_new); window.location.replace(url_new);
} }
$('#sidebar').prepend(
'<div id="r4ds">' +
' <a href="https://r4ds.had.co.nz/">' +
' <img src="../../AMR/cover_r4ds.png" width="25%">' +
' </a>' +
' <p>Learn R reading this great book!</p>' +
' <p>Or read it free online: <a href="https://r4ds.had.co.nz/" target="_blank">r4ds.co.nz</a>.</p>' +
' <hr>' +
'</div>');
$('footer').html( $('footer').html(
'<div>' + '<div>' +
'<p>' + $('footer .copyright p').html().replace( '<p>' + $('footer .copyright p').html().replace(

View File

@ -195,7 +195,7 @@
<p>This package can be used for:</p> <p>This package can be used for:</p>
<ul> <ul>
<li>Calculating antimicrobial resistance</li> <li>Calculating antimicrobial resistance</li>
<li>Predicting empiric susceptibility of both mono therapy and combination therapy</li> <li>Calculating empiric susceptibility of both mono therapy and combination therapy</li>
<li>Predicting future antimicrobial resistance using regression models</li> <li>Predicting future antimicrobial resistance using regression models</li>
<li>Getting properties for any microorganism (like Gram stain, species, genus or family)</li> <li>Getting properties for any microorganism (like Gram stain, species, genus or family)</li>
<li>Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)</li> <li>Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)</li>

View File

@ -342,6 +342,7 @@ These functions use <code><a href="../reference/as.atc.html">as.atc()</a></code>
</li> </li>
<li>Small text updates to summaries of class <code>rsi</code> and <code>mic</code> <li>Small text updates to summaries of class <code>rsi</code> and <code>mic</code>
</li> </li>
<li>Function <code><a href="../reference/as.rsi.html">as.rsi()</a></code> now gives a warning when inputting MIC values</li>
<li>Frequency tables (<code><a href="../reference/freq.html">freq()</a></code> function): <li>Frequency tables (<code><a href="../reference/freq.html">freq()</a></code> function):
<ul> <ul>
<li> <li>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
</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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co
</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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
</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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -80,7 +80,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="Released version">0.5.0.9016</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
</span> </span>
</div> </div>

View File

@ -14,7 +14,7 @@ This R package is actively maintained and free software; you can freely use and
This package can be used for: This package can be used for:
* Calculating antimicrobial resistance * Calculating antimicrobial resistance
* Predicting empiric susceptibility of both mono therapy and combination therapy * Calculating empiric susceptibility of both mono therapy and combination therapy
* Predicting future antimicrobial resistance using regression models * Predicting future antimicrobial resistance using regression models
* Getting properties for any microorganism (like Gram stain, species, genus or family) * Getting properties for any microorganism (like Gram stain, species, genus or family)
* Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name) * Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)

View File

@ -38,7 +38,7 @@ ggplot_rsi_predict(x, main = paste("Resistance prediction of",
\item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.} \item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.}
\item{model}{the statistical model of choice. Valid values are \code{"binomial"} (or \code{"binom"} or \code{"logit"}) or \code{"loglin"} (or \code{"poisson"}) or \code{"linear"} (or \code{"lin"}).} \item{model}{the statistical model of choice. Defaults to a generalised linear regression model with binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance. See Details for valid options.}
\item{I_as_R}{a logical to indicate whether values \code{I} should be treated as \code{R}} \item{I_as_R}{a logical to indicate whether values \code{I} should be treated as \code{R}}
@ -69,6 +69,14 @@ ggplot_rsi_predict(x, main = paste("Resistance prediction of",
\description{ \description{
Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns \code{se_min} and \code{se_max}. See Examples for a real live example. Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns \code{se_min} and \code{se_max}. See Examples for a real live example.
} }
\details{
Valid options for the statistical model are:
\itemize{
\item{\code{"binomial"} or \code{"binom"} or \code{"logit"}: a generalised linear regression model with binomial distribution}
\item{\code{"loglin"} or \code{"poisson"}: a generalised log-linear regression model with poisson distribution}
\item{\code{"lin"} or \code{"linear"}: a linear regression model}
}
}
\section{Read more on our website!}{ \section{Read more on our website!}{
\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr} \if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr}

View File

@ -21,6 +21,16 @@
# ==================================================================== # # ==================================================================== #
*/ */
/* R for Data Science (r4ds) */
#r4ds a {
display: inline;
}
#r4ds * {
text-align: center;
display: block;
margin: 0 auto;
}
/* class for footer */ /* class for footer */
.footer_logo { .footer_logo {
float: right; float: right;

View File

@ -34,6 +34,16 @@ $( document ).ready(function() {
window.location.replace(url_new); window.location.replace(url_new);
} }
$('#sidebar').prepend(
'<div id="r4ds">' +
' <a href="https://r4ds.had.co.nz/">' +
' <img src="../../AMR/cover_r4ds.png" width="25%">' +
' </a>' +
' <p>Learn R reading this great book!</p>' +
' <p>Or read it free online: <a href="https://r4ds.had.co.nz/" target="_blank">r4ds.co.nz</a>.</p>' +
' <hr>' +
'</div>');
$('footer').html( $('footer').html(
'<div>' + '<div>' +
'<p>' + $('footer .copyright p').html().replace( '<p>' + $('footer .copyright p').html().replace(

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

View File

@ -16,8 +16,96 @@ editor_options:
```{r setup, include = FALSE, results = 'markup'} ```{r setup, include = FALSE, results = 'markup'}
knitr::opts_chunk$set( knitr::opts_chunk$set(
collapse = TRUE, collapse = TRUE,
comment = "#" comment = "#",
fig.width = 7.5,
fig.height = 4.5
) )
``` ```
*(will be available soon)* ## Needed R packages
As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the [tidyverse packages](https://www.tidyverse.org) [`dplyr`](https://dplyr.tidyverse.org/) and [`ggplot2`](https://ggplot2.tidyverse.org) by [Dr Hadley Wickham](https://www.linkedin.com/in/hadleywickham/). The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.
Our `AMR` package depends on these packages and even extends their use and functions.
```{r lib packages, message = FALSE}
library(dplyr)
library(ggplot2)
library(AMR)
# (if not yet installed, install with:)
# install.packages(c("tidyverse", "AMR"))
```
## Prediction analysis
Our package contains a function `resistance_predict()`, which takes the same input as functions for [other AMR analysis](./articles/AMR.html). Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.
It is basically as easy as:
```{r, eval = FALSE}
# resistance prediction of piperacillin/tazobactam (pita):
resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "pita")
# or:
septic_patients %>%
resistance_predict(col_ab = "pita")
# to bind it to object 'predict_pita' for example:
predict_pita <- septic_patients %>%
resistance_predict(col_ab = "pita")
```
```{r, echo = FALSE}
predict_pita <- septic_patients %>%
resistance_predict(col_ab = "pita")
```
The function will look for a data column itself if `col_date` is not set. The result is nothing more than a `data.frame`, containing the years, number of observations, actual observed resistance, the estimated resistance and the standard error below and above the estimation:
```{r}
predict_pita
```
The function `plot` is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:
```{r}
plot(predict_pita)
```
We also support the `ggplot2` package with the function `ggplot_rsi_predict()`:
```{r}
library(ggplot2)
ggplot_rsi_predict(predict_pita)
```
### Choosing the right model
Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:
```{r}
septic_patients %>%
filter(mo_gramstain(mo) == "Gram positive") %>%
resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE) %>%
plot()
```
Vancomycin resistance could be 100% in ten years, but might also stay around 0%.
You can define the model with the `model` parameter. The default model is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.
Valid values are:
| Input values | Function used by R | Type of model |
|----------------------------------------|-------------------------------|-----------------------------------------------------|
| `"binomial"` or `"binom"` or `"logit"` | `glm(..., family = binomial)` | Generalised linear model with binomial distribution |
| `"loglin"` or `"poisson"` | `glm(..., family = poisson)` | Generalised linear model with poisson distribution |
| `"lin"` or `"linear"` | `lm()` | Linear model |
For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on observed years:
```{r}
septic_patients %>%
filter(mo_gramstain(mo) == "Gram positive") %>%
resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE, model = "linear") %>%
plot()
```
This seems more likely, doesn't it?