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

website update

This commit is contained in:
dr. M.S. (Matthijs) Berends 2018-12-31 12:03:35 +01:00
parent 68baf058cd
commit 154fec27dd
6 changed files with 380 additions and 507 deletions

View File

@ -174,139 +174,142 @@
<a href="#needed-r-packages" class="anchor"></a>Needed R packages</h2> <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. The most important one is <a href="https://dplyr.tidyverse.org/"><code>dplyr</code></a>, which tremendously improves the way we work with data - it allows for a very natural way of writing syntaxes in R. Another important dependency is <a href="https://ggplot2.tidyverse.org/"><code>ggplot2</code></a>. This package can be used to create beautiful plots in R.</p> <p>As with many uses in R, we need some additional packages for AMR analysis. The most important one is <a href="https://dplyr.tidyverse.org/"><code>dplyr</code></a>, which tremendously improves the way we work with data - it allows for a very natural way of writing syntaxes in R. Another important dependency is <a href="https://ggplot2.tidyverse.org/"><code>ggplot2</code></a>. This package can be used to create beautiful plots in R.</p>
<p>Our <code>AMR</code> package depends on these packages and even extends their use and functions.</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) <span class="co"># the data science package</span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr) <span class="co"># the data science package</span>
<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>(AMR) <span class="co"># this package, to simplify and automate AMR analysis</span></a> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(AMR) <span class="co"># this package, to simplify and automate AMR analysis</span>
<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>(ggplot2) <span class="co"># for appealing plots</span></a></code></pre></div> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(ggplot2) <span class="co"># for appealing plots</span></code></pre></div>
</div> </div>
<div id="creation-of-data" class="section level2"> <div id="creation-of-data" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#creation-of-data" class="anchor"></a>Creation of data</h2> <a href="#creation-of-data" class="anchor"></a>Creation of data</h2>
<p>We will create some fake example data to use for analysis. For antimicrobial resistance analysis, we need at least: a patients ID, name or code of a microorganism, a date and antimicrobial results (an antibiogram). It could also include a specimen type (e.g. to filter on blood or urine), the ward type (e.g. to filter on ICUs).</p> <p>We will create some fake example data to use for analysis. For antimicrobial resistance analysis, we need at least: a patient ID, name or code of a microorganism, a date and antimicrobial results (an antibiogram). It could also include a specimen type (e.g. to filter on blood or urine), the ward type (e.g. to filter on ICUs).</p>
<p>With additional columns (like a hospital name, the patients gender of even [well-defined] clinical properties) you can do a comparative analysis, as this tutorial will demonstrate too.</p> <p>With additional columns (like a hospital name, the patients gender of even [well-defined] clinical properties) you can do a comparative analysis, as this tutorial will demonstrate too.</p>
<div id="patients" class="section level4"> <div id="patients" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#patients" class="anchor"></a>Patients</h4> <a href="#patients" class="anchor"></a>Patients</h4>
<p>To start with patients, we need a unique list of patients.</p> <p>To start with patients, we need a unique list of patients.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1">patients &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/unlist">unlist</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/lapply">lapply</a></span>(LETTERS, paste0, <span class="dv">1</span><span class="op">:</span><span class="dv">10</span>))</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/unlist">unlist</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/lapply">lapply</a></span>(LETTERS, paste0, <span class="dv">1</span>:<span class="dv">10</span>))</code></pre></div>
<p>The <code>LETTERS</code> object is available in R - its a vector with 26 characters: <code>A</code> to <code>Z</code>. The <code>patients</code> object we just created is now a vector of length 260, with values (patient IDs) varying from <code>A1</code> to <code>Z10</code>.</p> <p>The <code>LETTERS</code> object is available in R - its a vector with 26 characters: <code>A</code> to <code>Z</code>. The <code>patients</code> object we just created is now a vector of length 260, with values (patient IDs) varying from <code>A1</code> to <code>Z10</code>. Now we we also set the gender of our patients, by putting the ID and the gender in a table:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">patients_table &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">patient_id =</span> patients,
<span class="dt">gender =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/strrep">strrep</a></span>(<span class="st">"M"</span>, <span class="dv">135</span>),
<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/strrep">strrep</a></span>(<span class="st">"F"</span>, <span class="dv">125</span>)))</code></pre></div>
<p>The first 135 patient IDs are now male, the other 125 are female.</p>
</div> </div>
<div id="dates" class="section level4"> <div id="dates" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#dates" class="anchor"></a>Dates</h4> <a href="#dates" class="anchor"></a>Dates</h4>
<p>Lets pretend that our data consists of blood cultures isolates from 1 January 2010 until 1 January 2018.</p> <p>Lets pretend that our data consists of blood cultures isolates from 1 January 2010 until 1 January 2018.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1">dates &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/seq">seq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/as.Date">as.Date</a></span>(<span class="st">"2010-01-01"</span>), <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/as.Date">as.Date</a></span>(<span class="st">"2018-01-01"</span>), <span class="dt">by =</span> <span class="st">"day"</span>)</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dates &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/seq">seq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/as.Date">as.Date</a></span>(<span class="st">"2010-01-01"</span>), <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/as.Date">as.Date</a></span>(<span class="st">"2018-01-01"</span>), <span class="dt">by =</span> <span class="st">"day"</span>)</code></pre></div>
<p>This <code>dates</code> object now contains all days in our date range.</p> <p>This <code>dates</code> object now contains all days in our date range.</p>
</div> </div>
<div id="microorganisms" class="section level4"> <div id="microorganisms" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#microorganisms" class="anchor"></a>Microorganisms</h4> <a href="#microorganisms" class="anchor"></a>Microorganisms</h4>
<p>For this tutorial, we will uses four different microorganisms: <em>Escherichia coli</em>, <em>Staphylococcus aureus</em>, <em>Streptococcus pneumoniae</em>, and <em>Klebsiella pneumoniae</em>:</p> <p>For this tutorial, we will uses four different microorganisms: <em>Escherichia coli</em>, <em>Staphylococcus aureus</em>, <em>Streptococcus pneumoniae</em>, and <em>Klebsiella pneumoniae</em>:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">bacteria &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Escherichia coli"</span>, <span class="st">"Staphylococcus aureus"</span>,</a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">bacteria &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Escherichia coli"</span>, <span class="st">"Staphylococcus aureus"</span>,
<a class="sourceLine" id="cb4-2" data-line-number="2"> <span class="st">"Streptococcus pneumoniae"</span>, <span class="st">"Klebsiella pneumoniae"</span>)</a></code></pre></div> <span class="st">"Streptococcus pneumoniae"</span>, <span class="st">"Klebsiella pneumoniae"</span>)</code></pre></div>
</div> </div>
<div id="other-variables" class="section level4"> <div id="other-variables" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-variables" class="anchor"></a>Other variables</h4> <a href="#other-variables" class="anchor"></a>Other variables</h4>
<p>For completeness, we can also add the patients gender, the hospital where the patients was admitted and all valid antibmicrobial results:</p> <p>For completeness, we can also add the hospital where the patients was admitted and we need to define valid antibmicrobial results for our randomisation:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1">genders &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"M"</span>, <span class="st">"F"</span>)</a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">hospitals &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Hospital A"</span>, <span class="st">"Hospital B"</span>, <span class="st">"Hospital C"</span>, <span class="st">"Hospital D"</span>)
<a class="sourceLine" id="cb5-2" data-line-number="2">hospitals &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Hospital A"</span>, <span class="st">"Hospital B"</span>, <span class="st">"Hospital C"</span>, <span class="st">"Hospital D"</span>)</a> ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"S"</span>, <span class="st">"I"</span>, <span class="st">"R"</span>)</code></pre></div>
<a class="sourceLine" id="cb5-3" data-line-number="3">ab_interpretations &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"S"</span>, <span class="st">"I"</span>, <span class="st">"R"</span>)</a></code></pre></div>
</div> </div>
<div id="put-everything-together" class="section level4"> <div id="put-everything-together" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#put-everything-together" class="anchor"></a>Put everything together</h4> <a href="#put-everything-together" class="anchor"></a>Put everything together</h4>
<p>Using the <code><a href="http://dplyr.tidyverse.org/reference/sample.html">sample()</a></code> function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the <code>prob</code> parameter.</p> <p>Using the <code><a href="http://dplyr.tidyverse.org/reference/sample.html">sample()</a></code> function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the <code>prob</code> parameter.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" data-line-number="1">data &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">date =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(dates, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/data.frame">data.frame</a></span>(<span class="dt">date =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(dates, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),
<a class="sourceLine" id="cb6-2" data-line-number="2"> <span class="dt">patient_id =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(patients, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a> <span class="dt">patient_id =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(patients, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),
<a class="sourceLine" id="cb6-3" data-line-number="3"> <span class="co"># gender - add slightly more men:</span></a> <span class="dt">hospital =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(hospitals, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),
<a class="sourceLine" id="cb6-4" data-line-number="4"> <span class="dt">gender =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(genders, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.55</span>, <span class="fl">0.45</span>)),</a> <span class="dt">bacteria =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(bacteria, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.50</span>, <span class="fl">0.25</span>, <span class="fl">0.15</span>, <span class="fl">0.10</span>)),
<a class="sourceLine" id="cb6-5" data-line-number="5"> <span class="dt">hospital =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(hospitals, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>),</a> <span class="dt">amox =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.6</span>, <span class="fl">0.05</span>, <span class="fl">0.35</span>)),
<a class="sourceLine" id="cb6-6" data-line-number="6"> <span class="dt">bacteria =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(bacteria, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.50</span>, <span class="fl">0.25</span>, <span class="fl">0.15</span>, <span class="fl">0.10</span>)),</a> <span class="dt">amcl =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.75</span>, <span class="fl">0.1</span>, <span class="fl">0.15</span>)),
<a class="sourceLine" id="cb6-7" data-line-number="7"> <span class="dt">amox =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.6</span>, <span class="fl">0.05</span>, <span class="fl">0.35</span>)),</a> <span class="dt">cipr =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.8</span>, <span class="dv">0</span>, <span class="fl">0.2</span>)),
<a class="sourceLine" id="cb6-8" data-line-number="8"> <span class="dt">amcl =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.75</span>, <span class="fl">0.1</span>, <span class="fl">0.15</span>)),</a> <span class="dt">gent =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.92</span>, <span class="dv">0</span>, <span class="fl">0.07</span>))
<a class="sourceLine" id="cb6-9" data-line-number="9"> <span class="dt">cipr =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.8</span>, <span class="dv">0</span>, <span class="fl">0.2</span>)),</a> )</code></pre></div>
<a class="sourceLine" id="cb6-10" data-line-number="10"> <span class="dt">gent =</span> <span class="kw"><a href="http://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(ab_interpretations, <span class="dv">5000</span>, <span class="dt">replace =</span> <span class="ot">TRUE</span>, <span class="dt">prob =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="fl">0.92</span>, <span class="dv">0</span>, <span class="fl">0.07</span>))</a> <p>Using the <code><a href="http://dplyr.tidyverse.org/reference/join.html">left_join()</a></code> function from the <code>dplyr</code> package, we can map the gender to the patient ID using the <code>patients_table</code> object we created earlier:</p>
<a class="sourceLine" id="cb6-11" data-line-number="11"> )</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/join.html">left_join</a></span>(patients_table)</code></pre></div>
<p>The resulting data set contains 5,000 blood culture isolates. With the <code><a href="https://www.rdocumentation.org/packages/utils/topics/head">head()</a></code> function we can preview the first 6 values of this data set:</p> <p>The resulting data set contains 5,000 blood culture isolates. With the <code><a href="https://www.rdocumentation.org/packages/utils/topics/head">head()</a></code> function we can preview the first 6 values of this data set:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data)</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data)</code></pre></div>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th align="center">date</th> <th align="center">date</th>
<th align="center">patient_id</th> <th align="center">patient_id</th>
<th align="center">gender</th>
<th align="center">hospital</th> <th align="center">hospital</th>
<th align="center">bacteria</th> <th align="center">bacteria</th>
<th align="center">amox</th> <th align="center">amox</th>
<th align="center">amcl</th> <th align="center">amcl</th>
<th align="center">cipr</th> <th align="center">cipr</th>
<th align="center">gent</th> <th align="center">gent</th>
<th align="center">gender</th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">2017-01-24</td> <td align="center">2011-11-05</td>
<td align="center">M8</td> <td align="center">F8</td>
<td align="center">F</td> <td align="center">Hospital A</td>
<td align="center">Hospital D</td>
<td align="center">Streptococcus 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">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2016-12-18</td> <td align="center">2013-06-01</td>
<td align="center">J6</td> <td align="center">L1</td>
<td align="center">M</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>
</tr>
<tr class="odd">
<td align="center">2015-06-29</td>
<td align="center">E1</td>
<td align="center">M</td>
<td align="center">Hospital C</td> <td align="center">Hospital C</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2013-02-28</td>
<td align="center">B1</td>
<td align="center">M</td>
<td align="center">Hospital C</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>
</tr>
<tr class="odd">
<td align="center">2013-05-19</td>
<td align="center">N8</td>
<td align="center">M</td>
<td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</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">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
</tr>
<tr class="odd">
<td align="center">2014-05-29</td>
<td align="center">X5</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</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">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">2014-04-02</td> <td align="center">2013-06-29</td>
<td align="center">M2</td> <td align="center">K6</td>
<td align="center">M</td> <td align="center">Hospital B</td>
<td align="center">Hospital D</td> <td align="center">Escherichia coli</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">R</td> <td align="center">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
</tr>
<tr class="odd">
<td align="center">2015-02-02</td>
<td align="center">W2</td>
<td align="center">Hospital D</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">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
</tr>
<tr class="even">
<td align="center">2011-10-28</td>
<td align="center">T5</td>
<td align="center">Hospital D</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -316,98 +319,98 @@
<div id="cleaning-the-data" class="section level2"> <div id="cleaning-the-data" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#cleaning-the-data" class="anchor"></a>Cleaning the data</h2> <a href="#cleaning-the-data" class="anchor"></a>Cleaning the data</h2>
<p>Use the frequency table function <code><a href="../reference/freq.html">freq()</a></code> to look specifically for unique values in every variables. For example, for the <code>gender</code> variable:</p> <p>Use the frequency table function <code><a href="../reference/freq.html">freq()</a></code> to look specifically for unique values in any variable. For example, for the <code>gender</code> variable:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender) <span class="co"># this would be the same: freq(data$gender)</span></a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data %&gt;%<span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender) <span class="co"># this would be the same: freq(data$gender)</span></code></pre></div>
<pre><code># Frequency table of `gender` <pre><code># Frequency table of `gender`
# Class: factor (numeric) # Class: factor (numeric)
# Levels: F, M # Levels: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
# Length: 5,000 (of which NA: 0 = 0.00%) # Length: 5,000 (of which NA: 0 = 0.00%)
# Unique: 2 # Unique: 2
# #
# Item Count Percent Cum. Count Cum. Percent # Item Count Percent Cum. Count Cum. Percent
# --- ----- ------ -------- ----------- ------------- # --- ---------------------------------------------------------------------------------------------------------------------------------------- ------ -------- ----------- -------------
# 1 M 2,773 55.5% 2,773 55.5% # 1 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2,536 50.7% 2,536 50.7%
# 2 F 2,227 44.5% 5,000 100.0%</code></pre> # 2 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2,464 49.3% 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>mutate</code> function of the dplyr 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>mutate</code> function of the dplyr package makes this really easy:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%
<a class="sourceLine" id="cb10-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">bacteria =</span> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(bacteria))</a></code></pre></div> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">bacteria =</span> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(bacteria))</code></pre></div>
<p>We also want to transform the antibiotics, because in real life data we dont know if they are really clean. The <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function ensures reliability and reproducibility in these kind of variables. The <code><a href="http://dplyr.tidyverse.org/reference/summarise_all.html">mutate_at()</a></code> will run the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function on defined variables:</p> <p>We also want to transform the antibiotics, because in real life data we dont know if they are really clean. The <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function ensures reliability and reproducibility in these kind of variables. The <code><a href="http://dplyr.tidyverse.org/reference/summarise_all.html">mutate_at()</a></code> will run the <code><a href="../reference/as.rsi.html">as.rsi()</a></code> function on defined variables:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%
<a class="sourceLine" id="cb11-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/summarise_all.html">mutate_at</a></span>(<span class="kw"><a href="http://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(amox<span class="op">:</span>cipr), as.rsi)</a></code></pre></div> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/summarise_all.html">mutate_at</a></span>(<span class="kw"><a href="http://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(amox:cipr), as.rsi)</code></pre></div>
<p>Finally, we will apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST rules</a> on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p> <p>Finally, we will apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST rules</a> on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.</p>
<p>Because the amoxicillin (column <code>amox</code>) and amoxicillin/clavulanic acid (column <code>amcl</code>) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> fixes this:</p> <p>Because the amoxicillin (column <code>amox</code>) and amoxicillin/clavulanic acid (column <code>amcl</code>) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> fixes this:</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><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(data, <span class="dt">col_mo =</span> <span class="st">"bacteria"</span>)</a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(data, <span class="dt">col_mo =</span> <span class="st">"bacteria"</span>)
<a class="sourceLine" id="cb12-2" data-line-number="2"><span class="co"># </span></a> <span class="co"># </span>
<a class="sourceLine" id="cb12-3" data-line-number="3"><span class="co"># Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span></a> <span class="co"># Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span>
<a class="sourceLine" id="cb12-4" data-line-number="4"><span class="co"># </span></a> <span class="co"># </span>
<a class="sourceLine" id="cb12-5" data-line-number="5"><span class="co"># EUCAST Clinical Breakpoints (v8.1, 2018)</span></a> <span class="co"># EUCAST Clinical Breakpoints (v8.1, 2018)</span>
<a class="sourceLine" id="cb12-6" data-line-number="6"><span class="co"># Enterobacteriales (Order) (no changes)</span></a> <span class="co"># Enterobacteriales (Order) (no changes)</span>
<a class="sourceLine" id="cb12-7" data-line-number="7"><span class="co"># Staphylococcus (no changes)</span></a> <span class="co"># Staphylococcus (no changes)</span>
<a class="sourceLine" id="cb12-8" data-line-number="8"><span class="co"># Enterococcus (no changes)</span></a> <span class="co"># Enterococcus (no changes)</span>
<a class="sourceLine" id="cb12-9" data-line-number="9"><span class="co"># Streptococcus groups A, B, C, G (no changes)</span></a> <span class="co"># Streptococcus groups A, B, C, G (no changes)</span>
<a class="sourceLine" id="cb12-10" data-line-number="10"><span class="co"># Streptococcus pneumoniae (386 changes)</span></a> <span class="co"># Streptococcus pneumoniae (366 changes)</span>
<a class="sourceLine" id="cb12-11" data-line-number="11"><span class="co"># Viridans group streptococci (no changes)</span></a> <span class="co"># Viridans group streptococci (no changes)</span>
<a class="sourceLine" id="cb12-12" data-line-number="12"><span class="co"># Haemophilus influenzae (no changes)</span></a> <span class="co"># Haemophilus influenzae (no changes)</span>
<a class="sourceLine" id="cb12-13" data-line-number="13"><span class="co"># Moraxella catarrhalis (no changes)</span></a> <span class="co"># Moraxella catarrhalis (no changes)</span>
<a class="sourceLine" id="cb12-14" data-line-number="14"><span class="co"># Anaerobic Gram positives (no changes)</span></a> <span class="co"># Anaerobic Gram positives (no changes)</span>
<a class="sourceLine" id="cb12-15" data-line-number="15"><span class="co"># Anaerobic Gram negatives (no changes)</span></a> <span class="co"># Anaerobic Gram negatives (no changes)</span>
<a class="sourceLine" id="cb12-16" data-line-number="16"><span class="co"># Pasteurella multocida (no changes)</span></a> <span class="co"># Pasteurella multocida (no changes)</span>
<a class="sourceLine" id="cb12-17" data-line-number="17"><span class="co"># Campylobacter jejuni and C. coli (no changes)</span></a> <span class="co"># Campylobacter jejuni and C. coli (no changes)</span>
<a class="sourceLine" id="cb12-18" data-line-number="18"><span class="co"># Aerococcus sanguinicola and A. urinae (no changes)</span></a> <span class="co"># Aerococcus sanguinicola and A. urinae (no changes)</span>
<a class="sourceLine" id="cb12-19" data-line-number="19"><span class="co"># Kingella kingae (no changes)</span></a> <span class="co"># Kingella kingae (no changes)</span>
<a class="sourceLine" id="cb12-20" data-line-number="20"><span class="co"># </span></a> <span class="co"># </span>
<a class="sourceLine" id="cb12-21" data-line-number="21"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a> <span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span>
<a class="sourceLine" id="cb12-22" data-line-number="22"><span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (342 changes)</span></a> <span class="co"># Table 1: Intrinsic resistance in Enterobacteriaceae (332 changes)</span>
<a class="sourceLine" id="cb12-23" data-line-number="23"><span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a> <span class="co"># Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span>
<a class="sourceLine" id="cb12-24" data-line-number="24"><span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a> <span class="co"># Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span>
<a class="sourceLine" id="cb12-25" data-line-number="25"><span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (705 changes)</span></a> <span class="co"># Table 4: Intrinsic resistance in Gram-positive bacteria (699 changes)</span>
<a class="sourceLine" id="cb12-26" data-line-number="26"><span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a> <span class="co"># Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span>
<a class="sourceLine" id="cb12-27" data-line-number="27"><span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a> <span class="co"># Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span>
<a class="sourceLine" id="cb12-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> <span class="co"># Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span>
<a class="sourceLine" id="cb12-29" data-line-number="29"><span class="co"># Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a> <span class="co"># Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span>
<a class="sourceLine" id="cb12-30" data-line-number="30"><span class="co"># Table 12: Interpretive rules for aminoglycosides (no changes)</span></a> <span class="co"># Table 12: Interpretive rules for aminoglycosides (no changes)</span>
<a class="sourceLine" id="cb12-31" data-line-number="31"><span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span></a> <span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span>
<a class="sourceLine" id="cb12-32" data-line-number="32"><span class="co"># </span></a> <span class="co"># </span>
<a class="sourceLine" id="cb12-33" data-line-number="33"><span class="co"># Other rules</span></a> <span class="co"># Other rules</span>
<a class="sourceLine" id="cb12-34" data-line-number="34"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (364 changes)</span></a> <span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (351 changes)</span>
<a class="sourceLine" id="cb12-35" data-line-number="35"><span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a> <span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span>
<a class="sourceLine" id="cb12-36" data-line-number="36"><span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a> <span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span>
<a class="sourceLine" id="cb12-37" data-line-number="37"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (211 changes)</span></a> <span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (242 changes)</span>
<a class="sourceLine" id="cb12-38" data-line-number="38"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a> <span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span>
<a class="sourceLine" id="cb12-39" data-line-number="39"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a> <span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span>
<a class="sourceLine" id="cb12-40" data-line-number="40"><span class="co"># </span></a> <span class="co"># </span>
<a class="sourceLine" id="cb12-41" data-line-number="41"><span class="co"># =&gt; EUCAST rules affected 4,626 out of 5,000 rows -&gt; changed 2,008 test results.</span></a></code></pre></div> <span class="co"># =&gt; EUCAST rules affected 4,575 out of 5,000 rows -&gt; changed 1,990 test results.</span></code></pre></div>
</div> </div>
<div id="adding-new-variables" class="section level2"> <div id="adding-new-variables" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#adding-new-variables" class="anchor"></a>Adding new variables</h2> <a href="#adding-new-variables" class="anchor"></a>Adding new variables</h2>
<p>Now we have the microbial ID, we can add some taxonomic properties:</p> <p>Now we have the microbial ID, we can add some taxonomic properties:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-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"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb13-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">gramstain =</span> <span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(bacteria),</a> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">gramstain =</span> <span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(bacteria),
<a class="sourceLine" id="cb13-3" data-line-number="3"> <span class="dt">family =</span> <span class="kw"><a href="../reference/mo_property.html">mo_family</a></span>(bacteria))</a></code></pre></div> <span class="dt">family =</span> <span class="kw"><a href="../reference/mo_property.html">mo_family</a></span>(bacteria))</code></pre></div>
<div id="first-isolates" class="section level3"> <div id="first-isolates" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
<a href="#first-isolates" class="anchor"></a>First isolates</h3> <a href="#first-isolates" class="anchor"></a>First isolates</h3>
<p>We also need to know which isolates we can <em>actually</em> use for analysis.</p> <p>We also need to know which isolates we can <em>actually</em> use for analysis.</p>
<p>To conduct an analysis of antimicrobial resistance, you <a href="https://www.ncbi.nlm.nih.gov/pubmed/17304462">must only include the first isolate of every patient per episode</a>. If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following weeks (yes, some countries like the Netherlands have these blood drawing policies). The resistance percentage of oxacillin of all isolates would be overestimated, because you included this MRSA more than once. It would clearly be .</p> <p>To conduct an analysis of antimicrobial resistance, you must <a href="https://www.ncbi.nlm.nih.gov/pubmed/17304462">only include the first isolate of every patient per episode</a> (Hindler <em>et al.</em>, Clin Infect Dis. 2007). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following weeks (yes, some countries like the Netherlands have these blood drawing policies). The resistance percentage of oxacillin of all isolates would be overestimated, because you included this MRSA more than once. It would clearly be <a href="https://en.wikipedia.org/wiki/Selection_bias">selection bias</a>.</p>
<p>The Clinical and Laboratory Standards Institute (CLSI) appoints this as follows:</p> <p>The Clinical and Laboratory Standards Institute (CLSI) appoints this as follows:</p>
<blockquote> <blockquote>
<p><em>(…) When preparing a cumulative antibiogram to guide clinical decisions about empirical antimicrobial therapy of initial infections, <strong>only the first isolate of a given species per patient, per analysis period (eg, one year) should be included, irrespective of body site, antimicrobial susceptibility profile, or other phenotypical characteristics (eg, biotype)</strong>. The first isolate is easily identified, and cumulative antimicrobial susceptibility test data prepared using the first isolate are generally comparable to cumulative antimicrobial susceptibility test data calculated by other methods, providing duplicate isolates are excluded.</em> Chapter 6.4, M39-A4 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition. CLSI, 2014. <a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="uri">https://clsi.org/standards/products/microbiology/documents/m39/</a></p> <p><em>(…) When preparing a cumulative antibiogram to guide clinical decisions about empirical antimicrobial therapy of initial infections, <strong>only the first isolate of a given species per patient, per analysis period (eg, one year) should be included, irrespective of body site, antimicrobial susceptibility profile, or other phenotypical characteristics (eg, biotype)</strong>. The first isolate is easily identified, and cumulative antimicrobial susceptibility test data prepared using the first isolate are generally comparable to cumulative antimicrobial susceptibility test data calculated by other methods, providing duplicate isolates are excluded.</em> <br>Chapter 6.4, M39-A4 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition. CLSI, 2014. <a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="uri">https://clsi.org/standards/products/microbiology/documents/m39/</a></p>
</blockquote> </blockquote>
<p>This <code>AMR</code> package includes this methodology with the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:</p> <p>This <code>AMR</code> package includes this methodology with the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-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"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb14-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">first =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(.))</a> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">first =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(.))
<a class="sourceLine" id="cb14-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> <span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<a class="sourceLine" id="cb14-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> <span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<a class="sourceLine" id="cb14-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> <span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<a class="sourceLine" id="cb14-6" data-line-number="6"><span class="co"># =&gt; Found 2,913 first isolates (58.3% of total)</span></a></code></pre></div> <span class="co"># =&gt; Found 2,928 first isolates (58.6% of total)</span></code></pre></div>
<p>So only 58.3% is suitable for resistance analysis! We can now filter on is with the <code><a href="http://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p> <p>So only 58.6% is suitable for resistance analysis! We can now filter on is with the <code><a href="http://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-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"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb15-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://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> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first ==<span class="st"> </span><span class="ot">TRUE</span>)</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>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb16-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"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb16-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_isolate</a></span>()</a></code></pre></div> <span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_isolate</a></span>()</code></pre></div>
</div> </div>
<div id="first-weighted-isolates" class="section level3"> <div id="first-weighted-isolates" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
@ -428,8 +431,41 @@
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-07-19</td> <td align="center">2010-04-08</td>
<td align="center">S6</td> <td align="center">W2</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">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-07-04</td>
<td align="center">W2</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">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-07-25</td>
<td align="center">W2</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">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2011-08-12</td>
<td align="center">W2</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>
@ -437,43 +473,10 @@
<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">
<td align="center">2</td>
<td align="center">2010-10-13</td>
<td align="center">S6</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">3</td>
<td align="center">2010-12-24</td>
<td align="center">S6</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">FALSE</td>
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2011-01-02</td>
<td align="center">S6</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">R</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd"> <tr class="odd">
<td align="center">5</td> <td align="center">5</td>
<td align="center">2011-01-23</td> <td align="center">2012-03-16</td>
<td align="center">S6</td> <td align="center">W2</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>
@ -483,54 +486,54 @@
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">6</td> <td align="center">6</td>
<td align="center">2011-05-16</td> <td align="center">2012-08-15</td>
<td align="center">S6</td> <td align="center">W2</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">R</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">FALSE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td> <td align="center">7</td>
<td align="center">2011-10-13</td> <td align="center">2013-01-15</td>
<td align="center">S6</td> <td align="center">W2</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">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>
<tr class="even"> <tr class="even">
<td align="center">8</td> <td align="center">8</td>
<td align="center">2012-03-25</td> <td align="center">2013-06-15</td>
<td align="center">S6</td> <td align="center">W2</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">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">FALSE</td> <td align="center">FALSE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2012-09-01</td> <td align="center">2013-09-18</td>
<td align="center">S6</td> <td align="center">W2</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">FALSE</td> <td align="center">S</td>
<td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">10</td> <td align="center">10</td>
<td align="center">2012-10-04</td> <td align="center">2014-01-13</td>
<td align="center">S6</td> <td align="center">W2</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">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -538,20 +541,20 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Only 2 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 show 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 show 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="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-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"><pre class="sourceCode r"><code class="sourceCode r">data &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://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> <span class="st"> </span><span class="kw"><a href="http://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>(.)) %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb17-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">first_weighted =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(.))</a> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">first_weighted =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(.))
<a class="sourceLine" id="cb17-4" data-line-number="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a> <span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<a class="sourceLine" id="cb17-5" data-line-number="5"><span class="co"># Warning: These columns do not exist and will be ignored: cfur, pita, trsu, vanc, teic, tetr, eryt, oxac, rifa, tobr, coli, cfot, cfta, mero.</span></a> <span class="co"># Warning: These columns do not exist and will be ignored: cfur, pita, trsu, vanc, teic, tetr, eryt, oxac, rifa, tobr, coli, cfot, cfta, mero.</span>
<a class="sourceLine" id="cb17-6" data-line-number="6"><span class="co"># THIS MAY STRONGLY INFLUENCE THE OUTCOME.</span></a> <span class="co"># THIS MAY STRONGLY INFLUENCE THE OUTCOME.</span>
<a class="sourceLine" id="cb17-7" data-line-number="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a> <span class="co"># NOTE: Using column `bacteria` as input for `col_mo`.</span>
<a class="sourceLine" id="cb17-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a> <span class="co"># NOTE: Using column `date` as input for `col_date`.</span>
<a class="sourceLine" id="cb17-9" data-line-number="9"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a> <span class="co"># NOTE: Using column `patient_id` as input for `col_patient_id`.</span>
<a class="sourceLine" id="cb17-10" data-line-number="10"><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> <span class="co"># NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span>
<a class="sourceLine" id="cb17-11" data-line-number="11"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a> <span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span>
<a class="sourceLine" id="cb17-12" data-line-number="12"><span class="co"># =&gt; Found 4,318 first weighted isolates (86.4% of total)</span></a></code></pre></div> <span class="co"># =&gt; Found 4,412 first weighted isolates (88.2% of total)</span></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>
@ -568,118 +571,118 @@
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td align="center">1</td> <td align="center">1</td>
<td align="center">2010-07-19</td> <td align="center">2010-04-08</td>
<td align="center">S6</td> <td align="center">W2</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">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">TRUE</td> <td align="center">TRUE</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-13</td> <td align="center">2010-07-04</td>
<td align="center">S6</td> <td align="center">W2</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">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td> <td align="center">FALSE</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-12-24</td> <td align="center">2010-07-25</td>
<td align="center">S6</td> <td align="center">W2</td>
<td align="center">B_ESCHR_COL</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">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">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">2011-01-02</td> <td align="center">2011-08-12</td>
<td align="center">S6</td> <td align="center">W2</td>
<td align="center">B_ESCHR_COL</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">S</td>
<td align="center">S</td>
<td align="center">TRUE</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">2011-01-23</td> <td align="center">2012-03-16</td>
<td align="center">S6</td> <td align="center">W2</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">FALSE</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">6</td> <td align="center">6</td>
<td align="center">2011-05-16</td> <td align="center">2012-08-15</td>
<td align="center">S6</td> <td align="center">W2</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">R</td>
<td align="center">S</td> <td align="center">R</td>
<td align="center">FALSE</td> <td align="center">TRUE</td>
<td align="center">FALSE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">7</td> <td align="center">7</td>
<td align="center">2011-10-13</td> <td align="center">2013-01-15</td>
<td align="center">S6</td> <td align="center">W2</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">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>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td align="center">8</td> <td align="center">8</td>
<td align="center">2012-03-25</td> <td align="center">2013-06-15</td>
<td align="center">S6</td> <td align="center">W2</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">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">FALSE</td> <td align="center">FALSE</td>
<td align="center">FALSE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<td align="center">9</td> <td align="center">9</td>
<td align="center">2012-09-01</td> <td align="center">2013-09-18</td>
<td align="center">S6</td> <td align="center">W2</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">FALSE</td> <td align="center">S</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">10</td> <td align="center">10</td>
<td align="center">2012-10-04</td> <td align="center">2014-01-13</td>
<td align="center">S6</td> <td align="center">W2</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">S</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">S</td> <td align="center">S</td>
@ -688,28 +691,28 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>Instead of 2, now 6 isolates are flagged. In total, 86.4% of all isolates are marked first weighted - 28.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>Instead of 4, now 9 isolates are flagged. In total, 88.2% of all isolates are marked first weighted - 29.7% 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="cb18"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb18-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"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb18-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> <span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</code></pre></div>
<p>So we end up with 4,318 isolates for analysis.</p> <p>So we end up with 4,412 isolates for analysis.</p>
<p>We can remove unneeded columns:</p> <p>We can remove unneeded columns:</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_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data_1st &lt;-<span class="st"> </span>data_1st %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb19-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span>first, <span class="op">-</span>keyab)</a></code></pre></div> <span class="st"> </span><span class="kw"><a href="http://dplyr.tidyverse.org/reference/select.html">select</a></span>(-first, -keyab)</code></pre></div>
<p>Now our data looks like:</p> <p>Now our data looks like:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data_1st)</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">head</a></span>(data_1st)</code></pre></div>
<table class="table"> <table class="table">
<thead><tr class="header"> <thead><tr class="header">
<th></th> <th></th>
<th align="center">date</th> <th align="center">date</th>
<th align="center">patient_id</th> <th align="center">patient_id</th>
<th align="center">gender</th>
<th align="center">hospital</th> <th align="center">hospital</th>
<th align="center">bacteria</th> <th align="center">bacteria</th>
<th align="center">amox</th> <th align="center">amox</th>
<th align="center">amcl</th> <th align="center">amcl</th>
<th align="center">cipr</th> <th align="center">cipr</th>
<th align="center">gent</th> <th align="center">gent</th>
<th align="center">gender</th>
<th align="center">gramstain</th> <th align="center">gramstain</th>
<th align="center">family</th> <th align="center">family</th>
<th align="center">first_weighted</th> <th align="center">first_weighted</th>
@ -717,90 +720,90 @@
<tbody> <tbody>
<tr class="odd"> <tr class="odd">
<td>1</td> <td>1</td>
<td align="center">2017-01-24</td> <td align="center">2011-11-05</td>
<td align="center">M8</td> <td align="center">F8</td>
<td align="center">F</td> <td align="center">Hospital A</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPTC_PNE</td> <td align="center">B_STRPTC_PNE</td>
<td align="center">I</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">R</td>
<td align="center">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Streptococcaceae</td> <td align="center">Streptococcaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td>2</td> <td>2</td>
<td align="center">2016-12-18</td> <td align="center">2013-06-01</td>
<td align="center">J6</td> <td align="center">L1</td>
<td align="center">M</td>
<td align="center">Hospital A</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">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>3</td>
<td align="center">2015-06-29</td>
<td align="center">E1</td>
<td align="center">M</td>
<td align="center">Hospital C</td> <td align="center">Hospital C</td>
<td align="center">B_ESCHR_COL</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">S</td> <td align="center">S</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>4</td>
<td align="center">2013-02-28</td>
<td align="center">B1</td>
<td align="center">M</td>
<td align="center">Hospital C</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">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>6</td>
<td align="center">2014-04-02</td>
<td align="center">M2</td>
<td align="center">M</td>
<td align="center">Hospital D</td>
<td align="center">B_STPHY_AUR</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">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
<td align="center">Gram positive</td> <td align="center">Gram positive</td>
<td align="center">Staphylococcaceae</td> <td align="center">Streptococcaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>4</td>
<td align="center">2013-06-29</td>
<td align="center">K6</td>
<td align="center">Hospital B</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">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<td>6</td>
<td align="center">2011-10-28</td>
<td align="center">T5</td>
<td align="center">Hospital D</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">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>7</td> <td>7</td>
<td align="center">2015-11-12</td> <td align="center">2017-03-11</td>
<td align="center">E2</td> <td align="center">D5</td>
<td align="center">M</td> <td align="center">Hospital D</td>
<td align="center">Hospital B</td>
<td align="center">B_KLBSL_PNE</td> <td align="center">B_KLBSL_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">R</td>
<td align="center">S</td> <td align="center">S</td>
<td align="center">MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM</td>
<td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>8</td>
<td align="center">2013-04-06</td>
<td align="center">F6</td>
<td align="center">Hospital A</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">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</td>
<td align="center">Gram negative</td> <td align="center">Gram negative</td>
<td align="center">Enterobacteriaceae</td> <td align="center">Enterobacteriaceae</td>
<td align="center">TRUE</td> <td align="center">TRUE</td>

