Browse Source

mo_source improvement

new-mo-algorithm
parent
commit
c5efb272fd
  1. 2
      .gitlab-ci.yml
  2. 2
      DESCRIPTION
  3. 21
      R/mo.R
  4. 24
      R/mo_source.R
  5. 4
      appveyor.yml
  6. 400
      docs/articles/AMR.html
  7. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  8. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  9. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  10. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  11. 2
      docs/articles/EUCAST.html
  12. 2
      docs/articles/G_test.html
  13. 2
      docs/articles/WHONET.html
  14. 2
      docs/articles/atc_property.html
  15. 72
      docs/articles/benchmarks.html
  16. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png
  17. 2
      docs/articles/freq.html
  18. 2
      docs/articles/mo_property.html
  19. 2
      docs/articles/resistance_predict.html
  20. 13
      docs/reference/mo_source.html
  21. 14
      man/mo_source.Rd

2
.gitlab-ci.yml

@ -64,6 +64,7 @@ R: @@ -64,6 +64,7 @@ R:
variables:
WARNINGS_ARE_ERRORS: 1
script:
- export WARNINGS_ARE_ERRORS=1
# remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file
- rm -rf vignettes
- Rscript -e 'd <- read.dcf("DESCRIPTION"); d[, colnames(d) == "VignetteBuilder"] <- NA; write.dcf(d, "DESCRIPTION")'
@ -81,6 +82,7 @@ coverage: @@ -81,6 +82,7 @@ coverage:
allow_failure: true
when: on_success
only:
- premaster
- master
script:
- apt-get install --yes git

