1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 12:46:12 +01:00
AMR/articles/AMR.html

1272 lines
88 KiB
HTML
Raw Normal View History

2022-08-21 16:59:35 +02:00
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<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">
2022-12-20 16:22:22 +01:00
<link href="../deps/bootstrap-5.2.2/bootstrap.min.css" rel="stylesheet">
2023-01-24 10:29:55 +01:00
<script src="../deps/bootstrap-5.2.2/bootstrap.bundle.min.js"></script><link href="../deps/Fira_Code-0.4.5/font.css" rel="stylesheet">
2022-08-21 16:59:35 +02:00
<!-- 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">
2022-12-16 16:17:49 +01:00
<!-- 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.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></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">
2022-08-21 16:59:35 +02:00
<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">
2022-10-05 12:32:07 +02:00
<meta name="twitter:site" content="@msberends">
2022-08-21 16:59:35 +02:00
<!-- 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"><div class="container">
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
2023-03-12 14:14:27 +01:00
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.0.0</small>
2022-08-21 16:59:35 +02:00
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item">
<a class="nav-link" href="../index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<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>
2023-01-23 20:14:37 +01:00
Conduct AMR Analysis
2022-08-21 16:59:35 +02:00
</a>
2023-02-08 17:01:47 +01:00
<a class="dropdown-item" href="../reference/antibiogram.html">
<span class="fa fa-file-prescription"></span>
Generate Antibiogram (Trad./Syndromic/WISCA)
</a>
2022-08-21 16:59:35 +02:00
<a class="dropdown-item" href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
2023-01-23 20:14:37 +01:00
Predict Antimicrobial Resistance
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/datasets.html">
<span class="fa fa-database"></span>
2023-02-26 21:34:01 +01:00
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
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/PCA.html">
<span class="fa fa-compress"></span>
2023-01-23 20:14:37 +01:00
Conduct Principal Component Analysis for AMR
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
2023-01-23 20:14:37 +01:00
Determine Multi-Drug Resistance (MDR)
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
2023-01-23 20:14:37 +01:00
Work with WHONET Data
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/SPSS.html">
<span class="fa fa-file-upload"></span>
2023-01-23 20:14:37 +01:00
Import Data From SPSS/SAS/Stata
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
2023-01-23 20:14:37 +01:00
Apply Eucast Rules
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
2023-01-23 20:14:37 +01:00
Get Taxonomy of a Microorganism
2022-08-21 16:59:35 +02:00
</a>
<a class="dropdown-item" href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
2023-01-23 20:14:37 +01:00
Get Properties of an Antibiotic Drug
2022-08-21 16:59:35 +02:00
</a>
2022-11-13 08:54:32 +01:00
<a class="dropdown-item" href="../reference/av_property.html">
<span class="fa fa-capsules"></span>
2023-01-23 20:14:37 +01:00
Get Properties of an Antiviral Drug
2022-11-13 08:54:32 +01:00
</a>
2022-08-21 16:59:35 +02:00
</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>
<li class="nav-item">
<a class="nav-link" href="../news/index.html">
<span class="far fa far fa-newspaper"></span>
Changelog
</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="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>
2022-10-29 14:24:08 +02:00
<p><strong>Note:</strong> values on this page will change with every
website update since they are based on randomly created values and the
page was written in <a href="https://rmarkdown.rstudio.com/" class="external-link">R
Markdown</a>. However, the methodology remains unchanged. This page was
2023-03-12 13:10:15 +01:00
generated on 12 March 2023.</p>
2022-08-21 16:59:35 +02:00
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
2022-10-29 14:24:08 +02:00
<p>Conducting AMR data analysis unfortunately requires in-depth
knowledge from different scientific fields, which makes it hard to do
right. At least, it requires:</p>
2022-08-21 16:59:35 +02:00
<ul>
2023-02-26 21:34:01 +01:00
<li>Good questions (always start with those!) and reliable data</li>
2022-10-29 14:24:08 +02:00
<li>A thorough understanding of (clinical) epidemiology, to understand
the clinical and epidemiological relevance and possible bias of
results</li>
<li>A thorough understanding of (clinical) microbiology/infectious
diseases, to understand which microorganisms are causal to which
infections and the implications of pharmaceutical treatment, as well as
understanding intrinsic and acquired microbial resistance</li>
<li>Experience with data analysis with microbiological tests and their
results, to understand the determination and limitations of MIC values
2023-01-21 23:53:21 +01:00
and their interpretations to SIR values</li>
2022-10-29 14:24:08 +02:00
<li>Availability of the biological taxonomy of microorganisms and
probably normalisation factors for pharmaceuticals, such as defined
daily doses (DDD)</li>
<li>Available (inter-)national guidelines, and profound methods to apply
them</li>
2022-08-21 16:59:35 +02:00
</ul>
2022-10-29 14:24:08 +02:00
<p>Of course, we cannot instantly provide you with knowledge and
experience. But with this <code>AMR</code> package, we aimed at
providing (1) tools to simplify antimicrobial resistance data cleaning,
transformation and analysis, (2) methods to easily incorporate
international guidelines and (3) scientifically reliable reference data,
including the requirements mentioned above.</p>
<p>The <code>AMR</code> package enables standardised and reproducible
AMR data analysis, with the application of evidence-based rules,
determination of first isolates, translation of various codes for
microorganisms and antimicrobial agents, determination of (multi-drug)
resistant microorganisms, and calculation of antimicrobial resistance,
prevalence and future trends.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level2">
<h2 id="preparation">Preparation<a class="anchor" aria-label="anchor" href="#preparation"></a>
</h2>
2022-10-29 14:24:08 +02:00
<p>For this tutorial, we will create fake demonstration data to work
with.</p>
<p>You can skip to <a href="#cleaning-the-data">Cleaning the data</a> if
you already have your own data ready. If you start your analysis, try to
make the structure of your data generally look like this:</p>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
<th align="center">date</th>
<th align="center">patient_id</th>
<th align="center">mo</th>
<th align="center">AMX</th>
<th align="center">CIP</th>
</tr></thead>
<tbody>
<tr class="odd">
2023-03-12 13:10:15 +01:00
<td align="center">2023-03-12</td>
2022-08-21 16:59:35 +02:00
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
2023-03-12 13:10:15 +01:00
<td align="center">2023-03-12</td>
2022-08-21 16:59:35 +02:00
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
2023-03-12 13:10:15 +01:00
<td align="center">2023-03-12</td>
2022-08-21 16:59:35 +02:00
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">S</td>
</tr>
</tbody>
</table>
<div class="section level3">
<h3 id="needed-r-packages">Needed R packages<a class="anchor" aria-label="anchor" href="#needed-r-packages"></a>
</h3>
2022-10-29 14:24:08 +02:00
<p>As with many uses in R, we need some additional packages for AMR data
analysis. Our package works closely together with the <a href="https://www.tidyverse.org" class="external-link">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/" class="external-link"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org" class="external-link"><code>ggplot2</code></a> by
RStudio. The tidyverse tremendously improves the way we conduct data
science - it allows for a very natural way of writing syntaxes and
creating beautiful plots in R.</p>
<p>We will also use the <code>cleaner</code> package, that can be used
for cleaning data and creating frequency tables.</p>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<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>
2023-02-26 21:34:01 +01:00
<span><span class="co"># install.packages(c("dplyr", "ggplot2", "AMR"))</span></span></code></pre></div>
<p>The <code>AMR</code> package contains a data set
<code>example_isolates_unclean</code>, which might look data that users
have extracted from their laboratory systems:</p>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="va">example_isolates_unclean</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 3,000 × 8</span></span></span>
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 E. coli R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 K. pneumoniae R I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 E. coli S I S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 E. coli S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 S. aureus R S R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> J8 A 2016-06-14 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> M3 A 2015-10-25 E. coli R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> J3 A 2019-06-19 E. coli S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> G6 A 2015-04-27 S. aureus S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 2,990 more rows</span></span></span>
<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>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="taxonomy-of-microorganisms">Taxonomy of microorganisms<a class="anchor" aria-label="anchor" href="#taxonomy-of-microorganisms"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>With <code><a href="../reference/as.mo.html">as.mo()</a></code>, users can transform arbitrary
microorganism names or codes to current taxonomy. The <code>AMR</code>
package contains up-to-date taxonomic data. To be specific, currently
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="cb3"><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>
<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>
<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>
<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>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="fu"><a href="../reference/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>
<span><span class="fu"><a href="../reference/mo_property.html">mo_genus</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "Klebsiella"</span></span>
<span><span class="fu"><a href="../reference/mo_property.html">mo_species</a></span><span class="op">(</span><span class="st">"K. pneumoniae"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "pneumoniae"</span></span>
<span></span>
<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>
<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>
<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>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="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="cb6"><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; Based on input "E coli"</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), Ehrlichia canis (0.567), and Enterobacter cloacae</span></span>
<span><span class="co">#&gt; dissolvens (0.565)</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; Based on input "K pneumoniae"</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; Based on input "S aureus"</span></span>
<span><span class="co">#&gt; Also matched: Staphylococcus aureus aureus (0.643), Staphylococcus</span></span>
<span><span class="co">#&gt; argenteus (0.625), Staphylococcus aureus anaerobius (0.625),</span></span>
<span><span class="co">#&gt; Streptomyces argenteolus (0.483), Streptomyces aureus (0.474),</span></span>
<span><span class="co">#&gt; Streptomyces azureus (0.467), Streptomyces aureorectus (0.444),</span></span>
<span><span class="co">#&gt; Streptomyces auratus (0.433), Streptomyces aurantiogriseus (0.429), and</span></span>
<span><span class="co">#&gt; Streptomyces aureocirculatus (0.429)</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; Based on input "S pneumoniae"</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>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="antibiotic-results">Antibiotic results<a class="anchor" aria-label="anchor" href="#antibiotic-results"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>The column with antibiotic test results must also be cleaned. The
<code>AMR</code> package comes with three new data types to work with
such test results: <code>mic</code> for minimal inhibitory
concentrations (MIC), <code>disk</code> for disk diffusion diameters,
and <code>sir</code> for SIR data that have been interpreted already.
This package can also determine SIR values based on MIC or disk
diffusion values, read more about that on the <code><a href="../reference/as.sir.html">as.sir()</a></code>
page.</p>
<p>For now, we will just clean the SIR columns in our data using
dplyr:</p>
2022-08-21 16:59:35 +02:00
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
2023-02-26 21:34:01 +01:00
<code class="sourceCode R"><span><span class="co"># method 1, be explicit about the columns:</span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_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>
2022-08-21 16:59:35 +02:00
<span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># method 2, let the AMR package determine the eligible columns</span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data</span> <span class="op">&lt;-</span> <span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html" class="external-link">mutate_if</a></span><span class="op">(</span><span class="va">is_sir_eligible</span>, <span class="va">as.sir</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># result:</span></span>
<span><span class="va">our_data</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 3,000 × 8</span></span></span>
<span><span class="co">#&gt; patient_id hospital date bacteria AMX AMC CIP GEN </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<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;"># … with 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>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
<h3 id="first-isolates">First isolates<a class="anchor" aria-label="anchor" href="#first-isolates"></a>
</h3>
2023-02-26 21:34:01 +01:00
<p>We need to know which isolates we can <em>actually</em> use for
analysis without repetition bias.</p>
2022-10-29 14:24:08 +02:00
<p>To conduct an analysis of antimicrobial resistance, you must <a href="https:/pubmed.ncbi.nlm.nih.gov/17304462/">only include the first
isolate of every patient per episode</a> (Hindler <em>et al.</em>, Clin
Infect Dis. 2007). If you would not do this, you could easily get an
overestimate or underestimate of the resistance of an antibiotic.
Imagine that a patient was admitted with an MRSA and that it was found
in 5 different blood cultures the following weeks (yes, some countries
like the Netherlands have these blood drawing policies). The resistance
percentage of oxacillin of all isolates would be overestimated, because
you included this MRSA more than once. It would clearly be <a href="https://en.wikipedia.org/wiki/Selection_bias" class="external-link">selection
bias</a>.</p>
<p>The Clinical and Laboratory Standards Institute (CLSI) appoints this
as follows:</p>
2022-08-21 16:59:35 +02:00
<blockquote>
2022-10-29 14:24:08 +02:00
<p><em>(…) When preparing a cumulative antibiogram to guide clinical
decisions about empirical antimicrobial therapy of initial infections,
<strong>only the first isolate of a given species per patient, per
analysis period (eg, one year) should be included, irrespective of body
site, antimicrobial susceptibility profile, or other phenotypical
characteristics (eg, biotype)</strong>. The first isolate is easily
identified, and cumulative antimicrobial susceptibility test data
prepared using the first isolate are generally comparable to cumulative
antimicrobial susceptibility test data calculated by other methods,
providing duplicate isolates are excluded.</em> <br><a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="external-link">M39-A4
Analysis and Presentation of Cumulative Antimicrobial Susceptibility
Test Data, 4th Edition. CLSI, 2014. Chapter 6.4</a></p>
2022-08-21 16:59:35 +02:00
</blockquote>
2022-10-29 14:24:08 +02:00
<p>This <code>AMR</code> package includes this methodology with the
<code><a href="../reference/first_isolate.html">first_isolate()</a></code> function and is able to apply the four
different methods as defined by <a href="https://academic.oup.com/cid/article/44/6/867/364325" class="external-link">Hindler
<em>et al.</em> in 2007</a>: phenotype-based, episode-based,
patient-based, isolate-based. The right method depends on your goals and
analysis, but the default phenotype-based method is in any case the
2023-02-26 21:34:01 +01:00
method to properly correct for most duplicate isolates. Read more about
the methods on the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> page.</p>
2022-08-21 16:59:35 +02:00
<p>The outcome of the function can easily be added to our data:</p>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb8"><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>
2022-08-21 16:59:35 +02:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>first <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span>info <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></span>
2023-02-18 13:17:35 +01:00
<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 of</span></span>
<span><span class="co">#&gt; 2</span></span>
<span><span class="co">#&gt; Including isolates from ICU.</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; =&gt; Found 2,626 'phenotype-based' first isolates (87.6% within scope and</span></span>
<span><span class="co">#&gt; 87.5% of total where a microbial ID was available)</span></span></code></pre></div>
<p>So only 88% 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
2022-10-29 14:24:08 +02:00
<code>dplyr</code> package:</p>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb9"><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>
2022-08-21 16:59:35 +02:00
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="va">first</span> <span class="op">==</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<p>For future use, the above two syntaxes can be shortened:</p>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb10"><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>
2023-02-08 17:01:47 +01:00
<span> <span class="fu"><a href="../reference/first_isolate.html">filter_first_isolate</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
2023-02-26 21:34:01 +01:00
<p>So we end up with 2 626 isolates for analysis. Now our data looks
2022-10-29 14:24:08 +02:00
like:</p>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb11"><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,626 × 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> J8 A 2016-06-14 B_ESCHR_COLI R S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> M3 A 2015-10-25 B_ESCHR_COLI R S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> J3 A 2019-06-19 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> G6 A 2015-04-27 B_STPHY_AURS S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> P4 A 2011-06-21 B_ESCHR_COLI S S S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 2,616 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="cb12"><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:2626 Length:2626 Min. :2011-01-01 </span></span>
<span><span class="co">#&gt; Class :character Class :character 1st Qu.:2013-04-14 </span></span>
<span><span class="co">#&gt; Mode :character Mode :character Median :2015-06-05 </span></span>
<span><span class="co">#&gt; Mean :2015-06-15 </span></span>
<span><span class="co">#&gt; 3rd Qu.:2017-08-23 </span></span>
<span><span class="co">#&gt; Max. :2020-01-01 </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 %R :43.2% (n=1134) %R :36.1% (n=947) </span></span>
<span><span class="co">#&gt; Unique:4 %SI :56.8% (n=1492) %SI :63.9% (n=1679) </span></span>
<span><span class="co">#&gt; #1 :B_ESCHR_COLI - %S :41.1% (n=1080) - %S :52.7% (n=1383) </span></span>
<span><span class="co">#&gt; #2 :B_STPHY_AURS - %I :15.7% (n=412) - %I :11.3% (n=296) </span></span>
<span><span class="co">#&gt; #3 :B_STRPT_PNMN </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; %R :42.0% (n=1102) %R :37.0% (n=971) TRUE:2626 </span></span>
<span><span class="co">#&gt; %SI :58.0% (n=1524) %SI :63.0% (n=1655) </span></span>
<span><span class="co">#&gt; - %S :51.9% (n=1362) - %S :59.9% (n=1574) </span></span>
<span><span class="co">#&gt; - %I : 6.2% (n=162) - %I : 3.1% (n=81) </span></span>
<span><span class="co">#&gt; </span></span>
<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,626</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", "J8", "M3", "J3", "G6", "P4"…</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, R, S, S, S, S, R, S, S, R, R, R, R, I, S,…</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, S, S, S, S, S, R, S, R,…</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, S, R, 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>
<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 1808 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="cb13"><pre class="downlit sourceCode r">
2023-03-11 14:32:27 +01:00
<code class="sourceCode R"><span><span class="va">our_data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="../reference/count.html">count</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">bacteria</span><span class="op">)</span>, sort <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<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>
<span></span>
2023-03-11 14:32:27 +01:00
<span><span class="va">our_data_1st</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
2023-02-26 21:34:01 +01:00
<span> <span class="fu"><a href="../reference/count.html">count</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_name</a></span><span class="op">(</span><span class="va">bacteria</span><span class="op">)</span>, sort <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<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>250</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Staphylococcus aureus 661</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> Streptococcus pneumoniae 399</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> Klebsiella pneumoniae 316</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="cb14"><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,626 × 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> 2016-06-14 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2015-10-25 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2019-06-19 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2015-04-27 S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2011-06-21 S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 2,616 more rows</span></span></span>
<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,626 × 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 R S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_STPHY_AURS S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> B_ESCHR_COLI S S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 2,616 more rows</span></span></span>
<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,626 × 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 R S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> B_STPHY_AURS S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> B_ESCHR_COLI S S S S </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 2,616 more rows</span></span></span>
<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: 971 × 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;"># … with 961 more rows</span></span></span>
<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: 471 × 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> I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</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;"> 7</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;"> 8</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;"> 9</span> C5 A 2015-08-30 B_KLBSL_PNMN R R S R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> W9 A 2013-10-02 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 461 more rows</span></span></span>
<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: 471 × 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> I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</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;"> 7</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;"> 8</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;"> 9</span> C5 A 2015-08-30 B_KLBSL_PNMN R R S R TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> W9 A 2013-10-02 B_ESCHR_COLI R R S S TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># … with 461 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>This package comes with <code><a href="../reference/antibiogram.html">antibiogram()</a></code>, a function that
automatically generates traditional, combined, syndromic, and even
weighted-incidence syndromic combination antibiograms (WISCA). For R
Markdown (such as this page) it automatically prints in the right table
format.</p>
<p>Below are some suggestions for how to generate the different
antibiograms:</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># traditional:</span></span>
<span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">our_data_1st</span><span class="op">)</span></span></code></pre></div>
2023-02-24 17:15:07 +01:00
<table class="table">
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMC</th>
<th align="right">AMX</th>
<th align="right">CIP</th>
<th align="right">GEN</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>E. coli</em> (1250-1250)</td>
<td align="right">64</td>
<td align="right">58</td>
<td align="right">58</td>
<td align="right">63</td>
2023-02-13 17:04:12 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>K. pneumoniae</em> (316-316)</td>
<td align="right">63</td>
<td align="right">53</td>
<td align="right">59</td>
<td align="right">60</td>
2023-02-22 16:34:03 +01:00
</tr>
2023-02-24 20:02:09 +01:00
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. aureus</em> (661-661)</td>
<td align="right">64</td>
<td align="right">57</td>
<td align="right">57</td>
<td align="right">63</td>
2022-12-27 16:14:41 +01:00
</tr>
2023-02-24 20:02:09 +01:00
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. pneumoniae</em> (399-399)</td>
<td align="right">64</td>
<td align="right">56</td>
<td align="right">60</td>
<td align="right">66</td>
2023-02-24 17:15:07 +01:00
</tr>
2022-08-21 16:59:35 +02:00
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb16"><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">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<span> ab_transform <span class="op">=</span> <span class="st">"name"</span></span>
<span><span class="op">)</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
2022-10-29 14:24:08 +02:00
<colgroup>
2023-02-26 21:34:01 +01:00
<col width="28%">
<col width="13%">
<col width="30%">
<col width="15%">
2022-10-29 14:24:08 +02:00
<col width="12%">
</colgroup>
2022-08-21 16:59:35 +02:00
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Pathogen (N min-max)</th>
<th align="right">Amoxicillin</th>
<th align="right">Amoxicillin/clavulanic acid</th>
<th align="right">Ciprofloxacin</th>
<th align="right">Gentamicin</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>E. coli</em> (1250-1250)</td>
<td align="right">58</td>
<td align="right">64</td>
<td align="right">58</td>
<td align="right">63</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>K. pneumoniae</em> (316-316)</td>
<td align="right">53</td>
<td align="right">63</td>
<td align="right">59</td>
<td align="right">60</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. aureus</em> (661-661)</td>
<td align="right">57</td>
<td align="right">64</td>
<td align="right">57</td>
<td align="right">63</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. pneumoniae</em> (399-399)</td>
<td align="right">56</td>
<td align="right">64</td>
<td align="right">60</td>
<td align="right">66</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb17"><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">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<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>
<span><span class="op">)</span> <span class="co"># support for 20 languages</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<colgroup>
2023-02-26 21:34:01 +01:00
<col width="27%">
<col width="12%">
<col width="31%">
<col width="15%">
<col width="12%">
2022-08-21 16:59:35 +02:00
</colgroup>
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Patógeno (N min-max)</th>
<th align="right">Amoxicilina</th>
<th align="right">Amoxicilina/ácido clavulánico</th>
<th align="right">Ciprofloxacina</th>
<th align="right">Gentamicina</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>E. coli</em> (1250-1250)</td>
<td align="right">58</td>
<td align="right">64</td>
<td align="right">58</td>
<td align="right">63</td>
2022-11-10 22:16:02 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>K. pneumoniae</em> (316-316)</td>
<td align="right">53</td>
<td align="right">63</td>
<td align="right">59</td>
<td align="right">60</td>
2023-02-24 10:40:06 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. aureus</em> (661-661)</td>
<td align="right">57</td>
<td align="right">64</td>
<td align="right">57</td>
<td align="right">63</td>
2023-02-14 16:11:20 +01:00
</tr>
2023-02-24 17:15:07 +01:00
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. pneumoniae</em> (399-399)</td>
<td align="right">56</td>
<td align="right">64</td>
<td align="right">60</td>
<td align="right">66</td>
2023-01-12 11:42:13 +01:00
</tr>
2022-08-21 16:59:35 +02:00
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># combined:</span></span>
<span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<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">"AMC+GEN"</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMC</th>
<th align="right">AMC + CIP</th>
<th align="right">AMC + GEN</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>E. coli</em> (1250-1250)</td>
<td align="right">64</td>
<td align="right">76</td>
<td align="right">75</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>K. pneumoniae</em> (316-316)</td>
<td align="right">63</td>
<td align="right">78</td>
<td align="right">74</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. aureus</em> (661-661)</td>
<td align="right">64</td>
<td align="right">77</td>
<td align="right">75</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">
<em>S. pneumoniae</em> (399-399)</td>
<td align="right">64</td>
<td align="right">77</td>
<td align="right">76</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># for a syndromic antibiogram, we must fake some clinical conditions:</span></span>
<span><span class="va">our_data_1st</span><span class="op">$</span><span class="va">condition</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html" class="external-link">sample</a></span><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">"Cardial"</span>, <span class="st">"Respiratory"</span>, <span class="st">"Rheumatic"</span><span class="op">)</span>,</span>
2023-03-11 14:32:27 +01:00
<span> size <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">nrow</a></span><span class="op">(</span><span class="va">our_data_1st</span><span class="op">)</span>,</span>
<span> replace <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span></span>
<span><span class="co"># syndromic:</span></span>
<span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<span> syndromic_group <span class="op">=</span> <span class="st">"condition"</span></span>
<span><span class="op">)</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Syndromic Group</th>
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMC</th>
<th align="right">AMX</th>
<th align="right">CIP</th>
<th align="right">GEN</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>E. coli</em> (415-415)</td>
<td align="right">64</td>
<td align="right">58</td>
<td align="right">56</td>
2023-03-11 17:23:32 +01:00
<td align="right">63</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>E. coli</em> (432-432)</td>
<td align="right">64</td>
<td align="right">59</td>
<td align="right">58</td>
<td align="right">62</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>E. coli</em> (403-403)</td>
<td align="right">63</td>
<td align="right">58</td>
<td align="right">59</td>
2023-03-12 13:10:15 +01:00
<td align="right">63</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>K. pneumoniae</em> (98-98)</td>
<td align="right">66</td>
<td align="right">44</td>
<td align="right">64</td>
<td align="right">62</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>K. pneumoniae</em> (110-110)</td>
<td align="right">65</td>
<td align="right">61</td>
<td align="right">59</td>
<td align="right">59</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>K. pneumoniae</em> (108-108)</td>
<td align="right">57</td>
<td align="right">52</td>
<td align="right">54</td>
<td align="right">59</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. aureus</em> (212-212)</td>
2023-03-12 13:10:15 +01:00
<td align="right">61</td>
2023-03-12 14:14:27 +01:00
<td align="right">53</td>
<td align="right">51</td>
<td align="right">59</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. aureus</em> (236-236)</td>
<td align="right">68</td>
<td align="right">62</td>
2023-03-12 13:10:15 +01:00
<td align="right">64</td>
<td align="right">65</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. aureus</em> (213-213)</td>
2023-03-12 13:10:15 +01:00
<td align="right">63</td>
2023-03-12 14:14:27 +01:00
<td align="right">55</td>
<td align="right">56</td>
<td align="right">64</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. pneumoniae</em> (131-131)</td>
2023-03-12 13:10:15 +01:00
<td align="right">69</td>
<td align="right">56</td>
2023-03-12 14:14:27 +01:00
<td align="right">66</td>
<td align="right">71</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. pneumoniae</em> (146-146)</td>
<td align="right">62</td>
<td align="right">55</td>
2023-03-12 13:10:15 +01:00
<td align="right">57</td>
<td align="right">67</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
<td align="left">
2023-03-12 14:14:27 +01:00
<em>S. pneumoniae</em> (122-122)</td>
<td align="right">61</td>
<td align="right">57</td>
<td align="right">57</td>
<td align="right">58</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb20"><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">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<span> <span class="co"># you can use AB selectors here as well:</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">penicillins</a></span><span class="op">(</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>
<span> syndromic_group <span class="op">=</span> <span class="st">"condition"</span>,</span>
<span> mo_transform <span class="op">=</span> <span class="st">"gramstain"</span></span>
<span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co">#&gt; For penicillins() using columns 'AMX' (amoxicillin) and 'AMC'</span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
<span><span class="co">#&gt; For aminoglycosides() using column 'GEN' (gentamicin)</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<th align="left">Syndromic Group</th>
<th align="left">Pathogen (N min-max)</th>
<th align="right">AMC</th>
<th align="right">AMX</th>
<th align="right">GEN</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (513-513)</td>
<td align="right">65</td>
<td align="right">55</td>
<td align="right">63</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (542-542)</td>
2023-03-12 13:10:15 +01:00
<td align="right">64</td>
2023-03-12 14:14:27 +01:00
<td align="right">60</td>
2023-03-12 13:10:15 +01:00
<td align="right">62</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (511-511)</td>
<td align="right">62</td>
<td align="right">57</td>
<td align="right">62</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (343-343)</td>
<td align="right">64</td>
<td align="right">54</td>
2023-03-12 13:10:15 +01:00
<td align="right">64</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="odd">
<td align="left">Respiratory</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (382-382)</td>
<td align="right">66</td>
2023-03-12 13:10:15 +01:00
<td align="right">59</td>
2023-03-12 14:14:27 +01:00
<td align="right">66</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="even">
<td align="left">Rheumatic</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (335-335)</td>
2023-03-12 13:10:15 +01:00
<td align="right">63</td>
2023-03-12 14:14:27 +01:00
<td align="right">56</td>
<td align="right">62</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
2023-03-11 14:32:27 +01:00
<code class="sourceCode R"><span><span class="co"># WISCA:</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="co"># (we lack some details, but it could contain a filter on e.g. &gt;65 year-old males)</span></span>
<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">our_data_1st</span>,</span>
2023-03-11 14:32:27 +01:00
<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">"AMC+GEN"</span><span class="op">)</span>,</span>
<span> syndromic_group <span class="op">=</span> <span class="st">"condition"</span>,</span>
<span> mo_transform <span class="op">=</span> <span class="st">"gramstain"</span></span>
<span><span class="op">)</span></span>
2023-02-26 21:34:01 +01:00
<span><span class="va">wisca</span></span></code></pre></div>
2022-08-21 16:59:35 +02:00
<table class="table">
<thead><tr class="header">
2023-02-26 21:34:01 +01:00
<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">AMC + GEN</th>
2022-08-21 16:59:35 +02:00
</tr></thead>
<tbody>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (513-513)</td>
<td align="right">65</td>
2023-03-12 13:10:15 +01:00
<td align="right">76</td>
2023-03-12 14:14:27 +01:00
<td align="right">75</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Respiratory</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (542-542)</td>
2023-03-12 13:10:15 +01:00
<td align="right">64</td>
2023-03-12 14:14:27 +01:00
<td align="right">76</td>
<td align="right">76</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="odd">
2023-02-26 21:34:01 +01:00
<td align="left">Rheumatic</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-negative (511-511)</td>
<td align="right">62</td>
2023-03-12 13:10:15 +01:00
<td align="right">76</td>
2023-03-12 14:14:27 +01:00
<td align="right">74</td>
2022-08-21 16:59:35 +02:00
</tr>
<tr class="even">
2023-02-26 21:34:01 +01:00
<td align="left">Cardial</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (343-343)</td>
<td align="right">64</td>
<td align="right">75</td>
<td align="right">75</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="odd">
<td align="left">Respiratory</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (382-382)</td>
<td align="right">66</td>
<td align="right">80</td>
<td align="right">79</td>
2023-02-26 21:34:01 +01:00
</tr>
<tr class="even">
<td align="left">Rheumatic</td>
2023-03-12 14:14:27 +01:00
<td align="left">Gram-positive (335-335)</td>
<td align="right">63</td>
2023-03-12 13:10:15 +01:00
<td align="right">76</td>
2023-03-12 14:14:27 +01:00
<td align="right">73</td>
2022-08-21 16:59:35 +02:00
</tr>
</tbody>
</table>
2023-02-26 21:34:01 +01:00
<p>Antibiograms can be plotted using <code><a href="https://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot()</a></code> from the
<code>ggplot2</code> packages, since this package provides an extension
to that function:</p>
<div class="sourceCode" id="cb22"><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-13-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>
2022-08-21 16:59:35 +02:00
</div>
<div class="section level3">
2023-02-26 21:34:01 +01:00
<h3 id="resistance-percentages">Resistance percentages<a class="anchor" aria-label="anchor" href="#resistance-percentages"></a>
2022-08-21 16:59:35 +02:00
</h3>
2023-02-26 21:34:01 +01:00
<p>The functions <code><a href="../reference/proportion.html">resistance()</a></code> and
<code><a href="../reference/proportion.html">susceptibility()</a></code> can be used to calculate antimicrobial
resistance or susceptibility. For more specific analyses, the functions
<code><a href="../reference/proportion.html">proportion_S()</a></code>, <code><a href="../reference/proportion.html">proportion_SI()</a></code>,
<code><a href="../reference/proportion.html">proportion_I()</a></code>, <code><a href="../reference/proportion.html">proportion_IR()</a></code> and
<code><a href="../reference/proportion.html">proportion_R()</a></code> can be used to determine the proportion of a
specific antimicrobial outcome.</p>
<p>All these functions contain a <code>minimum</code> argument, denoting
the minimum required number of test results for returning a value. These
functions will otherwise return <code>NA</code>. The default is
<code>minimum = 30</code>, following the <a href="https://clsi.org/standards/products/microbiology/documents/m39/" class="external-link">CLSI
M39-A4 guideline</a> for applying microbial epidemiology.</p>
<p>As per the EUCAST guideline of 2019, we calculate resistance as the
proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to
<code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and
I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to
<code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their
own:</p>
<div class="sourceCode" id="cb23"><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.4318355</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="cb24"><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.343</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> B 0.569</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> C 0.375</span></span></code></pre></div>
2023-02-18 13:17:35 +01:00
<hr>
2023-02-26 21:34:01 +01:00
<p><em>Author: Dr. Matthijs Berends, 26th Feb 2023</em></p>
2022-08-21 16:59:35 +02:00
</div>
</div>
</main><aside class="col-md-3"><nav id="toc"><h2>On this page</h2>
</nav></aside>
</div>
<footer><div class="pkgdown-footer-left">
<p></p>
2022-12-11 11:50:34 +01:00
<p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
2022-08-21 16:59:35 +02:00
</div>
<div class="pkgdown-footer-right">
<p></p>
2022-12-11 11:50:34 +01:00
<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>
2022-08-21 16:59:35 +02:00
</div>
</footer>
</div>
</body>
</html>