View File

@ -162,7 +162,7 @@
<h3 class="hasAnchor"> <h3 class="hasAnchor">
<a href="#get-this-package" class="anchor"></a>Get this package</h3> <a href="#get-this-package" class="anchor"></a>Get this package</h3>
<p>This package is available on the official R network. Install this package in R with:</p> <p>This package is available on the official R network. Install this package in R with:</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/utils/topics/install.packages">install.packages</a></span>(<span class="st">"AMR"</span>)</a></code></pre></div> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/install.packages">install.packages</a></span>(<span class="st">"AMR"</span>)</code></pre></div>
<p>It will be downloaded and installed automatically.</p> <p>It will be downloaded and installed automatically.</p>
</div> </div>
<div id="get-started" class="section level3"> <div id="get-started" class="section level3">
@ -178,17 +178,17 @@
<p>All (sub)species from <strong>the taxonomic kingdoms Bacteria, Fungi and Protozoa are included in this package</strong>, as well as all previously accepted names known to ITIS. Furthermore, the responsible authors and year of publication are available. This allows users to use authoritative taxonomic information for their data analysis on any microorganism, not only human pathogens. It also helps to quickly determine the Gram stain of bacteria, since all bacteria are classified into subkingdom Negibacteria or Posibacteria. ITIS is a partnership of U.S., Canadian, and Mexican agencies and taxonomic specialists.</p> <p>All (sub)species from <strong>the taxonomic kingdoms Bacteria, Fungi and Protozoa are included in this package</strong>, as well as all previously accepted names known to ITIS. Furthermore, the responsible authors and year of publication are available. This allows users to use authoritative taxonomic information for their data analysis on any microorganism, not only human pathogens. It also helps to quickly determine the Gram stain of bacteria, since all bacteria are classified into subkingdom Negibacteria or Posibacteria. ITIS is a partnership of U.S., Canadian, and Mexican agencies and taxonomic specialists.</p>
<p>The <code>AMR</code> package basically does four important things:</p> <p>The <code>AMR</code> package basically does four important things:</p>
<ol> <ol>
<li> <li>It <strong>cleanses existing data</strong>, by transforming it to reproducible and profound <em>classes</em>, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:</li>
<p>It <strong>cleanses existing data</strong>, by transforming it to reproducible and profound <em>classes</em>, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:</p> </ol>
<ul> <ul>
<li>Use <code><a href="reference/as.mo.html">as.mo()</a></code> to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of <em>Klebsiella pneumoniae</em> is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of <em>S. aureus</em> is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” and “esccol”. Even <code><a href="reference/as.mo.html">as.mo("MRSA")</a></code> will return the ID of <em>S. aureus</em>. Moreover, it can group all coagulase negative and positive <em>Staphylococci</em>, and can transform <em>Streptococci</em> into Lancefield groups. To find bacteria based on your input, it uses Artificial Intelligence to look up values in the included ITIS data, consisting of more than 18,000 microorganisms.</li> <li>Use <code><a href="reference/as.mo.html">as.mo()</a></code> to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of <em>Klebsiella pneumoniae</em> is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of <em>S. aureus</em> is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” and “esccol”. Even <code><a href="reference/as.mo.html">as.mo("MRSA")</a></code> will return the ID of <em>S. aureus</em>. Moreover, it can group all coagulase negative and positive <em>Staphylococci</em>, and can transform <em>Streptococci</em> into Lancefield groups. To find bacteria based on your input, it uses Artificial Intelligence to look up values in the included ITIS data, consisting of more than 18,000 microorganisms.</li>
<li>Use <code><a href="reference/as.rsi.html">as.rsi()</a></code> to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like “&lt;=0.002; S” (combined MIC/RSI) will result in “S”.</li> <li>Use <code><a href="reference/as.rsi.html">as.rsi()</a></code> to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like “&lt;=0.002; S” (combined MIC/RSI) will result in “S”.</li>
<li>Use <code><a href="reference/as.mic.html">as.mic()</a></code> to cleanse your MIC values. It produces a so-called factor (called <em>ordinal</em> in SPSS) with valid MIC values as levels. A value like “&lt;=0.002; S” (combined MIC/RSI) will result in “&lt;=0.002”.</li> <li>Use <code><a href="reference/as.mic.html">as.mic()</a></code> to cleanse your MIC values. It produces a so-called factor (called <em>ordinal</em> in SPSS) with valid MIC values as levels. A value like “&lt;=0.002; S” (combined MIC/RSI) will result in “&lt;=0.002”.</li>
<li>Use <code><a href="reference/as.atc.html">as.atc()</a></code> to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values “Furabid”, “Furadantin”, “nitro” all return the ATC code of Nitrofurantoine.</li> <li>Use <code><a href="reference/as.atc.html">as.atc()</a></code> to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values “Furabid”, “Furadantin”, “nitro” all return the ATC code of Nitrofurantoine.</li>
</ul> </ul>
</li> <ol>
<li> <li>It <strong>enhances existing data</strong> and <strong>adds new data</strong> from data sets included in this package.</li>
<p>It <strong>enhances existing data</strong> and <strong>adds new data</strong> from data sets included in this package.</p> </ol>
<ul> <ul>
<li>Use <code><a href="reference/eucast_rules.html">eucast_rules()</a></code> to apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST expert rules to isolates</a>.</li> <li>Use <code><a href="reference/eucast_rules.html">eucast_rules()</a></code> to apply <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance/">EUCAST expert rules to isolates</a>.</li>
<li>Use <code><a href="reference/first_isolate.html">first_isolate()</a></code> to identify the first isolates of every patient <a href="https://clsi.org/standards/products/microbiology/documents/m39/">using guidelines from the CLSI</a> (Clinical and Laboratory Standards Institute). <li>Use <code><a href="reference/first_isolate.html">first_isolate()</a></code> to identify the first isolates of every patient <a href="https://clsi.org/standards/products/microbiology/documents/m39/">using guidelines from the CLSI</a> (Clinical and Laboratory Standards Institute).
@ -200,9 +200,9 @@
<li>The data set <code>microorganisms</code> contains the complete taxonomic tree of more than 18,000 microorganisms (bacteria, fungi/yeasts and protozoa). Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like <code><a href="reference/mo_property.html">mo_genus()</a></code>, <code><a href="reference/mo_property.html">mo_family()</a></code>, <code><a href="reference/mo_property.html">mo_gramstain()</a></code> or even <code><a href="reference/mo_property.html">mo_phylum()</a></code>. As they use <code><a href="reference/as.mo.html">as.mo()</a></code> internally, they also use artificial intelligence. For example, <code><a href="reference/mo_property.html">mo_genus("MRSA")</a></code> and <code><a href="reference/mo_property.html">mo_genus("S. aureus")</a></code> will both return <code>"Staphylococcus"</code>. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.</li> <li>The data set <code>microorganisms</code> contains the complete taxonomic tree of more than 18,000 microorganisms (bacteria, fungi/yeasts and protozoa). Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like <code><a href="reference/mo_property.html">mo_genus()</a></code>, <code><a href="reference/mo_property.html">mo_family()</a></code>, <code><a href="reference/mo_property.html">mo_gramstain()</a></code> or even <code><a href="reference/mo_property.html">mo_phylum()</a></code>. As they use <code><a href="reference/as.mo.html">as.mo()</a></code> internally, they also use artificial intelligence. For example, <code><a href="reference/mo_property.html">mo_genus("MRSA")</a></code> and <code><a href="reference/mo_property.html">mo_genus("S. aureus")</a></code> will both return <code>"Staphylococcus"</code>. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.</li>
<li>The data set <code>antibiotics</code> contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like <code><a href="reference/ab_property.html">ab_name()</a></code> and <code><a href="reference/ab_property.html">ab_tradenames()</a></code> to look up values. The <code>ab_*</code> functions use <code><a href="reference/as.atc.html">as.atc()</a></code> internally so they support AI to guess your expected result. For example, <code><a href="reference/ab_property.html">ab_name("Fluclox")</a></code>, <code><a href="reference/ab_property.html">ab_name("Floxapen")</a></code> and <code><a href="reference/ab_property.html">ab_name("J01CF05")</a></code> will all return <code>"Flucloxacillin"</code>. These functions can again be used to add new variables to your data.</li> <li>The data set <code>antibiotics</code> contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like <code><a href="reference/ab_property.html">ab_name()</a></code> and <code><a href="reference/ab_property.html">ab_tradenames()</a></code> to look up values. The <code>ab_*</code> functions use <code><a href="reference/as.atc.html">as.atc()</a></code> internally so they support AI to guess your expected result. For example, <code><a href="reference/ab_property.html">ab_name("Fluclox")</a></code>, <code><a href="reference/ab_property.html">ab_name("Floxapen")</a></code> and <code><a href="reference/ab_property.html">ab_name("J01CF05")</a></code> will all return <code>"Flucloxacillin"</code>. These functions can again be used to add new variables to your data.</li>
</ul> </ul>
</li> <ol>
<li> <li>It <strong>analyses the data</strong> with convenient functions that use well-known methods.</li>
<p>It <strong>analyses the data</strong> with convenient functions that use well-known methods.</p> </ol>
<ul> <ul>
<li>Calculate the resistance (and even co-resistance) of microbial isolates with the <code><a href="reference/portion.html">portion_R()</a></code>, <code><a href="reference/portion.html">portion_IR()</a></code>, <code><a href="reference/portion.html">portion_I()</a></code>, <code><a href="reference/portion.html">portion_SI()</a></code> and <code><a href="reference/portion.html">portion_S()</a></code> functions. Similarly, the <em>number</em> of isolates can be determined with the <code><a href="reference/count.html">count_R()</a></code>, <code><a href="reference/count.html">count_IR()</a></code>, <code><a href="reference/count.html">count_I()</a></code>, <code><a href="reference/count.html">count_SI()</a></code> and <code><a href="reference/count.html">count_S()</a></code> functions. All these functions can be used <a href="https://dplyr.tidyverse.org/#usage">with the <code>dplyr</code> package</a> (e.g. in conjunction with <a href="https://dplyr.tidyverse.org/reference/summarise.html"><code>summarise</code></a>)</li> <li>Calculate the resistance (and even co-resistance) of microbial isolates with the <code><a href="reference/portion.html">portion_R()</a></code>, <code><a href="reference/portion.html">portion_IR()</a></code>, <code><a href="reference/portion.html">portion_I()</a></code>, <code><a href="reference/portion.html">portion_SI()</a></code> and <code><a href="reference/portion.html">portion_S()</a></code> functions. Similarly, the <em>number</em> of isolates can be determined with the <code><a href="reference/count.html">count_R()</a></code>, <code><a href="reference/count.html">count_IR()</a></code>, <code><a href="reference/count.html">count_I()</a></code>, <code><a href="reference/count.html">count_SI()</a></code> and <code><a href="reference/count.html">count_S()</a></code> functions. All these functions can be used <a href="https://dplyr.tidyverse.org/#usage">with the <code>dplyr</code> package</a> (e.g. in conjunction with <a href="https://dplyr.tidyverse.org/reference/summarise.html"><code>summarise</code></a>)</li>
<li>Plot AMR results with <code><a href="reference/ggplot_rsi.html">geom_rsi()</a></code>, a function made for the <code>ggplot2</code> package</li> <li>Plot AMR results with <code><a href="reference/ggplot_rsi.html">geom_rsi()</a></code>, a function made for the <code>ggplot2</code> package</li>
@ -210,9 +210,9 @@
<li>Conduct descriptive statistics to enhance base R: calculate <code><a href="reference/kurtosis.html">kurtosis()</a></code>, <code><a href="reference/skewness.html">skewness()</a></code> and create frequency tables with <code><a href="reference/freq.html">freq()</a></code> <li>Conduct descriptive statistics to enhance base R: calculate <code><a href="reference/kurtosis.html">kurtosis()</a></code>, <code><a href="reference/skewness.html">skewness()</a></code> and create frequency tables with <code><a href="reference/freq.html">freq()</a></code>
</li> </li>
</ul> </ul>
</li> <ol>
<li> <li>It <strong>teaches the user</strong> how to use all the above actions.</li>
<p>It <strong>teaches the user</strong> how to use all the above actions.</p> </ol>
<ul> <ul>
<li>The package contains extensive help pages with many examples.</li> <li>The package contains extensive help pages with many examples.</li>
<li>It also contains an example data set called <code>septic_patients</code>. This data set contains: <li>It also contains an example data set called <code>septic_patients</code>. This data set contains:
@ -223,8 +223,6 @@
</ul> </ul>
</li> </li>
</ul> </ul>
</li>
</ol>
<hr> <hr>
<p><a href="https://www.rug.nl"><img src="./logo_rug.png" height="60px"></a> <a href="https://www.umcg.nl"><img src="./logo_umcg.png" height="60px"></a> <a href="https://www.certe.nl"><img src="./logo_certe.png" height="60px"></a> <a href="http://www.eurhealth-1health.eu"><img src="./logo_eh1h.png" height="60px"></a> <a href="http://www.eurhealth-1health.eu"><img src="./logo_interreg.png" height="60px"></a></p> <p><a href="https://www.rug.nl"><img src="./logo_rug.png" height="60px"></a> <a href="https://www.umcg.nl"><img src="./logo_umcg.png" height="60px"></a> <a href="https://www.certe.nl"><img src="./logo_certe.png" height="60px"></a> <a href="http://www.eurhealth-1health.eu"><img src="./logo_eh1h.png" height="60px"></a> <a href="http://www.eurhealth-1health.eu"><img src="./logo_interreg.png" height="60px"></a></p>
</div> </div>

