as.mo improvement
6
R/mo.R
@ -219,7 +219,6 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
||||
|
||||
# conversion of old MO codes from v0.5.0 (ITIS) to later versions (Catalogue of Life)
|
||||
if (any(x %like% "^[BFP]_[A-Z]{3,7}")) {
|
||||
print("is any")
|
||||
leftpart <- gsub("^([BFP]_[A-Z]{3,7}).*", "\\1", x)
|
||||
if (any(leftpart %in% names(mo_codes_v0.5.0))) {
|
||||
rightpart <- gsub("^[BFP]_[A-Z]{3,7}(.*)", "\\1", x)
|
||||
@ -267,9 +266,12 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
||||
x <- microorganismsDT[data.table(mo = x), on = "mo", ..property][[1]]
|
||||
|
||||
} else if (all(x %in% microorganismsDT[prevalence == 1, "fullname"][[1]])) {
|
||||
# we need special treatment for prevalent full names, they are likely!
|
||||
# we need special treatment for very prevalent full names, they are likely!
|
||||
# e.g. as.mo("Staphylococcus aureus")
|
||||
x <- microorganismsDT[prevalence == 1][data.table(fullname = x), on = "fullname", ..property][[1]]
|
||||
} else if (all(x %in% microorganismsDT[prevalence == 2, "fullname"][[1]])) {
|
||||
# same for common full names, they are also likely
|
||||
x <- microorganismsDT[prevalence == 2][data.table(fullname = x), on = "fullname", ..property][[1]]
|
||||
|
||||
} else if (all(toupper(x) %in% microorganisms.codes[, "code"])) {
|
||||
# commonly used MO codes
|
||||
|
@ -327,52 +327,52 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">2017-09-14</td>
|
||||
<td align="center">X8</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">2017-04-07</td>
|
||||
<td align="center">O7</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Staphylococcus aureus</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2011-10-29</td>
|
||||
<td align="center">H5</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">Streptococcus pneumoniae</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2013-02-03</td>
|
||||
<td align="center">D7</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">Streptococcus pneumoniae</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2013-01-14</td>
|
||||
<td align="center">U1</td>
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">2017-04-12</td>
|
||||
<td align="center">H4</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Staphylococcus aureus</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2010-02-23</td>
|
||||
<td align="center">O7</td>
|
||||
<td align="center">2013-08-17</td>
|
||||
<td align="center">C3</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Streptococcus pneumoniae</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2015-05-18</td>
|
||||
<td align="center">E9</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Klebsiella pneumoniae</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2012-12-26</td>
|
||||
<td align="center">W4</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">Staphylococcus aureus</td>
|
||||
<td align="center">R</td>
|
||||
@ -382,15 +382,15 @@
|
||||
<td align="center">F</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2010-09-26</td>
|
||||
<td align="center">E6</td>
|
||||
<td align="center">2016-09-28</td>
|
||||
<td align="center">W1</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">Klebsiella pneumoniae</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">Staphylococcus aureus</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -411,8 +411,8 @@
|
||||
#>
|
||||
#> Item Count Percent Cum. Count Cum. Percent
|
||||
#> --- ----- ------- -------- ----------- -------------
|
||||
#> 1 M 10,391 52.0% 10,391 52.0%
|
||||
#> 2 F 9,609 48.0% 20,000 100.0%</code></pre>
|
||||
#> 1 M 10,466 52.3% 10,466 52.3%
|
||||
#> 2 F 9,534 47.7% 20,000 100.0%</code></pre>
|
||||
<p>So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researcher perspective: there are slightly more men. Nothing we didn’t already know.</p>
|
||||
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1">data <-<span class="st"> </span>data <span class="op">%>%</span></a>
|
||||
@ -423,50 +423,48 @@
|
||||
<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>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb14-1" title="1">data <-<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>
|
||||
<a class="sourceLine" id="cb14-2" title="2"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb14-3" title="3"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb14-2" title="2"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-3" title="3"><span class="co">#> Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span></a>
|
||||
<a class="sourceLine" id="cb14-4" title="4"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-5" title="5"><span class="co">#> Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)</span></a>
|
||||
<a class="sourceLine" id="cb14-6" title="6"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-7" title="7"><span class="co">#> EUCAST Clinical Breakpoints (v9.0, 2019)</span></a>
|
||||
<a class="sourceLine" id="cb14-8" title="8"><span class="co">#> Enterobacteriales (Order) (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-9" title="9"><span class="co">#> Staphylococcus (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-10" title="10"><span class="co">#> Enterococcus (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-11" title="11"><span class="co">#> Streptococcus groups A, B, C, G (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-12" title="12"><span class="co">#> Streptococcus pneumoniae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-13" title="13"><span class="co">#> Viridans group streptococci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-14" title="14"><span class="co">#> Haemophilus influenzae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-15" title="15"><span class="co">#> Moraxella catarrhalis (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-16" title="16"><span class="co">#> Anaerobic Gram positives (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-17" title="17"><span class="co">#> Anaerobic Gram negatives (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-18" title="18"><span class="co">#> Pasteurella multocida (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-19" title="19"><span class="co">#> Campylobacter jejuni and C. coli (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-20" title="20"><span class="co">#> Aerococcus sanguinicola and A. urinae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-21" title="21"><span class="co">#> Kingella kingae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-23" title="23"><span class="co">#> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
|
||||
<a class="sourceLine" id="cb14-24" title="24"><span class="co">#> Table 1: Intrinsic resistance in Enterobacteriaceae (1230 changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#> Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-26" title="26"><span class="co">#> Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-27" title="27"><span class="co">#> Table 4: Intrinsic resistance in Gram-positive bacteria (2700 changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-28" title="28"><span class="co">#> Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-29" title="29"><span class="co">#> Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-30" title="30"><span class="co">#> Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-31" title="31"><span class="co">#> Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-32" title="32"><span class="co">#> Table 12: Interpretive rules for aminoglycosides (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-33" title="33"><span class="co">#> Table 13: Interpretive rules for quinolones (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-34" title="34"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-35" title="35"><span class="co">#> Other rules</span></a>
|
||||
<a class="sourceLine" id="cb14-36" title="36"><span class="co">#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-37" title="37"><span class="co">#> Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-38" title="38"><span class="co">#> Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-39" title="39"><span class="co">#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-40" title="40"><span class="co">#> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-42" title="42"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#> => EUCAST rules affected 7,267 out of 20,000 rows</span></a>
|
||||
<a class="sourceLine" id="cb14-44" title="44"><span class="co">#> -> added 0 test results</span></a>
|
||||
<a class="sourceLine" id="cb14-45" title="45"><span class="co">#> -> changed 3,930 test results (0 to S; 0 to I; 3,930 to R)</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb14-5" title="5"><span class="co">#> EUCAST Clinical Breakpoints (v9.0, 2019)</span></a>
|
||||
<a class="sourceLine" id="cb14-6" title="6"><span class="co">#> Enterobacteriales (Order) (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-7" title="7"><span class="co">#> Staphylococcus (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-8" title="8"><span class="co">#> Enterococcus (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-9" title="9"><span class="co">#> Streptococcus groups A, B, C, G (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-10" title="10"><span class="co">#> Streptococcus pneumoniae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-11" title="11"><span class="co">#> Viridans group streptococci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-12" title="12"><span class="co">#> Haemophilus influenzae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-13" title="13"><span class="co">#> Moraxella catarrhalis (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-14" title="14"><span class="co">#> Anaerobic Gram positives (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-15" title="15"><span class="co">#> Anaerobic Gram negatives (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-16" title="16"><span class="co">#> Pasteurella multocida (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-17" title="17"><span class="co">#> Campylobacter jejuni and C. coli (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-18" title="18"><span class="co">#> Aerococcus sanguinicola and A. urinae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-19" title="19"><span class="co">#> Kingella kingae (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-20" title="20"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-21" title="21"><span class="co">#> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
|
||||
<a class="sourceLine" id="cb14-22" title="22"><span class="co">#> Table 1: Intrinsic resistance in Enterobacteriaceae (1291 changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-23" title="23"><span class="co">#> Table 2: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-24" title="24"><span class="co">#> Table 3: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-25" title="25"><span class="co">#> Table 4: Intrinsic resistance in Gram-positive bacteria (2705 changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-26" title="26"><span class="co">#> Table 8: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-27" title="27"><span class="co">#> Table 9: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-28" title="28"><span class="co">#> Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-29" title="29"><span class="co">#> Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-30" title="30"><span class="co">#> Table 12: Interpretive rules for aminoglycosides (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-31" title="31"><span class="co">#> Table 13: Interpretive rules for quinolones (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-32" title="32"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-33" title="33"><span class="co">#> Other rules</span></a>
|
||||
<a class="sourceLine" id="cb14-34" title="34"><span class="co">#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-35" title="35"><span class="co">#> Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-36" title="36"><span class="co">#> Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-37" title="37"><span class="co">#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-38" title="38"><span class="co">#> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-39" title="39"><span class="co">#> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-40" title="40"><span class="co">#> </span></a>
|
||||
<a class="sourceLine" id="cb14-41" title="41"><span class="co">#> => EUCAST rules affected 7,376 out of 20,000 rows</span></a>
|
||||
<a class="sourceLine" id="cb14-42" title="42"><span class="co">#> -> added 0 test results</span></a>
|
||||
<a class="sourceLine" id="cb14-43" title="43"><span class="co">#> -> changed 3,996 test results (0 to S; 0 to I; 3,996 to R)</span></a></code></pre></div>
|
||||
</div>
|
||||
<div id="adding-new-variables" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
@ -475,11 +473,7 @@
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb15-1" title="1">data <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb15-2" title="2"><span class="st"> </span><span class="kw"><a href="https://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>
|
||||
<a class="sourceLine" id="cb15-3" title="3"> <span class="dt">genus =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(bacteria),</a>
|
||||
<a class="sourceLine" id="cb15-4" title="4"> <span class="dt">species =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(bacteria))</a>
|
||||
<a class="sourceLine" id="cb15-5" title="5"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb15-6" title="6"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb15-7" title="7"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb15-8" title="8"><span class="co">#> [1] "is any"</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb15-4" title="4"> <span class="dt">species =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(bacteria))</a></code></pre></div>
|
||||
<div id="first-isolates" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#first-isolates" class="anchor"></a>First isolates</h2>
|
||||
@ -495,8 +489,8 @@
|
||||
<a class="sourceLine" id="cb16-3" title="3"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
|
||||
<a class="sourceLine" id="cb16-4" title="4"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
|
||||
<a class="sourceLine" id="cb16-5" title="5"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
|
||||
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#> => Found 5,663 first isolates (28.3% of total)</span></a></code></pre></div>
|
||||
<p>So only 28.3% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
|
||||
<a class="sourceLine" id="cb16-6" title="6"><span class="co">#> => Found 5,641 first isolates (28.2% of total)</span></a></code></pre></div>
|
||||
<p>So only 28.2% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" title="1">data_1st <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb17-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
|
||||
<p>For future use, the above two syntaxes can be shortened with the <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code> function:</p>
|
||||
@ -522,54 +516,54 @@
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">1</td>
|
||||
<td align="center">2010-04-19</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-01-24</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2</td>
|
||||
<td align="center">2010-08-08</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-03-30</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">3</td>
|
||||
<td align="center">2010-10-31</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-07-21</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</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>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">4</td>
|
||||
<td align="center">2010-11-11</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-09-23</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</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">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">5</td>
|
||||
<td align="center">2011-04-04</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-10-05</td>
|
||||
<td align="center">A4</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>
|
||||
@ -577,8 +571,19 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">6</td>
|
||||
<td align="center">2011-05-22</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-10-26</td>
|
||||
<td align="center">A4</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">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2011-02-03</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -586,47 +591,36 @@
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2011-08-15</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">8</td>
|
||||
<td align="center">2011-08-20</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-02-16</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">9</td>
|
||||
<td align="center">2011-08-25</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-04-19</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">10</td>
|
||||
<td align="center">2011-12-16</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-05-17</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
@ -638,14 +632,12 @@
|
||||
<a class="sourceLine" id="cb19-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb19-3" title="3"><span class="st"> </span><span class="kw"><a href="https://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>
|
||||
<a class="sourceLine" id="cb19-4" title="4"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
|
||||
<a class="sourceLine" id="cb19-5" title="5"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb19-6" title="6"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb19-7" title="7"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
|
||||
<a class="sourceLine" id="cb19-8" title="8"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
|
||||
<a class="sourceLine" id="cb19-9" title="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>
|
||||
<a class="sourceLine" id="cb19-10" title="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>
|
||||
<a class="sourceLine" id="cb19-11" title="11"><span class="co">#> [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
|
||||
<a class="sourceLine" id="cb19-12" title="12"><span class="co">#> => Found 15,865 first weighted isolates (79.3% of total)</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb19-5" title="5"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
|
||||
<a class="sourceLine" id="cb19-6" title="6"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
|
||||
<a class="sourceLine" id="cb19-7" title="7"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
|
||||
<a class="sourceLine" id="cb19-8" title="8"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
|
||||
<a class="sourceLine" id="cb19-9" title="9"><span class="co">#> [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
|
||||
<a class="sourceLine" id="cb19-10" title="10"><span class="co">#> => Found 15,939 first weighted isolates (79.7% of total)</span></a></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">isolate</th>
|
||||
@ -662,11 +654,11 @@
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">1</td>
|
||||
<td align="center">2010-04-19</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-01-24</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
@ -674,46 +666,46 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2</td>
|
||||
<td align="center">2010-08-08</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-03-30</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</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>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">3</td>
|
||||
<td align="center">2010-10-31</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-07-21</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</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">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">4</td>
|
||||
<td align="center">2010-11-11</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-09-23</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</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">FALSE</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">5</td>
|
||||
<td align="center">2011-04-04</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-10-05</td>
|
||||
<td align="center">A4</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>
|
||||
@ -722,47 +714,47 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">6</td>
|
||||
<td align="center">2011-05-22</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2010-10-26</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2011-08-15</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COL</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">FALSE</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2011-02-03</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">8</td>
|
||||
<td align="center">2011-08-20</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-02-16</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">9</td>
|
||||
<td align="center">2011-08-25</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-04-19</td>
|
||||
<td align="center">A4</td>
|
||||
<td align="center">B_ESCHR_COL</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
@ -770,23 +762,23 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">10</td>
|
||||
<td align="center">2011-12-16</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">2011-05-17</td>
|
||||
<td align="center">A4</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">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Instead of 2, now 9 isolates are flagged. In total, 79.3% of all isolates are marked ‘first weighted’ - 51% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
|
||||
<p>Instead of 2, now 8 isolates are flagged. In total, 79.7% of all isolates are marked ‘first weighted’ - 51.5% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
|
||||
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, there’s a shortcut for this new algorithm too:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" title="1">data_1st <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb20-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
|
||||
<p>So we end up with 15,865 isolates for analysis.</p>
|
||||
<p>So we end up with 15,939 isolates for analysis.</p>
|
||||
<p>We can remove unneeded columns:</p>
|
||||
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" title="1">data_1st <-<span class="st"> </span>data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb21-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div>
|
||||
@ -812,28 +804,28 @@
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>2</td>
|
||||
<td align="center">2011-10-29</td>
|
||||
<td align="center">H5</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">B_STRPT_PNE</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">2017-04-12</td>
|
||||
<td align="center">H4</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_STPHY_AUR</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram positive</td>
|
||||
<td align="center">Streptococcus</td>
|
||||
<td align="center">pneumoniae</td>
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">aureus</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>3</td>
|
||||
<td align="center">2013-02-03</td>
|
||||
<td align="center">D7</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">2013-08-17</td>
|
||||
<td align="center">C3</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_STRPT_PNE</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">R</td>
|
||||
<td align="center">M</td>
|
||||
@ -844,24 +836,24 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>4</td>
|
||||
<td align="center">2013-01-14</td>
|
||||
<td align="center">U1</td>
|
||||
<td align="center">Hospital C</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">2015-05-18</td>
|
||||
<td align="center">E9</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_KLBSL_PNE</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
<td align="center">Klebsiella</td>
|
||||
<td align="center">pneumoniae</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>5</td>
|
||||
<td align="center">2010-02-23</td>
|
||||
<td align="center">O7</td>
|
||||
<td align="center">2012-12-26</td>
|
||||
<td align="center">W4</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">B_STPHY_AUR</td>
|
||||
<td align="center">R</td>
|
||||
@ -876,36 +868,36 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>6</td>
|
||||
<td align="center">2010-09-26</td>
|
||||
<td align="center">E6</td>
|
||||
<td align="center">2016-09-28</td>
|
||||
<td align="center">W1</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">B_KLBSL_PNE</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram negative</td>
|
||||
<td align="center">Klebsiella</td>
|
||||
<td align="center">pneumoniae</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>8</td>
|
||||
<td align="center">2017-06-19</td>
|
||||
<td align="center">J3</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_STPHY_AUR</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">M</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">Gram positive</td>
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">aureus</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>7</td>
|
||||
<td align="center">2016-05-04</td>
|
||||
<td align="center">R2</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">F</td>
|
||||
<td align="center">Gram negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Time for the analysis!</p>
|
||||
@ -923,9 +915,9 @@
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb23-1" title="1"><span class="kw"><a href="../reference/freq.html">freq</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/paste">paste</a></span>(data_1st<span class="op">$</span>genus, data_1st<span class="op">$</span>species))</a></code></pre></div>
|
||||
<p>Or can be used like the <code>dplyr</code> way, which is easier readable:</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" title="1">data_1st <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
|
||||
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,865 x 13)</strong></p>
|
||||
<p><strong>Frequency table of <code>genus</code> and <code>species</code> from a <code>data.frame</code> (15,939 x 13)</strong></p>
|
||||
<p>Columns: 2<br>
|
||||
Length: 15,865 (of which NA: 0 = 0.00%)<br>
|
||||
Length: 15,939 (of which NA: 0 = 0.00%)<br>
|
||||
Unique: 4</p>
|
||||
<p>Shortest: 16<br>
|
||||
Longest: 24</p>
|
||||
@ -942,33 +934,33 @@ Longest: 24</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Escherichia coli</td>
|
||||
<td align="right">7,999</td>
|
||||
<td align="right">50.4%</td>
|
||||
<td align="right">7,999</td>
|
||||
<td align="right">50.4%</td>
|
||||
<td align="right">8,055</td>
|
||||
<td align="right">50.5%</td>
|
||||
<td align="right">8,055</td>
|
||||
<td align="right">50.5%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Staphylococcus aureus</td>
|
||||
<td align="right">3,900</td>
|
||||
<td align="right">24.6%</td>
|
||||
<td align="right">11,899</td>
|
||||
<td align="right">75.0%</td>
|
||||
<td align="right">3,886</td>
|
||||
<td align="right">24.4%</td>
|
||||
<td align="right">11,941</td>
|
||||
<td align="right">74.9%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Streptococcus pneumoniae</td>
|
||||
<td align="right">2,453</td>
|
||||
<td align="right">15.5%</td>
|
||||
<td align="right">14,352</td>
|
||||
<td align="right">90.5%</td>
|
||||
<td align="right">2,439</td>
|
||||
<td align="right">15.3%</td>
|
||||
<td align="right">14,380</td>
|
||||
<td align="right">90.2%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Klebsiella pneumoniae</td>
|
||||
<td align="right">1,513</td>
|
||||
<td align="right">9.5%</td>
|
||||
<td align="right">15,865</td>
|
||||
<td align="right">1,559</td>
|
||||
<td align="right">9.8%</td>
|
||||
<td align="right">15,939</td>
|
||||
<td align="right">100.0%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -979,7 +971,7 @@ Longest: 24</p>
|
||||
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
|
||||
<p>The functions <code>portion_R</code>, <code>portion_RI</code>, <code>portion_I</code>, <code>portion_IS</code> and <code>portion_S</code> can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" title="1">data_1st <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_IR</a></span>(amox)</a>
|
||||
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#> [1] 0.4755121</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb25-2" title="2"><span class="co">#> [1] 0.4705439</span></a></code></pre></div>
|
||||
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" title="1">data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb26-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
@ -992,19 +984,19 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">0.4644901</td>
|
||||
<td align="center">0.4616191</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">0.4754156</td>
|
||||
<td align="center">0.4714054</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">0.4927721</td>
|
||||
<td align="center">0.4865089</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">0.4793125</td>
|
||||
<td align="center">0.4703324</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1022,23 +1014,23 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">0.4644901</td>
|
||||
<td align="center">4717</td>
|
||||
<td align="center">0.4616191</td>
|
||||
<td align="center">4768</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">0.4754156</td>
|
||||
<td align="center">5654</td>
|
||||
<td align="center">0.4714054</td>
|
||||
<td align="center">5543</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">0.4927721</td>
|
||||
<td align="center">2352</td>
|
||||
<td align="center">0.4865089</td>
|
||||
<td align="center">2409</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">0.4793125</td>
|
||||
<td align="center">3142</td>
|
||||
<td align="center">0.4703324</td>
|
||||
<td align="center">3219</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1058,27 +1050,27 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">0.7249656</td>
|
||||
<td align="center">0.8993624</td>
|
||||
<td align="center">0.9729966</td>
|
||||
<td align="center">0.7251397</td>
|
||||
<td align="center">0.9020484</td>
|
||||
<td align="center">0.9738051</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Klebsiella</td>
|
||||
<td align="center">0.7336418</td>
|
||||
<td align="center">0.9035030</td>
|
||||
<td align="center">0.9801718</td>
|
||||
<td align="center">0.7305965</td>
|
||||
<td align="center">0.8941629</td>
|
||||
<td align="center">0.9737011</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">0.7261538</td>
|
||||
<td align="center">0.9179487</td>
|
||||
<td align="center">0.9789744</td>
|
||||
<td align="center">0.7174472</td>
|
||||
<td align="center">0.9217705</td>
|
||||
<td align="center">0.9804426</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Streptococcus</td>
|
||||
<td align="center">0.7382797</td>
|
||||
<td align="center">0.7437474</td>
|
||||
<td align="center">0.0000000</td>
|
||||
<td align="center">0.7382797</td>
|
||||
<td align="center">0.7437474</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
@ -231,7 +231,6 @@
|
||||
<p>No errors or warnings, so all values are transformed succesfully. Let’s check it though, with a couple of frequency tables:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="co"># our newly created `mo` variable</span></a>
|
||||
<a class="sourceLine" id="cb4-2" title="2">data <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/freq.html">freq</a></span>(mo, <span class="dt">nmax =</span> <span class="dv">10</span>)</a></code></pre></div>
|
||||
<p>[1] “is any” [1] “is any” [1] “is any”</p>
|
||||
<p><strong>Frequency table of <code>mo</code> from a <code>data.frame</code> (500 x 54)</strong></p>
|
||||
<p>Class: <code>mo</code> (<code>character</code>)<br>
|
||||
Length: 500 (of which NA: 0 = 0.00%)<br>
|
||||
|
@ -218,13 +218,13 @@
|
||||
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> as.mo("sau") 12.7 12.7 22.7 13.2 13.5 71.1 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 87.6 87.8 90.2 87.9 90.6 104.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 12.6 12.6 12.8 12.7 12.8 13.6 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("S. aureus") 24.0 24.2 32.0 24.5 25.4 63.2 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 24.1 24.1 29.3 24.2 24.6 74.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("STAAUR") 12.6 12.7 16.6 12.7 12.8 51.5 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 13.5 13.5 17.9 13.6 14.5 54.5 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#> as.mo("sau") 15.0 15.0 21.8 15.2 15.5 80.5 10</span></a>
|
||||
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#> as.mo("stau") 90.4 90.6 106.0 91.0 92.7 180.0 10</span></a>
|
||||
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#> as.mo("staaur") 15.0 15.1 19.2 15.2 15.7 54.5 10</span></a>
|
||||
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#> as.mo("S. aureus") 26.5 26.6 34.7 26.9 28.1 65.9 10</span></a>
|
||||
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#> as.mo("S. aureus") 26.6 26.7 31.8 26.8 26.9 76.8 10</span></a>
|
||||
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#> as.mo("STAAUR") 15.0 15.1 19.2 15.2 15.5 54.2 10</span></a>
|
||||
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#> as.mo("Staphylococcus aureus") 13.4 13.5 17.7 13.6 14.7 52.1 10</span></a></code></pre></div>
|
||||
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 10 milliseconds means it can determine 100 input values per second. It case of 50 milliseconds, this is only 20 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first is a WHONET code) or common laboratory codes, or common full organism names like the last one.</p>
|
||||
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Mycoplasma leonicaptivi</em> (<code>B_MYCPL_LEO</code>), a bug probably never found before in humans:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">M.leonicaptivi <-<span class="st"> </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>(<span class="st">"myle"</span>),</a>
|
||||
@ -237,13 +237,13 @@
|
||||
<a class="sourceLine" id="cb3-8" title="8"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(M.leonicaptivi, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb3-9" title="9"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("myle") 134 135 144 135 138 184 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("mycleo") 445 458 479 487 493 500 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("M. leonicaptivi") 204 207 224 214 245 248 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("M. leonicaptivi") 205 206 223 208 246 250 10</span></a>
|
||||
<a class="sourceLine" id="cb3-15" title="15"><span class="co">#> as.mo("MYCLEO") 446 448 480 486 492 529 10</span></a>
|
||||
<a class="sourceLine" id="cb3-16" title="16"><span class="co">#> as.mo("Mycoplasma leonicaptivi") 146 149 170 169 191 193 10</span></a></code></pre></div>
|
||||
<p>That takes 9.1 times as much time on average! A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance.</p>
|
||||
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#> as.mo("myle") 136 137 141 137 138 176 10</span></a>
|
||||
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#> as.mo("mycleo") 447 464 484 487 490 551 10</span></a>
|
||||
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#> as.mo("M. leonicaptivi") 206 208 225 210 248 252 10</span></a>
|
||||
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#> as.mo("M. leonicaptivi") 207 208 230 229 251 255 10</span></a>
|
||||
<a class="sourceLine" id="cb3-15" title="15"><span class="co">#> as.mo("MYCLEO") 444 446 462 446 486 487 10</span></a>
|
||||
<a class="sourceLine" id="cb3-16" title="16"><span class="co">#> as.mo("Mycoplasma leonicaptivi") 147 148 170 173 187 192 10</span></a></code></pre></div>
|
||||
<p>That takes 8 times as much time on average! A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance.</p>
|
||||
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Mycoplasma leonicaptivi</em> (which is very uncommon):</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
|
||||
<a class="sourceLine" id="cb4-2" title="2"></a>
|
||||
@ -280,21 +280,11 @@
|
||||
<a class="sourceLine" id="cb5-15" title="15"><span class="co"># now let's see:</span></a>
|
||||
<a class="sourceLine" id="cb5-16" title="16">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(x),</a>
|
||||
<a class="sourceLine" id="cb5-17" title="17"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb5-18" title="18"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-19" title="19"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-20" title="20"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-21" title="21"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-22" title="22"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-23" title="23"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-24" title="24"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-25" title="25"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb5-28" title="28"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb5-29" title="29"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb5-30" title="30"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb5-31" title="31"><span class="co">#> mo_fullname(x) 623 641 708 648 822 864 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!) of 95 unique values only takes 0.65 seconds (647 ms). You only lose time on your unique input values.</p>
|
||||
<a class="sourceLine" id="cb5-18" title="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb5-19" title="19"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb5-20" title="20"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb5-21" title="21"><span class="co">#> mo_fullname(x) 615 647 698 649 801 851 10</span></a></code></pre></div>
|
||||
<p>So transforming 500,000 values (!) of 95 unique values only takes 0.65 seconds (649 ms). You only lose time on your unique input values.</p>
|
||||
</div>
|
||||
<div id="precalculated-results" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
@ -304,22 +294,12 @@
|
||||
<a class="sourceLine" id="cb6-2" title="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"S. aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb6-3" title="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
|
||||
<a class="sourceLine" id="cb6-5" title="5"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-6" title="6"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-11" title="11"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-12" title="12"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-13" title="13"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-14" title="14"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb6-15" title="15"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb6-16" title="16"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb6-17" title="17"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb6-18" title="18"><span class="co">#> A 6.500 6.590 6.710 6.680 6.870 6.900 10</span></a>
|
||||
<a class="sourceLine" id="cb6-19" title="19"><span class="co">#> B 24.900 25.000 25.300 25.300 25.500 25.800 10</span></a>
|
||||
<a class="sourceLine" id="cb6-20" title="20"><span class="co">#> C 0.259 0.383 0.387 0.395 0.411 0.564 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb6-5" title="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb6-6" title="6"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#> A 6.420 6.570 6.670 6.730 6.760 6.780 10</span></a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#> B 27.100 27.200 28.000 27.600 27.800 32.900 10</span></a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#> C 0.255 0.383 0.394 0.412 0.431 0.527 10</span></a></code></pre></div>
|
||||
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0004 seconds - it doesn’t even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
|
||||
<a class="sourceLine" id="cb7-2" title="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
|
||||
@ -333,14 +313,14 @@
|
||||
<a class="sourceLine" id="cb7-10" title="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
|
||||
<a class="sourceLine" id="cb7-11" title="11"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb7-12" title="12"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.304 0.337 0.393 0.396 0.440 0.513 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.297 0.304 0.348 0.349 0.380 0.409 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.312 0.361 0.428 0.427 0.513 0.527 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.242 0.254 0.302 0.298 0.328 0.414 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.243 0.296 0.325 0.328 0.348 0.431 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.237 0.257 0.302 0.322 0.329 0.343 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.242 0.260 0.306 0.325 0.341 0.345 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.244 0.283 0.322 0.335 0.360 0.375 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#> A 0.311 0.355 0.435 0.437 0.492 0.566 10</span></a>
|
||||
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#> B 0.283 0.299 0.340 0.337 0.362 0.411 10</span></a>
|
||||
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#> C 0.393 0.447 0.503 0.496 0.566 0.662 10</span></a>
|
||||
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#> D 0.253 0.288 0.324 0.305 0.325 0.523 10</span></a>
|
||||
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#> E 0.243 0.249 0.315 0.288 0.342 0.506 10</span></a>
|
||||
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#> F 0.239 0.295 0.349 0.327 0.411 0.482 10</span></a>
|
||||
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#> G 0.249 0.323 0.364 0.347 0.410 0.493 10</span></a>
|
||||
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#> H 0.226 0.303 0.368 0.339 0.478 0.523 10</span></a></code></pre></div>
|
||||
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
|
||||
</div>
|
||||
<div id="results-in-other-languages" class="section level3">
|
||||
@ -367,13 +347,13 @@
|
||||
<a class="sourceLine" id="cb8-18" title="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
|
||||
<a class="sourceLine" id="cb8-19" title="19"><span class="co">#> Unit: milliseconds</span></a>
|
||||
<a class="sourceLine" id="cb8-20" title="20"><span class="co">#> expr min lq mean median uq max neval</span></a>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 14.72 14.90 15.64 15.22 15.27 20.60 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 23.41 23.59 27.01 23.69 23.77 57.27 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 23.40 23.58 23.80 23.72 23.83 24.46 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 23.18 24.35 37.51 24.80 57.35 58.29 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 23.26 23.47 27.11 23.68 24.14 57.07 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 23.37 23.65 27.05 23.76 23.80 57.26 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 23.34 23.47 24.02 23.70 23.86 26.79 10</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#> en 17.14 17.39 20.87 17.54 17.93 50.49 10</span></a>
|
||||
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#> de 25.94 26.02 32.71 26.11 26.24 59.33 10</span></a>
|
||||
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#> nl 25.41 25.86 29.47 26.04 27.08 59.40 10</span></a>
|
||||
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#> es 25.55 25.97 32.75 26.11 26.77 59.62 10</span></a>
|
||||
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#> it 25.65 25.90 26.07 26.09 26.11 26.75 10</span></a>
|
||||
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#> fr 25.47 25.79 26.10 26.09 26.20 27.23 10</span></a>
|
||||
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#> pt 25.72 25.85 29.33 26.07 26.09 59.41 10</span></a></code></pre></div>
|
||||
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
@ -305,9 +305,7 @@
|
||||
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%>%</span></a>
|
||||
<a class="sourceLine" id="cb8-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
|
||||
<a class="sourceLine" id="cb8-5" title="5"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb8-6" title="6"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb8-7" title="7"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb8-5" title="5"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
|
||||
<p>Vancomycin resistance could be 100% in ten years, but might also stay around 0%.</p>
|
||||
<p>You can define the model with the <code>model</code> parameter. The default model is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.</p>
|
||||
@ -352,9 +350,7 @@
|
||||
<a class="sourceLine" id="cb9-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%>%</span></a>
|
||||
<a class="sourceLine" id="cb9-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb9-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
|
||||
<a class="sourceLine" id="cb9-5" title="5"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb9-6" title="6"><span class="co">#> [1] "is any"</span></a>
|
||||
<a class="sourceLine" id="cb9-7" title="7"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb9-5" title="5"><span class="co">#> </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
|
||||
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
|
||||
<p>This seems more likely, doesn’t it?</p>
|
||||
<p>The model itself is also available from the object, as an <code>attribute</code>:</p>
|
||||
|