2
DESCRIPTION

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9020
Date: 2019-02-28
Date: 2019-03-01
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(

21
R/mo.R

@ -117,6 +117,7 @@ @@ -117,6 +117,7 @@
#' @seealso \code{\link{microorganisms}} for the \code{data.frame} that is being used to determine ID's. \cr
#' The \code{\link{mo_property}} functions (like \code{\link{mo_genus}}, \code{\link{mo_gramstain}}) to get properties based on the returned code.
#' @inheritSection AMR Read more on our website!
#' @importFrom dplyr %>% pull left_join
#' @examples
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
#' as.mo("stau")
@ -171,16 +172,28 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, @@ -171,16 +172,28 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
# check onLoad() in R/zzz.R: data tables are created there.
}
if (all(x %in% AMR::microorganisms$mo)
if (deparse(substitute(reference_df)) == "get_mo_source()"
& isFALSE(Becker)
& isFALSE(Lancefield)
& is.null(reference_df)) {
& !is.null(reference_df)
& all(x %in% reference_df[,1])) {
# has valid own reference_df
# (data.table not faster here)
colnames(reference_df)[1] <- "x"
suppressWarnings(
y <- data.frame(x = x, stringsAsFactors = FALSE) %>%
left_join(reference_df, by = "x") %>%
pull("mo")
)
} else if (all(x %in% AMR::microorganisms$mo)
& isFALSE(Becker)
& isFALSE(Lancefield)) {
y <- x
} else if (all(tolower(x) %in% microorganismsDT$fullname_lower)
& isFALSE(Becker)
& isFALSE(Lancefield)
& is.null(reference_df)) {
& isFALSE(Lancefield)) {
# we need special treatment for very prevalent full names, they are likely! (case insensitive)
# e.g. as.mo("Staphylococcus aureus")
y <- microorganismsDT[prevalence == 1][data.table(fullname_lower = tolower(x)),

24
R/mo_source.R

@ -52,15 +52,19 @@ @@ -52,15 +52,19 @@
#' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' }
#'
#' It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression.
#' It has now created a file "~/.mo_source.rds" with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.
#'
#' And now we can use it in our functions:
#' \preformatted{
#' as.mo("lab_mo_ecoli")
#' # B_ESCHR_COL
#' [1] B_ESCHR_COL
#'
#' mo_genus("lab_mo_kpneumoniae")
#' # "Klebsiella"
#' [1] "Klebsiella"
#'
#' # other input values still work too
#' as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
#' [1] B_ESCHR_COL B_ESCHR_COL B_ESCHR_COL
#' }
#'
#' If we edit the Excel file to, let's say, this:
@ -78,10 +82,10 @@ @@ -78,10 +82,10 @@
#' \preformatted{
#' as.mo("lab_mo_ecoli")
#' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' # B_ESCHR_COL
#' [1] B_ESCHR_COL
#'
#' mo_genus("lab_Staph_aureus")
#' # "Staphylococcus"
#' [1] "Staphylococcus"
#' }
#'
#' To remove the reference completely, just use any of these:
@ -119,7 +123,9 @@ set_mo_source <- function(path) { @@ -119,7 +123,9 @@ set_mo_source <- function(path) {
valid <- FALSE
} else if (!"mo" %in% colnames(df)) {
valid <- FALSE
} else if (!all(df$mo %in% AMR::microorganisms$mo)) {
} else if (all(as.data.frame(df)[, 1] == "")) {
valid <- FALSE
} else if (!all(df$mo %in% c("", AMR::microorganisms$mo))) {
valid <- FALSE
} else if (NCOL(df) < 2) {
valid <- FALSE
@ -163,9 +169,11 @@ set_mo_source <- function(path) { @@ -163,9 +169,11 @@ set_mo_source <- function(path) {
stop("File must contain a column with self-defined values and a reference column `mo` with valid values from the `microorganisms` data set.")
}
# keep only first two columns, second must be mo
if (colnames(df)[1] == "mo") {
# put mo to the end
df <- df %>% select(-"mo", everything(), "mo")
df <- df[, c(2, 1)]
} else {
df <- df[, c(1, 2)]
}
df <- as.data.frame(df, stringAsFactors = FALSE)

4
appveyor.yml

@ -55,8 +55,8 @@ on_failure: @@ -55,8 +55,8 @@ on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
on_success:
- Rscript -e "library(covr); cc <- package_coverage(); codecov(coverage = cc, token = '50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca'); cat('Code coverage:', percent_coverage(cc))"
#on_success:
# - Rscript -e "library(covr); cc <- package_coverage(); codecov(coverage = cc, token = '50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca'); cat('Code coverage:', percent_coverage(cc))"
artifacts:
- path: '*.Rcheck\**\*.log'

400
docs/articles/AMR.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -201,7 +201,7 @@ @@ -201,7 +201,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 28 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 01 March 2019.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -217,21 +217,21 @@ @@ -217,21 +217,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2019-02-28</td>
<td align="center">2019-03-01</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2019-02-28</td>
<td align="center">2019-03-01</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2019-02-28</td>
<td align="center">2019-03-01</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -327,70 +327,70 @@ @@ -327,70 +327,70 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2015-09-11</td>
<td align="center">C6</td>
<td align="center">2017-06-13</td>
<td align="center">Z3</td>
<td align="center">Hospital D</td>
<td align="center">Staphylococcus aureus</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">M</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2015-05-10</td>
<td align="center">N2</td>
<td align="center">Hospital A</td>
<td align="center">2013-09-13</td>
<td align="center">A1</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</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">M</td>
</tr>
<tr class="odd">
<td align="center">2012-03-06</td>
<td align="center">C2</td>
<td align="center">Hospital C</td>
<td align="center">2015-06-10</td>
<td align="center">L8</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</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">M</td>
</tr>
<tr class="even">
<td align="center">2011-11-09</td>
<td align="center">X3</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">2010-08-05</td>
<td align="center">A7</td>
<td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">R</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">2017-02-01</td>
<td align="center">O6</td>
<td align="center">Hospital A</td>
<td align="center">2011-08-25</td>
<td align="center">X4</td>
<td align="center">Hospital C</td>
<td align="center">Staphylococcus aureus</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">F</td>
</tr>
<tr class="even">
<td align="center">2017-02-26</td>
<td align="center">X1</td>
<td align="center">2011-03-09</td>
<td align="center">B7</td>
<td align="center">Hospital D</td>
<td align="center">Klebsiella pneumoniae</td>
<td align="center">S</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">F</td>
<td align="center">M</td>
</tr>
</tbody>
</table>
@ -411,8 +411,8 @@ @@ -411,8 +411,8 @@
#&gt;
#&gt; Item Count Percent Cum. Count Cum. Percent
#&gt; --- ----- ------- -------- ----------- -------------
#&gt; 1 M 10,244 51.2% 10,244 51.2%
#&gt; 2 F 9,756 48.8% 20,000 100.0%</code></pre>
#&gt; 1 M 10,311 51.6% 10,311 51.6%
#&gt; 2 F 9,689 48.4% 20,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 didn’t 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>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a>
@ -443,10 +443,10 @@ @@ -443,10 +443,10 @@
<a class="sourceLine" id="cb14-19" title="19"><span class="co">#&gt; Kingella kingae (no changes)</span></a>
<a class="sourceLine" id="cb14-20" title="20"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-21" title="21"><span class="co">#&gt; EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#&gt; Table 1: Intrinsic resistance in Enterobacteriaceae (1275 changes)</span></a>
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#&gt; Table 1: Intrinsic resistance in Enterobacteriaceae (1364 changes)</span></a>
<a class="sourceLine" id="cb14-23" title="23"><span class="co">#&gt; Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-24" title="24"><span class="co">#&gt; Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#&gt; Table 4: Intrinsic resistance in Gram-positive bacteria (2727 changes)</span></a>
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#&gt; Table 4: Intrinsic resistance in Gram-positive bacteria (2659 changes)</span></a>
<a class="sourceLine" id="cb14-26" title="26"><span class="co">#&gt; Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
<a class="sourceLine" id="cb14-27" title="27"><span class="co">#&gt; Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
<a class="sourceLine" id="cb14-28" title="28"><span class="co">#&gt; Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
@ -462,9 +462,9 @@ @@ -462,9 +462,9 @@
<a class="sourceLine" id="cb14-38" title="38"><span class="co">#&gt; Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
<a class="sourceLine" id="cb14-39" title="39"><span class="co">#&gt; Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
<a class="sourceLine" id="cb14-40" title="40"><span class="co">#&gt; </span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#&gt; =&gt; EUCAST rules affected 7,427 out of 20,000 rows</span></a>
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#&gt; =&gt; EUCAST rules affected 7,366 out of 20,000 rows</span></a>
<a class="sourceLine" id="cb14-42" title="42"><span class="co">#&gt; -&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#&gt; -&gt; changed 4,002 test results (0 to S; 0 to I; 4,002 to R)</span></a></code></pre></div>
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#&gt; -&gt; changed 4,023 test results (0 to S; 0 to I; 4,023 to R)</span></a></code></pre></div>
</div>
<div id="adding-new-variables" class="section level1">
<h1 class="hasAnchor">
@ -489,8 +489,8 @@ @@ -489,8 +489,8 @@
<a class="sourceLine" id="cb16-3" title="3"><span class="co">#&gt; </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" title="4"><span class="co">#&gt; </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" title="5"><span class="co">#&gt; </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" title="6"><span class="co">#&gt; =&gt; Found 5,650 first isolates (28.3% of total)</span></a></code></pre></div>
<p>So only 28.3% 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>
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#&gt; =&gt; Found 5,641 first isolates (28.2% of total)</span></a></code></pre></div>
<p>So only 28.2% 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" title="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" title="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>
@ -516,8 +516,8 @@ @@ -516,8 +516,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-04-26</td>
<td align="center">H9</td>
<td align="center">2010-01-14</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
@ -527,10 +527,10 @@ @@ -527,10 +527,10 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-05-27</td>
<td align="center">H9</td>
<td align="center">2010-02-17</td>
<td align="center">K8</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">R</td>
<td align="center">S</td>
@ -538,19 +538,19 @@ @@ -538,19 +538,19 @@
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-07-20</td>
<td align="center">H9</td>
<td align="center">2010-03-01</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-11-25</td>
<td align="center">H9</td>
<td align="center">2010-03-11</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -560,54 +560,54 @@ @@ -560,54 +560,54 @@
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2011-01-19</td>
<td align="center">H9</td>
<td align="center">2010-04-13</td>
<td align="center">K8</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">R</td>
<td align="center">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2011-01-24</td>
<td align="center">H9</td>
<td align="center">2010-08-30</td>
<td align="center">K8</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">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2011-03-09</td>
<td align="center">H9</td>
<td align="center">2010-11-05</td>
<td align="center">K8</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">FALSE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-06-07</td>
<td align="center">H9</td>
<td align="center">2010-12-21</td>
<td align="center">K8</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">TRUE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-07-30</td>
<td align="center">H9</td>
<td align="center">2010-12-21</td>
<td align="center">K8</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">S</td>
@ -615,14 +615,14 @@ @@ -615,14 +615,14 @@
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-08-01</td>
<td align="center">H9</td>
<td align="center">2011-03-20</td>
<td align="center">K8</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">FALSE</td>
<td align="center">TRUE</td>
</tr>
</tbody>
</table>
@ -637,7 +637,7 @@ @@ -637,7 +637,7 @@
<a class="sourceLine" id="cb19-7" title="7"><span class="co">#&gt; </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" title="8"><span class="co">#&gt; </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" title="9"><span class="co">#&gt; [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#&gt; =&gt; Found 15,814 first weighted isolates (79.1% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#&gt; =&gt; Found 15,738 first weighted isolates (78.7% of total)</span></a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -654,8 +654,8 @@ @@ -654,8 +654,8 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-04-26</td>
<td align="center">H9</td>
<td align="center">2010-01-14</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
@ -666,10 +666,10 @@ @@ -666,10 +666,10 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-05-27</td>
<td align="center">H9</td>
<td align="center">2010-02-17</td>
<td align="center">K8</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">R</td>
<td align="center">S</td>
@ -678,20 +678,20 @@ @@ -678,20 +678,20 @@
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-07-20</td>
<td align="center">H9</td>
<td align="center">2010-03-01</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-11-25</td>
<td align="center">H9</td>
<td align="center">2010-03-11</td>
<td align="center">K8</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -702,83 +702,83 @@ @@ -702,83 +702,83 @@
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2011-01-19</td>
<td align="center">H9</td>
<td align="center">2010-04-13</td>
<td align="center">K8</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">FALSE</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2011-01-24</td>
<td align="center">H9</td>
<td align="center">2010-08-30</td>
<td align="center">K8</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">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2011-03-09</td>
<td align="center">H9</td>
<td align="center">2010-11-05</td>
<td align="center">K8</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">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2011-06-07</td>
<td align="center">H9</td>
<td align="center">2010-12-21</td>
<td align="center">K8</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">TRUE</td>
<td align="center">TRUE</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2011-07-30</td>
<td align="center">H9</td>
<td align="center">2010-12-21</td>
<td align="center">K8</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">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2011-08-01</td>
<td align="center">H9</td>
<td align="center">2011-03-20</td>
<td align="center">K8</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">FALSE</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
</tbody>
</table>
<p>Instead of 2, now 6 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.8% 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 2, now 9 isolates are flagged. In total, 78.7% of all isolates are marked ‘first weighted’ - 50.5% 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>, there’s 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" title="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" title="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 15,814 isolates for analysis.</p>
<p>So we end up with 15,738 isolates for analysis.</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" title="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" title="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>
@ -804,28 +804,28 @@ @@ -804,28 +804,28 @@
<tbody>
<tr class="odd">
<td>1</td>
<td align="center">2015-09-11</td>
<td align="center">C6</td>
<td align="center">2017-06-13</td>
<td align="center">Z3</td>
<td align="center">Hospital D</td>
<td align="center">B_STPHY_AUR</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">M</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">F</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="even">
<td>3</td>
<td align="center">2012-03-06</td>
<td align="center">C2</td>
<td align="center">Hospital C</td>
<td align="center">2015-06-10</td>
<td align="center">L8</td>
<td align="center">Hospital B</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">M</td>
@ -835,64 +835,64 @@ @@ -835,64 +835,64 @@
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>4</td>
<td align="center">2011-11-09</td>
<td align="center">X3</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">S</td>
<td>6</td>
<td align="center">2011-03-09</td>
<td align="center">B7</td>
<td align="center">Hospital D</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">F</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</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="even">
<td>6</td>
<td align="center">2017-02-26</td>
<td align="center">X1</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNE</td>
<td>8</td>
<td align="center">2015-03-15</td>
<td align="center">O1</td>
<td align="center">Hospital A</td>
<td align="center">B_STPHY_AUR</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">F</td>
<td align="center">Gram negative</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">Gram positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>7</td>
<td align="center">2010-02-15</td>
<td align="center">P3</td>
<td>9</td>
<td align="center">2012-09-07</td>
<td align="center">K5</td>
<td align="center">Hospital C</td>
<td align="center">B_STRPT_PNE</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">F</td>
<td align="center">Gram positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</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="even">
<td>8</td>
<td align="center">2012-10-20</td>
<td align="center">H4</td>
<td>10</td>
<td align="center">2015-08-09</td>
<td align="center">R5</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_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">F</td>
<td align="center">Gram positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
@ -915,9 +915,9 @@ @@ -915,9 +915,9 @@
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" title="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>
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" title="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> (15,814 x 13)</strong></p>
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,738 x 13)</strong></p>
<p>Columns: 2<br>
Length: 15,814 (of which NA: 0 = 0.00%)<br>
Length: 15,738 (of which NA: 0 = 0.00%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -934,33 +934,33 @@ Longest: 24</p> @@ -934,33 +934,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,918</td>
<td align="right">50.1%</td>
<td align="right">7,918</td>
<td align="right">50.1%</td>
<td align="right">7,875</td>
<td align="right">50.0%</td>
<td align="right">7,875</td>
<td align="right">50.0%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,865</td>
<td align="right">24.4%</td>
<td align="right">11,783</td>
<td align="right">74.5%</td>
<td align="right">3,897</td>
<td align="right">24.8%</td>
<td align="right">11,772</td>
<td align="right">74.8%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,458</td>
<td align="right">15.5%</td>
<td align="right">14,241</td>
<td align="right">90.1%</td>
<td align="right">2,400</td>
<td align="right">15.2%</td>
<td align="right">14,172</td>
<td align="right">90.0%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,573</td>
<td align="right">9.9%</td>
<td align="right">15,814</td>
<td align="right">1,566</td>
<td align="right">10.0%</td>
<td align="right">15,738</td>
<td align="right">100.0%</td>
</tr>
</tbody>
@ -971,7 +971,7 @@ Longest: 24</p> @@ -971,7 +971,7 @@ Longest: 24</p>
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
<p>The functions <code><a href="../reference/portion.html">portion_R()</a></code>, <code>portion_RI()</code>, <code><a href="../reference/portion.html">portion_I()</a></code>, <code>portion_IS()</code> and <code><a href="../reference/portion.html">portion_S()</a></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" title="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" title="2"><span class="co">#&gt; [1] 0.4762868</span></a></code></pre></div>
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#&gt; [1] 0.4757911</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>
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" title="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb26-2" title="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>
@ -984,19 +984,19 @@ Longest: 24</p> @@ -984,19 +984,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4752371</td>
<td align="center">0.4800594</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4825898</td>
<td align="center">0.4737983</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4705631</td>
<td align="center">0.4763514</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4711928</td>
<td align="center">0.4724536</td>
</tr>
</tbody>
</table>
@ -1014,23 +1014,23 @@ Longest: 24</p> @@ -1014,23 +1014,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4752371</td>
<td align="center">4745</td>
<td align="center">0.4800594</td>
<td align="center">4714</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4825898</td>
<td align="center">5514</td>
<td align="center">0.4737983</td>
<td align="center">5534</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4705631</td>
<td align="center">2344</td>
<td align="center">0.4763514</td>
<td align="center">2368</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4711928</td>
<td align="center">3211</td>
<td align="center">0.4724536</td>
<td align="center">3122</td>
</tr>
</tbody>
</table>
@ -1050,27 +1050,27 @@ Longest: 24</p> @@ -1050,27 +1050,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.7346552</td>
<td align="center">0.8993433</td>
<td align="center">0.9744885</td>
<td align="center">0.7283810</td>
<td align="center">0.9015873</td>
<td align="center">0.9751111</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.7406230</td>
<td align="center">0.9020979</td>
<td align="center">0.9726637</td>
<td align="center">0.7311622</td>
<td align="center">0.9157088</td>
<td align="center">0.9750958</td>
</tr>
<tr class="odd">
<td align="center">Staphylococcus</td>
<td align="center">0.7322122</td>
<td align="center">0.9210867</td>
<td align="center">0.9785252</td>
<td align="center">0.7251732</td>
<td align="center">0.9230177</td>
<td align="center">0.9799846</td>
</tr>
<tr class="even">
<td align="center">Streptococcus</td>
<td align="center">0.7135883</td>
<td align="center">0.7345833</td>
<td align="center">0.0000000</td>
<td align="center">0.7135883</td>
<td align="center">0.7345833</td>
</tr>
</tbody>
</table>

BIN
docs/articles/AMR_files/figure-html/plot 1-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

BIN
docs/articles/AMR_files/figure-html/plot 3-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/articles/AMR_files/figure-html/plot 4-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

BIN
docs/articles/AMR_files/figure-html/plot 5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

2
docs/articles/EUCAST.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div>

2
docs/articles/G_test.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to use the <em>G</em>-test</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>G_test.Rmd</code></div>

2
docs/articles/WHONET.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to work with WHONET data</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>WHONET.Rmd</code></div>

2
docs/articles/atc_property.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>How to get properties of an antibiotic</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>atc_property.Rmd</code></div>

72
docs/articles/benchmarks.html

@ -192,7 +192,7 @@ @@ -192,7 +192,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">28 February 2019</h4>
<h4 class="date">01 March 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -217,14 +217,14 @@ @@ -217,14 +217,14 @@
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 16.70 16.80 17.10 16.90 17.20 18.4 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 31.70 31.80 48.90 31.90 73.00 117.0 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 16.70 16.80 23.10 16.90 17.90 76.0 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("STAAUR") 16.80 17.00 33.20 18.20 56.00 58.6 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 24.60 24.70 29.00 24.70 25.30 65.8 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("S. aureus") 24.60 24.70 29.20 24.80 25.10 67.4 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#&gt; as.mo("Staphylococcus aureus") 7.02 7.11 7.73 7.26 7.33 11.9 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 16.6 16.70 25.10 16.70 18.30 58.00 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 31.8 31.90 36.20 31.90 31.90 74.90 10</span></a>