View File

@ -169,26 +169,14 @@
<ul> <ul>
<li> <li>
<strong>BREAKING</strong>: removed deprecated functions, parameters and references to bactid. Use <code><a href="../reference/as.mo.html">as.mo()</a></code> to identify an MO code.</li> <strong>BREAKING</strong>: removed deprecated functions, parameters and references to bactid. Use <code><a href="../reference/as.mo.html">as.mo()</a></code> to identify an MO code.</li>
<li>New website: <a href="https://msberends.gitlab.io/AMR" class="uri">https://msberends.gitlab.io/AMR</a> (built with the great <a href="https://pkgdown.r-lib.org/"><code>pkgdown</code></a>) <li>New website: <a href="https://msberends.gitlab.io/AMR" class="uri">https://msberends.gitlab.io/AMR</a> (built with the great <a href="https://pkgdown.r-lib.org/"><code>pkgdown</code></a>)</li>
<ul>
<li>Contains the complete manual of this package and all of its functions with an explanation of their parameters</li> <li>Contains the complete manual of this package and all of its functions with an explanation of their parameters</li>
</ul>
</li>
<li>Support for <a href="https://dplyr.tidyverse.org"><code>dplyr</code></a> version 0.8.0</li> <li>Support for <a href="https://dplyr.tidyverse.org"><code>dplyr</code></a> version 0.8.0</li>
<li>Function <code><a href="../reference/mo_failures.html">mo_failures()</a></code> to review values that could not be coerced to a valid MO code, using <code><a href="../reference/as.mo.html">as.mo()</a></code>. This latter function will now only show a maximum of 25 uncoerced values.</li> <li>Function <code><a href="../reference/mo_failures.html">mo_failures()</a></code> to review values that could not be coerced to a valid MO code, using <code><a href="../reference/as.mo.html">as.mo()</a></code>. This latter function will now only show a maximum of 25 uncoerced values.</li>
<li>Function <code><a href="../reference/mo_renamed.html">mo_renamed()</a></code> to get a list of all returned values from <code><a href="../reference/as.mo.html">as.mo()</a></code> that have had taxonomic renaming</li> <li>Function <code><a href="../reference/mo_renamed.html">mo_renamed()</a></code> to get a list of all returned values from <code><a href="../reference/as.mo.html">as.mo()</a></code> that have had taxonomic renaming</li>
<li>Function <code><a href="../reference/age.html">age()</a></code> to calculate the (patients) age in years</li> <li>Function <code><a href="../reference/age.html">age()</a></code> to calculate the (patients) age in years</li>
<li>Function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.</li> <li>Function <code><a href="../reference/age_groups.html">age_groups()</a></code> to split ages into custom or predefined groups (like children or elderly). This allows for easier demographic antimicrobial resistance analysis per age group.</li>
<li> <li>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/first_isolate.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.: <code>r septic_patients %&gt;% filter_first_isolate() # or filter_first_isolate(septic_patients)</code> is equal to: <code>r septic_patients %&gt;% mutate(only_firsts = first_isolate(septic_patients, ...)) %&gt;% filter(only_firsts == TRUE) %&gt;% select(-only_firsts)</code>
<p>Functions <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> and <code><a href="../reference/first_isolate.html">filter_first_weighted_isolate()</a></code> to shorten and fasten filtering on data sets with antimicrobial results, e.g.:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_isolate</a></span>()</a>
<a class="sourceLine" id="cb1-2" data-line-number="2"><span class="co"># or</span></a>
<a class="sourceLine" id="cb1-3" data-line-number="3"><span class="kw"><a href="../reference/first_isolate.html">filter_first_isolate</a></span>(septic_patients)</a></code></pre></div>
<p>is equal to:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb2-2" data-line-number="2"><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">only_firsts =</span> <span class="kw"><a href="../reference/first_isolate.html">first_isolate</a></span>(septic_patients, ...)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb2-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/stats/topics/filter">filter</a></span>(only_firsts <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb2-4" data-line-number="4"><span class="st"> </span><span class="kw">select</span>(<span class="op">-</span>only_firsts)</a></code></pre></div>
</li> </li>
</ul> </ul>
</div> </div>
@ -197,8 +185,7 @@
<a href="#changed" class="anchor"></a>Changed</h4> <a href="#changed" class="anchor"></a>Changed</h4>
<ul> <ul>
<li>Fixed a critical bug in <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> where some rules that depend on previous applied rules would not be applied adequately</li> <li>Fixed a critical bug in <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> where some rules that depend on previous applied rules would not be applied adequately</li>
<li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>: <li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>:</li>
<ul>
<li>Finds better results when input is in other languages</li> <li>Finds better results when input is in other languages</li>
<li>Better handling for subspecies</li> <li>Better handling for subspecies</li>
<li>Better handling for <em>Salmonellae</em> <li>Better handling for <em>Salmonellae</em>
@ -207,17 +194,12 @@
<li>Manual now contains more info about the algorithms</li> <li>Manual now contains more info about the algorithms</li>
<li>Progress bar will be shown when it takes more than 3 seconds to get results</li> <li>Progress bar will be shown when it takes more than 3 seconds to get results</li>
<li>Support for formatted console text</li> <li>Support for formatted console text</li>
</ul> <li>Function <code><a href="../reference/first_isolate.html">first_isolate()</a></code>:</li>
</li> <li>Fixed a bug where distances between dates would not be calculated right - in the <code>septic_patients</code> data set this yielded a difference of 0.15% more isolates</li>
<li>Function <code><a href="../reference/first_isolate.html">first_isolate()</a></code>:
<ul>
<li>Fixed a bug where distances between dates would not be calculated right - in the <code>septic_patients</code> data set this yielded a differences of 0.15% more isolates</li>
<li>Will now use a column named like “patid” for the patient ID (parameter <code>col_patientid</code>), when this parameter was left blank</li> <li>Will now use a column named like “patid” for the patient ID (parameter <code>col_patientid</code>), when this parameter was left blank</li>
<li>Will now use a column named like “key(…)ab” or “key(…)antibiotics” for the key antibiotics (parameter <code>col_keyantibiotics()</code>), when this parameter was left blank</li> <li>Will now use a column named like “key(…)ab” or “key(…)antibiotics” for the key antibiotics (parameter <code>col_keyantibiotics()</code>), when this parameter was left blank</li>
<li>Removed parameter <code>output_logical</code>, the function will now always return a logical value</li> <li>Removed parameter <code>output_logical</code>, the function will now always return a logical value</li>
<li>Renamed parameter <code>filter_specimen</code> to <code>specimen_group</code>, although using <code>filter_specimen</code> will still work</li> <li>Renamed parameter <code>filter_specimen</code> to <code>specimen_group</code>, although using <code>filter_specimen</code> will still work</li>
</ul>
</li>
<li>A note to the manual pages of the <code>portion</code> functions, that low counts can influence the outcome and that the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter)</li> <li>A note to the manual pages of the <code>portion</code> functions, that low counts can influence the outcome and that the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter)</li>
<li>Function <code><a href="../reference/mo_property.html">mo_taxonomy()</a></code> now contains the kingdom too</li> <li>Function <code><a href="../reference/mo_property.html">mo_taxonomy()</a></code> now contains the kingdom too</li>
<li>Reduce false positives for <code><a href="../reference/as.rsi.html">is.rsi.eligible()</a></code> <li>Reduce false positives for <code><a href="../reference/as.rsi.html">is.rsi.eligible()</a></code>
@ -226,8 +208,7 @@
</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>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):</li>
<ul>
<li>Header info is now available as a list, with the <code>header</code> function</li> <li>Header info is now available as a list, with the <code>header</code> function</li>
<li>Added header info for class <code>mo</code> to show unique count of families, genera and species</li> <li>Added header info for class <code>mo</code> to show unique count of families, genera and species</li>
<li>Now honours the <code>decimal.mark</code> setting, which just like <code>format</code> defaults to <code><a href="https://www.rdocumentation.org/packages/base/topics/options">getOption("OutDec")</a></code> <li>Now honours the <code>decimal.mark</code> setting, which just like <code>format</code> defaults to <code><a href="https://www.rdocumentation.org/packages/base/topics/options">getOption("OutDec")</a></code>
@ -237,8 +218,6 @@
</li> </li>
<li>New parameter <code>droplevels</code> to exclude empty factor levels when input is a factor</li> <li>New parameter <code>droplevels</code> to exclude empty factor levels when input is a factor</li>
<li>Factor levels will be in header when present in input data</li> <li>Factor levels will be in header when present in input data</li>
</ul>
</li>
<li>Function <code><a href="../reference/ggplot_rsi.html">scale_y_percent()</a></code> now contains the <code>limits</code> parameter</li> <li>Function <code><a href="../reference/ggplot_rsi.html">scale_y_percent()</a></code> now contains the <code>limits</code> parameter</li>
<li>Automatic parameter filling for <code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> <li>Automatic parameter filling for <code><a href="../reference/mdro.html">mdro()</a></code>, <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
</li> </li>
@ -280,8 +259,7 @@
</li> </li>
<li> <li>
<code>EUCAST_rules</code> was renamed to <code>eucast_rules</code>, the old function still exists as a deprecated function</li> <code>EUCAST_rules</code> was renamed to <code>eucast_rules</code>, the old function still exists as a deprecated function</li>
<li>Big changes to the <code>eucast_rules</code> function: <li>Big changes to the <code>eucast_rules</code> function:</li>
<ul>
<li>Now also applies rules from the EUCAST Breakpoint tables for bacteria, version 8.1, 2018, <a href="http://www.eucast.org/clinical_breakpoints/" class="uri">http://www.eucast.org/clinical_breakpoints/</a> (see Source of the function)</li> <li>Now also applies rules from the EUCAST Breakpoint tables for bacteria, version 8.1, 2018, <a href="http://www.eucast.org/clinical_breakpoints/" class="uri">http://www.eucast.org/clinical_breakpoints/</a> (see Source of the function)</li>
<li>New parameter <code>rules</code> to specify which rules should be applied (expert rules, breakpoints, others or all)</li> <li>New parameter <code>rules</code> to specify which rules should be applied (expert rules, breakpoints, others or all)</li>
<li>New parameter <code>verbose</code> which can be set to <code>TRUE</code> to get very specific messages about which columns and rows were affected</li> <li>New parameter <code>verbose</code> which can be set to <code>TRUE</code> to get very specific messages about which columns and rows were affected</li>
@ -290,18 +268,11 @@
<li>Data set <code>septic_patients</code> now reflects these changes</li> <li>Data set <code>septic_patients</code> now reflects these changes</li>
<li>Added parameter <code>pipe</code> for piperacillin (J01CA12), also to the <code>mdro</code> function</li> <li>Added parameter <code>pipe</code> for piperacillin (J01CA12), also to the <code>mdro</code> function</li>
<li>Small fixes to EUCAST clinical breakpoint rules</li> <li>Small fixes to EUCAST clinical breakpoint rules</li>
</ul>
</li>
<li>Added column <code>kingdom</code> to the microorganisms data set, and function <code>mo_kingdom</code> to look up values</li> <li>Added column <code>kingdom</code> to the microorganisms data set, and function <code>mo_kingdom</code> to look up values</li>
<li>Tremendous speed improvement for <code>as.mo</code> (and subsequently all <code>mo_*</code> functions), as empty values wil be ignored <em>a priori</em> <li>Tremendous speed improvement for <code>as.mo</code> (and subsequently all <code>mo_*</code> functions), as empty values wil be ignored <em>a priori</em>
</li> </li>
<li>Fewer than 3 characters as input for <code>as.mo</code> will return NA</li> <li>Fewer than 3 characters as input for <code>as.mo</code> will return NA</li>
<li> <li>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached <code>r as.mo("E. species") # B_ESCHR mo_fullname("E. spp.") # "Escherichia species" as.mo("S. spp") # B_STPHY mo_fullname("S. species") # "Staphylococcus species"</code>
<p>Function <code>as.mo</code> (and all <code>mo_*</code> wrappers) now supports genus abbreviations with “species” attached</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. species"</span>) <span class="co"># B_ESCHR</span></a>
<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"E. spp."</span>) <span class="co"># "Escherichia species"</span></a>
<a class="sourceLine" id="cb3-3" data-line-number="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S. spp"</span>) <span class="co"># B_STPHY</span></a>
<a class="sourceLine" id="cb3-4" data-line-number="4"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. species"</span>) <span class="co"># "Staphylococcus species"</span></a></code></pre></div>
</li> </li>
<li>Added parameter <code>combine_IR</code> (TRUE/FALSE) to functions <code>portion_df</code> and <code>count_df</code>, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)</li> <li>Added parameter <code>combine_IR</code> (TRUE/FALSE) to functions <code>portion_df</code> and <code>count_df</code>, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)</li>
<li>Fix for <code>portion_*(..., as_percent = TRUE)</code> when minimal number of isolates would not be met</li> <li>Fix for <code>portion_*(..., as_percent = TRUE)</code> when minimal number of isolates would not be met</li>
@ -310,19 +281,18 @@
<li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code> <li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code>
</li> </li>
<li>Functions <code>as.mo</code>, <code>as.rsi</code>, <code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not set package name as attribute anymore</li> <li>Functions <code>as.mo</code>, <code>as.rsi</code>, <code>as.mic</code>, <code>as.atc</code> and <code>freq</code> will not set package name as attribute anymore</li>
<li>Frequency tables - <code><a href="../reference/freq.html">freq()</a></code>: <li>Frequency tables - <code><a href="../reference/freq.html">freq()</a></code>:</li>
<ul>
<li> <li>
<p>Support for grouping variables, test with:</p> <p>Support for grouping variables, test with:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">septic_patients %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb4-2" data-line-number="2"><span class="st"> </span><span class="kw">group_by</span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a> <span class="st"> </span><span class="kw">group_by</span>(hospital_id) %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb4-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div> <span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</code></pre></div>
</li> </li>
<li> <li>
<p>Support for (un)selecting columns:</p> <p>Support for (un)selecting columns:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a> <div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">septic_patients %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span></a> <span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(hospital_id) %&gt;%<span class="st"> </span>
<a class="sourceLine" id="cb5-3" data-line-number="3"><span class="st"> </span><span class="kw">select</span>(<span class="op">-</span>count, <span class="op">-</span>cum_count) <span class="co"># only get item, percent, cum_percent</span></a></code></pre></div> <span class="st"> </span><span class="kw">select</span>(-count, -cum_count) <span class="co"># only get item, percent, cum_percent</span></code></pre></div>
</li> </li>
<li>Check for <code><a href="https://www.rdocumentation.org/packages/hms/topics/hms">hms::is.hms</a></code> <li>Check for <code><a href="https://www.rdocumentation.org/packages/hms/topics/hms">hms::is.hms</a></code>
</li> </li>
@ -333,8 +303,6 @@
<li>New parameter <code>na</code>, to choose which character to print for empty values</li> <li>New parameter <code>na</code>, to choose which character to print for empty values</li>
<li>New parameter <code>header</code> to turn the header info off (default when <code>markdown = TRUE</code>)</li> <li>New parameter <code>header</code> to turn the header info off (default when <code>markdown = TRUE</code>)</li>
<li>New parameter <code>title</code> to manually setbthe title of the frequency table</li> <li>New parameter <code>title</code> to manually setbthe title of the frequency table</li>
</ul>
</li>
<li> <li>
<code>first_isolate</code> now tries to find columns to use as input when parameters are left blank</li> <code>first_isolate</code> now tries to find columns to use as input when parameters are left blank</li>
<li>Improvements for MDRO algorithm (function <code>mdro</code>)</li> <li>Improvements for MDRO algorithm (function <code>mdro</code>)</li>
@ -346,8 +314,7 @@
</li> </li>
<li> <li>
<code>ggplot_rsi</code> and <code>scale_y_percent</code> have <code>breaks</code> parameter</li> <code>ggplot_rsi</code> and <code>scale_y_percent</code> have <code>breaks</code> parameter</li>
<li>AI improvements for <code>as.mo</code>: <li>AI improvements for <code>as.mo</code>:</li>
<ul>
<li> <li>
<code>"CRS"</code> -&gt; <em>Stenotrophomonas maltophilia</em> <code>"CRS"</code> -&gt; <em>Stenotrophomonas maltophilia</em>
</li> </li>
@ -360,8 +327,6 @@
<li> <li>
<code>"MSSE"</code> -&gt; <em>Staphylococcus epidermidis</em> <code>"MSSE"</code> -&gt; <em>Staphylococcus epidermidis</em>
</li> </li>
</ul>
</li>
<li>Fix for <code>join</code> functions</li> <li>Fix for <code>join</code> functions</li>
<li>Speed improvement for <code>is.rsi.eligible</code>, now 15-20 times faster</li> <li>Speed improvement for <code>is.rsi.eligible</code>, now 15-20 times faster</li>
<li>In <code>g.test</code>, when <code><a href="https://www.rdocumentation.org/packages/base/topics/sum">sum(x)</a></code> is below 1000 or any of the expected values is below 5, Fishers Exact Test will be suggested</li> <li>In <code>g.test</code>, when <code><a href="https://www.rdocumentation.org/packages/base/topics/sum">sum(x)</a></code> is below 1000 or any of the expected values is below 5, Fishers Exact Test will be suggested</li>
@ -390,8 +355,7 @@
<a href="#new-2" class="anchor"></a>New</h4> <a href="#new-2" class="anchor"></a>New</h4>
<ul> <ul>
<li>The data set <code>microorganisms</code> now contains <strong>all microbial taxonomic data from ITIS</strong> (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via <a href="https://itis.gov" class="uri">https://itis.gov</a>. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set <code>microorganisms.old</code> contains all previously known taxonomic names from those kingdoms.</li> <li>The data set <code>microorganisms</code> now contains <strong>all microbial taxonomic data from ITIS</strong> (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via <a href="https://itis.gov" class="uri">https://itis.gov</a>. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set <code>microorganisms.old</code> contains all previously known taxonomic names from those kingdoms.</li>
<li>New functions based on the existing function <code>mo_property</code>: <li>New functions based on the existing function <code>mo_property</code>:</li>
<ul>
<li>Taxonomic names: <code>mo_phylum</code>, <code>mo_class</code>, <code>mo_order</code>, <code>mo_family</code>, <code>mo_genus</code>, <code>mo_species</code>, <code>mo_subspecies</code> <li>Taxonomic names: <code>mo_phylum</code>, <code>mo_class</code>, <code>mo_order</code>, <code>mo_family</code>, <code>mo_genus</code>, <code>mo_species</code>, <code>mo_subspecies</code>
</li> </li>
<li>Semantic names: <code>mo_fullname</code>, <code>mo_shortname</code> <li>Semantic names: <code>mo_fullname</code>, <code>mo_shortname</code>
@ -401,52 +365,22 @@
<li>Author and year: <code>mo_ref</code> <li>Author and year: <code>mo_ref</code>
</li> </li>
</ul> </ul>
<p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:</p> <p>They also come with support for German, Dutch, French, Italian, Spanish and Portuguese: <code>r mo_gramstain("E. coli") # [1] "Gram negative" mo_gramstain("E. coli", language = "de") # German # [1] "Gramnegativ" mo_gramstain("E. coli", language = "es") # Spanish # [1] "Gram negativo" mo_fullname("S. group A", language = "pt") # Portuguese # [1] "Streptococcus grupo 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="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)</a> <p>Furthermore, former taxonomic names will give a note about the current taxonomic name: <code>r mo_gramstain("Esc blattae") # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010) # [1] "Gram negative"</code></p>
<a class="sourceLine" id="cb6-2" data-line-number="2"><span class="co"># [1] "Gram negative"</span></a>
<a class="sourceLine" id="cb6-3" data-line-number="3"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"de"</span>) <span class="co"># German</span></a>
<a class="sourceLine" id="cb6-4" data-line-number="4"><span class="co"># [1] "Gramnegativ"</span></a>
<a class="sourceLine" id="cb6-5" data-line-number="5"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>, <span class="dt">language =</span> <span class="st">"es"</span>) <span class="co"># Spanish</span></a>
<a class="sourceLine" id="cb6-6" data-line-number="6"><span class="co"># [1] "Gram negativo"</span></a>
<a class="sourceLine" id="cb6-7" data-line-number="7"><span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. group A"</span>, <span class="dt">language =</span> <span class="st">"pt"</span>) <span class="co"># Portuguese</span></a>
<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="co"># [1] "Streptococcus grupo A"</span></a></code></pre></div>
<p>Furthermore, former taxonomic names will give a note about the current taxonomic name:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1"><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"Esc blattae"</span>)</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"><span class="co"># Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)</span></a>
<a class="sourceLine" id="cb7-3" data-line-number="3"><span class="co"># [1] "Gram negative"</span></a></code></pre></div>
</li>
<li>Functions <code>count_R</code>, <code>count_IR</code>, <code>count_I</code>, <code>count_SI</code> and <code>count_S</code> to selectively count resistant or susceptible isolates
<ul> <ul>
<li>Functions <code>count_R</code>, <code>count_IR</code>, <code>count_I</code>, <code>count_SI</code> and <code>count_S</code> to selectively count resistant or susceptible isolates</li>
<li>Extra function <code>count_df</code> (which works like <code>portion_df</code>) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables</li> <li>Extra function <code>count_df</code> (which works like <code>portion_df</code>) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables</li>
</ul>
</li>
<li>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %&gt;% mutate_if(is.rsi.eligible, as.rsi)</code> <li>Function <code>is.rsi.eligible</code> to check for columns that have valid antimicrobial results, but do not have the <code>rsi</code> class yet. Transform the columns of your raw data with: <code>data %&gt;% mutate_if(is.rsi.eligible, as.rsi)</code>
</li> </li>
<li> <li>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using Artificial Intelligence (AI): <code>r as.mo("E. coli") # [1] B_ESCHR_COL as.mo("MRSA") # [1] B_STPHY_AUR as.mo("S group A") # [1] B_STRPTC_GRA</code> And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items: <code>r thousands_of_E_colis &lt;- rep("E. coli", 25000) microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s") # Unit: seconds # min median max neval # 0.01817717 0.01843957 0.03878077 100</code>
<p>Functions <code>as.mo</code> and <code>is.mo</code> as replacements for <code>as.bactid</code> and <code>is.bactid</code> (since the <code>microoganisms</code> data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The <code>as.mo</code> function determines microbial IDs using Artificial Intelligence (AI):</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. coli"</span>)</a>
<a class="sourceLine" id="cb8-2" data-line-number="2"><span class="co"># [1] B_ESCHR_COL</span></a>
<a class="sourceLine" id="cb8-3" data-line-number="3"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"MRSA"</span>)</a>
<a class="sourceLine" id="cb8-4" data-line-number="4"><span class="co"># [1] B_STPHY_AUR</span></a>
<a class="sourceLine" id="cb8-5" data-line-number="5"><span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"S group A"</span>)</a>
<a class="sourceLine" id="cb8-6" data-line-number="6"><span class="co"># [1] B_STRPTC_GRA</span></a></code></pre></div>
<p>And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">thousands_of_E_colis &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/rep">rep</a></span>(<span class="st">"E. coli"</span>, <span class="dv">25000</span>)</a>
<a class="sourceLine" id="cb9-2" data-line-number="2">microbenchmark<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(thousands_of_E_colis), <span class="dt">unit =</span> <span class="st">"s"</span>)</a>
<a class="sourceLine" id="cb9-3" data-line-number="3"><span class="co"># Unit: seconds</span></a>
<a class="sourceLine" id="cb9-4" data-line-number="4"><span class="co"># min median max neval</span></a>
<a class="sourceLine" id="cb9-5" data-line-number="5"><span class="co"># 0.01817717 0.01843957 0.03878077 100</span></a></code></pre></div>
</li> </li>
<li>Added parameter <code>reference_df</code> for <code>as.mo</code>, so users can supply their own microbial IDs, name or codes as a reference table</li> <li>Added parameter <code>reference_df</code> for <code>as.mo</code>, so users can supply their own microbial IDs, name or codes as a reference table</li>
<li>Renamed all previous references to <code>bactid</code> to <code>mo</code>, like: <li>Renamed all previous references to <code>bactid</code> to <code>mo</code>, like:</li>
<ul>
<li>Column names inputs of <code>EUCAST_rules</code>, <code>first_isolate</code> and <code>key_antibiotics</code> <li>Column names inputs of <code>EUCAST_rules</code>, <code>first_isolate</code> and <code>key_antibiotics</code>
</li> </li>
<li>Column names of datasets <code>microorganisms</code> and <code>septic_patients</code> <li>Column names of datasets <code>microorganisms</code> and <code>septic_patients</code>
</li> </li>
<li>All old syntaxes will still work with this version, but will throw warnings</li> <li>All old syntaxes will still work with this version, but will throw warnings</li>
</ul>
</li>
<li>Function <code>labels_rsi_count</code> to print datalabels on a RSI <code>ggplot2</code> model</li> <li>Function <code>labels_rsi_count</code> to print datalabels on a RSI <code>ggplot2</code> model</li>
<li><p>Functions <code>as.atc</code> and <code>is.atc</code> to transform/look up antibiotic ATC codes as defined by the WHO. The existing function <code>guess_atc</code> is now an alias of <code>as.atc</code>.</p></li> <li><p>Functions <code>as.atc</code> and <code>is.atc</code> to transform/look up antibiotic ATC codes as defined by the WHO. The existing function <code>guess_atc</code> is now an alias of <code>as.atc</code>.</p></li>
<li>Function <code>ab_property</code> and its aliases: <code>ab_name</code>, <code>ab_tradenames</code>, <code>ab_certe</code>, <code>ab_umcg</code> and <code>ab_trivial_nl</code> <li>Function <code>ab_property</code> and its aliases: <code>ab_name</code>, <code>ab_tradenames</code>, <code>ab_certe</code>, <code>ab_umcg</code> and <code>ab_trivial_nl</code>
@ -461,14 +395,7 @@
<a href="#changed-2" class="anchor"></a>Changed</h4> <a href="#changed-2" class="anchor"></a>Changed</h4>
<ul> <ul>
<li>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</li> <li>Added three antimicrobial agents to the <code>antibiotics</code> data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)</li>
<li> <li>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.: <code>r ab_official("Bactroban") # [1] "Mupirocin" ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) # [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin" ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) # [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"</code>
<p>Added 163 trade names to the <code>antibiotics</code> data set, it now contains 298 different trade names in total, e.g.:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" data-line-number="1"><span class="kw"><a href="../reference/ab_property.html">ab_official</a></span>(<span class="st">"Bactroban"</span>)</a>
<a class="sourceLine" id="cb10-2" data-line-number="2"><span class="co"># [1] "Mupirocin"</span></a>
<a class="sourceLine" id="cb10-3" data-line-number="3"><span class="kw"><a href="../reference/ab_property.html">ab_name</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb10-4" data-line-number="4"><span class="co"># [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"</span></a>
<a class="sourceLine" id="cb10-5" data-line-number="5"><span class="kw"><a href="../reference/ab_property.html">ab_atc</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"Bactroban"</span>, <span class="st">"Amoxil"</span>, <span class="st">"Zithromax"</span>, <span class="st">"Floxapen"</span>))</a>
<a class="sourceLine" id="cb10-6" data-line-number="6"><span class="co"># [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"</span></a></code></pre></div>
</li> </li>
<li>For <code>first_isolate</code>, rows will be ignored when theres no species available</li> <li>For <code>first_isolate</code>, rows will be ignored when theres no species available</li>
<li>Function <code>ratio</code> is now deprecated and will be removed in a future release, as it is not really the scope of this package</li> <li>Function <code>ratio</code> is now deprecated and will be removed in a future release, as it is not really the scope of this package</li>
@ -477,36 +404,9 @@
<li>Added <code>prevalence</code> column to the <code>microorganisms</code> data set</li> <li>Added <code>prevalence</code> column to the <code>microorganisms</code> data set</li>
<li>Added parameters <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code> <li>Added parameters <code>minimum</code> and <code>as_percent</code> to <code>portion_df</code>
</li> </li>
<li> <li>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns. ```r septic_patients %&gt;% select(amox, cipr) %&gt;% count_IR() # which is the same as: septic_patients %&gt;% count_IR(amox, cipr)</li>
<p>Support for quasiquotation in the functions series <code>count_*</code> and <code>portions_*</code>, and <code>n_rsi</code>. This allows to check for more than 2 vectors or columns.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">select</span>(amox, cipr) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>()</a>
<a class="sourceLine" id="cb11-2" data-line-number="2"><span class="co"># which is the same as:</span></a>
<a class="sourceLine" id="cb11-3" data-line-number="3">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>(amox, cipr)</a>
<a class="sourceLine" id="cb11-4" data-line-number="4"></a>
<a class="sourceLine" id="cb11-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl)</a>
<a class="sourceLine" id="cb11-6" data-line-number="6">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent)</a>
<a class="sourceLine" id="cb11-7" data-line-number="7">septic_patients <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent, pita)</a></code></pre></div>
</li>
<li>Edited <code>ggplot_rsi</code> and <code>geom_rsi</code> so they can cope with <code>count_df</code>. The new <code>fun</code> parameter has value <code>portion_df</code> at default, but can be set to <code>count_df</code>.</li>
<li>Fix for <code>ggplot_rsi</code> when the <code>ggplot2</code> package was not loaded</li>
<li>Added datalabels function <code>labels_rsi_count</code> to <code>ggplot_rsi</code>
</li>
<li>Added possibility to set any parameter to <code>geom_rsi</code> (and <code>ggplot_rsi</code>) so you can set your own preferences</li>
<li>Fix for joins, where predefined suffices would not be honoured</li>
<li>Added parameter <code>quote</code> to the <code>freq</code> function</li>
<li>Added generic function <code>diff</code> for frequency tables</li>
<li>Added longest en shortest character length in the frequency table (<code>freq</code>) header of class <code>character</code>
</li>
<li>
<p>Support for types (classes) list and matrix for <code>freq</code></p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1">my_matrix =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/with">with</a></span>(septic_patients, <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/matrix">matrix</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(age, gender), <span class="dt">ncol =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb12-2" data-line-number="2"><span class="kw"><a href="../reference/freq.html">freq</a></span>(my_matrix)</a></code></pre></div>
<p>For lists, subsetting is possible:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" data-line-number="1">my_list =<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">age =</span> septic_patients<span class="op">$</span>age, <span class="dt">gender =</span> septic_patients<span class="op">$</span>gender)</a>
<a class="sourceLine" id="cb13-2" data-line-number="2">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(age)</a>
<a class="sourceLine" id="cb13-3" data-line-number="3">my_list <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(gender)</a></code></pre></div>
</li>
</ul> </ul>
<p>septic_patients %&gt;% portion_S(amcl) septic_patients %&gt;% portion_S(amcl, gent) septic_patients %&gt;% portion_S(amcl, gent, pita) <code>* Edited `ggplot_rsi` and `geom_rsi` so they can cope with `count_df`. The new `fun` parameter has value `portion_df` at default, but can be set to `count_df`. * Fix for `ggplot_rsi` when the `ggplot2` package was not loaded * Added datalabels function `labels_rsi_count` to `ggplot_rsi` * Added possibility to set any parameter to `geom_rsi` (and `ggplot_rsi`) so you can set your own preferences * Fix for joins, where predefined suffices would not be honoured * Added parameter `quote` to the `freq` function * Added generic function `diff` for frequency tables * Added longest en shortest character length in the frequency table (`freq`) header of class `character` * Support for types (classes) list and matrix for `freq`</code>r my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2)) freq(my_matrix) <code>For lists, subsetting is possible:</code>r my_list = list(age = septic_patients$age, gender = septic_patients$gender) my_list %&gt;% freq(age) my_list %&gt;% freq(gender) ```</p>
</div> </div>
<div id="other-2" class="section level4"> <div id="other-2" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
@ -525,21 +425,15 @@
<a href="#new-3" class="anchor"></a>New</h4> <a href="#new-3" class="anchor"></a>New</h4>
<ul> <ul>
<li> <li>
<strong>BREAKING</strong>: <code>rsi_df</code> was removed in favour of new functions <code>portion_R</code>, <code>portion_IR</code>, <code>portion_I</code>, <code>portion_SI</code> and <code>portion_S</code> to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old <code>rsi</code> function. The old function still works, but is deprecated. <strong>BREAKING</strong>: <code>rsi_df</code> was removed in favour of new functions <code>portion_R</code>, <code>portion_IR</code>, <code>portion_I</code>, <code>portion_SI</code> and <code>portion_S</code> to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old <code>rsi</code> function. The old function still works, but is deprecated.</li>
<ul>
<li>New function <code>portion_df</code> to get all portions of S, I and R of a data set with antibiotic columns, with support for grouped variables</li> <li>New function <code>portion_df</code> to get all portions of S, I and R of a data set with antibiotic columns, with support for grouped variables</li>
</ul>
</li>
<li> <li>
<strong>BREAKING</strong>: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call <em>key antibiotics</em>) to include more first isolates (afterwards called first <em>weighted</em> isolates) are now as follows: <strong>BREAKING</strong>: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call <em>key antibiotics</em>) to include more first isolates (afterwards called first <em>weighted</em> isolates) are now as follows:</li>
<ul>
<li>Universal: amoxicillin, amoxicillin/clavlanic acid, cefuroxime, piperacillin/tazobactam, ciprofloxacin, trimethoprim/sulfamethoxazole</li> <li>Universal: amoxicillin, amoxicillin/clavlanic acid, cefuroxime, piperacillin/tazobactam, ciprofloxacin, trimethoprim/sulfamethoxazole</li>
<li>Gram-positive: vancomycin, teicoplanin, tetracycline, erythromycin, oxacillin, rifampicin</li> <li>Gram-positive: vancomycin, teicoplanin, tetracycline, erythromycin, oxacillin, rifampicin</li>
<li>Gram-negative: gentamicin, tobramycin, colistin, cefotaxime, ceftazidime, meropenem</li> <li>Gram-negative: gentamicin, tobramycin, colistin, cefotaxime, ceftazidime, meropenem</li>
</ul>
</li>
<li>Support for <code>ggplot2</code> <li>Support for <code>ggplot2</code>
<ul> </li>
<li>New functions <code>geom_rsi</code>, <code>facet_rsi</code>, <code>scale_y_percent</code>, <code>scale_rsi_colours</code> and <code>theme_rsi</code> <li>New functions <code>geom_rsi</code>, <code>facet_rsi</code>, <code>scale_y_percent</code>, <code>scale_rsi_colours</code> and <code>theme_rsi</code>
</li> </li>
<li>New wrapper function <code>ggplot_rsi</code> to apply all above functions on a data set: <li>New wrapper function <code>ggplot_rsi</code> to apply all above functions on a data set:
@ -550,32 +444,22 @@
</li> </li>
</ul> </ul>
</li> </li>
</ul> <li>Determining bacterial ID:</li>
</li>
<li>Determining bacterial ID:
<ul>
<li>New functions <code>as.bactid</code> and <code>is.bactid</code> to transform/ look up microbial IDs.</li> <li>New functions <code>as.bactid</code> and <code>is.bactid</code> to transform/ look up microbial IDs.</li>
<li>The existing function <code>guess_bactid</code> is now an alias of <code>as.bactid</code> <li>The existing function <code>guess_bactid</code> is now an alias of <code>as.bactid</code>
</li> </li>
<li>New Becker classification for <em>Staphylococcus</em> to categorise them into Coagulase Negative <em>Staphylococci</em> (CoNS) and Coagulase Positve <em>Staphylococci</em> (CoPS)</li> <li>New Becker classification for <em>Staphylococcus</em> to categorise them into Coagulase Negative <em>Staphylococci</em> (CoNS) and Coagulase Positve <em>Staphylococci</em> (CoPS)</li>
<li>New Lancefield classification for <em>Streptococcus</em> to categorise them into Lancefield groups</li> <li>New Lancefield classification for <em>Streptococcus</em> to categorise them into Lancefield groups</li>
</ul>
</li>
<li>For convience, new descriptive statistical functions <code>kurtosis</code> and <code>skewness</code> that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices</li> <li>For convience, new descriptive statistical functions <code>kurtosis</code> and <code>skewness</code> that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices</li>
<li>Function <code>g.test</code> to perform the Χ<sup>2</sup> distributed <a href="https://en.wikipedia.org/wiki/G-test"><em>G</em>-test</a>, which use is the same as <code>chisq.test</code> <li>Function <code>g.test</code> to perform the Χ<sup>2</sup> distributed <a href="https://en.wikipedia.org/wiki/G-test"><em>G</em>-test</a>, which use is the same as <code>chisq.test</code>
</li> </li>
<li> <li><del>Function <code>ratio</code> to transform a vector of values to a preset ratio</del></li>
<del>Function <code>ratio</code> to transform a vector of values to a preset ratio</del>
<ul>
<li><del>For example: <code><a href="../reference/AMR-deprecated.html">ratio(c(10, 500, 10), ratio = "1:2:1")</a></code> would return <code>130, 260, 130</code></del></li> <li><del>For example: <code><a href="../reference/AMR-deprecated.html">ratio(c(10, 500, 10), ratio = "1:2:1")</a></code> would return <code>130, 260, 130</code></del></li>
</ul>
</li>
<li>Support for Addins menu in RStudio to quickly insert <code>%in%</code> or <code>%like%</code> (and give them keyboard shortcuts), or to view the datasets that come with this package</li> <li>Support for Addins menu in RStudio to quickly insert <code>%in%</code> or <code>%like%</code> (and give them keyboard shortcuts), or to view the datasets that come with this package</li>
<li>Function <code>p.symbol</code> to transform p values to their related symbols: <code>0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code> <li>Function <code>p.symbol</code> to transform p values to their related symbols: <code>0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code>
</li> </li>
<li>Functions <code>clipboard_import</code> and <code>clipboard_export</code> as helper functions to quickly copy and paste from/to software like Excel and SPSS. These functions use the <code>clipr</code> package, but are a little altered to also support headless Linux servers (so you can use it in RStudio Server)</li> <li>Functions <code>clipboard_import</code> and <code>clipboard_export</code> as helper functions to quickly copy and paste from/to software like Excel and SPSS. These functions use the <code>clipr</code> package, but are a little altered to also support headless Linux servers (so you can use it in RStudio Server)</li>
<li>New for frequency tables (function <code>freq</code>): <li>New for frequency tables (function <code>freq</code>):</li>
<ul>
<li>A vignette to explain its usage</li> <li>A vignette to explain its usage</li>
<li>Support for <code>rsi</code> (antimicrobial resistance) to use as input</li> <li>Support for <code>rsi</code> (antimicrobial resistance) to use as input</li>
<li>Support for <code>table</code> to use as input: <code><a href="../reference/freq.html">freq(table(x, y))</a></code> <li>Support for <code>table</code> to use as input: <code><a href="../reference/freq.html">freq(table(x, y))</a></code>
@ -590,8 +474,6 @@
<li>Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)</li> <li>Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)</li>
<li>Possibility to globally set the default for the amount of items to print, with <code><a href="https://www.rdocumentation.org/packages/base/topics/options">options(max.print.freq = n)</a></code> where <em>n</em> is your preset value</li> <li>Possibility to globally set the default for the amount of items to print, with <code><a href="https://www.rdocumentation.org/packages/base/topics/options">options(max.print.freq = n)</a></code> where <em>n</em> is your preset value</li>
</ul> </ul>
</li>
</ul>
</div> </div>
<div id="changed-3" class="section level4"> <div id="changed-3" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
@ -613,27 +495,21 @@
</li> </li>
<li>Small improvements to the <code>microorganisms</code> dataset (especially for <em>Salmonella</em>) and the column <code>bactid</code> now has the new class <code>"bactid"</code> <li>Small improvements to the <code>microorganisms</code> dataset (especially for <em>Salmonella</em>) and the column <code>bactid</code> now has the new class <code>"bactid"</code>
</li> </li>
<li>Combined MIC/RSI values will now be coerced by the <code>rsi</code> and <code>mic</code> functions: <li>Combined MIC/RSI values will now be coerced by the <code>rsi</code> and <code>mic</code> functions:</li>
<ul>
<li> <li>
<code><a href="../reference/as.rsi.html">as.rsi("&lt;=0.002; S")</a></code> will return <code>S</code> <code><a href="../reference/as.rsi.html">as.rsi("&lt;=0.002; S")</a></code> will return <code>S</code>
</li> </li>
<li> <li>
<code><a href="../reference/as.mic.html">as.mic("&lt;=0.002; S")</a></code> will return <code>&lt;=0.002</code> <code><a href="../reference/as.mic.html">as.mic("&lt;=0.002; S")</a></code> will return <code>&lt;=0.002</code>
</li> </li>
</ul>
</li>
<li>Now possible to coerce MIC values with a space between operator and value, i.e. <code><a href="../reference/as.mic.html">as.mic("&lt;= 0.002")</a></code> now works</li> <li>Now possible to coerce MIC values with a space between operator and value, i.e. <code><a href="../reference/as.mic.html">as.mic("&lt;= 0.002")</a></code> now works</li>
<li>Classes <code>rsi</code> and <code>mic</code> do not add the attribute <code>package.version</code> anymore</li> <li>Classes <code>rsi</code> and <code>mic</code> do not add the attribute <code>package.version</code> anymore</li>
<li>Added <code>"groups"</code> option for <code><a href="../reference/atc_property.html">atc_property(..., property)</a></code>. It will return a vector of the ATC hierarchy as defined by the <a href="https://www.whocc.no/atc/structure_and_principles/">WHO</a>. The new function <code>atc_groups</code> is a convenient wrapper around this.</li> <li>Added <code>"groups"</code> option for <code><a href="../reference/atc_property.html">atc_property(..., property)</a></code>. It will return a vector of the ATC hierarchy as defined by the <a href="https://www.whocc.no/atc/structure_and_principles/">WHO</a>. The new function <code>atc_groups</code> is a convenient wrapper around this.</li>
<li>Build-in host check for <code>atc_property</code> as it requires the host set by <code>url</code> to be responsive</li> <li>Build-in host check for <code>atc_property</code> as it requires the host set by <code>url</code> to be responsive</li>
<li>Improved <code>first_isolate</code> algorithm to exclude isolates where bacteria ID or genus is unavailable</li> <li>Improved <code>first_isolate</code> algorithm to exclude isolates where bacteria ID or genus is unavailable</li>
<li>Fix for warning <em>hybrid evaluation forced for row_number</em> (<a href="https://github.com/tidyverse/dplyr/commit/924b62"><code>924b62</code></a>) from the <code>dplyr</code> package v0.7.5 and above</li> <li>Fix for warning <em>hybrid evaluation forced for row_number</em> (<a href="https://github.com/tidyverse/dplyr/commit/924b62"><code>924b62</code></a>) from the <code>dplyr</code> package v0.7.5 and above</li>
<li>Support for empty values and for 1 or 2 columns as input for <code>guess_bactid</code> (now called <code>as.bactid</code>) <li>Support for empty values and for 1 or 2 columns as input for <code>guess_bactid</code> (now called <code>as.bactid</code>)</li>
<ul>
<li>So <code>yourdata %&gt;% select(genus, species) %&gt;% as.bactid()</code> now also works</li> <li>So <code>yourdata %&gt;% select(genus, species) %&gt;% as.bactid()</code> now also works</li>
</ul>
</li>
<li>Other small fixes</li> <li>Other small fixes</li>
</ul> </ul>
</div> </div>
@ -641,14 +517,11 @@
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-3" class="anchor"></a>Other</h4> <a href="#other-3" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher <li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher</li>
<ul>
<li>Linux and macOS: <a href="https://travis-ci.org/msberends/AMR" class="uri">https://travis-ci.org/msberends/AMR</a> <li>Linux and macOS: <a href="https://travis-ci.org/msberends/AMR" class="uri">https://travis-ci.org/msberends/AMR</a>
</li> </li>
<li>Windows: <a href="https://ci.appveyor.com/project/msberends/amr" class="uri">https://ci.appveyor.com/project/msberends/amr</a> <li>Windows: <a href="https://ci.appveyor.com/project/msberends/amr" class="uri">https://ci.appveyor.com/project/msberends/amr</a>
</li> </li>
</ul>
</li>
<li>Added thesis advisors to DESCRIPTION file</li> <li>Added thesis advisors to DESCRIPTION file</li>
</ul> </ul>
</div> </div>
@ -667,15 +540,12 @@
<li>Function <code>guess_bactid</code> to <strong>determine the ID</strong> of a microorganism based on genus/species or known abbreviations like MRSA</li> <li>Function <code>guess_bactid</code> to <strong>determine the ID</strong> of a microorganism based on genus/species or known abbreviations like MRSA</li>
<li>Function <code>guess_atc</code> to <strong>determine the ATC</strong> of an antibiotic based on name, trade name, or known abbreviations</li> <li>Function <code>guess_atc</code> to <strong>determine the ATC</strong> of an antibiotic based on name, trade name, or known abbreviations</li>
<li>Function <code>freq</code> to create <strong>frequency tables</strong>, with additional info in a header</li> <li>Function <code>freq</code> to create <strong>frequency tables</strong>, with additional info in a header</li>
<li>Function <code>MDRO</code> to <strong>determine Multi Drug Resistant Organisms (MDRO)</strong> with support for country-specific guidelines. <li>Function <code>MDRO</code> to <strong>determine Multi Drug Resistant Organisms (MDRO)</strong> with support for country-specific guidelines.</li>
<ul>
<li>Suggest your own via <a href="https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&amp;body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E">https://github.com/msberends/AMR/issues/new</a> <li>Suggest your own via <a href="https://github.com/msberends/AMR/issues/new?title=New%20guideline%20for%20MDRO&amp;body=%3C--%20Please%20add%20your%20country%20code,%20guideline%20name,%20version%20and%20source%20below%20and%20remove%20this%20line--%3E">https://github.com/msberends/AMR/issues/new</a>
</li> </li>
<li> <li>
<a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance">Exceptional resistances defined by EUCAST</a> are also supported instead of countries alone</li> <a href="http://www.eucast.org/expert_rules_and_intrinsic_resistance">Exceptional resistances defined by EUCAST</a> are also supported instead of countries alone</li>
<li>Functions <code>BRMO</code> and <code>MRGN</code> are wrappers for Dutch and German guidelines, respectively</li> <li>Functions <code>BRMO</code> and <code>MRGN</code> are wrappers for Dutch and German guidelines, respectively</li>
</ul>
</li>
<li>New algorithm to determine weighted isolates, can now be <code>"points"</code> or <code>"keyantibiotics"</code>, see <code><a href="../reference/first_isolate.html">?first_isolate</a></code> <li>New algorithm to determine weighted isolates, can now be <code>"points"</code> or <code>"keyantibiotics"</code>, see <code><a href="../reference/first_isolate.html">?first_isolate</a></code>
</li> </li>
<li>New print format for <code>tibble</code>s and <code>data.table</code>s</li> <li>New print format for <code>tibble</code>s and <code>data.table</code>s</li>

