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

1311 lines
98 KiB
HTML
Raw Permalink Normal View History

2022-08-21 16:59:35 +02:00
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>How to conduct AMR data analysis • AMR (for R)</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
2023-12-03 01:14:24 +01:00
<link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
2024-04-05 16:58:51 +02:00
<script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/Lato-0.4.9/font.css" rel="stylesheet">
<link href="../deps/Fira_Code-0.4.9/font.css" rel="stylesheet">
2024-11-21 10:17:08 +01:00
<link href="../deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet">
<link href="../deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet">
2024-07-16 15:00:55 +02:00
<script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
2022-08-21 16:59:35 +02:00
<script src="../extra.js"></script><meta property="og:title" content="How to conduct AMR data analysis">
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
2024-07-16 15:00:55 +02:00
<nav class="navbar navbar-expand-lg fixed-top bg-primary" data-bs-theme="dark" aria-label="Site navigation"><div class="container">
2022-08-21 16:59:35 +02:00
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
2024-12-20 11:03:24 +01:00
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.1.1.9122</small>
2024-07-16 15:00:55 +02:00
2022-08-21 16:59:35 +02:00
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="active nav-item dropdown">
2024-07-16 15:00:55 +02:00
<button class="nav-link dropdown-toggle" type="button" id="dropdown-how-to" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"><span class="fa fa-question-circle"></span> How to</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-how-to">
<li><a class="dropdown-item" href="../articles/AMR.html"><span class="fa fa-directions"></span> Conduct AMR Analysis</a></li>
<li><a class="dropdown-item" href="../reference/antibiogram.html"><span class="fa fa-file-prescription"></span> Generate Antibiogram (Trad./Syndromic/WISCA)</a></li>
<li><a class="dropdown-item" href="../articles/resistance_predict.html"><span class="fa fa-dice"></span> Predict Antimicrobial Resistance</a></li>
<li><a class="dropdown-item" href="../articles/datasets.html"><span class="fa fa-database"></span> Download Data Sets for Own Use</a></li>
2024-12-19 20:25:10 +01:00
<li><a class="dropdown-item" href="../articles/AMR_with_tidymodels.html"><span class="fa fa-square-root-variable"></span> Use AMR for Predictive Modelling (tidymodels)</a></li>
2024-07-16 15:00:55 +02:00
<li><a class="dropdown-item" href="../reference/AMR-options.html"><span class="fa fa-gear"></span> Set User- Or Team-specific Package Settings</a></li>
<li><a class="dropdown-item" href="../articles/PCA.html"><span class="fa fa-compress"></span> Conduct Principal Component Analysis for AMR</a></li>
<li><a class="dropdown-item" href="../articles/MDR.html"><span class="fa fa-skull-crossbones"></span> Determine Multi-Drug Resistance (MDR)</a></li>
<li><a class="dropdown-item" href="../articles/WHONET.html"><span class="fa fa-globe-americas"></span> Work with WHONET Data</a></li>
<li><a class="dropdown-item" href="../articles/EUCAST.html"><span class="fa fa-exchange-alt"></span> Apply Eucast Rules</a></li>
<li><a class="dropdown-item" href="../reference/mo_property.html"><span class="fa fa-bug"></span> Get Taxonomy of a Microorganism</a></li>
<li><a class="dropdown-item" href="../reference/ab_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antibiotic Drug</a></li>
<li><a class="dropdown-item" href="../reference/av_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antiviral Drug</a></li>
</ul>
2022-08-21 16:59:35 +02:00
</li>
2024-09-30 22:12:21 +02:00
<li class="nav-item"><a class="nav-link" href="../articles/AMR_for_Python.html"><span class="fa fab fa-python"></span> AMR for Python</a></li>
2024-07-16 15:00:55 +02:00
<li class="nav-item"><a class="nav-link" href="../reference/index.html"><span class="fa fa-book-open"></span> Manual</a></li>
<li class="nav-item"><a class="nav-link" href="../authors.html"><span class="fa fa-users"></span> Authors</a></li>
2023-05-24 16:03:18 +02:00
</ul>
2024-07-16 15:00:55 +02:00
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="../news/index.html"><span class="fa far fa-newspaper"></span> Changelog</a></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/msberends/AMR"><span class="fa fab fa-github"></span> Source Code</a></li>
2022-08-21 16:59:35 +02:00
</ul>
</div>
2024-07-16 15:00:55 +02:00
2022-08-21 16:59:35 +02:00
</div>
</nav><div class="container template-article">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="../logo.svg" class="logo" alt=""><h1>How to conduct AMR data analysis</h1>
2024-07-16 15:00:55 +02:00
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/main/vignettes/AMR.Rmd" class="external-link"><code>vignettes/AMR.Rmd</code></a></small>
2022-08-21 16:59:35 +02:00
<div class="d-none name"><code>AMR.Rmd</code></div>
</div>
2022-10-29 14:24:08 +02:00
<p><strong>Note:</strong> values on this page will change with every
website update since they are based on randomly created values and the
page was written in <a href="https://rmarkdown.rstudio.com/" class="external-link">R
Markdown</a>. However, the methodology remains unchanged. This page was
2024-12-20 11:03:24 +01:00
generated on 20 December 2024.</p>
2022-08-21 16:59:35 +02:00
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
2022-10-29 14:24:08 +02:00
<p>Conducting AMR data analysis unfortunately requires in-depth
knowledge from different scientific fields, which makes it hard to do
right. At least, it requires:</p>
2022-08-21 16:59:35 +02:00
<ul>
2023-02-26 21:34:01 +01:00
<li>Good questions (always start with those!) and reliable data</li>
2022-10-29 14:24:08 +02:00
<li>A thorough understanding of (clinical) epidemiology, to understand
the clinical and epidemiological relevance and possible bias of
results</li>
<li>A thorough understanding of (clinical) microbiology/infectious
diseases, to understand which microorganisms are causal to which
infections and the implications of pharmaceutical treatment, as well as
understanding intrinsic and acquired microbial resistance</li>
<li>Experience with data analysis with microbiological tests and their
results, to understand the determination and limitations of MIC values
2023-01-21 23:53:21 +01:00
and their interpretations to SIR values</li>
2022-10-29 14:24:08 +02:00
<li>Availability of the biological taxonomy of microorganisms and
probably normalisation factors for pharmaceuticals, such as defined
daily doses (DDD)</li>
<li>Available (inter-)national guidelines, and profound methods to apply
them</li>
2022-08-21 16:59:35 +02:00
</ul>
2022-10-29 14:24:08 +02:00
<p>Of course, we cannot instantly provide you with knowledge and
experience. But with this <code>AMR</code> package, we aimed at
providing (1) tools to simplify antimicrobial resistance data cleaning,
transformation and analysis, (2) methods to easily incorporate
international guidelines and (3) scientifically reliable reference data,
including the requirements mentioned above.</p>
<p>The <code>AMR</code> package enables standardised and reproducible
AMR data analysis, with the application of evidence-based rules,
determination of first isolates, translation of various codes for
microorganisms and antimicrobial agents, determination of (multi-drug)
resistant microorganisms, and calculation of antimicrobial resistance,
prevalence and future trends.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level2">
<h2 id="preparation">Preparation<a class="anchor" aria-label="anchor" href="#preparation"></a>
</h2>
2022-10-29 14:24:08 +02:00
<p>For this tutorial, we will create fake demonstration data to work
with.</p>
<p>You can skip to <a href="#cleaning-the-data">Cleaning the data</a> if
you already have your own data ready. If you start your analysis, try to
make the structure of your data generally look like this:</p>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
<th align="center">date</th>
<th align="center">patient_id</th>
<th align="center">mo</th>
<th align="center">AMX</th>
<th align="center">CIP</th>
</tr></thead>
<tbody>
<tr class="odd">
2024-12-20 11:03:24 +01:00
<td align="center">2024-12-20</td>
2022-08-21 16:59:35 +02:00
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
2024-12-20 11:03:24 +01:00
<td align="center">2024-12-20</td>
2022-08-21 16:59:35 +02:00
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
2024-12-20 11:03:24 +01:00
<td align="center">2024-12-20</td>
2022-08-21 16:59:35 +02:00
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">S</td>
</tr>
</tbody>
</table>
<div class="section level3">
<h3 id="needed-r-packages">Needed R packages<a class="anchor" aria-label="anchor" href="#needed-r-packages"></a>
</h3>
2022-10-29 14:24:08 +02:00
<p>As with many uses in R, we need some additional packages for AMR data
analysis. Our package works closely together with the <a href="https://www.tidyverse.org" class="external-link">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/" class="external-link"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org" class="external-link"><code>ggplot2</code></a> by
RStudio. The tidyverse tremendously improves the way we conduct data
science - it allows for a very natural way of writing syntaxes and
creating beautiful plots in R.</p>
<p>We will also use the <code>cleaner</code> package, that can be used
for cleaning data and creating frequency tables.</p>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
2024-12-19 20:25:10 +01:00
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span></span></code></pre></div>
<p>Error in get(paste0(generic, “.”, class), envir = get_method_env()) :
object type_sum.accel not found</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://msberends.github.io/AMR/">AMR</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># (if not yet installed, install with:)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># install.packages(c("dplyr", "ggplot2", "AMR"))</span></span></code></pre></div>
<p>The <code>AMR</code> package contains a data set
<code>example_isolates_unclean</code>, which might look data that users
have extracted from their laboratory systems:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">example_isolates_unclean</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 3,000 × 8</span></span></span>
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 E. coli R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 K. pneumoniae R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 E. coli S I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 E. coli S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 S. aureus R S R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> J8 A 2016-06-14 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> M3 A 2015-10-25 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> J3 A 2019-06-19 E. coli S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> G6 A 2015-04-27 S. aureus S S S S </span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># 2,990 more rows</span></span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># we will use 'our_data' as the data set name for this tutorial</span></span>
<span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">example_isolates_unclean</span></span></code></pre></div>
<p>For AMR data analysis, we would like the microorganism column to
contain valid, up-to-date taxonomy, and the antibiotic columns to be
cleaned as SIR values as well.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="taxonomy-of-microorganisms">Taxonomy of microorganisms<a class="anchor" aria-label="anchor" href="#taxonomy-of-microorganisms"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>With <code><a href="../reference/as.mo.html">as.mo()</a></code>, users can transform arbitrary
microorganism names or codes to current taxonomy. The <code>AMR</code>
package contains up-to-date taxonomic data. To be specific, currently
2024-07-16 15:00:55 +02:00
included data were retrieved on 24 Jun 2024.</p>
2023-02-26 21:34:01 +01:00
<p>The codes of the AMR packages that come from <code><a href="../reference/as.mo.html">as.mo()</a></code> are
short, but still human readable. More importantly, <code><a href="../reference/as.mo.html">as.mo()</a></code>
supports all kinds of input:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"Klebsiella pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; Class 'mo'</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span>
<span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; Class 'mo'</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span>
<span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"KLEPNE"</span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; Class 'mo'</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span>
<span><span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="st">"KLPN"</span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; Class 'mo'</span></span>
2023-05-26 16:18:12 +02:00
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
<p>The first character in above codes denote their taxonomic kingdom,
such as Bacteria (B), Fungi (F), and Protozoa (P).</p>
<p>The <code>AMR</code> package also contain functions to directly
retrieve taxonomic properties, such as the name, genus, species, family,
order, and even Gram-stain. They all start with <code>mo_</code> and
they use <code><a href="../reference/as.mo.html">as.mo()</a></code> internally, so that still any arbitrary
user input can be used:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/mo_property.html">mo_family</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] "Enterobacteriaceae"</span></span>
<span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "Klebsiella"</span></span>
<span><span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "pneumoniae"</span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="st">"Klebsiella pneumoniae"</span><span class="op">)</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] "Gram-negative"</span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="fu"><a href="../reference/mo_property.html">mo_ref</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; [1] "Trevisan, 1887"</span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="fu"><a href="../reference/mo_property.html">mo_snomed</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [[1]]</span></span>
<span><span class="co">#&gt; [1] "1098101000112102" "446870005" "1098201000112108" "409801009" </span></span>
<span><span class="co">#&gt; [5] "56415008" "714315002" "713926009"</span></span></code></pre></div>
<p>Now we can thus clean our data:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data</span><span class="op">$</span><span class="va">bacteria</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">our_data</span><span class="op">$</span><span class="va">bacteria</span>, info <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">#&gt; Microorganism translation was uncertain for four microorganisms. Run</span></span>
<span><span class="co">#&gt; mo_uncertainties() to review these uncertainties, or use</span></span>
<span><span class="co">#&gt; add_custom_microorganisms() to add custom entries.</span></span></code></pre></div>
<p>Apparently, there was some uncertainty about the translation to
taxonomic codes. Lets check this:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/as.mo.html">mo_uncertainties</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; Matching scores are based on the resemblance between the input and the full</span></span>
<span><span class="co">#&gt; taxonomic name, and the pathogenicity in humans. See ?mo_matching_score.</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; "E. coli" -&gt; Escherichia coli (B_ESCHR_COLI, 0.688)</span></span>
<span><span class="co">#&gt; Also matched: Enterococcus crotali (0.650), Escherichia coli coli</span></span>
2024-10-06 16:35:11 +02:00
<span><span class="co">#&gt; (0.643), Escherichia coli expressing (0.611), Enterobacter cowanii</span></span>
<span><span class="co">#&gt; (0.600), Enterococcus columbae (0.595), Enterococcus camelliae (0.591),</span></span>
<span><span class="co">#&gt; Enterococcus casseliflavus (0.577), Enterobacter cloacae cloacae</span></span>
<span><span class="co">#&gt; (0.571), Enterobacter cloacae complex (0.571), and Enterobacter cloacae</span></span>
<span><span class="co">#&gt; dissolvens (0.565)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
<span><span class="co">#&gt; "K. pneumoniae" -&gt; Klebsiella pneumoniae (B_KLBSL_PNMN, 0.786)</span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; Also matched: Klebsiella pneumoniae ozaenae (0.707), Klebsiella</span></span>
<span><span class="co">#&gt; pneumoniae pneumoniae (0.688), Klebsiella pneumoniae rhinoscleromatis</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; (0.658), Klebsiella pasteurii (0.500), Klebsiella planticola (0.500),</span></span>
<span><span class="co">#&gt; Kingella potus (0.400), Kluyveromyces pseudotropicale (0.386),</span></span>
<span><span class="co">#&gt; Kluyveromyces pseudotropicalis (0.363), Kosakonia pseudosacchari</span></span>
<span><span class="co">#&gt; (0.361), and Kluyveromyces pseudotropicalis pseudotropicalis (0.361)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; "S. aureus" -&gt; Staphylococcus aureus (B_STPHY_AURS, 0.690)</span></span>
<span><span class="co">#&gt; Also matched: Staphylococcus aureus aureus (0.643), Staphylococcus</span></span>
<span><span class="co">#&gt; argenteus (0.625), Staphylococcus aureus anaerobius (0.625),</span></span>
<span><span class="co">#&gt; Staphylococcus auricularis (0.615), Salmonella Aurelianis (0.595),</span></span>
<span><span class="co">#&gt; Salmonella Aarhus (0.588), Salmonella Amounderness (0.587),</span></span>
<span><span class="co">#&gt; Staphylococcus argensis (0.587), Streptococcus australis (0.587), and</span></span>
<span><span class="co">#&gt; Salmonella choleraesuis arizonae (0.562)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; "S. pneumoniae" -&gt; Streptococcus pneumoniae (B_STRPT_PNMN, 0.750)</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; Also matched: Streptococcus pseudopneumoniae (0.700), Streptococcus</span></span>
2024-10-06 16:35:11 +02:00
<span><span class="co">#&gt; phocae salmonis (0.552), Serratia proteamaculans quinovora (0.545),</span></span>
<span><span class="co">#&gt; Streptococcus pseudoporcinus (0.536), Staphylococcus piscifermentans</span></span>
<span><span class="co">#&gt; (0.533), Staphylococcus pseudintermedius (0.532), Serratia</span></span>
<span><span class="co">#&gt; proteamaculans proteamaculans (0.526), Streptococcus gallolyticus</span></span>
<span><span class="co">#&gt; pasteurianus (0.526), Salmonella Portanigra (0.524), and Streptococcus</span></span>
<span><span class="co">#&gt; periodonticum (0.519)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Only the first 10 other matches of each record are shown. Run</span></span>
<span><span class="co">#&gt; print(mo_uncertainties(), n = ...) to view more entries, or save</span></span>
<span><span class="co">#&gt; mo_uncertainties() to an object.</span></span></code></pre></div>
<p>Thats all good.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="antibiotic-results">Antibiotic results<a class="anchor" aria-label="anchor" href="#antibiotic-results"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>The column with antibiotic test results must also be cleaned. The
<code>AMR</code> package comes with three new data types to work with
such test results: <code>mic</code> for minimal inhibitory
concentrations (MIC), <code>disk</code> for disk diffusion diameters,
and <code>sir</code> for SIR data that have been interpreted already.
This package can also determine SIR values based on MIC or disk
diffusion values, read more about that on the <code><a href="../reference/as.sir.html">as.sir()</a></code>
page.</p>
<p>For now, we will just clean the SIR columns in our data using
dplyr:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="co"># method 1, be explicit about the columns:</span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2024-12-19 20:25:10 +01:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_at</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/vars.html" class="external-link">vars</a></span><span class="op">(</span><span class="va">AMX</span><span class="op">:</span><span class="va">GEN</span><span class="op">)</span>, <span class="va">as.sir</span><span class="op">)</span></span>
2022-08-21 16:59:35 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># method 2, let the AMR package determine the eligible columns</span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_if</a></span><span class="op">(</span><span class="va">is_sir_eligible</span>, <span class="va">as.sir</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># result:</span></span>
<span><span class="va">our_data</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 3,000 × 8</span></span></span>
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 B_ESCHR_COLI R I S S </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 B_KLBSL_PNMN R I S S </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 B_ESCHR_COLI S I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 B_ESCHR_COLI S S S S </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 B_STPHY_AURS R S R S </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> J8 A 2016-06-14 B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> M3 A 2015-10-25 B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> J3 A 2019-06-19 B_ESCHR_COLI S S S S </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> G6 A 2015-04-27 B_STPHY_AURS S S S S </span></span>
2023-04-14 11:23:10 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># 2,990 more rows</span></span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
<p>This is basically it for the cleaning, time to start the data
inclusion.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
<h3 id="first-isolates">First isolates<a class="anchor" aria-label="anchor" href="#first-isolates"></a>
</h3>
2023-02-26 21:34:01 +01:00
<p>We need to know which isolates we can <em>actually</em> use for
analysis without repetition bias.</p>
2022-10-29 14:24:08 +02:00
<p>To conduct an analysis of antimicrobial resistance, you must <a href="https:/pubmed.ncbi.nlm.nih.gov/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" class="external-link">selection
bias</a>.</p>
<p>The Clinical and Laboratory Standards Institute (CLSI) appoints this
as follows:</p>
2022-08-21 16:59:35 +02:00
<blockquote>
2022-10-29 14:24:08 +02:00
<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><a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="external-link">M39-A4
Analysis and Presentation of Cumulative Antimicrobial Susceptibility
Test Data, 4th Edition. CLSI, 2014. Chapter 6.4</a></p>
2022-08-21 16:59:35 +02:00
</blockquote>
2022-10-29 14:24:08 +02:00
<p>This <code>AMR</code> package includes this methodology with the
<code><a href="../reference/first_isolate.html">first_isolate()</a></code> function and is able to apply the four
different methods as defined by <a href="https://academic.oup.com/cid/article/44/6/867/364325" class="external-link">Hindler
<em>et al.</em> in 2007</a>: phenotype-based, episode-based,
patient-based, isolate-based. The right method depends on your goals and
analysis, but the default phenotype-based method is in any case the
2023-02-26 21:34:01 +01:00
method to properly correct for most duplicate isolates. Read more about
the methods on the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> page.</p>
2022-08-21 16:59:35 +02:00
<p>The outcome of the function can easily be added to our data:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2022-08-21 16:59:35 +02:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>first <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span>info <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></span>
2023-05-17 22:20:27 +02:00
<span><span class="co">#&gt; Determining first isolates using an episode length of 365 days</span></span>
2023-02-18 13:17:35 +01:00
<span><span class="co">#&gt; Using column 'bacteria' as input for col_mo.</span></span>
<span><span class="co">#&gt; Using column 'date' as input for col_date.</span></span>
<span><span class="co">#&gt; Using column 'patient_id' as input for col_patient_id.</span></span>
2023-05-17 22:20:27 +02:00
<span><span class="co">#&gt; Basing inclusion on all antimicrobial results, using a points threshold</span></span>
<span><span class="co">#&gt; of 2</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; =&gt; Found 2,724 'phenotype-based' first isolates (90.8% of total where a</span></span>
2023-10-20 15:01:19 +02:00
<span><span class="co">#&gt; microbial ID was available)</span></span></code></pre></div>
2024-10-02 10:29:15 +02:00
<p>So only 91% is suitable for resistance analysis! We can now filter on
2023-02-26 21:34:01 +01:00
it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter()</a></code> function, also from the
2022-10-29 14:24:08 +02:00
<code>dplyr</code> package:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2022-08-21 16:59:35 +02:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="va">first</span> <span class="op">==</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<p>For future use, the above two syntaxes can be shortened:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-08 17:01:47 +01:00
<span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
2024-10-02 10:29:15 +02:00
<p>So we end up with 2 724 isolates for analysis. Now our data looks
2022-10-29 14:24:08 +02:00
like:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 9</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN first</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 B_ESCHR_COLI R I S S TRUE </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 B_KLBSL_PNMN R I S S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 B_ESCHR_COLI R S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 B_ESCHR_COLI S I S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 B_STPHY_AURS R S R S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> M3 A 2015-10-25 B_ESCHR_COLI R S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> J3 A 2019-06-19 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> G6 A 2015-04-27 B_STPHY_AURS S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> P4 A 2011-06-21 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,714 more rows</span></span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
<p>Time for the analysis.</p>
</div>
</div>
<div class="section level2">
<h2 id="analysing-the-data">Analysing the data<a class="anchor" aria-label="anchor" href="#analysing-the-data"></a>
</h2>
<p>The base R <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code> function gives a good first
impression, as it comes with support for the new <code>mo</code> and
<code>sir</code> classes that we now have in our data set:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">our_data_1st</span><span class="op">)</span></span>
<span><span class="co">#&gt; patient_id hospital date </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; Length:2724 Length:2724 Min. :2011-01-01 </span></span>
<span><span class="co">#&gt; Class :character Class :character 1st Qu.:2013-04-07 </span></span>
<span><span class="co">#&gt; Mode :character Mode :character Median :2015-06-03 </span></span>
<span><span class="co">#&gt; Mean :2015-06-09 </span></span>
<span><span class="co">#&gt; 3rd Qu.:2017-08-11 </span></span>
<span><span class="co">#&gt; Max. :2019-12-27 </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; bacteria AMX AMC </span></span>
<span><span class="co">#&gt; Class :mo Class:sir Class:sir </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; &lt;NA&gt; :0 %S :41.6% (n=1133) %S :52.6% (n=1432) </span></span>
<span><span class="co">#&gt; Unique:4 %SDD : 0.0% (n=0) %SDD : 0.0% (n=0) </span></span>
<span><span class="co">#&gt; #1 :B_ESCHR_COLI %I :16.4% (n=446) %I :12.2% (n=333) </span></span>
<span><span class="co">#&gt; #2 :B_STPHY_AURS %R :42.0% (n=1145) %R :35.2% (n=959) </span></span>
<span><span class="co">#&gt; #3 :B_STRPT_PNMN %NI : 0.0% (n=0) %NI : 0.0% (n=0) </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; CIP GEN first </span></span>
<span><span class="co">#&gt; Class:sir Class:sir Mode:logical </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; %S :52.5% (n=1431) %S :61.0% (n=1661) TRUE:2724 </span></span>
2024-06-10 10:40:19 +02:00
<span><span class="co">#&gt; %SDD : 0.0% (n=0) %SDD : 0.0% (n=0) </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; %I : 6.5% (n=176) %I : 3.0% (n=82) </span></span>
<span><span class="co">#&gt; %R :41.0% (n=1117) %R :36.0% (n=981) </span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; %NI : 0.0% (n=0) %NI : 0.0% (n=0)</span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="fu"><a href="https://pillar.r-lib.org/reference/glimpse.html" class="external-link">glimpse</a></span><span class="op">(</span><span class="va">our_data_1st</span><span class="op">)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; Rows: 2,724</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; Columns: 9</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; $ patient_id <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> "J3", "R7", "P3", "P10", "B7", "W3", "M3", "J3", "G6", "P4"…</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; $ hospital <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",…</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; $ date <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> 2012-11-21, 2018-04-03, 2014-09-19, 2015-12-10, 2015-03-02…</span></span>
<span><span class="co">#&gt; $ bacteria <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> "B_ESCHR_COLI", "B_KLBSL_PNMN", "B_ESCHR_COLI", "B_ESCHR_COL…</span></span>
<span><span class="co">#&gt; $ AMX <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> R, R, R, S, S, R, R, S, S, S, S, R, S, S, R, R, R, R, S, R,…</span></span>
<span><span class="co">#&gt; $ AMC <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> I, I, S, I, S, S, S, S, S, S, S, S, S, S, S, S, S, R, S, S,…</span></span>
<span><span class="co">#&gt; $ CIP <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> S, S, S, S, S, R, S, S, S, S, S, S, S, S, S, S, S, S, S, S,…</span></span>
<span><span class="co">#&gt; $ GEN <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> S, S, S, S, S, S, S, S, S, S, S, R, S, S, S, S, S, S, S, S,…</span></span>
2024-07-16 15:00:55 +02:00
<span><span class="co">#&gt; $ first <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,…</span></span>
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># number of unique values per column:</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">sapply</a></span><span class="op">(</span><span class="va">our_data_1st</span>, <span class="va">n_distinct</span><span class="op">)</span></span>
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; 260 3 1854 4 3 3 3 </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; GEN first </span></span>
<span><span class="co">#&gt; 3 1</span></span></code></pre></div>
<div class="section level3">
<h3 id="availability-of-species">Availability of species<a class="anchor" aria-label="anchor" href="#availability-of-species"></a>
</h3>
<p>To just get an idea how the species are distributed, create a
frequency table with <code><a href="../reference/count.html">count()</a></code> based on the name of the
microorganisms:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
2023-03-11 14:32:27 +01:00
<code class="sourceCode R"><span><span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="../reference/count.html">count</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">bacteria</span><span class="op">)</span>, sort <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 4 × 2</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; `mo_name(bacteria)` n</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;int&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Escherichia coli <span style="text-decoration: underline;">1</span>518</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Staphylococcus aureus 730</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> Streptococcus pneumoniae 426</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> Klebsiella pneumoniae 326</span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="../reference/count.html">count</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">bacteria</span><span class="op">)</span>, sort <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 4 × 2</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; `mo_name(bacteria)` n</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;int&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Escherichia coli <span style="text-decoration: underline;">1</span>321</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Staphylococcus aureus 682</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> Streptococcus pneumoniae 402</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> Klebsiella pneumoniae 319</span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
</div>
<div class="section level3">
<h3 id="select-and-filter-with-antibiotic-selectors">Select and filter with antibiotic selectors<a class="anchor" aria-label="anchor" href="#select-and-filter-with-antibiotic-selectors"></a>
</h3>
<p>Using so-called antibiotic class selectors, you can select or filter
columns based on the antibiotic class that your antibiotic results are
in:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">date</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; For aminoglycosides() using column 'GEN' (gentamicin)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 2</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; date GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2012-11-21 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2018-04-03 S </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2014-09-19 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2015-12-10 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2015-03-02 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2018-03-31 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2015-10-25 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2019-06-19 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2015-04-27 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2011-06-21 S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,714 more rows</span></span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">bacteria</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">betalactams</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'</span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 3</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; bacteria AMX AMC </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI R I </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> B_KLBSL_PNMN R I </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B_ESCHR_COLI R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> B_ESCHR_COLI S I </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> B_STPHY_AURS R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> B_ESCHR_COLI R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_STPHY_AURS S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,714 more rows</span></span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">bacteria</span>, <span class="fu"><a href="https://tidyselect.r-lib.org/reference/where.html" class="external-link">where</a></span><span class="op">(</span><span class="va">is.sir</span><span class="op">)</span><span class="op">)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 5</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; bacteria AMX AMC CIP GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI R I S S </span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> B_KLBSL_PNMN R I S S </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> B_ESCHR_COLI S I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> B_STPHY_AURS R S R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_STPHY_AURS S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,714 more rows</span></span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># filtering using AB selectors is also possible:</span></span>
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/any.html" class="external-link">any</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; For aminoglycosides() using column 'GEN' (gentamicin)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 981 × 9</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN first</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span></span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J5 A 2017-12-25 B_STRPT_PNMN R S S R TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> X1 A 2017-07-04 B_STPHY_AURS R S S R TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B3 A 2016-07-24 B_ESCHR_COLI S S S R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> V7 A 2012-04-03 B_ESCHR_COLI S S S R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> C9 A 2017-03-23 B_ESCHR_COLI S S S R TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> R1 A 2018-06-10 B_STPHY_AURS S S S R TRUE </span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> S2 A 2013-07-19 B_STRPT_PNMN S S S R TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> P5 A 2019-03-09 B_STPHY_AURS S S S R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> Q8 A 2019-08-10 B_STPHY_AURS S S S R TRUE </span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> K5 A 2013-03-15 B_STRPT_PNMN S S S R TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># 971 more rows</span></span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/all.html" class="external-link">all</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">betalactams</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'</span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 462 × 9</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN first</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span></span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> M7 A 2013-07-22 B_STRPT_PNMN R R S S TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 B_STPHY_AURS R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 B_STPHY_AURS R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 B_STPHY_AURS R R S S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 B_ESCHR_COLI R R R R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE </span></span>
2023-10-20 15:01:19 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 B_STRPT_PNMN R R R S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 B_ESCHR_COLI R R S R TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 B_STPHY_AURS R R S S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># 452 more rows</span></span></span>
2024-07-16 15:00:55 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># even works in base R (since R 3.0):</span></span>
<span><span class="va">our_data_1st</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/all.html" class="external-link">all</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">betalactams</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="st">"R"</span><span class="op">)</span>, <span class="op">]</span></span>
<span><span class="co">#&gt; For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'</span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 462 × 9</span></span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN first</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span></span></span>
2023-05-26 19:31:22 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> M7 A 2013-07-22 B_STRPT_PNMN R R S S TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 B_STPHY_AURS R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 B_STPHY_AURS R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 B_STPHY_AURS R R S S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 B_ESCHR_COLI R R R R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE </span></span>
2023-10-20 15:01:19 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 B_STRPT_PNMN R R R S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 B_ESCHR_COLI R R S R TRUE </span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 B_STPHY_AURS R R S S TRUE </span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #949494;"># 452 more rows</span></span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
</div>
<div class="section level3">
<h3 id="generate-antibiograms">Generate antibiograms<a class="anchor" aria-label="anchor" href="#generate-antibiograms"></a>
</h3>
2023-04-21 10:16:10 +02:00
<p>Since AMR v2.0 (March 2023), it is very easy to create different
types of antibiograms, with support for 20 different languages.</p>
<p>There are four antibiogram types, as proposed by Klinker <em>et
al.</em> (2021, <a href="https://doi.org/10.1177/20499361211011373" class="external-link">DOI
10.1177/20499361211011373</a>), and they are all supported by the new
<code><a href="../reference/antibiogram.html">antibiogram()</a></code> function:</p>
<ol style="list-style-type: decimal">
<li>
<strong>Traditional Antibiogram (TA)</strong> e.g, for the
susceptibility of <em>Pseudomonas aeruginosa</em> to
piperacillin/tazobactam (TZP)</li>
<li>
<strong>Combination Antibiogram (CA)</strong> e.g, for the
sdditional susceptibility of <em>Pseudomonas aeruginosa</em> to TZP +
tobramycin versus TZP alone</li>
<li>
<strong>Syndromic Antibiogram (SA)</strong> e.g, for the
susceptibility of <em>Pseudomonas aeruginosa</em> to TZP among
respiratory specimens (obtained among ICU patients only)</li>
<li>
<strong>Weighted-Incidence Syndromic Combination Antibiogram
(WISCA)</strong> e.g, for the susceptibility of <em>Pseudomonas
aeruginosa</em> to TZP among respiratory specimens (obtained among ICU
patients only) for male patients age &gt;=65 years with heart
failure</li>
</ol>
<p>In this section, we show how to use the <code><a href="../reference/antibiogram.html">antibiogram()</a></code>
function to create any of the above antibiogram types. For starters,
this is what the included <code>example_isolates</code> data set looks
like:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="va">example_isolates</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,000 × 46</span></span></span>
<span><span class="co">#&gt; date patient age gender ward mo PEN OXA FLC AMX </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 1,990 more rows</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># TOB &lt;sir&gt;, AMK &lt;sir&gt;, KAN &lt;sir&gt;, TMP &lt;sir&gt;, SXT &lt;sir&gt;, NIT &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># FOS &lt;sir&gt;, LNZ &lt;sir&gt;, CIP &lt;sir&gt;, MFX &lt;sir&gt;, VAN &lt;sir&gt;, TEC &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># TCY &lt;sir&gt;, TGC &lt;sir&gt;, DOX &lt;sir&gt;, ERY &lt;sir&gt;, CLI &lt;sir&gt;, AZM &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># IPM &lt;sir&gt;, MEM &lt;sir&gt;, MTR &lt;sir&gt;, CHL &lt;sir&gt;, COL &lt;sir&gt;, MUP &lt;sir&gt;, …</span></span></span></code></pre></div>
<div class="section level4">
<h4 id="traditional-antibiogram">Traditional Antibiogram<a class="anchor" aria-label="anchor" href="#traditional-antibiogram"></a>
</h4>
<p>To create a traditional antibiogram, simply state which antibiotics
should be used. The <code>antibiotics</code> argument in the
<code><a href="../reference/antibiogram.html">antibiogram()</a></code> function supports any (combination) of the
previously mentioned antibiotic class selectors:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
2024-12-13 09:54:23 +01:00
<span><span class="co">#&gt; The function aminoglycosides() should be used inside a dplyr verb or</span></span>
<span><span class="co">#&gt; data.frame call, e.g.:</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(column_a, column_b, aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% filter(any(aminoglycosides() == "R"))</span></span>
<span><span class="co">#&gt; • your_data[, aminoglycosides()]</span></span>
<span><span class="co">#&gt; • your_data[, c("column_a", "column_b", aminoglycosides())]</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Now returning a vector of all possible antimicrobials that</span></span>
<span><span class="co">#&gt; aminoglycosides() can select.</span></span>
<span><span class="co">#&gt; The function carbapenems() should be used inside a dplyr verb or</span></span>
<span><span class="co">#&gt; data.frame call, e.g.:</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(carbapenems())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(column_a, column_b, carbapenems())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% filter(any(carbapenems() == "R"))</span></span>
<span><span class="co">#&gt; • your_data[, carbapenems()]</span></span>
<span><span class="co">#&gt; • your_data[, c("column_a", "column_b", carbapenems())]</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Now returning a vector of all possible antimicrobials that carbapenems()</span></span>
<span><span class="co">#&gt; can select.</span></span></code></pre></div>
2023-02-24 17:15:07 +01:00
<table class="table">
2024-09-22 11:55:27 +02:00
<colgroup>
<col width="16%">
<col width="14%">
<col width="13%">
<col width="14%">
<col width="10%">
<col width="14%">
<col width="13%">
</colgroup>
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2024-09-22 11:55:27 +02:00
<th align="left">Pathogen</th>
<th align="left">Amikacin</th>
<th align="left">Gentamicin</th>
<th align="left">Imipenem</th>
<th align="left">Kanamycin</th>
<th align="left">Meropenem</th>
<th align="left">Tobramycin</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left">CoNS</td>
<td align="left">0% (0/43)</td>
<td align="left">86% (267/309)</td>
<td align="left">52% (25/48)</td>
<td align="left">0% (0/43)</td>
<td align="left">52% (25/48)</td>
<td align="left">22% (12/55)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>E. coli</em></td>
<td align="left">100% (171/171)</td>
<td align="left">98% (451/460)</td>
<td align="left">100% (422/422)</td>
<td align="left"></td>
<td align="left">100% (418/418)</td>
<td align="left">97% (450/462)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>E. faecalis</em></td>
<td align="left">0% (0/39)</td>
<td align="left">0% (0/39)</td>
<td align="left">100% (38/38)</td>
<td align="left">0% (0/39)</td>
<td align="left"></td>
<td align="left">0% (0/39)</td>
2023-02-13 17:04:12 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>K. pneumoniae</em></td>
<td align="left"></td>
<td align="left">90% (52/58)</td>
<td align="left">100% (51/51)</td>
<td align="left"></td>
<td align="left">100% (53/53)</td>
<td align="left">90% (52/58)</td>
2023-02-22 16:34:03 +01:00
</tr>
2023-02-24 20:02:09 +01:00
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>P. aeruginosa</em></td>
<td align="left"></td>
<td align="left">100% (30/30)</td>
<td align="left"></td>
<td align="left">0% (0/30)</td>
<td align="left"></td>
<td align="left">100% (30/30)</td>
2022-12-27 16:14:41 +01:00
</tr>
2023-02-24 20:02:09 +01:00
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>P. mirabilis</em></td>
<td align="left"></td>
<td align="left">94% (32/34)</td>
<td align="left">94% (30/32)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">94% (32/34)</td>
2023-02-24 17:15:07 +01:00
</tr>
2022-08-21 16:59:35 +02:00
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. aureus</em></td>
<td align="left"></td>
<td align="left">99% (231/233)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">98% (84/86)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. epidermidis</em></td>
<td align="left">0% (0/44)</td>
<td align="left">79% (128/163)</td>
<td align="left"></td>
<td align="left">0% (0/44)</td>
<td align="left"></td>
<td align="left">51% (45/89)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. hominis</em></td>
<td align="left"></td>
<td align="left">92% (74/80)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">85% (53/62)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. pneumoniae</em></td>
<td align="left">0% (0/117)</td>
<td align="left">0% (0/117)</td>
<td align="left"></td>
<td align="left">0% (0/117)</td>
<td align="left"></td>
<td align="left">0% (0/117)</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-04-21 10:16:10 +02:00
<p>Notice that the <code><a href="../reference/antibiogram.html">antibiogram()</a></code> function automatically
prints in the right format when using Quarto or R Markdown (such as this
page), and even applies italics for taxonomic names (by using
<code><a href="../reference/italicise_taxonomy.html">italicise_taxonomy()</a></code> internally).</p>
<p>It also uses the language of your OS if this is either English,
Chinese, Czech, Danish, Dutch, Finnish, French, German, Greek, Italian,
Japanese, Norwegian, Polish, Portuguese, Romanian, Russian, Spanish,
Swedish, Turkish, or Ukrainian. In this next example, we force the
language to be Spanish using the <code>language</code> argument:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> mo_transform <span class="op">=</span> <span class="st">"gramstain"</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="../reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>,</span>
<span> ab_transform <span class="op">=</span> <span class="st">"name"</span>,</span>
<span> language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span></span>
2024-12-13 09:54:23 +01:00
<span><span class="co">#&gt; The function aminoglycosides() should be used inside a dplyr verb or</span></span>
<span><span class="co">#&gt; data.frame call, e.g.:</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(column_a, column_b, aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% filter(any(aminoglycosides() == "R"))</span></span>
<span><span class="co">#&gt; • your_data[, aminoglycosides()]</span></span>
<span><span class="co">#&gt; • your_data[, c("column_a", "column_b", aminoglycosides())]</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Now returning a vector of all possible antimicrobials that</span></span>
<span><span class="co">#&gt; aminoglycosides() can select.</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<colgroup>
2024-09-22 11:55:27 +02:00
<col width="20%">
<col width="20%">
<col width="22%">
<col width="16%">
<col width="20%">
2022-08-21 16:59:35 +02:00
</colgroup>
<thead><tr class="header">
2024-09-22 11:55:27 +02:00
<th align="left">Patógeno</th>
<th align="left">Amikacina</th>
<th align="left">Gentamicina</th>
<th align="left">Kanamicina</th>
<th align="left">Tobramicina</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left">Gram negativo</td>
<td align="left">98% (251/256)</td>
<td align="left">96% (659/684)</td>
<td align="left">0% (0/35)</td>
<td align="left">96% (658/686)</td>
2022-11-10 22:16:02 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left">Gram positivo</td>
<td align="left">0% (0/436)</td>
<td align="left">63% (740/1170)</td>
<td align="left">0% (0/436)</td>
<td align="left">34% (228/665)</td>
2023-01-12 11:42:13 +01:00
</tr>
2022-08-21 16:59:35 +02:00
</tbody>
</table>
2023-04-21 10:16:10 +02:00
</div>
<div class="section level4">
<h4 id="combined-antibiogram">Combined Antibiogram<a class="anchor" aria-label="anchor" href="#combined-antibiogram"></a>
</h4>
<p>To create a combined antibiogram, use antibiotic codes or names with
a plus <code>+</code> character like this:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"TZP"</span>, <span class="st">"TZP+TOB"</span>, <span class="st">"TZP+GEN"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
2024-09-22 11:55:27 +02:00
<colgroup>
<col width="14%">
<col width="20%">
<col width="32%">
<col width="32%">
</colgroup>
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2024-09-22 11:55:27 +02:00
<th align="left">Pathogen</th>
<th align="left">Piperacillin/tazobactam</th>
<th align="left">Piperacillin/tazobactam + Gentamicin</th>
<th align="left">Piperacillin/tazobactam + Tobramycin</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left">CoNS</td>
<td align="left">30% (10/33)</td>
<td align="left">97% (267/274)</td>
<td align="left"></td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>E. coli</em></td>
<td align="left">94% (393/416)</td>
<td align="left">100% (457/459)</td>
<td align="left">99% (455/461)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>K. pneumoniae</em></td>
<td align="left">89% (47/53)</td>
<td align="left">93% (54/58)</td>
<td align="left">93% (54/58)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>P. aeruginosa</em></td>
<td align="left"></td>
<td align="left">100% (30/30)</td>
<td align="left">100% (30/30)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>P. mirabilis</em></td>
<td align="left"></td>
<td align="left">100% (34/34)</td>
<td align="left">100% (34/34)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. aureus</em></td>
<td align="left"></td>
<td align="left">100% (231/231)</td>
<td align="left">100% (91/91)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. epidermidis</em></td>
<td align="left"></td>
<td align="left">100% (128/128)</td>
<td align="left">100% (46/46)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="even">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. hominis</em></td>
<td align="left"></td>
<td align="left">100% (74/74)</td>
<td align="left">100% (53/53)</td>
2023-04-21 10:16:10 +02:00
</tr>
<tr class="odd">
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. pneumoniae</em></td>
<td align="left">100% (112/112)</td>
<td align="left">100% (112/112)</td>
<td align="left">100% (112/112)</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-04-21 10:16:10 +02:00
</div>
<div class="section level4">
<h4 id="syndromic-antibiogram">Syndromic Antibiogram<a class="anchor" aria-label="anchor" href="#syndromic-antibiogram"></a>
</h4>
<p>To create a syndromic antibiogram, the <code>syndromic_group</code>
argument must be used. This can be any column in the data, or e.g. an
<code><a href="https://rdrr.io/r/base/ifelse.html" class="external-link">ifelse()</a></code> with calculations based on certain columns:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu"><a href="../reference/antibiotic_class_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="../reference/antibiotic_class_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,</span>
<span> syndromic_group <span class="op">=</span> <span class="st">"ward"</span><span class="op">)</span></span>
2024-12-13 09:54:23 +01:00
<span><span class="co">#&gt; The function aminoglycosides() should be used inside a dplyr verb or</span></span>
<span><span class="co">#&gt; data.frame call, e.g.:</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(column_a, column_b, aminoglycosides())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% filter(any(aminoglycosides() == "R"))</span></span>
<span><span class="co">#&gt; • your_data[, aminoglycosides()]</span></span>
<span><span class="co">#&gt; • your_data[, c("column_a", "column_b", aminoglycosides())]</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Now returning a vector of all possible antimicrobials that</span></span>
<span><span class="co">#&gt; aminoglycosides() can select.</span></span>
<span><span class="co">#&gt; The function carbapenems() should be used inside a dplyr verb or</span></span>
<span><span class="co">#&gt; data.frame call, e.g.:</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(carbapenems())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% select(column_a, column_b, carbapenems())</span></span>
<span><span class="co">#&gt; • your_data %&gt;% filter(any(carbapenems() == "R"))</span></span>
<span><span class="co">#&gt; • your_data[, carbapenems()]</span></span>
<span><span class="co">#&gt; • your_data[, c("column_a", "column_b", carbapenems())]</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Now returning a vector of all possible antimicrobials that carbapenems()</span></span>
<span><span class="co">#&gt; can select.</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
2023-04-21 10:16:10 +02:00
<colgroup>
2024-09-22 11:55:27 +02:00
<col width="13%">
<col width="14%">
<col width="12%">
<col width="12%">
<col width="12%">
<col width="8%">
<col width="12%">
<col width="12%">
2023-04-21 10:16:10 +02:00
</colgroup>
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Syndromic Group</th>
2024-09-22 11:55:27 +02:00
<th align="left">Pathogen</th>
<th align="left">Amikacin</th>
<th align="left">Gentamicin</th>
<th align="left">Imipenem</th>
<th align="left">Kanamycin</th>
<th align="left">Meropenem</th>
<th align="left">Tobramycin</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left">CoNS</td>
<td align="left"></td>
<td align="left">89% (183/205)</td>
<td align="left">57% (20/35)</td>
<td align="left"></td>
<td align="left">57% (20/35)</td>
<td align="left">26% (8/31)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">ICU</td>
2024-09-22 11:55:27 +02:00
<td align="left">CoNS</td>
<td align="left"></td>
<td align="left">79% (58/73)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">Outpatient</td>
2024-09-22 11:55:27 +02:00
<td align="left">CoNS</td>
<td align="left"></td>
<td align="left">84% (26/31)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>E. coli</em></td>
<td align="left">100% (104/104)</td>
<td align="left">98% (291/297)</td>
<td align="left">100% (266/266)</td>
<td align="left"></td>
<td align="left">100% (276/276)</td>
<td align="left">98% (293/299)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">ICU</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>E. coli</em></td>
<td align="left">100% (52/52)</td>
<td align="left">99% (135/137)</td>
<td align="left">100% (133/133)</td>
<td align="left"></td>
<td align="left">100% (118/118)</td>
<td align="left">96% (132/137)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>K. pneumoniae</em></td>
<td align="left"></td>
<td align="left">92% (47/51)</td>
<td align="left">100% (44/44)</td>
<td align="left"></td>
<td align="left">100% (46/46)</td>
<td align="left">92% (47/51)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>P. mirabilis</em></td>
<td align="left"></td>
<td align="left">100% (30/30)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">100% (30/30)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. aureus</em></td>
<td align="left"></td>
<td align="left">99% (148/150)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">97% (61/63)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">ICU</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. aureus</em></td>
<td align="left"></td>
<td align="left">100% (66/66)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. epidermidis</em></td>
<td align="left"></td>
<td align="left">82% (65/79)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">55% (24/44)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">ICU</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. epidermidis</em></td>
<td align="left"></td>
<td align="left">72% (54/75)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">41% (17/41)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. hominis</em></td>
<td align="left"></td>
<td align="left">96% (43/45)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">94% (29/31)</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">Clinical</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. pneumoniae</em></td>
<td align="left">0% (0/78)</td>
<td align="left">0% (0/78)</td>
<td align="left"></td>
<td align="left">0% (0/78)</td>
<td align="left"></td>
<td align="left">0% (0/78)</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">ICU</td>
2024-09-22 11:55:27 +02:00
<td align="left"><em>S. pneumoniae</em></td>
<td align="left">0% (0/30)</td>
<td align="left">0% (0/30)</td>
<td align="left"></td>
<td align="left">0% (0/30)</td>
<td align="left"></td>
<td align="left">0% (0/30)</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-04-21 10:16:10 +02:00
</div>
<div class="section level4">
<h4 id="weighted-incidence-syndromic-combination-antibiogram-wisca">Weighted-Incidence Syndromic Combination Antibiogram (WISCA)<a class="anchor" aria-label="anchor" href="#weighted-incidence-syndromic-combination-antibiogram-wisca"></a>
</h4>
<p>To create a WISCA, you must state combination therapy in the
<code>antibiotics</code> argument (similar to the Combination
Antibiogram), define a syndromic group with the
<code>syndromic_group</code> argument (similar to the Syndromic
Antibiogram) in which cases are predefined based on clinical or
demographic characteristics (e.g., endocarditis in 75+ females). This
next example is a simplification without clinical characteristics, but
just gives an idea of how a WISCA can be created:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
2023-04-21 10:16:10 +02:00
<code class="sourceCode R"><span><span class="va">wisca</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"AMC"</span>, <span class="st">"AMC+CIP"</span>, <span class="st">"TZP"</span>, <span class="st">"TZP+TOB"</span><span class="op">)</span>,</span>
<span> mo_transform <span class="op">=</span> <span class="st">"gramstain"</span>,</span>
<span> minimum <span class="op">=</span> <span class="fl">10</span>, <span class="co"># this should be &gt;= 30, but now just as example</span></span>
<span> syndromic_group <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/ifelse.html" class="external-link">ifelse</a></span><span class="op">(</span><span class="va">example_isolates</span><span class="op">$</span><span class="va">age</span> <span class="op">&gt;=</span> <span class="fl">65</span> <span class="op">&amp;</span></span>
<span> <span class="va">example_isolates</span><span class="op">$</span><span class="va">gender</span> <span class="op">==</span> <span class="st">"M"</span>,</span>
<span> <span class="st">"WISCA Group 1"</span>, <span class="st">"WISCA Group 2"</span><span class="op">)</span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="va">wisca</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
2023-04-21 10:16:10 +02:00
<colgroup>
2024-09-22 11:55:27 +02:00
<col width="9%">
<col width="8%">
<col width="17%">
<col width="26%">
2023-04-21 10:16:10 +02:00
<col width="14%">
2024-09-22 11:55:27 +02:00
<col width="22%">
2023-04-21 10:16:10 +02:00
</colgroup>
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Syndromic Group</th>
2024-09-22 11:55:27 +02:00
<th align="left">Pathogen</th>
<th align="left">Amoxicillin/clavulanic acid</th>
<th align="left">Amoxicillin/clavulanic acid + Ciprofloxacin</th>
<th align="left">Piperacillin/tazobactam</th>
<th align="left">Piperacillin/tazobactam + Tobramycin</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">WISCA Group 1</td>
2024-09-22 11:55:27 +02:00
<td align="left">Gram-negative</td>
<td align="left">76% (216/285)</td>
<td align="left">95% (270/284)</td>
<td align="left">89% (231/261)</td>
<td align="left">99% (270/274)</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">WISCA Group 2</td>
2024-09-22 11:55:27 +02:00
<td align="left">Gram-negative</td>
<td align="left">76% (336/441)</td>
<td align="left">98% (432/442)</td>
<td align="left">88% (334/380)</td>
<td align="left">98% (409/419)</td>
2023-02-26 21:34:01 +01:00
</tr>
2023-04-19 00:44:09 +02:00
<tr class="odd">
2023-04-21 10:16:10 +02:00
<td align="left">WISCA Group 1</td>
2024-09-22 11:55:27 +02:00
<td align="left">Gram-positive</td>
<td align="left">76% (310/406)</td>
<td align="left">89% (347/392)</td>
<td align="left">81% (100/123)</td>
<td align="left">95% (184/193)</td>
2023-04-19 00:44:09 +02:00
</tr>
2023-02-26 21:34:01 +01:00
<tr class="even">
2023-04-21 10:16:10 +02:00
<td align="left">WISCA Group 2</td>
2024-09-22 11:55:27 +02:00
<td align="left">Gram-positive</td>
<td align="left">76% (556/732)</td>
<td align="left">89% (617/695)</td>
<td align="left">88% (196/222)</td>
<td align="left">95% (340/357)</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-04-21 10:16:10 +02:00
</div>
<div class="section level4">
<h4 id="plotting-antibiograms">Plotting antibiograms<a class="anchor" aria-label="anchor" href="#plotting-antibiograms"></a>
</h4>
2023-02-26 21:34:01 +01:00
<p>Antibiograms can be plotted using <code><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot()</a></code> from the
2023-04-21 10:16:10 +02:00
<code>ggplot2</code> packages, since this <code>AMR</code> package
provides an extension to that function:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot</a></span><span class="op">(</span><span class="va">wisca</span><span class="op">)</span></span></code></pre></div>
2023-04-21 10:16:10 +02:00
<p><img src="AMR_files/figure-html/unnamed-chunk-10-1.png" width="720"></p>
2023-02-26 21:34:01 +01:00
<p>To calculate antimicrobial resistance in a more sensible way, also by
correcting for too few results, we use the <code><a href="../reference/proportion.html">resistance()</a></code> and
<code><a href="../reference/proportion.html">susceptibility()</a></code> functions.</p>
2022-08-21 16:59:35 +02:00
</div>
2023-04-21 10:16:10 +02:00
</div>
2022-08-21 16:59:35 +02:00
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="resistance-percentages">Resistance percentages<a class="anchor" aria-label="anchor" href="#resistance-percentages"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>The functions <code><a href="../reference/proportion.html">resistance()</a></code> and
<code><a href="../reference/proportion.html">susceptibility()</a></code> can be used to calculate antimicrobial
resistance or susceptibility. For more specific analyses, the functions
<code><a href="../reference/proportion.html">proportion_S()</a></code>, <code><a href="../reference/proportion.html">proportion_SI()</a></code>,
<code><a href="../reference/proportion.html">proportion_I()</a></code>, <code><a href="../reference/proportion.html">proportion_IR()</a></code> and
<code><a href="../reference/proportion.html">proportion_R()</a></code> can be used to determine the proportion of a
specific antimicrobial outcome.</p>
<p>All these functions contain a <code>minimum</code> argument, denoting
the minimum required number of test results for returning a value. These
functions will otherwise return <code>NA</code>. The default is
<code>minimum = 30</code>, following the <a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="external-link">CLSI
M39-A4 guideline</a> for applying microbial epidemiology.</p>
<p>As per the EUCAST guideline of 2019, we calculate resistance as the
proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to
<code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and
I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to
<code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their
own:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="../reference/proportion.html">resistance</a></span><span class="op">(</span><span class="va">AMX</span><span class="op">)</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; [1] 0.4203377</span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
<p>Or can be used in conjunction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by()</a></code> and
<code><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
2024-12-19 20:25:10 +01:00
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html" class="external-link">group_by</a></span><span class="op">(</span><span class="va">hospital</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></span><span class="op">(</span>amoxicillin <span class="op">=</span> <span class="fu"><a href="../reference/proportion.html">resistance</a></span><span class="op">(</span><span class="va">AMX</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 3 × 2</span></span></span>
<span><span class="co">#&gt; hospital amoxicillin</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span></span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> A 0.340</span></span>
2024-09-30 19:20:49 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> B 0.551</span></span>
2024-10-02 10:29:15 +02:00
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> C 0.370</span></span></code></pre></div>
2023-02-18 13:17:35 +01:00
<hr>
2023-02-26 21:34:01 +01:00
<p><em>Author: Dr. Matthijs Berends, 26th Feb 2023</em></p>
2022-08-21 16:59:35 +02:00
</div>
</div>
2024-07-16 15:00:55 +02:00
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
2022-08-21 16:59:35 +02:00
</nav></aside>
</div>
<footer><div class="pkgdown-footer-left">
2024-04-23 10:39:01 +02:00
<p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="pkgdown-footer-right">
2024-09-19 14:48:19 +02:00
<p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_umcg.svg" style="max-width: 150px;"></a></p>
2022-08-21 16:59:35 +02:00
</div>
</footer>
</div>
2024-07-16 15:00:55 +02:00
2022-08-21 16:59:35 +02:00
</body>
</html>