1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 07:26:13 +01:00
AMR/articles/AMR.html
github-actions dba1186b76 cli-147-2111
2024-06-19 13:47:27 +00:00

1413 lines
99 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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">
<meta name="description" content="AMR">
<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">
<link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
<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">
<!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- bootstrap-toc --><script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@v1.0.1/dist/bootstrap-toc.min.js" integrity="sha256-4veVQbu7//Lk5TSmc7YV48MxtMy98e26cf5MrgZYnwo=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js" integrity="sha512-7O5pXpc0oCRrxk8RUfDYFgn0nO1t+jLuIOQdOMRp4APB7uZ4vSjspzp5y6YDtDs4VzUSTbWzBFZ/LKJhnyFOKw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- search --><script src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.js" integrity="sha512-zv6Ywkjyktsohkbp9bb45V6tEMoWhzFzXis+LrMehmJZZSys19Yxf1dopHx7WzIKxr5tK2dVcYmaCk2uqdjF4A==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.jquery.min.js" integrity="sha512-GU9ayf+66Xx2TmpxqJpliWbT5PiGYxpaG8rfnBEk1LL8l1KGkRShhngwdXK1UgqhAzWpZHSiYPc09/NwDQIGyg==" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js" integrity="sha512-5CYOlHXGh6QpOFA/TeTylKLWfB3ftPsde7AnmhuitiTX4K5SqCLBeKro6sPS8ilsz1Q4NRx3v8Ko2IBiszzdww==" crossorigin="anonymous"></script><!-- pkgdown --><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script><meta property="og:title" content="How to conduct AMR data analysis">
<meta property="og:description" content="AMR">
<meta property="og:image" content="https://msberends.github.io/AMR/logo.svg">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@msberends">
<meta name="twitter:site" content="@msberends">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar fixed-top navbar-dark navbar-expand-lg bg-primary" data-bs-theme="dark"><div class="container">
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.1.1.9061</small>
<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">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown--how-to">
<span class="fa fa-question-circle"></span>
How to
</a>
<div class="dropdown-menu" aria-labelledby="dropdown--how-to">
<a class="dropdown-item" href="../articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR Analysis
</a>
<a class="dropdown-item" href="../reference/antibiogram.html">
<span class="fa fa-file-prescription"></span>
Generate Antibiogram (Trad./Syndromic/WISCA)
</a>
<a class="dropdown-item" href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
Predict Antimicrobial Resistance
</a>
<a class="dropdown-item" href="../articles/datasets.html">
<span class="fa fa-database"></span>
Download Data Sets for Own Use
</a>
<a class="dropdown-item" href="../reference/AMR-options.html">
<span class="fa fa-gear"></span>
Set User- Or Team-specific Package Settings
</a>
<a class="dropdown-item" href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct Principal Component Analysis for AMR
</a>
<a class="dropdown-item" href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
Determine Multi-Drug Resistance (MDR)
</a>
<a class="dropdown-item" href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
Work with WHONET Data
</a>
<a class="dropdown-item" href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
Apply Eucast Rules
</a>
<a class="dropdown-item" href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
Get Taxonomy of a Microorganism
</a>
<a class="dropdown-item" href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get Properties of an Antibiotic Drug
</a>
<a class="dropdown-item" href="../reference/av_property.html">
<span class="fa fa-capsules"></span>
Get Properties of an Antiviral Drug
</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" id="dropdown--with-other-pkgs">
<span class="fa fa-layer-group"></span>
With other pkgs
</a>
<div class="dropdown-menu" aria-labelledby="dropdown--with-other-pkgs">
<a class="dropdown-item" href="../articles/other_pkg.html">
<span class="fa fa-layer-group"></span>
AMR &amp; dplyr/tidyverse
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
<span class="fa fa-layer-group"></span>
AMR &amp; data.table
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
<span class="fa fa-layer-group"></span>
AMR &amp; tidymodels
</a>
<a class="dropdown-item" href="../articles/other_pkg.html">
<span class="fa fa-layer-group"></span>
AMR &amp; base R
</a>
</div>
</li>
<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>
</ul>
<form class="form-inline my-2 my-lg-0" role="search">
<input type="search" class="form-control me-sm-2" aria-label="Toggle navigation" name="search-input" data-search-index="../search.json" id="search-input" placeholder="Search for" autocomplete="off">
</form>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="../news/index.html">
<span class="far 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="fab fa fab fa-github"></span>
Source Code
</a>
</li>
</ul>
</div>
</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>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/HEAD/vignettes/AMR.Rmd" class="external-link"><code>vignettes/AMR.Rmd</code></a></small>
<div class="d-none name"><code>AMR.Rmd</code></div>
</div>
<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
generated on 19 June 2024.</p>
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
<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>
<ul>
<li>Good questions (always start with those!) and reliable data</li>
<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
and their interpretations to SIR values</li>
<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>
</ul>
<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>
</div>
<div class="section level2">
<h2 id="preparation">Preparation<a class="anchor" aria-label="anchor" href="#preparation"></a>
</h2>
<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>
<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">
<td align="center">2024-06-19</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2024-06-19</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2024-06-19</td>
<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>
<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>
<div class="sourceCode" id="cb1"><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://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span></span>
<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>
<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>
<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>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,990 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
</div>
<div class="section level3">
<h3 id="taxonomy-of-microorganisms">Taxonomy of microorganisms<a class="anchor" aria-label="anchor" href="#taxonomy-of-microorganisms"></a>
</h3>
<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
included data were retrieved on 11 Dec 2022.</p>
<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>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<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">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; Class 'mo'</span></span>
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<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">"KLEPNE"</span><span class="op">)</span></span>
<span><span class="co">#&gt; Class 'mo'</span></span>
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<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">"KLPN"</span><span class="op">)</span></span>
<span><span class="co">#&gt; Class 'mo'</span></span>
<span><span class="co">#&gt; [1] B_KLBSL_PNMN</span></span></code></pre></div>
<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>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; [1] "Enterobacteriaceae"</span></span></code></pre></div>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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></code></pre></div>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; [1] "Gram-negative"</span></span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; [1] "Trevisan, 1887"</span></span></code></pre></div>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<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>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; "E. coli" -&gt; Escherichia coli (B_ESCHR_COLI, 0.688)</span></span>
<span><span class="co">#&gt; Also matched: Enterobacter cowanii (0.600), Eubacterium combesii</span></span>
<span><span class="co">#&gt; (0.600), Eggerthia catenaformis (0.591), Eubacterium callanderi</span></span>
<span><span class="co">#&gt; (0.591), Enterocloster citroniae (0.587), Eubacterium cylindroides</span></span>
<span><span class="co">#&gt; (0.583), Enterococcus casseliflavus (0.577), Enterobacter cloacae</span></span>
<span><span class="co">#&gt; cloacae (0.571), Enterobacter cloacae complex (0.571), and Ehrlichia</span></span>
<span><span class="co">#&gt; canis (0.567)</span></span>
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
<span><span class="co">#&gt; "K. pneumoniae" -&gt; Klebsiella pneumoniae (B_KLBSL_PNMN, 0.786)</span></span>
<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>
<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), Kosakonia pseudosacchari (0.361), Kaistella</span></span>
<span><span class="co">#&gt; palustris (0.333), Kocuria palustris (0.333), and Kocuria pelophila</span></span>
<span><span class="co">#&gt; (0.333)</span></span>
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
<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), Salmonella</span></span>
<span><span class="co">#&gt; Aurelianis (0.595), Salmonella Aarhus (0.588), Salmonella Amounderness</span></span>
<span><span class="co">#&gt; (0.587), Selenomonas artemidis (0.571), Salmonella choleraesuis</span></span>
<span><span class="co">#&gt; arizonae (0.562), Streptococcus anginosus anginosus (0.561), and</span></span>
<span><span class="co">#&gt; Salmonella Abaetetuba (0.548)</span></span>
<span><span class="co">#&gt; --------------------------------------------------------------------------------</span></span>
<span><span class="co">#&gt; "S. pneumoniae" -&gt; Streptococcus pneumoniae (B_STRPT_PNMN, 0.750)</span></span>
<span><span class="co">#&gt; Also matched: Streptococcus pseudopneumoniae (0.700), Serratia</span></span>
<span><span class="co">#&gt; proteamaculans quinovora (0.545), Streptococcus pseudoporcinus (0.536),</span></span>
<span><span class="co">#&gt; Staphylococcus pseudintermedius (0.532), Serratia proteamaculans</span></span>
<span><span class="co">#&gt; proteamaculans (0.526), Salmonella Portanigra (0.524), Sphingomonas</span></span>
<span><span class="co">#&gt; paucimobilis (0.520), Streptococcus pluranimalium (0.519),</span></span>
<span><span class="co">#&gt; Streptococcus constellatus pharyngis (0.514), and Salmonella Pakistan</span></span>
<span><span class="co">#&gt; (0.500)</span></span>
<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>
</div>
<div class="section level3">
<h3 id="antibiotic-results">Antibiotic results<a class="anchor" aria-label="anchor" href="#antibiotic-results"></a>
</h3>
<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>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># method 1, be explicit about the columns:</span></span>
<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>
<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://dplyr.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>
<span></span>
<span><span class="co"># method 2, let the AMR package determine the eligible columns</span></span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,990 more rows</span></span></span></code></pre></div>
<p>This is basically it for the cleaning, time to start the data
inclusion.</p>
</div>
<div class="section level3">
<h3 id="first-isolates">First isolates<a class="anchor" aria-label="anchor" href="#first-isolates"></a>
</h3>
<p>We need to know which isolates we can <em>actually</em> use for
analysis without repetition bias.</p>
<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>
<blockquote>
<p><em>(…) When preparing a cumulative antibiogram to guide clinical
decisions about empirical antimicrobial therapy of initial infections,
<strong>only the first isolate of a given species per patient, per
analysis period (eg, one year) should be included, irrespective of body
site, antimicrobial susceptibility profile, or other phenotypical
characteristics (eg, biotype)</strong>. The first isolate is easily
identified, and cumulative antimicrobial susceptibility test data
prepared using the first isolate are generally comparable to cumulative
antimicrobial susceptibility test data calculated by other methods,
providing duplicate isolates are excluded.</em> <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>
</blockquote>
<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
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>
<p>The outcome of the function can easily be added to our data:</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<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>
<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>
<span><span class="co">#&gt; Determining first isolates using an episode length of 365 days</span></span>
<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>
<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>
<span><span class="co">#&gt; =&gt; Found 2,712 'phenotype-based' first isolates (90.4% of total where a</span></span>
<span><span class="co">#&gt; microbial ID was available)</span></span></code></pre></div>
<p>So only 90% is suitable for resistance analysis! We can now filter on
it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter()</a></code> function, also from the
<code>dplyr</code> package:</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<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>
<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>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<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>
<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>
<p>So we end up with 2 712 isolates for analysis. Now our data looks
like:</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">our_data_1st</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,712 × 9</span></span></span>
<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>
<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>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</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;"> 4</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;"> 5</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;"> 6</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;"> 7</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;"> 8</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;"> 9</span> P4 A 2011-06-21 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> Z1 A 2014-09-05 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,702 more rows</span></span></span></code></pre></div>
<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>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; Length:2712 Length:2712 Min. :2011-01-01 </span></span>
<span><span class="co">#&gt; Class :character Class :character 1st Qu.:2013-05-03 </span></span>
<span><span class="co">#&gt; Mode :character Mode :character Median :2015-06-16 </span></span>
<span><span class="co">#&gt; Mean :2015-06-21 </span></span>
<span><span class="co">#&gt; 3rd Qu.:2017-08-24 </span></span>
<span><span class="co">#&gt; Max. :2019-12-27 </span></span>
<span><span class="co">#&gt; bacteria AMX AMC </span></span>
<span><span class="co">#&gt; Class :mo Class:sir Class:sir </span></span>
<span><span class="co">#&gt; &lt;NA&gt; :0 %S :41.0% (n=1112) %S :52.0% (n=1409) </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.1% (n=437) %I :12.0% (n=325) </span></span>
<span><span class="co">#&gt; #2 :B_STPHY_AURS %R :42.9% (n=1163) %R :36.1% (n=978) </span></span>
<span><span class="co">#&gt; #3 :B_STRPT_PNMN %NI : 0.0% (n=0) %NI : 0.0% (n=0) </span></span>
<span><span class="co">#&gt; CIP GEN first </span></span>
<span><span class="co">#&gt; Class:sir Class:sir Mode:logical </span></span>
<span><span class="co">#&gt; %S :51.5% (n=1396) %S :59.6% (n=1616) TRUE:2712 </span></span>
<span><span class="co">#&gt; %SDD : 0.0% (n=0) %SDD : 0.0% (n=0) </span></span>
<span><span class="co">#&gt; %I : 6.6% (n=178) %I : 3.1% (n=85) </span></span>
<span><span class="co">#&gt; %R :42.0% (n=1138) %R :37.3% (n=1011) </span></span>
<span><span class="co">#&gt; %NI : 0.0% (n=0) %NI : 0.0% (n=0)</span></span></code></pre></div>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; Rows: 2,712</span></span>
<span><span class="co">#&gt; Columns: 9</span></span>
<span><span class="co">#&gt; $ patient_id <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> "J3", "R7", "P10", "B7", "W3", "M3", "J3", "G6", "P4", "Z1"…</span></span>
<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>
<span><span class="co">#&gt; $ date <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> 2012-11-21, 2018-04-03, 2015-12-10, 2015-03-02, 2018-03-31…</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, S, S, R, R, S, S, S, S, R, S, 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, I, S, S, S, S, S, S, S, S, S, I, 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, R, S, 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, R, S, S, S, S, S, S, S, S, S,…</span></span>
<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></code></pre></div>
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; 260 3 1852 4 3 3 3 </span></span>
<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>
<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<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>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 4 × 2</span></span></span>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Escherichia coli <span style="text-decoration: underline;">1</span>518</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Staphylococcus aureus 730</span></span>
<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></code></pre></div>
<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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="../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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 4 × 2</span></span></span>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Escherichia coli <span style="text-decoration: underline;">1</span>319</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Staphylococcus aureus 676</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> Streptococcus pneumoniae 400</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> Klebsiella pneumoniae 317</span></span></code></pre></div>
</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>
<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,712 × 2</span></span></span>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2015-12-10 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2015-03-02 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2018-03-31 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2015-10-25 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2019-06-19 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2015-04-27 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2011-06-21 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2014-09-05 S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,702 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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/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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,712 × 3</span></span></span>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI R I </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> B_KLBSL_PNMN R I </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B_ESCHR_COLI S I </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B_STPHY_AURS R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> B_ESCHR_COLI R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_STPHY_AURS S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_ESCHR_COLI 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,702 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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/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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,712 × 5</span></span></span>
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> B_ESCHR_COLI R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> B_KLBSL_PNMN R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B_ESCHR_COLI S I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B_STPHY_AURS R S R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> B_ESCHR_COLI R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_STPHY_AURS S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_ESCHR_COLI 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,702 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 1,011 × 9</span></span></span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># 1,001 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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/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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 483 × 9</span></span></span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># 473 more rows</span></span></span></code></pre></div>
<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 483 × 9</span></span></span>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<span><span class="co">#&gt; <span style="color: #949494;"># 473 more rows</span></span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="generate-antibiograms">Generate antibiograms<a class="anchor" aria-label="anchor" href="#generate-antibiograms"></a>
</h3>
<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>
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<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>
<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span></span>
<span><span class="co">#&gt; (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span></span>
<span><span class="co">#&gt; For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span></span></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMK</th>
<th align="right">GEN</th>
<th align="right">IPM</th>
<th align="right">KAN</th>
<th align="right">MEM</th>
<th align="right">TOB</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">CoNS (43-309)</td>
<td align="right">0</td>
<td align="right">86</td>
<td align="right">52</td>
<td align="right">0</td>
<td align="right">52</td>
<td align="right">22</td>
</tr>
<tr class="even">
<td align="left">
<em>E. coli</em> (0-462)</td>
<td align="right">100</td>
<td align="right">98</td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">97</td>
</tr>
<tr class="odd">
<td align="left">
<em>E. faecalis</em> (0-39)</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">100</td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
</tr>
<tr class="even">
<td align="left">
<em>K. pneumoniae</em> (0-58)</td>
<td align="right"></td>
<td align="right">90</td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">90</td>
</tr>
<tr class="odd">
<td align="left">
<em>P. aeruginosa</em> (17-30)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">100</td>
</tr>
<tr class="even">
<td align="left">
<em>P. mirabilis</em> (0-34)</td>
<td align="right"></td>
<td align="right">94</td>
<td align="right">94</td>
<td align="right"></td>
<td align="right"></td>
<td align="right">94</td>
</tr>
<tr class="odd">
<td align="left">
<em>S. aureus</em> (2-233)</td>
<td align="right"></td>
<td align="right">99</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">98</td>
</tr>
<tr class="even">
<td align="left">
<em>S. epidermidis</em> (8-163)</td>
<td align="right">0</td>
<td align="right">79</td>
<td align="right"></td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">51</td>
</tr>
<tr class="odd">
<td align="left">
<em>S. hominis</em> (3-80)</td>
<td align="right"></td>
<td align="right">92</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">85</td>
</tr>
<tr class="even">
<td align="left">
<em>S. pneumoniae</em> (11-117)</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
</tr>
</tbody>
</table>
<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>
<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span></span>
<span><span class="co">#&gt; (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="35%">
<col width="14%">
<col width="17%">
<col width="15%">
<col width="17%">
</colgroup>
<thead><tr class="header">
<th align="left">Patógeno (N min-max)</th>
<th align="right">Amikacina</th>
<th align="right">Gentamicina</th>
<th align="right">Kanamicina</th>
<th align="right">Tobramicina</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">Gram negativo (35-686)</td>
<td align="right">98</td>
<td align="right">96</td>
<td align="right">0</td>
<td align="right">96</td>
</tr>
<tr class="even">
<td align="left">Gram positivo (436-1170)</td>
<td align="right">0</td>
<td align="right">63</td>
<td align="right">0</td>
<td align="right">34</td>
</tr>
</tbody>
</table>
</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>
<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
<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>
<table class="table">
<thead><tr class="header">
<th align="left">Pathogen (N min-max)</th>
<th align="right">TZP</th>
<th align="right">TZP + GEN</th>
<th align="right">TZP + TOB</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">CoNS (29-274)</td>
<td align="right">30</td>
<td align="right">97</td>
<td align="right"></td>
</tr>
<tr class="even">
<td align="left">
<em>E. coli</em> (416-461)</td>
<td align="right">94</td>
<td align="right">100</td>
<td align="right">99</td>
</tr>
<tr class="odd">
<td align="left">
<em>K. pneumoniae</em> (53-58)</td>
<td align="right">89</td>
<td align="right">93</td>
<td align="right">93</td>
</tr>
<tr class="even">
<td align="left">
<em>P. aeruginosa</em> (27-30)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
<tr class="odd">
<td align="left">
<em>P. mirabilis</em> (27-34)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
<tr class="even">
<td align="left">
<em>S. aureus</em> (7-231)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
<tr class="odd">
<td align="left">
<em>S. epidermidis</em> (5-128)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
<tr class="even">
<td align="left">
<em>S. hominis</em> (0-74)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
<tr class="odd">
<td align="left">
<em>S. pneumoniae</em> (112-112)</td>
<td align="right">100</td>
<td align="right">100</td>
<td align="right">100</td>
</tr>
</tbody>
</table>
</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>
<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'</span></span>
<span><span class="co">#&gt; (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)</span></span>
<span><span class="co">#&gt; For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="25%">
<col width="37%">
<col width="6%">
<col width="6%">
<col width="6%">
<col width="6%">
<col width="6%">
<col width="6%">
</colgroup>
<thead><tr class="header">
<th align="left">Syndromic Group</th>
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMK</th>
<th align="right">GEN</th>
<th align="right">IPM</th>
<th align="right">KAN</th>
<th align="right">MEM</th>
<th align="right">TOB</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">Clinical</td>
<td align="left">CoNS (23-205)</td>
<td align="right"></td>
<td align="right">89</td>
<td align="right">57</td>
<td align="right"></td>
<td align="right">57</td>
<td align="right">26</td>
</tr>
<tr class="even">
<td align="left">ICU</td>
<td align="left">CoNS (10-73)</td>
<td align="right"></td>
<td align="right">79</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
</tr>
<tr class="odd">
<td align="left">Outpatient</td>
<td align="left">CoNS (3-31)</td>
<td align="right"></td>
<td align="right">84</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
</tr>
<tr class="even">
<td align="left">Clinical</td>
<td align="left">
<em>E. coli</em> (0-299)</td>
<td align="right">100</td>
<td align="right">98</td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">98</td>
</tr>
<tr class="odd">
<td align="left">ICU</td>
<td align="left">
<em>E. coli</em> (0-137)</td>
<td align="right">100</td>
<td align="right">99</td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">96</td>
</tr>
<tr class="even">
<td align="left">Clinical</td>
<td align="left">
<em>K. pneumoniae</em> (0-51)</td>
<td align="right"></td>
<td align="right">92</td>
<td align="right">100</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right">92</td>
</tr>
<tr class="odd">
<td align="left">Clinical</td>
<td align="left">
<em>P. mirabilis</em> (0-30)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">100</td>
</tr>
<tr class="even">
<td align="left">Clinical</td>
<td align="left">
<em>S. aureus</em> (2-150)</td>
<td align="right"></td>
<td align="right">99</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">97</td>
</tr>
<tr class="odd">
<td align="left">ICU</td>
<td align="left">
<em>S. aureus</em> (0-66)</td>
<td align="right"></td>
<td align="right">100</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
</tr>
<tr class="even">
<td align="left">Clinical</td>
<td align="left">
<em>S. epidermidis</em> (4-79)</td>
<td align="right"></td>
<td align="right">82</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">55</td>
</tr>
<tr class="odd">
<td align="left">ICU</td>
<td align="left">
<em>S. epidermidis</em> (4-75)</td>
<td align="right"></td>
<td align="right">72</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">41</td>
</tr>
<tr class="even">
<td align="left">Clinical</td>
<td align="left">
<em>S. hominis</em> (1-45)</td>
<td align="right"></td>
<td align="right">96</td>
<td align="right"></td>
<td align="right"></td>
<td align="right"></td>
<td align="right">94</td>
</tr>
<tr class="odd">
<td align="left">Clinical</td>
<td align="left">
<em>S. pneumoniae</em> (5-78)</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
</tr>
<tr class="even">
<td align="left">ICU</td>
<td align="left">
<em>S. pneumoniae</em> (5-30)</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
<td align="right"></td>
<td align="right">0</td>
</tr>
</tbody>
</table>
</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>
<div class="sourceCode" id="cb37"><pre class="downlit sourceCode r">
<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>
<span><span class="va">wisca</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="23%">
<col width="35%">
<col width="5%">
<col width="14%">
<col width="5%">
<col width="14%">
</colgroup>
<thead><tr class="header">
<th align="left">Syndromic Group</th>
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMC</th>
<th align="right">AMC + CIP</th>
<th align="right">TZP</th>
<th align="right">TZP + TOB</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">WISCA Group 1</td>
<td align="left">Gram-negative (261-285)</td>
<td align="right">76</td>
<td align="right">95</td>
<td align="right">89</td>
<td align="right">99</td>
</tr>
<tr class="even">
<td align="left">WISCA Group 2</td>
<td align="left">Gram-negative (380-442)</td>
<td align="right">76</td>
<td align="right">98</td>
<td align="right">88</td>
<td align="right">98</td>
</tr>
<tr class="odd">
<td align="left">WISCA Group 1</td>
<td align="left">Gram-positive (123-406)</td>
<td align="right">76</td>
<td align="right">89</td>
<td align="right">81</td>
<td align="right">95</td>
</tr>
<tr class="even">
<td align="left">WISCA Group 2</td>
<td align="left">Gram-positive (222-732)</td>
<td align="right">76</td>
<td align="right">89</td>
<td align="right">88</td>
<td align="right">95</td>
</tr>
</tbody>
</table>
</div>
<div class="section level4">
<h4 id="plotting-antibiograms">Plotting antibiograms<a class="anchor" aria-label="anchor" href="#plotting-antibiograms"></a>
</h4>
<p>Antibiograms can be plotted using <code><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot()</a></code> from the
<code>ggplot2</code> packages, since this <code>AMR</code> package
provides an extension to that function:</p>
<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<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>
<p><img src="AMR_files/figure-html/unnamed-chunk-10-1.png" width="720"></p>
<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>
</div>
</div>
<div class="section level3">
<h3 id="resistance-percentages">Resistance percentages<a class="anchor" aria-label="anchor" href="#resistance-percentages"></a>
</h3>
<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>
<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; [1] 0.4288348</span></span></code></pre></div>
<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>
<div class="sourceCode" id="cb40"><pre class="downlit sourceCode r">
<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>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> A 0.342</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> B 0.564</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> C 0.372</span></span></code></pre></div>
<hr>
<p><em>Author: Dr. Matthijs Berends, 26th Feb 2023</em></p>
</div>
</div>
</main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
</nav></aside>
</div>
<footer><div class="pkgdown-footer-left">
<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>
</div>
<div class="pkgdown-footer-right">
<p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/logos/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/logos/logo_umcg.svg" style="max-width: 150px;"></a></p>
</div>
</footer>
</div>
</body>
</html>