View File

@ -1,4 +1,4 @@
pandoc: 2.3.1 pandoc: 1.17.2
pkgdown: 1.3.0 pkgdown: 1.3.0
pkgdown_sha: ~ pkgdown_sha: ~
articles: articles:

View File

@ -47,7 +47,8 @@
<script src="../extra.js"></script> <script src="../extra.js"></script>
<meta property="og:title" content="Frequency table — freq" /> <meta property="og:title" content="Frequency table — freq" />
<meta property="og:description" content="Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. top_freq can be used to get the top/bottom n items of a frequency table, with counts as names." /> <meta property="og:description" content="Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. The best practice is: data %&amp;gt;% freq(var).
top_freq can be used to get the top/bottom n items of a frequency table, with counts as names." />
<meta property="og:image" content="https://msberends.gitlab.io/logo.png" /> <meta property="og:image" content="https://msberends.gitlab.io/logo.png" />
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
@ -163,7 +164,8 @@
<div class="ref-description"> <div class="ref-description">
<p>Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. <code>top_freq</code> can be used to get the top/bottom <em>n</em> items of a frequency table, with counts as names.</p> <p>Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. The best practice is: <code>data %&gt;% freq(var)</code>.<br />
<code>top_freq</code> can be used to get the top/bottom <em>n</em> items of a frequency table, with counts as names.</p>
</div> </div>
@ -240,7 +242,7 @@
</tr> </tr>
<tr> <tr>
<th>na</th> <th>na</th>
<td><p>a character string to should be used to show empty (<code>NA</code>) values (only useful when <code>na.rm = FALSE</code>)</p></td> <td><p>a character string that should be used to show empty (<code>NA</code>) values (only useful when <code>na.rm = FALSE</code>)</p></td>
</tr> </tr>
<tr> <tr>
<th>droplevels</th> <th>droplevels</th>

View File

@ -66,9 +66,9 @@ patients <- unlist(lapply(LETTERS, paste0, 1:10))
The `LETTERS` object is available in R - it's a vector with 26 characters: `A` to `Z`. The `patients` object we just created is now a vector of length `r length(patients)`, with values (patient IDs) varying from ``r patients[1]`` to ``r patients[length(patients)]``. Now we we also set the gender of our patients, by putting the ID and the gender in a table: The `LETTERS` object is available in R - it's a vector with 26 characters: `A` to `Z`. The `patients` object we just created is now a vector of length `r length(patients)`, with values (patient IDs) varying from ``r patients[1]`` to ``r patients[length(patients)]``. Now we we also set the gender of our patients, by putting the ID and the gender in a table:
```{r create gender} ```{r create gender}
patients_table <- data.frame(patients, patients_table <- data.frame(patient_id = patients,
gender = c(strrep("M", 135), gender = c(strrep("M", 135),
strrep("F", 125)) strrep("F", 125)))
``` ```
The first 135 patient IDs are now male, the other 125 are female. The first 135 patient IDs are now male, the other 125 are female.