1
0
mirror of https://github.com/msberends/AMR.git synced 2026-04-03 11:35:55 +02:00

45 Commits

Author SHA1 Message Date
github-actions
59b2ce5621 Built site for AMR@3.0.1.9043: 2254931 2026-04-02 10:32:06 +00:00
github-actions
d0fd6aa2cc Built site for AMR@3.0.1.9042: 26613d7 2026-04-02 09:54:05 +00:00
github-actions
d6c59896e9 Built site for AMR@3.0.1.9041: 3a736bc 2026-03-30 08:18:09 +00:00
github-actions
d55d073ae9 Built site for AMR@3.0.1.9040: 9c95aa4 2026-03-24 12:34:17 +00:00
github-actions
330f1a9dfe Built site for AMR@3.0.1.9038: 975a690 2026-03-22 21:31:11 +00:00
github-actions
c95646d39c Built site for AMR@3.0.1.9037: 3d1412e 2026-03-22 19:55:49 +00:00
github-actions
3560dfd611 Built site for AMR@3.0.1.9036: 4171d5b 2026-03-20 16:11:30 +00:00
github-actions
ba003f3e23 Built site for AMR@3.0.1.9035: 8439e9c 2026-03-18 09:45:05 +00:00
github-actions
33e262ed9b Built site for AMR@3.0.1.9034: 4dc3ec0 2026-03-11 15:20:20 +00:00
github-actions
86a53a0901 Built site for AMR@3.0.1.9033: 353eaa3 2026-03-09 11:08:33 +00:00
github-actions
e7e8aa636e Built site for AMR@3.0.1.9032: cba315c 2026-03-08 19:46:45 +00:00
github-actions
1e81c2a013 Built site for AMR@3.0.1.9031: b6f8584 2026-03-08 10:40:48 +00:00
github-actions
ab5ce59112 Built site for AMR@3.0.1.9030: e2102c0 2026-03-07 17:15:05 +00:00
github-actions
599302f0bd Built site for AMR@3.0.1.9026: 60e8f2b 2026-03-06 11:55:19 +00:00
github-actions
acc807a02c Built site for AMR@3.0.1.9023: 4e3ea95 2026-03-04 08:11:02 +00:00
github-actions
3c74d99480 Built site for AMR@3.0.1.9022: 0311834 2026-03-03 14:52:15 +00:00
github-actions
6f0dc96d0d Built site for AMR@3.0.1.9021: 2c21eba 2026-02-27 16:25:41 +00:00
github-actions
f0ec851466 Built site for AMR@3.0.1.9021: 12cf144 2026-02-12 19:45:10 +00:00
github-actions
c149bb1f65 Built site for AMR@3.0.1.9020: 499c830 2026-02-09 12:53:52 +00:00
github-actions
8b71d0eb99 Built site for AMR@3.0.1.9019: ba4c159 2026-02-08 22:40:23 +00:00
github-actions
0551ea51cb Built site for AMR@3.0.1.9018: 2df2911 2026-01-16 10:08:12 +00:00
github-actions
86f19c7576 Built site for AMR@3.0.1.9017: fd50c51 2026-01-08 13:12:14 +00:00
github-actions
39894d56c9 Built site for AMR@3.0.1.9016: cfd1922 2026-01-08 11:36:31 +00:00
github-actions
a4edc69618 Built site for AMR@3.0.1.9015: 7df28bc 2026-01-08 09:35:29 +00:00
github-actions
e2ba695c2c Built site for AMR@3.0.1.9014: 7b9c151 2026-01-07 14:17:42 +00:00
github-actions
bb2e68890c Built site for AMR@3.0.1.9013: 85e8e81 2026-01-07 12:40:00 +00:00
github-actions
70d4d19168 Built site for AMR@3.0.1.9012: fa827f2 2026-01-07 10:08:49 +00:00
github-actions
46858ec0a2 Built site for AMR@3.0.1.9008: 9d1b456 2026-01-06 22:21:25 +00:00
github-actions
01880ee020 Built site for AMR@3.0.1.9009: 35debe2 2025-12-23 10:12:20 +00:00
github-actions
1227e2c60c Built site for AMR@3.0.1.9007: a5c6aa9 2025-12-22 08:48:41 +00:00
github-actions
7c8d0f82f9 Built site for AMR@3.0.1.9004: 225c73f 2025-12-15 12:32:31 +00:00
github-actions
141fc468f8 Built site for AMR@3.0.1.9003: ba30b08 2025-11-24 10:42:21 +00:00
github-actions
7d16891987 Built site for AMR@3.0.1.9002: d366949 2025-10-13 20:22:22 +00:00
github-actions
0d195202fd Built site for AMR@3.0.1.9001: 0b24967 2025-09-30 09:09:19 +00:00
github-actions
2d20ac1a7d Built site for AMR@3.0.1: adee419 2025-09-20 16:24:20 +00:00
github-actions
dc9493d2d8 Built site for AMR@3.0.0.9036: 33fb184 2025-09-19 11:39:04 +00:00
github-actions
a33b95eb3d Built site for AMR@3.0.0.9035: 13f2a86 2025-09-18 13:33:09 +00:00
github-actions
f4ce3570ff Built site for AMR@3.0.0.9034: 10ba368 2025-09-18 13:08:52 +00:00
github-actions
32361053f1 Built site for AMR@3.0.0.9033: 5796e8f 2025-09-15 07:19:27 +00:00
github-actions
660bcf00e5 Built site for AMR@3.0.0.9032: b11866a 2025-09-13 12:12:30 +00:00
github-actions
cf182a28f1 Built site for AMR@3.0.0.9031: e8c99f2 2025-09-12 15:01:39 +00:00
github-actions
ccfe6caf58 Built site for AMR@3.0.0.9030: 5b99888 2025-09-11 12:48:56 +00:00
github-actions
be9c71b572 Built site for AMR@3.0.0.9029: c7b2acb 2025-09-10 14:30:52 +00:00
github-actions
d1f9877a8e Built site for AMR@3.0.0.9021: 0744c6f 2025-09-03 10:21:26 +00:00
github-actions
75b8c2485a Built site for AMR@3.0.0.9019: eca6385 2025-09-03 09:56:20 +00:00
371 changed files with 25504 additions and 5927 deletions

View File

@@ -31,7 +31,7 @@
<a class="navbar-brand me-2" href="https://amr-for-r.org/index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">

3
404.md Normal file
View File

@@ -0,0 +1,3 @@
Content not found. Please use links in the navbar.
# Page not found (404)

274
CLAUDE.html Normal file
View File

@@ -0,0 +1,274 @@
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>CLAUDE.md — AMR R Package • AMR (for R)</title><!-- favicons --><link rel="icon" type="image/png" sizes="96x96" href="favicon-96x96.png"><link rel="icon" type="”image/svg+xml”" href="favicon.svg"><link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png"><link rel="icon" sizes="any" href="favicon.ico"><link rel="manifest" href="site.webmanifest"><script src="deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="deps/Lato-0.4.10/font.css" rel="stylesheet"><link href="deps/Fira_Code-0.4.10/font.css" rel="stylesheet"><link href="deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet"><link href="deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet"><script src="deps/headroom-0.11.0/headroom.min.js"></script><script src="deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="deps/search-1.0.0/fuse.min.js"></script><script src="deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="pkgdown.js"></script><link href="extra.css" rel="stylesheet"><script src="extra.js"></script><meta property="og:title" content="CLAUDE.md — AMR R Package"><meta property="og:image" content="https://amr-for-r.org/logo.svg"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous"><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script></head><body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar navbar-expand-lg fixed-top bg-primary" data-bs-theme="dark" aria-label="Site navigation"><div class="container">
<a class="navbar-brand me-2" href="index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto"><li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" type="button" id="dropdown-how-to" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"><span class="fa fa-question-circle"></span> How to</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-how-to"><li><a class="dropdown-item" href="articles/AMR.html"><span class="fa fa-directions"></span> Conduct AMR Analysis</a></li>
<li><a class="dropdown-item" href="reference/antibiogram.html"><span class="fa fa-file-prescription"></span> Generate Antibiogram (Trad./Syndromic/WISCA)</a></li>
<li><a class="dropdown-item" href="articles/AMR_with_tidymodels.html"><span class="fa fa-square-root-variable"></span> Use AMR for Predictive Modelling (tidymodels)</a></li>
<li><a class="dropdown-item" href="articles/datasets.html"><span class="fa fa-database"></span> Download Data Sets for Own Use</a></li>
<li><a class="dropdown-item" href="reference/AMR-options.html"><span class="fa fa-gear"></span> Set User- Or Team-specific Package Settings</a></li>
<li><a class="dropdown-item" href="articles/PCA.html"><span class="fa fa-compress"></span> Conduct Principal Component Analysis for AMR</a></li>
<li><a class="dropdown-item" href="reference/mdro.html"><span class="fa fa-skull-crossbones"></span> Determine Multi-Drug Resistance (MDR)</a></li>
<li><a class="dropdown-item" href="articles/WHONET.html"><span class="fa fa-globe-americas"></span> Work with WHONET Data</a></li>
<li><a class="dropdown-item" href="articles/EUCAST.html"><span class="fa fa-exchange-alt"></span> Apply EUCAST Rules</a></li>
<li><a class="dropdown-item" href="reference/mo_property.html"><span class="fa fa-bug"></span> Get Taxonomy of a Microorganism</a></li>
<li><a class="dropdown-item" href="reference/ab_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antibiotic Drug</a></li>
<li><a class="dropdown-item" href="reference/av_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antiviral Drug</a></li>
</ul></li>
<li class="nav-item"><a class="nav-link" href="articles/AMR_for_Python.html"><span class="fa fab fa-python"></span> AMR for Python</a></li>
<li class="nav-item"><a class="nav-link" href="reference/index.html"><span class="fa fa-book-open"></span> Manual</a></li>
<li class="nav-item"><a class="nav-link" href="authors.html"><span class="fa fa-users"></span> Authors</a></li>
</ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
<input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="search.json"></form></li>
<li class="nav-item"><a class="nav-link" href="news/index.html"><span class="fa fa-newspaper"></span> Changelog</a></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/msberends/AMR"><span class="fa fa-github"></span> Source Code</a></li>
</ul></div>
</div>
</nav><div class="container template-title-body">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="logo.svg" class="logo" alt=""><h1>CLAUDE.md — AMR R Package</h1>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/main/CLAUDE.md" class="external-link"><code>CLAUDE.md</code></a></small>
</div>
<div id="claudemd--amr-r-package" class="section level1">
<p>This file provides context for Claude Code when working in this repository.</p>
<div class="section level2">
<h2 id="project-overview">Project Overview<a class="anchor" aria-label="anchor" href="#project-overview"></a></h2>
<p><strong>AMR</strong> is a zero-dependency R package for antimicrobial resistance (AMR) data analysis using a One Health approach. It is peer-reviewed, used in 175+ countries, and supports 28 languages.</p>
<p>Key capabilities: - SIR (Susceptible/Intermediate/Resistant) classification using EUCAST 20112025 and CLSI 20112025 breakpoints - Antibiogram generation: traditional, combined, syndromic, and WISCA - Microorganism taxonomy database (~79,000 species) - Antimicrobial drug database (~620 drugs) - Multi-drug resistant organism (MDRO) classification - First-isolate identification - Minimum Inhibitory Concentration (MIC) and disk diffusion handling - Multilingual output (28 languages)</p>
</div>
<div class="section level2">
<h2 id="common-commands">Common Commands<a class="anchor" aria-label="anchor" href="#common-commands"></a></h2>
<p>All commands run inside an R session:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Rebuild documentation (roxygen2 → .Rd files + NAMESPACE)</span></span>
<span><span class="fu">devtools</span><span class="fu">::</span><span class="fu">document</span><span class="op">(</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Run all tests</span></span>
<span><span class="fu">devtools</span><span class="fu">::</span><span class="fu">test</span><span class="op">(</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Full package check (CRAN-level: docs + tests + checks)</span></span>
<span><span class="fu">devtools</span><span class="fu">::</span><span class="fu">check</span><span class="op">(</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Build pkgdown website locally</span></span>
<span><span class="fu">pkgdown</span><span class="fu">::</span><span class="fu"><a href="https://pkgdown.r-lib.org/reference/build_site.html" class="external-link">build_site</a></span><span class="op">(</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Code coverage report</span></span>
<span><span class="fu">covr</span><span class="fu">::</span><span class="fu">package_coverage</span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p>From the shell:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a><span class="co"># CRAN check from parent directory</span></span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a><span class="ex">R</span> CMD check AMR</span></code></pre></div>
</div>
<div class="section level2">
<h2 id="repository-structure">Repository Structure<a class="anchor" aria-label="anchor" href="#repository-structure"></a></h2>
<pre><code>R/ # All R source files (62 files, ~28,000 lines)
man/ # Auto-generated .Rd documentation (do not edit manually)
tests/testthat/ # testthat test files (test-*.R) and helper-functions.R
data/ # Pre-compiled .rda datasets
data-raw/ # Scripts used to generate data/ files
vignettes/ # Rmd vignette articles
inst/ # Installed files (translations, etc.)
_pkgdown.yml # pkgdown website configuration</code></pre>
</div>
<div class="section level2">
<h2 id="r-source-file-conventions">R Source File Conventions<a class="anchor" aria-label="anchor" href="#r-source-file-conventions"></a></h2>
<p><strong>Naming conventions in <code>R/</code>:</strong></p>
<table class="table"><thead><tr class="header"><th>Prefix/Name</th>
<th>Purpose</th>
</tr></thead><tbody><tr class="odd"><td><code>aa_*.R</code></td>
<td>Loaded first (helpers, globals, options, package docs)</td>
</tr><tr class="even"><td><code>zz_deprecated.R</code></td>
<td>Deprecated function wrappers</td>
</tr><tr class="odd"><td><code>zzz.R</code></td>
<td>
<code>.onLoad</code> / <code>.onAttach</code> initialization</td>
</tr></tbody></table><p><strong>Key source files:</strong></p>
<ul><li>
<code>aa_helper_functions.R</code> / <code>aa_helper_pm_functions.R</code> — internal utility functions (large; ~63 KB and ~37 KB)</li>
<li>
<code>aa_globals.R</code> — global constants and breakpoint lookup structures</li>
<li>
<code>aa_options.R</code><code>amr_options()</code> / <code>get_AMR_option()</code> system</li>
<li>
<code>mo.R</code> / <code>mo_property.R</code> — microorganism lookup and properties</li>
<li>
<code>ab.R</code> / <code>ab_property.R</code> — antimicrobial drug functions</li>
<li>
<code>av.R</code> / <code>av_property.R</code> — antiviral drug functions</li>
<li>
<code>sir.R</code> / <code>sir_calc.R</code> / <code>sir_df.R</code> — SIR classification engine</li>
<li>
<code>mic.R</code> / <code>disk.R</code> — MIC and disk diffusion classes</li>
<li>
<code>antibiogram.R</code> — antibiogram generation (traditional, combined, syndromic, WISCA)</li>
<li>
<code>first_isolate.R</code> — first-isolate identification algorithms</li>
<li>
<code>mdro.R</code> — MDRO classification (EUCAST, CLSI, CDC, custom guidelines)</li>
<li>
<code>amr_selectors.R</code> — tidyselect helpers for selecting AMR columns</li>
<li>
<code>interpretive_rules.R</code> / <code>custom_eucast_rules.R</code> — clinical interpretation rules</li>
<li>
<code>translate.R</code> — 28-language translation system</li>
<li>
<code>ggplot_sir.R</code> / <code>ggplot_pca.R</code> / <code>plotting.R</code> — visualisation functions</li>
</ul></div>
<div class="section level2">
<h2 id="custom-s3-classes">Custom S3 Classes<a class="anchor" aria-label="anchor" href="#custom-s3-classes"></a></h2>
<p>The package defines five S3 classes with full print/format/plot/vctrs support:</p>
<table class="table"><thead><tr class="header"><th>Class</th>
<th>Created by</th>
<th>Represents</th>
</tr></thead><tbody><tr class="odd"><td><code>&lt;mo&gt;</code></td>
<td><code><a href="reference/as.mo.html">as.mo()</a></code></td>
<td>Microorganism code</td>
</tr><tr class="even"><td><code>&lt;ab&gt;</code></td>
<td><code><a href="reference/as.ab.html">as.ab()</a></code></td>
<td>Antimicrobial drug code</td>
</tr><tr class="odd"><td><code>&lt;av&gt;</code></td>
<td><code><a href="reference/as.av.html">as.av()</a></code></td>
<td>Antiviral drug code</td>
</tr><tr class="even"><td><code>&lt;sir&gt;</code></td>
<td><code><a href="reference/as.sir.html">as.sir()</a></code></td>
<td>SIR value (S/I/R/SDD)</td>
</tr><tr class="odd"><td><code>&lt;mic&gt;</code></td>
<td><code><a href="reference/as.mic.html">as.mic()</a></code></td>
<td>Minimum inhibitory concentration</td>
</tr><tr class="even"><td><code>&lt;disk&gt;</code></td>
<td><code><a href="reference/as.disk.html">as.disk()</a></code></td>
<td>Disk diffusion diameter</td>
</tr></tbody></table></div>
<div class="section level2">
<h2 id="data-files">Data Files<a class="anchor" aria-label="anchor" href="#data-files"></a></h2>
<p>Pre-compiled in <code>data/</code> (do not edit directly; regenerate via <code>data-raw/</code> scripts):</p>
<table class="table"><colgroup><col width="50%"><col width="50%"></colgroup><thead><tr class="header"><th>File</th>
<th>Contents</th>
</tr></thead><tbody><tr class="odd"><td><code>microorganisms.rda</code></td>
<td>~79,000 microbial species with full taxonomy</td>
</tr><tr class="even"><td><code>antimicrobials.rda</code></td>
<td>~620 antimicrobial drugs with ATC codes</td>
</tr><tr class="odd"><td><code>antivirals.rda</code></td>
<td>Antiviral drugs</td>
</tr><tr class="even"><td><code>clinical_breakpoints.rda</code></td>
<td>EUCAST + CLSI breakpoints (20112025)</td>
</tr><tr class="odd"><td><code>intrinsic_resistant.rda</code></td>
<td>Intrinsic resistance patterns</td>
</tr><tr class="even"><td><code>example_isolates.rda</code></td>
<td>Example AMR dataset for documentation/testing</td>
</tr><tr class="odd"><td><code>WHONET.rda</code></td>
<td>Example WHONET-format dataset</td>
</tr></tbody></table></div>
<div class="section level2">
<h2 id="zero-dependency-design">Zero-Dependency Design<a class="anchor" aria-label="anchor" href="#zero-dependency-design"></a></h2>
<p>The package has <strong>no <code>Imports</code></strong> in <code>DESCRIPTION</code>. All optional integrations (ggplot2, dplyr, data.table, tidymodels, cli, crayon, etc.) are listed in <code>Suggests</code> and guarded with:</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/ns-load.html" class="external-link">requireNamespace</a></span><span class="op">(</span><span class="st">"pkg"</span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span> <span class="va">...</span> <span class="op">}</span></span></code></pre></div>
<p>Never add packages to <code>Imports</code>. If new functionality requires an external package, add it to <code>Suggests</code> and guard usage appropriately.</p>
</div>
<div class="section level2">
<h2 id="testing">Testing<a class="anchor" aria-label="anchor" href="#testing"></a></h2>
<ul><li>
<strong>Framework:</strong> <code>testthat</code> (R ≥ 3.1); legacy <code>tinytest</code> used for R 3.03.6 CI</li>
<li>
<strong>Test files:</strong> <code>tests/testthat/test-*.R</code>
</li>
<li>
<strong>Helpers:</strong> <code>tests/testthat/helper-functions.R</code>
</li>
<li>
<strong>CI matrix:</strong> GitHub Actions across Windows / macOS / Linux × R devel / release / oldrel-1 through oldrel-4</li>
<li>
<strong>Coverage:</strong> <code>covr</code> (some files excluded: <code>atc_online.R</code>, <code>mo_source.R</code>, <code>translate.R</code>, <code>resistance_predict.R</code>, <code>zz_deprecated.R</code>, helper files, <code>zzz.R</code>)</li>
</ul></div>
<div class="section level2">
<h2 id="documentation">Documentation<a class="anchor" aria-label="anchor" href="#documentation"></a></h2>
<ul><li>All exported functions use <strong>roxygen2</strong> blocks (<code>RoxygenNote: 7.3.3</code>, markdown enabled)</li>
<li>Run <code>devtools::document()</code> after any change to roxygen comments</li>
<li>Never edit files in <code>man/</code> directly — they are auto-generated</li>
<li>Vignettes live in <code>vignettes/</code> as <code>.Rmd</code> files</li>
<li>The pkgdown website is configured in <code>_pkgdown.yml</code>
</li>
</ul></div>
<div class="section level2">
<h2 id="versioning">Versioning<a class="anchor" aria-label="anchor" href="#versioning"></a></h2>
<p>Version format: <code>major.minor.patch.dev</code> (e.g., <code>3.0.1.9021</code>)</p>
<ul><li>Development versions use a <code>.9xxx</code> suffix</li>
<li>Stable CRAN releases drop the dev suffix (e.g., <code>3.0.1</code>)</li>
<li>
<code>NEWS.md</code> uses sections <strong>New</strong>, <strong>Fixes</strong>, <strong>Updates</strong> with GitHub issue references (<code>#NNN</code>)</li>
</ul><div class="section level3">
<h3 id="version-and-date-bump-required-for-every-pr">Version and date bump required for every PR<a class="anchor" aria-label="anchor" href="#version-and-date-bump-required-for-every-pr"></a></h3>
<p>All PRs are <strong>squash-merged</strong>, so each PR lands as exactly <strong>one commit</strong> on the default branch. Version numbers are kept in sync with the cumulative commit count since the last released tag. Therefore <strong>exactly one version bump is allowed per PR</strong>, regardless of how many intermediate commits are made on the branch.</p>
<div class="section level4">
<h4 id="computing-the-correct-version-number">Computing the correct version number<a class="anchor" aria-label="anchor" href="#computing-the-correct-version-number"></a></h4>
<p>Run the following from the repo root to determine the version string to use:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="va">currenttag</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> describe <span class="at">--tags</span> <span class="at">--abbrev</span><span class="op">=</span>0 <span class="kw">|</span> <span class="fu">sed</span> <span class="st">'s/v//'</span><span class="va">)</span></span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a><span class="va">currenttagfull</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> describe <span class="at">--tags</span> <span class="at">--abbrev</span><span class="op">=</span>0<span class="va">)</span></span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="va">defaultbranch</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> branch <span class="kw">|</span> <span class="fu">cut</span> <span class="at">-c</span> 3- <span class="kw">|</span> <span class="fu">grep</span> <span class="at">-E</span> <span class="st">'^master$|^main$'</span><span class="va">)</span></span>
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a><span class="va">currentcommit</span><span class="op">=</span><span class="va">$(</span><span class="fu">git</span> rev-list <span class="at">--count</span> <span class="va">${currenttagfull}</span>..<span class="va">${defaultbranch})</span></span>
<span id="cb5-5"><a href="#cb5-5" tabindex="-1"></a><span class="va">currentversion</span><span class="op">=</span><span class="st">"</span><span class="va">${currenttag}</span><span class="st">.</span><span class="va">$((currentcommit</span> <span class="op">+</span> <span class="dv">9001</span> <span class="op">+</span> <span class="dv">1</span><span class="va">))</span><span class="st">"</span></span>
<span id="cb5-6"><a href="#cb5-6" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"</span><span class="va">$currentversion</span><span class="st">"</span></span></code></pre></div>
<p>The <code>+ 1</code> accounts for the fact that this PRs squash commit is not yet on the default branch. Set <strong>both</strong> of these files to the resulting version string (and only once per PR, even across multiple commits):</p>
<ol style="list-style-type: decimal"><li><p><strong><code>DESCRIPTION</code></strong> — the <code>Version:</code> field</p></li>
<li>
<p><strong><code>NEWS.md</code></strong><strong>only replace line 1</strong> (the <code># AMR &lt;version&gt;</code> heading) with the new version number; do <strong>not</strong> create a new section. <code>NEWS.md</code> is a <strong>continuous log</strong> for the entire current <code>x.y.z.9nnn</code> development series: all changes since the last stable release accumulate under that single heading. After updating line 1, append the new change as a bullet under the appropriate sub-heading (<code>### New</code>, <code>### Fixes</code>, or <code>### Updates</code>).</p>
<p>Style rules for <code>NEWS.md</code> entries:</p>
<ul><li>Be <strong>extremely concise</strong> — one short line per item</li>
<li>Do <strong>not</strong> end with a full stop (period)</li>
<li>No verbose explanations; just the essential fact</li>
</ul></li>
</ol><p>If <code>git describe</code> fails (e.g. no tags exist in the environment), fall back to reading the current version from <code>DESCRIPTION</code> and adding 1 to the last numeric component — but only if no bump has already been made in this PR.</p>
</div>
<div class="section level4">
<h4 id="date-field">Date field<a class="anchor" aria-label="anchor" href="#date-field"></a></h4>
<p>The <code>Date:</code> field in <code>DESCRIPTION</code> must reflect the date of the <strong>last commit to the PR</strong> (not the first), in ISO format. Update it with every commit so it is always current:</p>
<pre><code><span><span class="va">Date</span><span class="op">:</span> <span class="fl">2026</span><span class="op">-</span><span class="fl">03</span><span class="op">-</span><span class="fl">07</span></span></code></pre>
</div>
</div>
</div>
<div class="section level2">
<h2 id="internal-state">Internal State<a class="anchor" aria-label="anchor" href="#internal-state"></a></h2>
<p>The package uses a private <code>AMR_env</code> environment (created in <code>aa_globals.R</code>) for caching expensive lookups (e.g., microorganism matching scores, breakpoint tables). This avoids re-computation within a session.</p>
</div>
</div>
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
</nav></aside></div>
<footer><div class="pkgdown-footer-left">
<p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
</div>
<div class="pkgdown-footer-right">
<p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://amr-for-r.org/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl" class="external-link"><img src="https://amr-for-r.org/logo_umcg.svg" style="max-width: 150px;"></a></p>
</div>
</footer></div>
</body></html>

224
CLAUDE.md Normal file
View File

@@ -0,0 +1,224 @@
# CLAUDE.md — AMR R Package
This file provides context for Claude Code when working in this
repository.
## Project Overview
**AMR** is a zero-dependency R package for antimicrobial resistance
(AMR) data analysis using a One Health approach. It is peer-reviewed,
used in 175+ countries, and supports 28 languages.
Key capabilities: - SIR (Susceptible/Intermediate/Resistant)
classification using EUCAST 20112025 and CLSI 20112025 breakpoints -
Antibiogram generation: traditional, combined, syndromic, and WISCA -
Microorganism taxonomy database (~79,000 species) - Antimicrobial drug
database (~620 drugs) - Multi-drug resistant organism (MDRO)
classification - First-isolate identification - Minimum Inhibitory
Concentration (MIC) and disk diffusion handling - Multilingual output
(28 languages)
## Common Commands
All commands run inside an R session:
``` r
# Rebuild documentation (roxygen2 → .Rd files + NAMESPACE)
devtools::document()
# Run all tests
devtools::test()
# Full package check (CRAN-level: docs + tests + checks)
devtools::check()
# Build pkgdown website locally
pkgdown::build_site()
# Code coverage report
covr::package_coverage()
```
From the shell:
``` bash
# CRAN check from parent directory
R CMD check AMR
```
## Repository Structure
R/ # All R source files (62 files, ~28,000 lines)
man/ # Auto-generated .Rd documentation (do not edit manually)
tests/testthat/ # testthat test files (test-*.R) and helper-functions.R
data/ # Pre-compiled .rda datasets
data-raw/ # Scripts used to generate data/ files
vignettes/ # Rmd vignette articles
inst/ # Installed files (translations, etc.)
_pkgdown.yml # pkgdown website configuration
## R Source File Conventions
**Naming conventions in `R/`:**
| Prefix/Name | Purpose |
|-------------------|--------------------------------------------------------|
| `aa_*.R` | Loaded first (helpers, globals, options, package docs) |
| `zz_deprecated.R` | Deprecated function wrappers |
| `zzz.R` | `.onLoad` / `.onAttach` initialization |
**Key source files:**
- `aa_helper_functions.R` / `aa_helper_pm_functions.R` — internal
utility functions (large; ~63 KB and ~37 KB)
- `aa_globals.R` — global constants and breakpoint lookup structures
- `aa_options.R` — `amr_options()` / `get_AMR_option()` system
- `mo.R` / `mo_property.R` — microorganism lookup and properties
- `ab.R` / `ab_property.R` — antimicrobial drug functions
- `av.R` / `av_property.R` — antiviral drug functions
- `sir.R` / `sir_calc.R` / `sir_df.R` — SIR classification engine
- `mic.R` / `disk.R` — MIC and disk diffusion classes
- `antibiogram.R` — antibiogram generation (traditional, combined,
syndromic, WISCA)
- `first_isolate.R` — first-isolate identification algorithms
- `mdro.R` — MDRO classification (EUCAST, CLSI, CDC, custom guidelines)
- `amr_selectors.R` — tidyselect helpers for selecting AMR columns
- `interpretive_rules.R` / `custom_eucast_rules.R` — clinical
interpretation rules
- `translate.R` — 28-language translation system
- `ggplot_sir.R` / `ggplot_pca.R` / `plotting.R` — visualisation
functions
## Custom S3 Classes
The package defines five S3 classes with full print/format/plot/vctrs
support:
| Class | Created by | Represents |
|----------|-----------------------------------------------------------|----------------------------------|
| `<mo>` | [`as.mo()`](https://amr-for-r.org/reference/as.mo.md) | Microorganism code |
| `<ab>` | [`as.ab()`](https://amr-for-r.org/reference/as.ab.md) | Antimicrobial drug code |
| `<av>` | [`as.av()`](https://amr-for-r.org/reference/as.av.md) | Antiviral drug code |
| `<sir>` | [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) | SIR value (S/I/R/SDD) |
| `<mic>` | [`as.mic()`](https://amr-for-r.org/reference/as.mic.md) | Minimum inhibitory concentration |
| `<disk>` | [`as.disk()`](https://amr-for-r.org/reference/as.disk.md) | Disk diffusion diameter |
## Data Files
Pre-compiled in `data/` (do not edit directly; regenerate via
`data-raw/` scripts):
| File | Contents |
|----------------------------|-----------------------------------------------|
| `microorganisms.rda` | ~79,000 microbial species with full taxonomy |
| `antimicrobials.rda` | ~620 antimicrobial drugs with ATC codes |
| `antivirals.rda` | Antiviral drugs |
| `clinical_breakpoints.rda` | EUCAST + CLSI breakpoints (20112025) |
| `intrinsic_resistant.rda` | Intrinsic resistance patterns |
| `example_isolates.rda` | Example AMR dataset for documentation/testing |
| `WHONET.rda` | Example WHONET-format dataset |
## Zero-Dependency Design
The package has **no `Imports`** in `DESCRIPTION`. All optional
integrations (ggplot2, dplyr, data.table, tidymodels, cli, crayon, etc.)
are listed in `Suggests` and guarded with:
``` r
if (requireNamespace("pkg", quietly = TRUE)) { ... }
```
Never add packages to `Imports`. If new functionality requires an
external package, add it to `Suggests` and guard usage appropriately.
## Testing
- **Framework:** `testthat` (R ≥ 3.1); legacy `tinytest` used for R
3.03.6 CI
- **Test files:** `tests/testthat/test-*.R`
- **Helpers:** `tests/testthat/helper-functions.R`
- **CI matrix:** GitHub Actions across Windows / macOS / Linux × R devel
/ release / oldrel-1 through oldrel-4
- **Coverage:** `covr` (some files excluded: `atc_online.R`,
`mo_source.R`, `translate.R`, `resistance_predict.R`,
`zz_deprecated.R`, helper files, `zzz.R`)
## Documentation
- All exported functions use **roxygen2** blocks (`RoxygenNote: 7.3.3`,
markdown enabled)
- Run `devtools::document()` after any change to roxygen comments
- Never edit files in `man/` directly — they are auto-generated
- Vignettes live in `vignettes/` as `.Rmd` files
- The pkgdown website is configured in `_pkgdown.yml`
## Versioning
Version format: `major.minor.patch.dev` (e.g., `3.0.1.9021`)
- Development versions use a `.9xxx` suffix
- Stable CRAN releases drop the dev suffix (e.g., `3.0.1`)
- `NEWS.md` uses sections **New**, **Fixes**, **Updates** with GitHub
issue references (`#NNN`)
### Version and date bump required for every PR
All PRs are **squash-merged**, so each PR lands as exactly **one
commit** on the default branch. Version numbers are kept in sync with
the cumulative commit count since the last released tag. Therefore
**exactly one version bump is allowed per PR**, regardless of how many
intermediate commits are made on the branch.
#### Computing the correct version number
Run the following from the repo root to determine the version string to
use:
``` bash
currenttag=$(git describe --tags --abbrev=0 | sed 's/v//')
currenttagfull=$(git describe --tags --abbrev=0)
defaultbranch=$(git branch | cut -c 3- | grep -E '^master$|^main$')
currentcommit=$(git rev-list --count ${currenttagfull}..${defaultbranch})
currentversion="${currenttag}.$((currentcommit + 9001 + 1))"
echo "$currentversion"
```
The `+ 1` accounts for the fact that this PRs squash commit is not yet
on the default branch. Set **both** of these files to the resulting
version string (and only once per PR, even across multiple commits):
1. **`DESCRIPTION`** — the `Version:` field
2. **`NEWS.md`** — **only replace line 1** (the `# AMR <version>`
heading) with the new version number; do **not** create a new
section. `NEWS.md` is a **continuous log** for the entire current
`x.y.z.9nnn` development series: all changes since the last stable
release accumulate under that single heading. After updating line 1,
append the new change as a bullet under the appropriate sub-heading
(`### New`, `### Fixes`, or `### Updates`).
Style rules for `NEWS.md` entries:
- Be **extremely concise** — one short line per item
- Do **not** end with a full stop (period)
- No verbose explanations; just the essential fact
If `git describe` fails (e.g. no tags exist in the environment), fall
back to reading the current version from `DESCRIPTION` and adding 1 to
the last numeric component — but only if no bump has already been made
in this PR.
#### Date field
The `Date:` field in `DESCRIPTION` must reflect the date of the **last
commit to the PR** (not the first), in ISO format. Update it with every
commit so it is always current:
Date: 2026-03-07
## Internal State
The package uses a private `AMR_env` environment (created in
`aa_globals.R`) for caching expensive lookups (e.g., microorganism
matching scores, breakpoint tables). This avoids re-computation within a
session.

View File

@@ -7,7 +7,7 @@
<a class="navbar-brand me-2" href="index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">

250
LICENSE-text.md Normal file
View File

@@ -0,0 +1,250 @@
# License
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
A SUMMARY OF THIS LICENSE BY THE ORIGINAL AUTHORS OF THE AMR R PACKAGE
This R package, with package name 'AMR':
- May be used for commercial purposes
- May be used for private purposes
- May NOT be used for patent purposes
- May be modified, although:
- Modifications MUST be released under the same license when distributing the package
- Changes made to the code MUST be documented
- May be distributed, although:
- Source code MUST be made available when the package is distributed
- A copy of the license and copyright notice MUST be included with the package.
- Comes with a LIMITATION of liability
- Comes with NO warranty
END OF THE SUMMARY
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -91,7 +91,7 @@
website update since they are based on randomly created values and the
page was written in <a href="https://rmarkdown.rstudio.com/" class="external-link">R
Markdown</a>. However, the methodology remains unchanged. This page was
generated on 01 September 2025.</p>
generated on 02 April 2026.</p>
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
@@ -125,7 +125,7 @@ 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)
microorganisms and antimicrobial drugs, determination of (multi-drug)
resistant microorganisms, and calculation of antimicrobial resistance,
prevalence and future trends.</p>
</div>
@@ -147,21 +147,21 @@ make the structure of your data generally look like this:</p>
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2025-09-01</td>
<td align="center">2026-04-02</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2025-09-01</td>
<td align="center">2026-04-02</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2025-09-01</td>
<td align="center">2026-04-02</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@@ -224,16 +224,16 @@ short, but still human readable. More importantly, <code><a href="../reference/a
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; Class <span style="color: #0000BB;">&lt;mo&gt;</span></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; Class <span style="color: #0000BB;">&lt;mo&gt;</span></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; Class <span style="color: #0000BB;">&lt;mo&gt;</span></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; Class <span style="color: #0000BB;">&lt;mo&gt;</span></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>
@@ -263,56 +263,51 @@ user input can be used:</p>
<p>Now we can thus clean our data:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">our_data</span><span class="op">$</span><span class="va">bacteria</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/as.mo.html">as.mo</a></span><span class="op">(</span><span class="va">our_data</span><span class="op">$</span><span class="va">bacteria</span>, info <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Retrieved values from the </span><span style="color: #0000BB; background-color: #EEEEEE;">`microorganisms.codes`</span><span style="color: #0000BB;"> data set for "ESCCOL",</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; "KLEPNE", "STAAUR", and "STRPNE".</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Microorganism translation was uncertain for four microorganisms. Run</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; </span><span style="color: #0000BB; background-color: #EEEEEE;">`mo_uncertainties()`</span><span style="color: #0000BB;"> to review these uncertainties, or use</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; </span><span style="color: #0000BB; background-color: #EEEEEE;">`add_custom_microorganisms()`</span><span style="color: #0000BB;"> to add custom entries.</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Retrieved values from the `microorganisms.codes` data set for <span style="color: #0000BB;">"ESCCOL"</span>,</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"KLEPNE"</span>, <span style="color: #0000BB;">"STAAUR"</span>, and <span style="color: #0000BB;">"STRPNE"</span>.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> 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; <span style="color: #0000BB;">Matching scores are based on the resemblance between the input and the full</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; taxonomic name, and the pathogenicity in humans. See </span><span style="color: #0000BB; background-color: #EEEEEE;">`?mo_matching_score`</span><span style="color: #0000BB;">.</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">Colour keys: </span><span style="color: #080808; background-color: #FFAFAF;"> 0.000-0.549 </span><span style="color: #080808; background-color: #FFD787;"> 0.550-0.649 </span><span style="color: #080808; background-color: #FFFF87;"> 0.650-0.749 </span><span style="color: #080808; background-color: #5FD7AF;"> 0.750-1.000 </span></span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">--------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; "E. coli" -&gt; <span style="font-weight: bold; font-style: italic;">Escherichia coli</span> (B_ESCHR_COLI, <span style="color: #080808; background-color: #FFFF87;">0.688</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Enterococcus crotali</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.650</span>), <span style="font-style: italic;">Escherichia coli coli</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFD787;">0.643</span>), <span style="font-style: italic;">Escherichia coli expressing</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.611</span>), <span style="font-style: italic;">Enterobacter cowanii</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFD787;">0.600</span>), <span style="font-style: italic;">Enterococcus columbae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.595</span>), <span style="font-style: italic;">Enterococcus camelliae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.591</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Enterococcus casseliflavus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.577</span>), <span style="font-style: italic;">Enterobacter cloacae cloacae</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFD787;">0.571</span>), <span style="font-style: italic;">Enterobacter cloacae</span> complex<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.571</span>), and <span style="font-style: italic;">Enterobacter cloacae</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; dissolvens</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.565</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">--------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; "K. pneumoniae" -&gt; <span style="font-weight: bold; font-style: italic;">Klebsiella pneumoniae</span> (B_KLBSL_PNMN, <span style="color: #080808; background-color: #5FD7AF;">0.786</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Klebsiella pneumoniae</span> complex<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.707</span>), <span style="font-style: italic;">Klebsiella</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; pneumoniae ozaenae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.707</span>), <span style="font-style: italic;">Klebsiella pneumoniae pneumoniae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.688</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Klebsiella pneumoniae rhinoscleromatis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.658</span>), <span style="font-style: italic;">Klebsiella pasteurii</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFAFAF;">0.500</span>), <span style="font-style: italic;">Klebsiella planticola</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.500</span>), <span style="font-style: italic;">Kingella potus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.400</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Kluyveromyces pseudotropicale</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.386</span>), <span style="font-style: italic;">Kluyveromyces pseudotropicalis</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFAFAF;">0.363</span>), and <span style="font-style: italic;">Kosakonia pseudosacchari</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.361</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">--------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; "S. aureus" -&gt; <span style="font-weight: bold; font-style: italic;">Staphylococcus aureus</span> (B_STPHY_AURS, <span style="color: #080808; background-color: #FFFF87;">0.690</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Staphylococcus aureus aureus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.643</span>), <span style="font-style: italic;">Staphylococcus</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; argenteus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.625</span>), <span style="font-style: italic;">Staphylococcus aureus anaerobius</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.625</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Staphylococcus auricularis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.615</span>), <span style="font-style: italic;">Salmonella</span> Aurelianis<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.595</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Salmonella</span> Aarhus<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.588</span>), <span style="font-style: italic;">Salmonella</span> Amounderness<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.587</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Staphylococcus argensis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.587</span>), <span style="font-style: italic;">Streptococcus australis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.587</span>), and</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Salmonella choleraesuis arizonae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.562</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">--------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; "S. pneumoniae" -&gt; <span style="font-weight: bold; font-style: italic;">Streptococcus pneumoniae</span> (B_STRPT_PNMN, <span style="color: #080808; background-color: #5FD7AF;">0.750</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Streptococcus pseudopneumoniae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.700</span>), <span style="font-style: italic;">Streptococcus</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; phocae salmonis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.552</span>), <span style="font-style: italic;">Serratia proteamaculans quinovora</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.545</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Streptococcus pseudoporcinus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.536</span>), <span style="font-style: italic;">Staphylococcus piscifermentans</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (</span><span style="color: #080808; background-color: #FFAFAF;">0.533</span>), <span style="font-style: italic;">Staphylococcus pseudintermedius</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.532</span>), <span style="font-style: italic;">Serratia</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; proteamaculans proteamaculans</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.526</span>), <span style="font-style: italic;">Streptococcus gallolyticus</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; pasteurianus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.526</span>), <span style="font-style: italic;">Salmonella</span> Portanigra<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.524</span>), and <span style="font-style: italic;">Streptococcus</span></span></span>
<span><span class="co"><span style="font-style: italic;">#&gt; periodonticum</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFAFAF;">0.519</span>)</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; Only the first 10 other matches of each record are shown. Run</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; </span><span style="color: #0000BB; background-color: #EEEEEE;">`print(mo_uncertainties(), n = ...)`</span><span style="color: #0000BB;"> to view more entries, or save</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; </span><span style="color: #0000BB; background-color: #EEEEEE;">`mo_uncertainties()`</span><span style="color: #0000BB;"> to an object.</span></span></span></code></pre></div>
<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; Colour keys: <span style="color: #080808; background-color: #FF5F5F;"> 0.000-0.549 </span><span style="color: #080808; background-color: #FFD787;"> 0.550-0.649 </span><span style="color: #080808; background-color: #FFFF87;"> 0.650-0.749 </span><span style="color: #080808; background-color: #5FD7AF;"> 0.750-1.000 </span></span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">-------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"E. coli"</span> -&gt; <span style="font-weight: bold; font-style: italic;">Escherichia coli</span> (B_ESCHR_COLI, <span style="color: #080808; background-color: #FFFF87;">0.688</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Enterococcus crotali</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.650</span>), <span style="font-style: italic;">Escherichia coli coli</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.643</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Escherichia coli expressing</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.611</span>), <span style="font-style: italic;">Enterobacter cowanii</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.600</span>), <span style="font-style: italic;">Enterococcus</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">columbae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.595</span>), <span style="font-style: italic;">Enterococcus camelliae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.591</span>), <span style="font-style: italic;">Enterococcus casseliflavus</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FFD787;">0.577</span>), <span style="font-style: italic;">Enterobacter cloacae cloacae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.571</span>), <span style="font-style: italic;">Enterobacter cloacae</span> complex</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FFD787;">0.571</span>), and <span style="font-style: italic;">Enterobacter cloacae dissolvens</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.565</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">-------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"K. pneumoniae"</span> -&gt; <span style="font-weight: bold; font-style: italic;">Klebsiella pneumoniae</span> (B_KLBSL_PNMN, <span style="color: #080808; background-color: #5FD7AF;">0.786</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Klebsiella pneumoniae</span> complex<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.707</span>), <span style="font-style: italic;">Klebsiella pneumoniae</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">ozaenae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.707</span>), <span style="font-style: italic;">Klebsiella pneumoniae pneumoniae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.688</span>), <span style="font-style: italic;">Klebsiella</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">pneumoniae rhinoscleromatis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.658</span>), <span style="font-style: italic;">Klebsiella pasteurii</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.500</span>), <span style="font-style: italic;">Klebsiella</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">planticola</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.500</span>), <span style="font-style: italic;">Kingella potus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.400</span>), <span style="font-style: italic;">Kluyveromyces pseudotropicale</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FF5F5F;">0.386</span>), <span style="font-style: italic;">Kluyveromyces pseudotropicalis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.363</span>), and <span style="font-style: italic;">Kosakonia pseudosacchari</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FF5F5F;">0.361</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">-------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"S. aureus"</span> -&gt; <span style="font-weight: bold; font-style: italic;">Staphylococcus aureus</span> (B_STPHY_AURS, <span style="color: #080808; background-color: #FFFF87;">0.690</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Staphylococcus aureus aureus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.643</span>), <span style="font-style: italic;">Staphylococcus argenteus</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FFD787;">0.625</span>), <span style="font-style: italic;">Staphylococcus aureus anaerobius</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.625</span>), <span style="font-style: italic;">Staphylococcus auricularis</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FFD787;">0.615</span>), <span style="font-style: italic;">Salmonella</span> Aurelianis<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.595</span>), <span style="font-style: italic;">Salmonella</span> Aarhus<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.588</span>), <span style="font-style: italic;">Salmonella</span></span></span>
<span><span class="co">#&gt; Amounderness<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.587</span>), <span style="font-style: italic;">Staphylococcus argensis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.587</span>), <span style="font-style: italic;">Streptococcus australis</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">(</span><span style="color: #080808; background-color: #FFD787;">0.587</span>), and <span style="font-style: italic;">Salmonella choleraesuis arizonae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.562</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #B2B2B2;">-------------------------------------------------------------------------------</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"S. pneumoniae"</span> -&gt; <span style="font-weight: bold; font-style: italic;">Streptococcus pneumoniae</span> (B_STRPT_PNMN, <span style="color: #080808; background-color: #5FD7AF;">0.750</span>)</span></span>
<span><span class="co">#&gt; Also matched: <span style="font-style: italic;">Streptococcus pseudopneumoniae</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFFF87;">0.700</span>), <span style="font-style: italic;">Streptococcus phocae</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">salmonis</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FFD787;">0.552</span>), <span style="font-style: italic;">Serratia proteamaculans quinovora</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.545</span>), <span style="font-style: italic;">Streptococcus</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">pseudoporcinus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.536</span>), <span style="font-style: italic;">Staphylococcus piscifermentans</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.533</span>), <span style="font-style: italic;">Staphylococcus</span></span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">pseudintermedius</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.532</span>), <span style="font-style: italic;">Serratia proteamaculans proteamaculans</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.526</span>),</span></span>
<span><span class="co">#&gt; <span style="font-style: italic;">Streptococcus gallolyticus pasteurianus</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.526</span>), <span style="font-style: italic;">Salmonella</span> Portanigra<span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.524</span>),</span></span>
<span><span class="co">#&gt; and <span style="font-style: italic;">Streptococcus periodonticum</span><span style="color: #0000BB;"> (</span><span style="color: #080808; background-color: #FF5F5F;">0.519</span>)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Only the first 10 other matches of each record are shown. Run ``</span></span>
<span><span class="co">#&gt; `print(mo_uncertainties(), n = ...)` `` to view more entries, or save</span></span>
<span><span class="co">#&gt; `mo_uncertainties()` to an object.</span></span></code></pre></div>
<p>Thats all good.</p>
</div>
<div class="section level3">
@@ -342,14 +337,14 @@ dplyr:</p>
<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 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> J8 A 2016-06-14 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> M3 A 2015-10-25 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> J8 A 2016-06-14 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> M3 A 2015-10-25 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> J3 A 2019-06-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> G6 A 2015-04-27 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 2,990 more rows</span></span></span></code></pre></div>
@@ -399,14 +394,15 @@ the methods on the <code><a href="../reference/first_isolate.html">first_isolate
<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>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>first <span class="op">=</span> <span class="fu"><a href="../reference/first_isolate.html">first_isolate</a></span><span class="op">(</span>info <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #BB0000;"> Determining first isolates using an episode length of </span><span style="color: #BB0000; font-weight: bold;">365 days</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Using column '</span><span style="color: #0000BB; font-weight: bold;">bacteria</span><span style="color: #0000BB;">' as input for </span><span style="color: #0000BB; background-color: #EEEEEE;">`col_mo`</span><span style="color: #0000BB;">.</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Using column '</span><span style="color: #0000BB; font-weight: bold;">date</span><span style="color: #0000BB;">' as input for </span><span style="color: #0000BB; background-color: #EEEEEE;">`col_date`</span><span style="color: #0000BB;">.</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Using column '</span><span style="color: #0000BB; font-weight: bold;">patient_id</span><span style="color: #0000BB;">' as input for </span><span style="color: #0000BB; background-color: #EEEEEE;">`col_patient_id`</span><span style="color: #0000BB;">.</span></span></span>
<span><span class="co">#&gt; <span style="color: #BB0000;"> Basing inclusion on all antimicrobial results, using a points threshold</span></span></span>
<span><span class="co"><span style="color: #BB0000;">#&gt; of 2</span></span></span>
<span><span class="co">#&gt; <span style="color: #080808;">=&gt; Found </span><span style="color: #080808; font-weight: bold;">2,724 'phenotype-based' first isolates</span><span style="color: #080808;"> (90.8% of total where a</span></span></span>
<span><span class="co"><span style="color: #080808;">#&gt; microbial ID was available)</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Determining first isolates using an episode length of <span style="font-weight: bold;">365 days</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Using column <span style="color: #00BB00; font-weight: bold;">bacteria</span> as input for `col_mo`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Column <span style="color: #00BB00; font-weight: bold;">first</span> is SIR eligible (despite only having empty values), since it</span></span>
<span><span class="co">#&gt; seems to be cefozopran (ZOP)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Using column <span style="color: #00BB00; font-weight: bold;">date</span> as input for `col_date`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Using column <span style="color: #00BB00; font-weight: bold;">patient_id</span> as input for `col_patient_id`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Basing inclusion on all antimicrobial results, using a points threshold of 2</span></span>
<span><span class="co">#&gt; =&gt; Found <span style="font-weight: bold;">2,724 'phenotype-based' first isolates</span> (90.8% of total where a</span></span>
<span><span class="co">#&gt; microbial ID was available)</span></span></code></pre></div>
<p>So only 91% is suitable for resistance analysis! We can now filter on
it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter()</a></code> function, also from the
<code>dplyr</code> package:</p>
@@ -424,13 +420,13 @@ like:</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 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 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J3 A 2012-11-21 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R7 A 2018-04-03 <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> P3 A 2014-09-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> P10 A 2015-12-10 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B7 A 2015-03-02 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> M3 A 2015-10-25 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> W3 A 2018-03-31 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> M3 A 2015-10-25 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> J3 A 2019-06-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> G6 A 2015-04-27 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> P4 A 2011-06-21 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
@@ -523,7 +519,8 @@ 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/antimicrobial_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using column '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using column <span style="color: #00BB00; font-weight: bold;">GEN</span></span></span>
<span><span class="co">#&gt; (gentamicin)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 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>
@@ -541,18 +538,18 @@ in:</p>
<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/antimicrobial_selectors.html">betalactams</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`betalactams()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">AMX</span><span style="color: #0000BB;">' (amoxicillin) and '</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (amoxicillin/clavulanic acid)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `betalactams()` using columns <span style="color: #00BB00; font-weight: bold;">AMX</span> (amoxicillin) and <span style="color: #00BB00; font-weight: bold;">AMC</span></span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 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> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFD787;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
@@ -563,13 +560,13 @@ in:</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,724 × 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> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFD787;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> <span style="color: #949494;">B_</span>KLBSL<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #AFFFD7;"> I </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
@@ -578,58 +575,59 @@ in:</p>
<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/antimicrobial_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; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using column '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using column <span style="color: #00BB00; font-weight: bold;">GEN</span></span></span>
<span><span class="co">#&gt; (gentamicin)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 981 × 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 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> X1 A 2017-07-04 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B3 A 2016-07-24 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> V7 A 2012-04-03 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> C9 A 2017-03-23 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> R1 A 2018-06-10 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> S2 A 2013-07-19 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> P5 A 2019-03-09 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> Q8 A 2019-08-10 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> K5 A 2013-03-15 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> J5 A 2017-12-25 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> X1 A 2017-07-04 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> B3 A 2016-07-24 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> V7 A 2012-04-03 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> C9 A 2017-03-23 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> R1 A 2018-06-10 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> S2 A 2013-07-19 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> P5 A 2019-03-09 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> Q8 A 2019-08-10 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> K5 A 2013-03-15 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 971 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/antimicrobial_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; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`betalactams()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">AMX</span><span style="color: #0000BB;">' (amoxicillin) and '</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (amoxicillin/clavulanic acid)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `betalactams()` using columns <span style="color: #00BB00; font-weight: bold;">AMX</span> (amoxicillin) and <span style="color: #00BB00; font-weight: bold;">AMC</span></span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 462 × 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 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> M7 A 2013-07-22 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 452 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/antimicrobial_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; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`betalactams()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">AMX</span><span style="color: #0000BB;">' (amoxicillin) and '</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (amoxicillin/clavulanic acid)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `betalactams()` using columns <span style="color: #00BB00; font-weight: bold;">AMX</span> (amoxicillin) and <span style="color: #00BB00; font-weight: bold;">AMC</span></span></span>
<span><span class="co">#&gt; (amoxicillin/clavulanic acid)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 462 × 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 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> M7 A 2013-07-22 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> R10 A 2013-12-20 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> R7 A 2015-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> R8 A 2019-10-25 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> B6 A 2016-11-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> I7 A 2015-08-19 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> N3 A 2014-12-29 <span style="color: #949494;">B_</span>STRPT<span style="color: #949494;">_</span>PNMN <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> Q2 A 2019-09-22 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> X7 A 2011-03-20 <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> V1 A 2018-08-07 <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> TRUE </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 452 more rows</span></span></span></code></pre></div>
</div>
<div class="section level3">
@@ -670,16 +668,16 @@ like:</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,000 × 46</span></span></span>
<span><span class="co">#&gt; date patient age gender ward mo PEN OXA FLC AMX </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 1,990 more rows</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span></span>
@@ -697,9 +695,9 @@ previously mentioned antibiotic class selectors:</p>
<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">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu"><a href="../reference/antimicrobial_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="../reference/antimicrobial_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin), '</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (tobramycin), '</span><span style="color: #0000BB; font-weight: bold;">AMK</span><span style="color: #0000BB;">' (amikacin), and '</span><span style="color: #0000BB; font-weight: bold;">KAN</span><span style="color: #0000BB;">' (kanamycin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`carbapenems()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">IPM</span><span style="color: #0000BB;">' (imipenem) and '</span><span style="color: #0000BB; font-weight: bold;">MEM</span><span style="color: #0000BB;">' (meropenem)</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using columns <span style="color: #00BB00; font-weight: bold;">GEN</span> (gentamicin), <span style="color: #00BB00; font-weight: bold;">TOB</span> (tobramycin), <span style="color: #00BB00; font-weight: bold;">AMK</span></span></span>
<span><span class="co">#&gt; (amikacin), and <span style="color: #00BB00; font-weight: bold;">KAN</span> (kanamycin)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `carbapenems()` using columns <span style="color: #00BB00; font-weight: bold;">IPM</span> (imipenem) and <span style="color: #00BB00; font-weight: bold;">MEM</span> (meropenem)</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="12%">
@@ -828,8 +826,8 @@ language to be Spanish using the <code>language</code> argument:</p>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="../reference/antimicrobial_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>,</span>
<span> ab_transform <span class="op">=</span> <span class="st">"name"</span>,</span>
<span> language <span class="op">=</span> <span class="st">"es"</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin), '</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (tobramycin), '</span><span style="color: #0000BB; font-weight: bold;">AMK</span><span style="color: #0000BB;">' (amikacin), and '</span><span style="color: #0000BB; font-weight: bold;">KAN</span><span style="color: #0000BB;">' (kanamycin)</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using columns <span style="color: #00BB00; font-weight: bold;">GEN</span> (gentamicin), <span style="color: #00BB00; font-weight: bold;">TOB</span> (tobramycin), <span style="color: #00BB00; font-weight: bold;">AMK</span></span></span>
<span><span class="co">#&gt; (amikacin), and <span style="color: #00BB00; font-weight: bold;">KAN</span> (kanamycin)</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="15%">
@@ -954,9 +952,9 @@ argument must be used. This can be any column in the data, or e.g. an
<code class="sourceCode R"><span><span class="fu"><a href="../reference/antibiogram.html">antibiogram</a></span><span class="op">(</span><span class="va">example_isolates</span>,</span>
<span> antibiotics <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu"><a href="../reference/antimicrobial_selectors.html">aminoglycosides</a></span><span class="op">(</span><span class="op">)</span>, <span class="fu"><a href="../reference/antimicrobial_selectors.html">carbapenems</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span>,</span>
<span> syndromic_group <span class="op">=</span> <span class="st">"ward"</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin), '</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (tobramycin), '</span><span style="color: #0000BB; font-weight: bold;">AMK</span><span style="color: #0000BB;">' (amikacin), and '</span><span style="color: #0000BB; font-weight: bold;">KAN</span><span style="color: #0000BB;">' (kanamycin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`carbapenems()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">IPM</span><span style="color: #0000BB;">' (imipenem) and '</span><span style="color: #0000BB; font-weight: bold;">MEM</span><span style="color: #0000BB;">' (meropenem)</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using columns <span style="color: #00BB00; font-weight: bold;">GEN</span> (gentamicin), <span style="color: #00BB00; font-weight: bold;">TOB</span> (tobramycin), <span style="color: #00BB00; font-weight: bold;">AMK</span></span></span>
<span><span class="co">#&gt; (amikacin), and <span style="color: #00BB00; font-weight: bold;">KAN</span> (kanamycin)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `carbapenems()` using columns <span style="color: #00BB00; font-weight: bold;">IPM</span> (imipenem) and <span style="color: #00BB00; font-weight: bold;">MEM</span> (meropenem)</span></span></code></pre></div>
<table class="table">
<colgroup>
<col width="10%">
@@ -1254,7 +1252,7 @@ function on a grouped <code>tibble</code>, i.e., using
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">combined_ab</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_files/figure-html/unnamed-chunk-10-1.png" width="720"></p>
<p><img src="AMR_files/figure-html/unnamed-chunk-10-1.png" class="r-plt" alt="" 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>
@@ -1283,6 +1281,10 @@ I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equa
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; <span style="color: #00BBBB;"></span> `resistance()` assumes the EUCAST guideline and thus considers the 'I'</span></span>
<span><span class="co">#&gt; category susceptible. Set the `guideline` argument or the `AMR_guideline`</span></span>
<span><span class="co">#&gt; option to either "CLSI" or "EUCAST", see `?AMR-options`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> This message will be shown once per session.</span></span>
<span><span class="co">#&gt; [1] 0.4203377</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>
@@ -1314,15 +1316,15 @@ values for <em>Klebsiella pneumoniae</em> and ciprofloxacin:</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 100 × 2</span></span></span>
<span><span class="co">#&gt; MIC SIR </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;mic&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> <span style="color: #555555;">&lt;=</span>0.0001 <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 0.016<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #555555;">&gt;=</span>8<span style="color: #BBBBBB;">.0000</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 0.032<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 0.008<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 64<span style="color: #BBBBBB;">.0000</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 0.008<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 0.125<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 0.032<span style="color: #BBBBBB;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> <span style="color: #949494;">&lt;=</span>0.0001 <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 0.016<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> <span style="color: #949494;">&gt;=</span>8<span style="color: #949494;">.0000</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 0.032<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 0.008<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 64<span style="color: #949494;">.0000</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 0.008<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 0.125<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 0.032<span style="color: #949494;">0</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 0.0002 <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 90 more rows</span></span></span></code></pre></div>
<p>This allows direct interpretation according to EUCAST or CLSI
@@ -1348,7 +1350,7 @@ categories.</p>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"MIC Distribution and SIR Interpretation"</span>,</span>
<span> x <span class="op">=</span> <span class="st">"Sample Groups"</span>,</span>
<span> y <span class="op">=</span> <span class="st">"MIC (mg/L)"</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_files/figure-html/mic_plot-1.png" width="720"></p>
<p><img src="AMR_files/figure-html/mic_plot-1.png" class="r-plt" alt="" width="720"></p>
<p>This plot provides an intuitive way to assess susceptibility patterns
across different groups while incorporating clinical breakpoints.</p>
<p>For a more straightforward and less manual approach,
@@ -1357,12 +1359,12 @@ extended by this package to directly plot MIC and disk diffusion
values:</p>
<div class="sourceCode" id="cb27"><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">mic_values</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_files/figure-html/autoplot-1.png" width="720"></p>
<p><img src="AMR_files/figure-html/autoplot-1.png" class="r-plt" alt="" width="720"></p>
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span></span>
<span><span class="co"># by providing `mo` and `ab`, colours will indicate the SIR interpretation:</span></span>
<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">mic_values</span>, mo <span class="op">=</span> <span class="st">"K. pneumoniae"</span>, ab <span class="op">=</span> <span class="st">"cipro"</span>, guideline <span class="op">=</span> <span class="st">"EUCAST 2024"</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_files/figure-html/autoplot-2.png" width="720"></p>
<p><img src="AMR_files/figure-html/autoplot-2.png" class="r-plt" alt="" width="720"></p>
<hr>
<p><em>Author: Dr. Matthijs Berends, 23rd Feb 2025</em></p>
</div>

952
articles/AMR.md Normal file
View File

@@ -0,0 +1,952 @@
# Conduct AMR data analysis
**Note:** values on this page will change with every website update
since they are based on randomly created values and the page was written
in [R Markdown](https://rmarkdown.rstudio.com/). However, the
methodology remains unchanged. This page was generated on 02 April 2026.
## Introduction
Conducting AMR data analysis unfortunately requires in-depth knowledge
from different scientific fields, which makes it hard to do right. At
least, it requires:
- Good questions (always start with those!) and reliable data
- A thorough understanding of (clinical) epidemiology, to understand the
clinical and epidemiological relevance and possible bias of results
- 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
- Experience with data analysis with microbiological tests and their
results, to understand the determination and limitations of MIC values
and their interpretations to SIR values
- Availability of the biological taxonomy of microorganisms and probably
normalisation factors for pharmaceuticals, such as defined daily doses
(DDD)
- Available (inter-)national guidelines, and profound methods to apply
them
Of course, we cannot instantly provide you with knowledge and
experience. But with this `AMR` 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.
The `AMR` 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 drugs, determination of (multi-drug) resistant
microorganisms, and calculation of antimicrobial resistance, prevalence
and future trends.
## Preparation
For this tutorial, we will create fake demonstration data to work with.
You can skip to [Cleaning the data](#cleaning-the-data) 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:
| date | patient_id | mo | AMX | CIP |
|:----------:|:----------:|:----------------:|:---:|:---:|
| 2026-04-02 | abcd | Escherichia coli | S | S |
| 2026-04-02 | abcd | Escherichia coli | S | R |
| 2026-04-02 | efgh | Escherichia coli | R | S |
### Needed R packages
As with many uses in R, we need some additional packages for AMR data
analysis. Our package works closely together with the [tidyverse
packages](https://www.tidyverse.org)
[`dplyr`](https://dplyr.tidyverse.org/) and
[`ggplot2`](https://ggplot2.tidyverse.org) 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.
We will also use the `cleaner` package, that can be used for cleaning
data and creating frequency tables.
``` r
library(dplyr)
library(ggplot2)
library(AMR)
# (if not yet installed, install with:)
# install.packages(c("dplyr", "ggplot2", "AMR"))
```
The `AMR` package contains a data set `example_isolates_unclean`, which
might look data that users have extracted from their laboratory systems:
``` r
example_isolates_unclean
#> # A tibble: 3,000 × 8
#> patient_id hospital date bacteria AMX AMC CIP GEN
#> <chr> <chr> <date> <chr> <chr> <chr> <chr> <chr>
#> 1 J3 A 2012-11-21 E. coli R I S S
#> 2 R7 A 2018-04-03 K. pneumoniae R I S S
#> 3 P3 A 2014-09-19 E. coli R S S S
#> 4 P10 A 2015-12-10 E. coli S I S S
#> 5 B7 A 2015-03-02 E. coli S S S S
#> 6 W3 A 2018-03-31 S. aureus R S R S
#> 7 J8 A 2016-06-14 E. coli R S S S
#> 8 M3 A 2015-10-25 E. coli R S S S
#> 9 J3 A 2019-06-19 E. coli S S S S
#> 10 G6 A 2015-04-27 S. aureus S S S S
#> # 2,990 more rows
# we will use 'our_data' as the data set name for this tutorial
our_data <- example_isolates_unclean
```
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.
### Taxonomy of microorganisms
With [`as.mo()`](https://amr-for-r.org/reference/as.mo.md), users can
transform arbitrary microorganism names or codes to current taxonomy.
The `AMR` package contains up-to-date taxonomic data. To be specific,
currently included data were retrieved on 24 Jun 2024.
The codes of the AMR packages that come from
[`as.mo()`](https://amr-for-r.org/reference/as.mo.md) are short, but
still human readable. More importantly,
[`as.mo()`](https://amr-for-r.org/reference/as.mo.md) supports all kinds
of input:
``` r
as.mo("Klebsiella pneumoniae")
#> Class <mo>
#> [1] B_KLBSL_PNMN
as.mo("K. pneumoniae")
#> Class <mo>
#> [1] B_KLBSL_PNMN
as.mo("KLEPNE")
#> Class <mo>
#> [1] B_KLBSL_PNMN
as.mo("KLPN")
#> Class <mo>
#> [1] B_KLBSL_PNMN
```
The first character in above codes denote their taxonomic kingdom, such
as Bacteria (B), Fungi (F), and Protozoa (P).
The `AMR` 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 `mo_` and they use
[`as.mo()`](https://amr-for-r.org/reference/as.mo.md) internally, so
that still any arbitrary user input can be used:
``` r
mo_family("K. pneumoniae")
#> [1] "Enterobacteriaceae"
mo_genus("K. pneumoniae")
#> [1] "Klebsiella"
mo_species("K. pneumoniae")
#> [1] "pneumoniae"
mo_gramstain("Klebsiella pneumoniae")
#> [1] "Gram-negative"
mo_ref("K. pneumoniae")
#> [1] "Trevisan, 1887"
mo_snomed("K. pneumoniae")
#> [[1]]
#> [1] "1098101000112102" "446870005" "1098201000112108" "409801009"
#> [5] "56415008" "714315002" "713926009"
```
Now we can thus clean our data:
``` r
our_data$bacteria <- as.mo(our_data$bacteria, info = TRUE)
#> Retrieved values from the `microorganisms.codes` data set for "ESCCOL",
#> "KLEPNE", "STAAUR", and "STRPNE".
#> Microorganism translation was uncertain for four microorganisms. Run
#> `mo_uncertainties()` to review these uncertainties, or use
#> `add_custom_microorganisms()` to add custom entries.
```
Apparently, there was some uncertainty about the translation to
taxonomic codes. Lets check this:
``` r
mo_uncertainties()
#> Matching scores are based on the resemblance between the input and the full
#> taxonomic name, and the pathogenicity in humans. See `mo_matching_score()`.
#> Colour keys: 0.000-0.549 0.550-0.649 0.650-0.749 0.750-1.000
#> -------------------------------------------------------------------------------
#> "E. coli" -> Escherichia coli (B_ESCHR_COLI, 0.688)
#> Also matched: Enterococcus crotali (0.650), Escherichia coli coli (0.643),
#> Escherichia coli expressing (0.611), Enterobacter cowanii (0.600), Enterococcus
#> columbae (0.595), Enterococcus camelliae (0.591), Enterococcus casseliflavus
#> (0.577), Enterobacter cloacae cloacae (0.571), Enterobacter cloacae complex
#> (0.571), and Enterobacter cloacae dissolvens (0.565)
#> -------------------------------------------------------------------------------
#> "K. pneumoniae" -> Klebsiella pneumoniae (B_KLBSL_PNMN, 0.786)
#> Also matched: Klebsiella pneumoniae complex (0.707), Klebsiella pneumoniae
#> ozaenae (0.707), Klebsiella pneumoniae pneumoniae (0.688), Klebsiella
#> pneumoniae rhinoscleromatis (0.658), Klebsiella pasteurii (0.500), Klebsiella
#> planticola (0.500), Kingella potus (0.400), Kluyveromyces pseudotropicale
#> (0.386), Kluyveromyces pseudotropicalis (0.363), and Kosakonia pseudosacchari
#> (0.361)
#> -------------------------------------------------------------------------------
#> "S. aureus" -> Staphylococcus aureus (B_STPHY_AURS, 0.690)
#> Also matched: Staphylococcus aureus aureus (0.643), Staphylococcus argenteus
#> (0.625), Staphylococcus aureus anaerobius (0.625), Staphylococcus auricularis
#> (0.615), Salmonella Aurelianis (0.595), Salmonella Aarhus (0.588), Salmonella
#> Amounderness (0.587), Staphylococcus argensis (0.587), Streptococcus australis
#> (0.587), and Salmonella choleraesuis arizonae (0.562)
#> -------------------------------------------------------------------------------
#> "S. pneumoniae" -> Streptococcus pneumoniae (B_STRPT_PNMN, 0.750)
#> Also matched: Streptococcus pseudopneumoniae (0.700), Streptococcus phocae
#> salmonis (0.552), Serratia proteamaculans quinovora (0.545), Streptococcus
#> pseudoporcinus (0.536), Staphylococcus piscifermentans (0.533), Staphylococcus
#> pseudintermedius (0.532), Serratia proteamaculans proteamaculans (0.526),
#> Streptococcus gallolyticus pasteurianus (0.526), Salmonella Portanigra (0.524),
#> and Streptococcus periodonticum (0.519)
#> Only the first 10 other matches of each record are shown. Run ``
#> `print(mo_uncertainties(), n = ...)` `` to view more entries, or save
#> `mo_uncertainties()` to an object.
```
Thats all good.
### Antibiotic results
The column with antibiotic test results must also be cleaned. The `AMR`
package comes with three new data types to work with such test results:
`mic` for minimal inhibitory concentrations (MIC), `disk` for disk
diffusion diameters, and `sir` 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
[`as.sir()`](https://amr-for-r.org/reference/as.sir.md) page.
For now, we will just clean the SIR columns in our data using dplyr:
``` r
# method 1, be explicit about the columns:
our_data <- our_data %>%
mutate_at(vars(AMX:GEN), as.sir)
# method 2, let the AMR package determine the eligible columns
our_data <- our_data %>%
mutate_if(is_sir_eligible, as.sir)
# result:
our_data
#> # A tibble: 3,000 × 8
#> patient_id hospital date bacteria AMX AMC CIP GEN
#> <chr> <chr> <date> <mo> <sir> <sir> <sir> <sir>
#> 1 J3 A 2012-11-21 B_ESCHR_COLI R I S S
#> 2 R7 A 2018-04-03 B_KLBSL_PNMN R I S S
#> 3 P3 A 2014-09-19 B_ESCHR_COLI R S S S
#> 4 P10 A 2015-12-10 B_ESCHR_COLI S I S S
#> 5 B7 A 2015-03-02 B_ESCHR_COLI S S S S
#> 6 W3 A 2018-03-31 B_STPHY_AURS R S R S
#> 7 J8 A 2016-06-14 B_ESCHR_COLI R S S S
#> 8 M3 A 2015-10-25 B_ESCHR_COLI R S S S
#> 9 J3 A 2019-06-19 B_ESCHR_COLI S S S S
#> 10 G6 A 2015-04-27 B_STPHY_AURS S S S S
#> # 2,990 more rows
```
This is basically it for the cleaning, time to start the data inclusion.
### First isolates
We need to know which isolates we can *actually* use for analysis
without repetition bias.
To conduct an analysis of antimicrobial resistance, you must [only
include the first isolate of every patient per
episode](https:/pubmed.ncbi.nlm.nih.gov/17304462/) (Hindler *et al.*,
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 [selection
bias](https://en.wikipedia.org/wiki/Selection_bias).
The Clinical and Laboratory Standards Institute (CLSI) appoints this as
follows:
> *(…) When preparing a cumulative antibiogram to guide clinical
> decisions about empirical antimicrobial therapy of initial infections,
> **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)**. 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.*
> [M39-A4 Analysis and Presentation of Cumulative Antimicrobial
> Susceptibility Test Data, 4th Edition. CLSI, 2014. Chapter
> 6.4](https://clsi.org/standards/products/microbiology/documents/m39/)
This `AMR` package includes this methodology with the
[`first_isolate()`](https://amr-for-r.org/reference/first_isolate.md)
function and is able to apply the four different methods as defined by
[Hindler *et al.* in
2007](https://academic.oup.com/cid/article/44/6/867/364325):
phenotype-based, episode-based, patient-based, isolate-based. The right
method depends on your goals and analysis, but the default
phenotype-based method is in any case the method to properly correct for
most duplicate isolates. Read more about the methods on the
[`first_isolate()`](https://amr-for-r.org/reference/first_isolate.md)
page.
The outcome of the function can easily be added to our data:
``` r
our_data <- our_data %>%
mutate(first = first_isolate(info = TRUE))
#> Determining first isolates using an episode length of 365 days
#> Using column bacteria as input for `col_mo`.
#> Column first is SIR eligible (despite only having empty values), since it
#> seems to be cefozopran (ZOP)
#> Using column date as input for `col_date`.
#> Using column patient_id as input for `col_patient_id`.
#> Basing inclusion on all antimicrobial results, using a points threshold of 2
#> => Found 2,724 'phenotype-based' first isolates (90.8% of total where a
#> microbial ID was available)
```
So only 91% is suitable for resistance analysis! We can now filter on it
with the [`filter()`](https://dplyr.tidyverse.org/reference/filter.html)
function, also from the `dplyr` package:
``` r
our_data_1st <- our_data %>%
filter(first == TRUE)
```
For future use, the above two syntaxes can be shortened:
``` r
our_data_1st <- our_data %>%
filter_first_isolate()
```
So we end up with 2 724 isolates for analysis. Now our data looks like:
``` r
our_data_1st
#> # A tibble: 2,724 × 9
#> patient_id hospital date bacteria AMX AMC CIP GEN first
#> <chr> <chr> <date> <mo> <sir> <sir> <sir> <sir> <lgl>
#> 1 J3 A 2012-11-21 B_ESCHR_COLI R I S S TRUE
#> 2 R7 A 2018-04-03 B_KLBSL_PNMN R I S S TRUE
#> 3 P3 A 2014-09-19 B_ESCHR_COLI R S S S TRUE
#> 4 P10 A 2015-12-10 B_ESCHR_COLI S I S S TRUE
#> 5 B7 A 2015-03-02 B_ESCHR_COLI S S S S TRUE
#> 6 W3 A 2018-03-31 B_STPHY_AURS R S R S TRUE
#> 7 M3 A 2015-10-25 B_ESCHR_COLI R S S S TRUE
#> 8 J3 A 2019-06-19 B_ESCHR_COLI S S S S TRUE
#> 9 G6 A 2015-04-27 B_STPHY_AURS S S S S TRUE
#> 10 P4 A 2011-06-21 B_ESCHR_COLI S S S S TRUE
#> # 2,714 more rows
```
Time for the analysis.
## Analysing the data
The base R [`summary()`](https://rdrr.io/r/base/summary.html) function
gives a good first impression, as it comes with support for the new `mo`
and `sir` classes that we now have in our data set:
``` r
summary(our_data_1st)
#> patient_id hospital date
#> Length:2724 Length:2724 Min. :2011-01-01
#> Class :character Class :character 1st Qu.:2013-04-07
#> Mode :character Mode :character Median :2015-06-03
#> Mean :2015-06-09
#> 3rd Qu.:2017-08-11
#> Max. :2019-12-27
#> bacteria AMX AMC
#> Class :mo Class:sir Class:sir
#> <NA> :0 %S :41.6% (n=1133) %S :52.6% (n=1432)
#> Unique:4 %SDD : 0.0% (n=0) %SDD : 0.0% (n=0)
#> #1 :B_ESCHR_COLI %I :16.4% (n=446) %I :12.2% (n=333)
#> #2 :B_STPHY_AURS %R :42.0% (n=1145) %R :35.2% (n=959)
#> #3 :B_STRPT_PNMN %NI : 0.0% (n=0) %NI : 0.0% (n=0)
#> CIP GEN first
#> Class:sir Class:sir Mode:logical
#> %S :52.5% (n=1431) %S :61.0% (n=1661) TRUE:2724
#> %SDD : 0.0% (n=0) %SDD : 0.0% (n=0)
#> %I : 6.5% (n=176) %I : 3.0% (n=82)
#> %R :41.0% (n=1117) %R :36.0% (n=981)
#> %NI : 0.0% (n=0) %NI : 0.0% (n=0)
glimpse(our_data_1st)
#> Rows: 2,724
#> Columns: 9
#> $ patient_id <chr> "J3", "R7", "P3", "P10", "B7", "W3", "M3", "J3", "G6", "P4"…
#> $ hospital <chr> "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",…
#> $ date <date> 2012-11-21, 2018-04-03, 2014-09-19, 2015-12-10, 2015-03-02…
#> $ bacteria <mo> "B_ESCHR_COLI", "B_KLBSL_PNMN", "B_ESCHR_COLI", "B_ESCHR_COL…
#> $ AMX <sir> R, R, R, S, S, R, R, S, S, S, S, R, S, S, R, R, R, R, S, R,…
#> $ AMC <sir> I, I, S, I, S, S, S, S, S, S, S, S, S, S, S, S, S, R, S, S,…
#> $ CIP <sir> S, S, S, S, S, R, S, S, S, S, S, S, S, S, S, S, S, S, S, S,…
#> $ GEN <sir> S, S, S, S, S, S, S, S, S, S, S, R, S, S, S, S, S, S, S, S,…
#> $ first <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,…
# number of unique values per column:
sapply(our_data_1st, n_distinct)
#> patient_id hospital date bacteria AMX AMC CIP
#> 260 3 1854 4 3 3 3
#> GEN first
#> 3 1
```
### Availability of species
To just get an idea how the species are distributed, create a frequency
table with [`count()`](https://amr-for-r.org/reference/count.md) based
on the name of the microorganisms:
``` r
our_data %>%
count(mo_name(bacteria), sort = TRUE)
#> # A tibble: 4 × 2
#> `mo_name(bacteria)` n
#> <chr> <int>
#> 1 Escherichia coli 1518
#> 2 Staphylococcus aureus 730
#> 3 Streptococcus pneumoniae 426
#> 4 Klebsiella pneumoniae 326
our_data_1st %>%
count(mo_name(bacteria), sort = TRUE)
#> # A tibble: 4 × 2
#> `mo_name(bacteria)` n
#> <chr> <int>
#> 1 Escherichia coli 1321
#> 2 Staphylococcus aureus 682
#> 3 Streptococcus pneumoniae 402
#> 4 Klebsiella pneumoniae 319
```
### Select and filter with antibiotic selectors
Using so-called antibiotic class selectors, you can select or filter
columns based on the antibiotic class that your antibiotic results are
in:
``` r
our_data_1st %>%
select(date, aminoglycosides())
#> For `aminoglycosides()` using column GEN
#> (gentamicin)
#> # A tibble: 2,724 × 2
#> date GEN
#> <date> <sir>
#> 1 2012-11-21 S
#> 2 2018-04-03 S
#> 3 2014-09-19 S
#> 4 2015-12-10 S
#> 5 2015-03-02 S
#> 6 2018-03-31 S
#> 7 2015-10-25 S
#> 8 2019-06-19 S
#> 9 2015-04-27 S
#> 10 2011-06-21 S
#> # 2,714 more rows
our_data_1st %>%
select(bacteria, betalactams())
#> For `betalactams()` using columns AMX (amoxicillin) and AMC
#> (amoxicillin/clavulanic acid)
#> # A tibble: 2,724 × 3
#> bacteria AMX AMC
#> <mo> <sir> <sir>
#> 1 B_ESCHR_COLI R I
#> 2 B_KLBSL_PNMN R I
#> 3 B_ESCHR_COLI R S
#> 4 B_ESCHR_COLI S I
#> 5 B_ESCHR_COLI S S
#> 6 B_STPHY_AURS R S
#> 7 B_ESCHR_COLI R S
#> 8 B_ESCHR_COLI S S
#> 9 B_STPHY_AURS S S
#> 10 B_ESCHR_COLI S S
#> # 2,714 more rows
our_data_1st %>%
select(bacteria, where(is.sir))
#> # A tibble: 2,724 × 5
#> bacteria AMX AMC CIP GEN
#> <mo> <sir> <sir> <sir> <sir>
#> 1 B_ESCHR_COLI R I S S
#> 2 B_KLBSL_PNMN R I S S
#> 3 B_ESCHR_COLI R S S S
#> 4 B_ESCHR_COLI S I S S
#> 5 B_ESCHR_COLI S S S S
#> 6 B_STPHY_AURS R S R S
#> 7 B_ESCHR_COLI R S S S
#> 8 B_ESCHR_COLI S S S S
#> 9 B_STPHY_AURS S S S S
#> 10 B_ESCHR_COLI S S S S
#> # 2,714 more rows
# filtering using AB selectors is also possible:
our_data_1st %>%
filter(any(aminoglycosides() == "R"))
#> For `aminoglycosides()` using column GEN
#> (gentamicin)
#> # A tibble: 981 × 9
#> patient_id hospital date bacteria AMX AMC CIP GEN first
#> <chr> <chr> <date> <mo> <sir> <sir> <sir> <sir> <lgl>
#> 1 J5 A 2017-12-25 B_STRPT_PNMN R S S R TRUE
#> 2 X1 A 2017-07-04 B_STPHY_AURS R S S R TRUE
#> 3 B3 A 2016-07-24 B_ESCHR_COLI S S S R TRUE
#> 4 V7 A 2012-04-03 B_ESCHR_COLI S S S R TRUE
#> 5 C9 A 2017-03-23 B_ESCHR_COLI S S S R TRUE
#> 6 R1 A 2018-06-10 B_STPHY_AURS S S S R TRUE
#> 7 S2 A 2013-07-19 B_STRPT_PNMN S S S R TRUE
#> 8 P5 A 2019-03-09 B_STPHY_AURS S S S R TRUE
#> 9 Q8 A 2019-08-10 B_STPHY_AURS S S S R TRUE
#> 10 K5 A 2013-03-15 B_STRPT_PNMN S S S R TRUE
#> # 971 more rows
our_data_1st %>%
filter(all(betalactams() == "R"))
#> For `betalactams()` using columns AMX (amoxicillin) and AMC
#> (amoxicillin/clavulanic acid)
#> # A tibble: 462 × 9
#> patient_id hospital date bacteria AMX AMC CIP GEN first
#> <chr> <chr> <date> <mo> <sir> <sir> <sir> <sir> <lgl>
#> 1 M7 A 2013-07-22 B_STRPT_PNMN R R S S TRUE
#> 2 R10 A 2013-12-20 B_STPHY_AURS R R S S TRUE
#> 3 R7 A 2015-10-25 B_STPHY_AURS R R S S TRUE
#> 4 R8 A 2019-10-25 B_STPHY_AURS R R S S TRUE
#> 5 B6 A 2016-11-20 B_ESCHR_COLI R R R R TRUE
#> 6 I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE
#> 7 N3 A 2014-12-29 B_STRPT_PNMN R R R S TRUE
#> 8 Q2 A 2019-09-22 B_ESCHR_COLI R R S S TRUE
#> 9 X7 A 2011-03-20 B_ESCHR_COLI R R S R TRUE
#> 10 V1 A 2018-08-07 B_STPHY_AURS R R S S TRUE
#> # 452 more rows
# even works in base R (since R 3.0):
our_data_1st[all(betalactams() == "R"), ]
#> For `betalactams()` using columns AMX (amoxicillin) and AMC
#> (amoxicillin/clavulanic acid)
#> # A tibble: 462 × 9
#> patient_id hospital date bacteria AMX AMC CIP GEN first
#> <chr> <chr> <date> <mo> <sir> <sir> <sir> <sir> <lgl>
#> 1 M7 A 2013-07-22 B_STRPT_PNMN R R S S TRUE
#> 2 R10 A 2013-12-20 B_STPHY_AURS R R S S TRUE
#> 3 R7 A 2015-10-25 B_STPHY_AURS R R S S TRUE
#> 4 R8 A 2019-10-25 B_STPHY_AURS R R S S TRUE
#> 5 B6 A 2016-11-20 B_ESCHR_COLI R R R R TRUE
#> 6 I7 A 2015-08-19 B_ESCHR_COLI R R S S TRUE
#> 7 N3 A 2014-12-29 B_STRPT_PNMN R R R S TRUE
#> 8 Q2 A 2019-09-22 B_ESCHR_COLI R R S S TRUE
#> 9 X7 A 2011-03-20 B_ESCHR_COLI R R S R TRUE
#> 10 V1 A 2018-08-07 B_STPHY_AURS R R S S TRUE
#> # 452 more rows
```
### Generate antibiograms
Since AMR v2.0 (March 2023), it is very easy to create different types
of antibiograms, with support for 20 different languages.
There are four antibiogram types, as proposed by Klinker *et al.* (2021,
[DOI
10.1177/20499361211011373](https://doi.org/10.1177/20499361211011373)),
and they are all supported by the new
[`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md)
function:
1. **Traditional Antibiogram (TA)** e.g, for the susceptibility of
*Pseudomonas aeruginosa* to piperacillin/tazobactam (TZP)
2. **Combination Antibiogram (CA)** e.g, for the sdditional
susceptibility of *Pseudomonas aeruginosa* to TZP + tobramycin
versus TZP alone
3. **Syndromic Antibiogram (SA)** e.g, for the susceptibility of
*Pseudomonas aeruginosa* to TZP among respiratory specimens
(obtained among ICU patients only)
4. **Weighted-Incidence Syndromic Combination Antibiogram (WISCA)**
e.g, for the susceptibility of *Pseudomonas aeruginosa* to TZP among
respiratory specimens (obtained among ICU patients only) for male
patients age \>=65 years with heart failure
In this section, we show how to use the
[`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md)
function to create any of the above antibiogram types. For starters,
this is what the included `example_isolates` data set looks like:
``` r
example_isolates
#> # A tibble: 2,000 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
#> 1 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 2 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 3 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 4 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 5 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 6 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 7 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 8 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 9 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 10 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA
#> # 1,990 more rows
#> # 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
```
#### Traditional Antibiogram
To create a traditional antibiogram, simply state which antibiotics
should be used. The `antibiotics` argument in the
[`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md)
function supports any (combination) of the previously mentioned
antibiotic class selectors:
``` r
antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems()))
#> For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK
#> (amikacin), and KAN (kanamycin)
#> For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem)
```
| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------|
| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) |
| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) |
| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) |
| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) |
| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) |
| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) |
| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) |
| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) |
| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) |
| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) |
Notice that the
[`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md)
function automatically prints in the right format when using Quarto or R
Markdown (such as this page), and even applies italics for taxonomic
names (by using
[`italicise_taxonomy()`](https://amr-for-r.org/reference/italicise_taxonomy.md)
internally).
It also uses the language of your OS if this is either English, Arabic,
Bengali, Chinese, Czech, Danish, Dutch, Finnish, French, German, Greek,
Hindi, Indonesian, Italian, Japanese, Korean, Norwegian, Polish,
Portuguese, Romanian, Russian, Spanish, Swahili, Swedish, Turkish,
Ukrainian, Urdu, or Vietnamese. In this next example, we force the
language to be Spanish using the `language` argument:
``` r
antibiogram(example_isolates,
mo_transform = "gramstain",
antibiotics = aminoglycosides(),
ab_transform = "name",
language = "es")
#> For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK
#> (amikacin), and KAN (kanamycin)
```
| Patógeno | Amikacina | Gentamicina | Kanamicina | Tobramicina |
|:--------------|:-------------------|:--------------------|:----------------|:-------------------|
| Gram negativo | 98% (96-99%,N=256) | 96% (95-98%,N=684) | 0% (0-10%,N=35) | 96% (94-97%,N=686) |
| Gram positivo | 0% (0-1%,N=436) | 63% (60-66%,N=1170) | 0% (0-1%,N=436) | 34% (31-38%,N=665) |
#### Combined Antibiogram
To create a combined antibiogram, use antibiotic codes or names with a
plus `+` character like this:
``` r
combined_ab <- antibiogram(example_isolates,
antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"),
ab_transform = NULL)
combined_ab
```
| Pathogen | TZP | TZP + GEN | TZP + TOB |
|:-----------------|:---------------------|:---------------------|:---------------------|
| CoNS | 30% (16-49%,N=33) | 97% (95-99%,N=274) | NA |
| *E. coli* | 94% (92-96%,N=416) | 100% (98-100%,N=459) | 99% (97-100%,N=461) |
| *K. pneumoniae* | 89% (77-96%,N=53) | 93% (83-98%,N=58) | 93% (83-98%,N=58) |
| *P. aeruginosa* | NA | 100% (88-100%,N=30) | 100% (88-100%,N=30) |
| *P. mirabilis* | NA | 100% (90-100%,N=34) | 100% (90-100%,N=34) |
| *S. aureus* | NA | 100% (98-100%,N=231) | 100% (96-100%,N=91) |
| *S. epidermidis* | NA | 100% (97-100%,N=128) | 100% (92-100%,N=46) |
| *S. hominis* | NA | 100% (95-100%,N=74) | 100% (93-100%,N=53) |
| *S. pneumoniae* | 100% (97-100%,N=112) | 100% (97-100%,N=112) | 100% (97-100%,N=112) |
#### Syndromic Antibiogram
To create a syndromic antibiogram, the `syndromic_group` argument must
be used. This can be any column in the data, or e.g. an
[`ifelse()`](https://rdrr.io/r/base/ifelse.html) with calculations based
on certain columns:
``` r
antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems()),
syndromic_group = "ward")
#> For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK
#> (amikacin), and KAN (kanamycin)
#> For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem)
```
| Syndromic Group | Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|:----------------|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------|
| Clinical | CoNS | NA | 89% (84-93%,N=205) | 57% (39-74%,N=35) | NA | 57% (39-74%,N=35) | 26% (12-45%,N=31) |
| ICU | CoNS | NA | 79% (68-88%,N=73) | NA | NA | NA | NA |
| Outpatient | CoNS | NA | 84% (66-95%,N=31) | NA | NA | NA | NA |
| Clinical | *E. coli* | 100% (97-100%,N=104) | 98% (96-99%,N=297) | 100% (99-100%,N=266) | NA | 100% (99-100%,N=276) | 98% (96-99%,N=299) |
| ICU | *E. coli* | 100% (93-100%,N=52) | 99% (95-100%,N=137) | 100% (97-100%,N=133) | NA | 100% (97-100%,N=118) | 96% (92-99%,N=137) |
| Clinical | *K. pneumoniae* | NA | 92% (81-98%,N=51) | 100% (92-100%,N=44) | NA | 100% (92-100%,N=46) | 92% (81-98%,N=51) |
| Clinical | *P. mirabilis* | NA | 100% (88-100%,N=30) | NA | NA | NA | 100% (88-100%,N=30) |
| Clinical | *S. aureus* | NA | 99% (95-100%,N=150) | NA | NA | NA | 97% (89-100%,N=63) |
| ICU | *S. aureus* | NA | 100% (95-100%,N=66) | NA | NA | NA | NA |
| Clinical | *S. epidermidis* | NA | 82% (72-90%,N=79) | NA | NA | NA | 55% (39-70%,N=44) |
| ICU | *S. epidermidis* | NA | 72% (60-82%,N=75) | NA | NA | NA | 41% (26-58%,N=41) |
| Clinical | *S. hominis* | NA | 96% (85-99%,N=45) | NA | NA | NA | 94% (79-99%,N=31) |
| Clinical | *S. pneumoniae* | 0% (0-5%,N=78) | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) |
| ICU | *S. pneumoniae* | 0% (0-12%,N=30) | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) |
#### Weighted-Incidence Syndromic Combination Antibiogram (WISCA)
To create a **Weighted-Incidence Syndromic Combination Antibiogram
(WISCA)**, simply set `wisca = TRUE` in the
[`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md)
function, or use the dedicated
[`wisca()`](https://amr-for-r.org/reference/antibiogram.md) function.
Unlike traditional antibiograms, WISCA provides syndrome-based
susceptibility estimates, weighted by pathogen incidence and
antimicrobial susceptibility patterns.
``` r
example_isolates %>%
wisca(antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"),
minimum = 10) # Recommended threshold: ≥30
```
| Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|:------------------------|:-------------------------------------|:-------------------------------------|
| 69.4% (64.3-74.3%) | 92.6% (91.1-93.9%) | 88.7% (85.8-91.2%) |
WISCA uses a **Bayesian decision model** to integrate data from multiple
pathogens, improving empirical therapy guidance, especially for
low-incidence infections. It is **pathogen-agnostic**, meaning results
are syndrome-based rather than stratified by microorganism.
For reliable results, ensure your data includes **only first isolates**
(use
[`first_isolate()`](https://amr-for-r.org/reference/first_isolate.md))
and consider filtering for **the top *n* species** (use
[`top_n_microorganisms()`](https://amr-for-r.org/reference/top_n_microorganisms.md)),
as WISCA outcomes are most meaningful when based on robust incidence
estimates.
For **patient- or syndrome-specific WISCA**, run the function on a
grouped `tibble`, i.e., using
[`group_by()`](https://dplyr.tidyverse.org/reference/group_by.html)
first:
``` r
example_isolates %>%
top_n_microorganisms(n = 10) %>%
group_by(age_group = age_groups(age, c(25, 50, 75)),
gender) %>%
wisca(antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"))
```
| age_group | gender | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|:----------|:-------|:------------------------|:-------------------------------------|:-------------------------------------|
| 0-24 | F | 56.6% (25.2-83.9%) | 73.6% (48-91.6%) | 68.6% (42.9-89.5%) |
| 0-24 | M | 60.3% (28.4-87.1%) | 79.7% (57.6-94.2%) | 60.1% (29.5-87.7%) |
| 25-49 | F | 66.6% (45.6-85.5%) | 91.7% (84.6-96.7%) | 83% (67.9-94%) |
| 25-49 | M | 56.4% (29.1-81.7%) | 89.2% (80.3-95.7%) | 72.4% (49.7-90%) |
| 50-74 | F | 67.8% (55.8-80.1%) | 95.6% (93.2-97.5%) | 88.1% (80.4-94.6%) |
| 50-74 | M | 66.2% (54.8-75.8%) | 95.2% (92.4-97.4%) | 84.4% (74.4-92.5%) |
| 75+ | F | 71.7% (61-81.7%) | 96.6% (94.4-98.2%) | 90.6% (84.6-95.3%) |
| 75+ | M | 72.9% (63.8-82%) | 96.6% (94.6-98.1%) | 92.8% (87.8-96.5%) |
#### Plotting antibiograms
Antibiograms can be plotted using
[`autoplot()`](https://ggplot2.tidyverse.org/reference/autoplot.html)
from the `ggplot2` packages, since this `AMR` package provides an
extension to that function:
``` r
autoplot(combined_ab)
```
![](AMR_files/figure-html/unnamed-chunk-10-1.png)
To calculate antimicrobial resistance in a more sensible way, also by
correcting for too few results, we use the
[`resistance()`](https://amr-for-r.org/reference/proportion.md) and
[`susceptibility()`](https://amr-for-r.org/reference/proportion.md)
functions.
### Resistance percentages
The functions
[`resistance()`](https://amr-for-r.org/reference/proportion.md) and
[`susceptibility()`](https://amr-for-r.org/reference/proportion.md) can
be used to calculate antimicrobial resistance or susceptibility. For
more specific analyses, the functions
[`proportion_S()`](https://amr-for-r.org/reference/proportion.md),
[`proportion_SI()`](https://amr-for-r.org/reference/proportion.md),
[`proportion_I()`](https://amr-for-r.org/reference/proportion.md),
[`proportion_IR()`](https://amr-for-r.org/reference/proportion.md) and
[`proportion_R()`](https://amr-for-r.org/reference/proportion.md) can be
used to determine the proportion of a specific antimicrobial outcome.
All these functions contain a `minimum` argument, denoting the minimum
required number of test results for returning a value. These functions
will otherwise return `NA`. The default is `minimum = 30`, following the
[CLSI M39-A4
guideline](https://clsi.org/standards/products/microbiology/documents/m39/)
for applying microbial epidemiology.
As per the EUCAST guideline of 2019, we calculate resistance as the
proportion of R
([`proportion_R()`](https://amr-for-r.org/reference/proportion.md),
equal to
[`resistance()`](https://amr-for-r.org/reference/proportion.md)) and
susceptibility as the proportion of S and I
([`proportion_SI()`](https://amr-for-r.org/reference/proportion.md),
equal to
[`susceptibility()`](https://amr-for-r.org/reference/proportion.md)).
These functions can be used on their own:
``` r
our_data_1st %>% resistance(AMX)
#> `resistance()` assumes the EUCAST guideline and thus considers the 'I'
#> category susceptible. Set the `guideline` argument or the `AMR_guideline`
#> option to either "CLSI" or "EUCAST", see `?AMR-options`.
#> This message will be shown once per session.
#> [1] 0.4203377
```
Or can be used in conjunction with
[`group_by()`](https://dplyr.tidyverse.org/reference/group_by.html) and
[`summarise()`](https://dplyr.tidyverse.org/reference/summarise.html),
both from the `dplyr` package:
``` r
our_data_1st %>%
group_by(hospital) %>%
summarise(amoxicillin = resistance(AMX))
#> # A tibble: 3 × 2
#> hospital amoxicillin
#> <chr> <dbl>
#> 1 A 0.340
#> 2 B 0.551
#> 3 C 0.370
```
### Interpreting MIC and Disk Diffusion Values
Minimal inhibitory concentration (MIC) values and disk diffusion
diameters can be interpreted into clinical breakpoints (SIR) using
[`as.sir()`](https://amr-for-r.org/reference/as.sir.md). Heres an
example with randomly generated MIC values for *Klebsiella pneumoniae*
and ciprofloxacin:
``` r
set.seed(123)
mic_values <- random_mic(100)
sir_values <- as.sir(mic_values, mo = "K. pneumoniae", ab = "cipro", guideline = "EUCAST 2024")
my_data <- tibble(MIC = mic_values, SIR = sir_values)
my_data
#> # A tibble: 100 × 2
#> MIC SIR
#> <mic> <sir>
#> 1 <=0.0001 S
#> 2 0.0160 S
#> 3 >=8.0000 R
#> 4 0.0320 S
#> 5 0.0080 S
#> 6 64.0000 R
#> 7 0.0080 S
#> 8 0.1250 S
#> 9 0.0320 S
#> 10 0.0002 S
#> # 90 more rows
```
This allows direct interpretation according to EUCAST or CLSI
breakpoints, facilitating automated AMR data processing.
### Plotting MIC and SIR Interpretations
We can visualise MIC distributions and their SIR interpretations using
`ggplot2`, using the new
[`scale_y_mic()`](https://amr-for-r.org/reference/plot.md) for the
y-axis and
[`scale_colour_sir()`](https://amr-for-r.org/reference/plot.md) to
colour-code SIR categories.
``` r
# add a group
my_data$group <- rep(c("A", "B", "C", "D"), each = 25)
ggplot(my_data,
aes(x = group, y = MIC, colour = SIR)) +
geom_jitter(width = 0.2, size = 2) +
geom_boxplot(fill = NA, colour = "grey40") +
scale_y_mic() +
scale_colour_sir() +
labs(title = "MIC Distribution and SIR Interpretation",
x = "Sample Groups",
y = "MIC (mg/L)")
```
![](AMR_files/figure-html/mic_plot-1.png)
This plot provides an intuitive way to assess susceptibility patterns
across different groups while incorporating clinical breakpoints.
For a more straightforward and less manual approach, `ggplot2`s
function
[`autoplot()`](https://ggplot2.tidyverse.org/reference/autoplot.html)
has been extended by this package to directly plot MIC and disk
diffusion values:
``` r
autoplot(mic_values)
```
![](AMR_files/figure-html/autoplot-1.png)
``` r
# by providing `mo` and `ab`, colours will indicate the SIR interpretation:
autoplot(mic_values, mo = "K. pneumoniae", ab = "cipro", guideline = "EUCAST 2024")
```
![](AMR_files/figure-html/autoplot-2.png)
------------------------------------------------------------------------
*Author: Dr. Matthijs Berends, 23rd Feb 2025*

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">

217
articles/AMR_for_Python.md Normal file
View File

@@ -0,0 +1,217 @@
# AMR for Python
## Introduction
The `AMR` package for R is a powerful tool for antimicrobial resistance
(AMR) analysis. It provides extensive features for handling microbial
and antimicrobial data. However, for those who work primarily in Python,
we now have a more intuitive option available: the [`AMR` Python
package](https://pypi.org/project/AMR/).
This Python package is a wrapper around the `AMR` R package. It uses the
`rpy2` package internally. Despite the need to have R installed, Python
users can now easily work with AMR data directly through Python code.
## Prerequisites
This package was only tested with a [virtual environment
(venv)](https://docs.python.org/3/library/venv.html). You can set up
such an environment by running:
``` python
# linux and macOS:
python -m venv /path/to/new/virtual/environment
# Windows:
python -m venv C:\path\to\new\virtual\environment
```
Then you can [activate the
environment](https://docs.python.org/3/library/venv.html#how-venvs-work),
after which the venv is ready to work with.
## Install AMR
1. Since the Python package is available on the official [Python
Package Index](https://pypi.org/project/AMR/), you can just run:
``` bash
pip install AMR
```
2. Make sure you have R installed. There is **no need to install the
`AMR` R package**, as it will be installed automatically.
For Linux:
``` bash
# Ubuntu / Debian
sudo apt install r-base
# Fedora:
sudo dnf install R
# CentOS/RHEL
sudo yum install R
```
For macOS (using [Homebrew](https://brew.sh)):
``` bash
brew install r
```
For Windows, visit the [CRAN download
page](https://cran.r-project.org) to download and install R.
## Examples of Usage
### Cleaning Taxonomy
Heres an example that demonstrates how to clean microorganism and drug
names using the `AMR` Python package:
``` python
import pandas as pd
import AMR
# Sample data
data = {
"MOs": ['E. coli', 'ESCCOL', 'esco', 'Esche coli'],
"Drug": ['Cipro', 'CIP', 'J01MA02', 'Ciproxin']
}
df = pd.DataFrame(data)
# Use AMR functions to clean microorganism and drug names
df['MO_clean'] = AMR.mo_name(df['MOs'])
df['Drug_clean'] = AMR.ab_name(df['Drug'])
# Display the results
print(df)
```
| MOs | Drug | MO_clean | Drug_clean |
|------------|----------|------------------|---------------|
| E. coli | Cipro | Escherichia coli | Ciprofloxacin |
| ESCCOL | CIP | Escherichia coli | Ciprofloxacin |
| esco | J01MA02 | Escherichia coli | Ciprofloxacin |
| Esche coli | Ciproxin | Escherichia coli | Ciprofloxacin |
#### Explanation
- **mo_name:** This function standardises microorganism names. Here,
different variations of *Escherichia coli* (such as “E. coli”,
“ESCCOL”, “esco”, and “Esche coli”) are all converted into the
correct, standardised form, “Escherichia coli”.
- **ab_name**: Similarly, this function standardises antimicrobial
names. The different representations of ciprofloxacin (e.g., “Cipro”,
“CIP”, “J01MA02”, and “Ciproxin”) are all converted to the standard
name, “Ciprofloxacin”.
### Calculating AMR
``` python
import AMR
import pandas as pd
df = AMR.example_isolates
result = AMR.resistance(df["AMX"])
print(result)
```
[0.59555556]
### Generating Antibiograms
One of the core functions of the `AMR` package is generating an
antibiogram, a table that summarises the antimicrobial susceptibility of
bacterial isolates. Heres how you can generate an antibiogram from
Python:
``` python
result2a = AMR.antibiogram(df[["mo", "AMX", "CIP", "TZP"]])
print(result2a)
```
| Pathogen | Amoxicillin | Ciprofloxacin | Piperacillin/tazobactam |
|----------------|----------------|---------------|-------------------------|
| CoNS | 7% (10/142) | 73% (183/252) | 30% (10/33) |
| E. coli | 50% (196/392) | 88% (399/456) | 94% (393/416) |
| K. pneumoniae | 0% (0/58) | 96% (53/55) | 89% (47/53) |
| P. aeruginosa | 0% (0/30) | 100% (30/30) | None |
| P. mirabilis | None | 94% (34/36) | None |
| S. aureus | 6% (8/131) | 90% (171/191) | None |
| S. epidermidis | 1% (1/91) | 64% (87/136) | None |
| S. hominis | None | 80% (56/70) | None |
| S. pneumoniae | 100% (112/112) | None | 100% (112/112) |
``` python
result2b = AMR.antibiogram(df[["mo", "AMX", "CIP", "TZP"]], mo_transform = "gramstain")
print(result2b)
```
| Pathogen | Amoxicillin | Ciprofloxacin | Piperacillin/tazobactam |
|---------------|---------------|---------------|-------------------------|
| Gram-negative | 36% (226/631) | 91% (621/684) | 88% (565/641) |
| Gram-positive | 43% (305/703) | 77% (560/724) | 86% (296/345) |
In this example, we generate an antibiogram by selecting various
antibiotics.
### Taxonomic Data Sets Now in Python!
As a Python user, you might like that the most important data sets of
the `AMR` R package, `microorganisms`, `antimicrobials`,
`clinical_breakpoints`, and `example_isolates`, are now available as
regular Python data frames:
``` python
AMR.microorganisms
```
| mo | fullname | status | kingdom | gbif | gbif_parent | gbif_renamed_to | prevalence |
|--------------|------------------------------------|----------|----------|----------|-------------|-----------------|------------|
| B_GRAMN | (unknown Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 |
| B_GRAMP | (unknown Gram-positives) | unknown | Bacteria | None | None | None | 2.0 |
| B_ANAER-NEG | (unknown anaerobic Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 |
| B_ANAER-POS | (unknown anaerobic Gram-positives) | unknown | Bacteria | None | None | None | 2.0 |
| B_ANAER | (unknown anaerobic bacteria) | unknown | Bacteria | None | None | None | 2.0 |
| … | … | … | … | … | … | … | … |
| B_ZYMMN_POMC | Zymomonas pomaceae | accepted | Bacteria | 10744418 | 3221412 | None | 2.0 |
| B_ZYMPH | Zymophilus | synonym | Bacteria | None | 9475166 | None | 2.0 |
| B_ZYMPH_PCVR | Zymophilus paucivorans | synonym | Bacteria | None | None | None | 2.0 |
| B_ZYMPH_RFFN | Zymophilus raffinosivorans | synonym | Bacteria | None | None | None | 2.0 |
| F_ZYZYG | Zyzygomyces | unknown | Fungi | None | 7581 | None | 2.0 |
``` python
AMR.antimicrobials
```
| ab | cid | name | group | oral_ddd | oral_units | iv_ddd | iv_units |
|-----|------------|-----------------------|--------------------------|----------|------------|--------|----------|
| AMA | 4649.0 | 4-aminosalicylic acid | Antimycobacterials | 12.00 | g | NaN | None |
| ACM | 6450012.0 | Acetylmidecamycin | Macrolides/lincosamides | NaN | None | NaN | None |
| ASP | 49787020.0 | Acetylspiramycin | Macrolides/lincosamides | NaN | None | NaN | None |
| ALS | 8954.0 | Aldesulfone sodium | Other antibacterials | 0.33 | g | NaN | None |
| AMK | 37768.0 | Amikacin | Aminoglycosides | NaN | None | 1.0 | g |
| … | … | … | … | … | … | … | … |
| VIR | 11979535.0 | Virginiamycine | Other antibacterials | NaN | None | NaN | None |
| VOR | 71616.0 | Voriconazole | Antifungals/antimycotics | 0.40 | g | 0.4 | g |
| XBR | 72144.0 | Xibornol | Other antibacterials | NaN | None | NaN | None |
| ZID | 77846445.0 | Zidebactam | Other antibacterials | NaN | None | NaN | None |
| ZFD | NaN | Zoliflodacin | None | NaN | None | NaN | None |
## Conclusion
With the `AMR` Python package, Python users can now effortlessly call R
functions from the `AMR` R package. This eliminates the need for complex
`rpy2` configurations and provides a clean, easy-to-use interface for
antimicrobial resistance analysis. The examples provided above
demonstrate how this can be applied to typical workflows, such as
standardising microorganism and antimicrobial names or calculating
resistance.
By just running `import AMR`, users can seamlessly integrate the robust
features of the R `AMR` package into Python workflows.
Whether youre cleaning data or analysing resistance patterns, the `AMR`
Python package makes it easy to work with AMR data in Python.

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -88,7 +88,7 @@
<blockquote>
<p>This page was entirely written by our <a href="https://chat.amr-for-r.org" class="external-link">AMR for R Assistant</a>, a ChatGPT
<p>This page was almost entirely written by our <a href="https://chat.amr-for-r.org" class="external-link">AMR for R Assistant</a>, a ChatGPT
manually-trained model able to answer any question about the
<code>AMR</code> package.</p>
</blockquote>
@@ -147,16 +147,16 @@ package.</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,000 × 46</span></span></span>
<span><span class="co">#&gt; date patient age gender ward mo PEN OXA FLC AMX </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 1,990 more rows</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span></span>
@@ -179,14 +179,13 @@ package.</p>
<span> mo <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html" class="external-link">as.factor</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="va">mo</span><span class="op">)</span><span class="op">)</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="co"># drop NAs - the ones without a Gramstain (fungi, etc.)</span></span>
<span> <span class="fu">drop_na</span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin), '</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (tobramycin), '</span><span style="color: #0000BB; font-weight: bold;">AMK</span><span style="color: #0000BB;">' (amikacin), and '</span><span style="color: #0000BB; font-weight: bold;">KAN</span><span style="color: #0000BB;">' (kanamycin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`betalactams()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">PEN</span><span style="color: #0000BB;">' (benzylpenicillin), '</span><span style="color: #0000BB; font-weight: bold;">OXA</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (oxacillin), '</span><span style="color: #0000BB; font-weight: bold;">FLC</span><span style="color: #0000BB;">' (flucloxacillin), '</span><span style="color: #0000BB; font-weight: bold;">AMX</span><span style="color: #0000BB;">' (amoxicillin), '</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (amoxicillin/clavulanic acid), '</span><span style="color: #0000BB; font-weight: bold;">AMP</span><span style="color: #0000BB;">' (ampicillin), '</span><span style="color: #0000BB; font-weight: bold;">TZP</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (piperacillin/tazobactam), '</span><span style="color: #0000BB; font-weight: bold;">CZO</span><span style="color: #0000BB;">' (cefazolin), '</span><span style="color: #0000BB; font-weight: bold;">FEP</span><span style="color: #0000BB;">' (cefepime), '</span><span style="color: #0000BB; font-weight: bold;">CXM</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (cefuroxime), '</span><span style="color: #0000BB; font-weight: bold;">FOX</span><span style="color: #0000BB;">' (cefoxitin), '</span><span style="color: #0000BB; font-weight: bold;">CTX</span><span style="color: #0000BB;">' (cefotaxime), '</span><span style="color: #0000BB; font-weight: bold;">CAZ</span><span style="color: #0000BB;">' (ceftazidime),</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; '</span><span style="color: #0000BB; font-weight: bold;">CRO</span><span style="color: #0000BB;">' (ceftriaxone), '</span><span style="color: #0000BB; font-weight: bold;">IPM</span><span style="color: #0000BB;">' (imipenem), and '</span><span style="color: #0000BB; font-weight: bold;">MEM</span><span style="color: #0000BB;">' (meropenem)</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using columns <span style="color: #00BB00; font-weight: bold;">GEN</span> (gentamicin), <span style="color: #00BB00; font-weight: bold;">TOB</span> (tobramycin), <span style="color: #00BB00; font-weight: bold;">AMK</span></span></span>
<span><span class="co">#&gt; (amikacin), and <span style="color: #00BB00; font-weight: bold;">KAN</span> (kanamycin)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `betalactams()` using columns <span style="color: #00BB00; font-weight: bold;">PEN</span> (benzylpenicillin), <span style="color: #00BB00; font-weight: bold;">OXA</span> (oxacillin),</span></span>
<span><span class="co">#&gt; <span style="color: #00BB00; font-weight: bold;">FLC</span> (flucloxacillin), <span style="color: #00BB00; font-weight: bold;">AMX</span> (amoxicillin), <span style="color: #00BB00; font-weight: bold;">AMC</span> (amoxicillin/clavulanic acid),</span></span>
<span><span class="co">#&gt; <span style="color: #00BB00; font-weight: bold;">AMP</span> (ampicillin), <span style="color: #00BB00; font-weight: bold;">TZP</span> (piperacillin/tazobactam), <span style="color: #00BB00; font-weight: bold;">CZO</span> (cefazolin), <span style="color: #00BB00; font-weight: bold;">FEP</span></span></span>
<span><span class="co">#&gt; (cefepime), <span style="color: #00BB00; font-weight: bold;">CXM</span> (cefuroxime), <span style="color: #00BB00; font-weight: bold;">FOX</span> (cefoxitin), <span style="color: #00BB00; font-weight: bold;">CTX</span> (cefotaxime), <span style="color: #00BB00; font-weight: bold;">CAZ</span></span></span>
<span><span class="co">#&gt; (ceftazidime), <span style="color: #00BB00; font-weight: bold;">CRO</span> (ceftriaxone), <span style="color: #00BB00; font-weight: bold;">IPM</span> (imipenem), and <span style="color: #00BB00; font-weight: bold;">MEM</span> (meropenem)</span></span></code></pre></div>
<p><strong>Explanation:</strong></p>
<ul>
<li>
@@ -227,26 +226,36 @@ we have with <code>step_corr()</code>, the necessary parameters can be
estimated from a training set using <code>prep()</code>:</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu">prep</span><span class="op">(</span><span class="va">resistance_recipe</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`aminoglycosides()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">' (gentamicin), '</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (tobramycin), '</span><span style="color: #0000BB; font-weight: bold;">AMK</span><span style="color: #0000BB;">' (amikacin), and '</span><span style="color: #0000BB; font-weight: bold;">KAN</span><span style="color: #0000BB;">' (kanamycin)</span></span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> For </span><span style="color: #0000BB; background-color: #EEEEEE;">`betalactams()`</span><span style="color: #0000BB;"> using columns '</span><span style="color: #0000BB; font-weight: bold;">PEN</span><span style="color: #0000BB;">' (benzylpenicillin), '</span><span style="color: #0000BB; font-weight: bold;">OXA</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (oxacillin), '</span><span style="color: #0000BB; font-weight: bold;">FLC</span><span style="color: #0000BB;">' (flucloxacillin), '</span><span style="color: #0000BB; font-weight: bold;">AMX</span><span style="color: #0000BB;">' (amoxicillin), '</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (amoxicillin/clavulanic acid), '</span><span style="color: #0000BB; font-weight: bold;">AMP</span><span style="color: #0000BB;">' (ampicillin), '</span><span style="color: #0000BB; font-weight: bold;">TZP</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (piperacillin/tazobactam), '</span><span style="color: #0000BB; font-weight: bold;">CZO</span><span style="color: #0000BB;">' (cefazolin), '</span><span style="color: #0000BB; font-weight: bold;">FEP</span><span style="color: #0000BB;">' (cefepime), '</span><span style="color: #0000BB; font-weight: bold;">CXM</span><span style="color: #0000BB;">'</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; (cefuroxime), '</span><span style="color: #0000BB; font-weight: bold;">FOX</span><span style="color: #0000BB;">' (cefoxitin), '</span><span style="color: #0000BB; font-weight: bold;">CTX</span><span style="color: #0000BB;">' (cefotaxime), '</span><span style="color: #0000BB; font-weight: bold;">CAZ</span><span style="color: #0000BB;">' (ceftazidime),</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; '</span><span style="color: #0000BB; font-weight: bold;">CRO</span><span style="color: #0000BB;">' (ceftriaxone), '</span><span style="color: #0000BB; font-weight: bold;">IPM</span><span style="color: #0000BB;">' (imipenem), and '</span><span style="color: #0000BB; font-weight: bold;">MEM</span><span style="color: #0000BB;">' (meropenem)</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `aminoglycosides()` using columns <span style="color: #00BB00; font-weight: bold;">GEN</span> (gentamicin), <span style="color: #00BB00; font-weight: bold;">TOB</span> (tobramycin), <span style="color: #00BB00; font-weight: bold;">AMK</span></span></span>
<span><span class="co">#&gt; (amikacin), and <span style="color: #00BB00; font-weight: bold;">KAN</span> (kanamycin)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> For `betalactams()` using columns <span style="color: #00BB00; font-weight: bold;">PEN</span> (benzylpenicillin), <span style="color: #00BB00; font-weight: bold;">OXA</span> (oxacillin),</span></span>
<span><span class="co">#&gt; <span style="color: #00BB00; font-weight: bold;">FLC</span> (flucloxacillin), <span style="color: #00BB00; font-weight: bold;">AMX</span> (amoxicillin), <span style="color: #00BB00; font-weight: bold;">AMC</span> (amoxicillin/clavulanic acid),</span></span>
<span><span class="co">#&gt; <span style="color: #00BB00; font-weight: bold;">AMP</span> (ampicillin), <span style="color: #00BB00; font-weight: bold;">TZP</span> (piperacillin/tazobactam), <span style="color: #00BB00; font-weight: bold;">CZO</span> (cefazolin), <span style="color: #00BB00; font-weight: bold;">FEP</span></span></span>
<span><span class="co">#&gt; (cefepime), <span style="color: #00BB00; font-weight: bold;">CXM</span> (cefuroxime), <span style="color: #00BB00; font-weight: bold;">FOX</span> (cefoxitin), <span style="color: #00BB00; font-weight: bold;">CTX</span> (cefotaxime), <span style="color: #00BB00; font-weight: bold;">CAZ</span></span></span>
<span><span class="co">#&gt; (ceftazidime), <span style="color: #00BB00; font-weight: bold;">CRO</span> (ceftriaxone), <span style="color: #00BB00; font-weight: bold;">IPM</span> (imipenem), and <span style="color: #00BB00; font-weight: bold;">MEM</span> (meropenem)</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;">──</span> <span style="font-weight: bold;">Recipe</span> <span style="color: #00BBBB;">──────────────────────────────────────────────────────────────────────</span></span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Inputs</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Inputs </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Number of variables by role</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; outcome: 1</span></span>
<span><span class="co">#&gt; predictor: 20</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Training information</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Training information </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; Training data contained 1968 data points and no incomplete rows.</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Operations</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Operations </span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Correlation filter on: <span style="color: #0000BB;">AMX</span> <span style="color: #0000BB;">CTX</span> | <span style="font-style: italic;">Trained</span></span></span></code></pre></div>
<p><strong>Explanation:</strong></p>
<ul>
@@ -413,13 +422,13 @@ ROC curve looks like this:</p>
<code class="sourceCode R"><span><span class="va">predictions</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu">roc_curve</span><span class="op">(</span><span class="va">mo</span>, <span class="va">`.pred_Gram-negative`</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://ggplot2.tidyverse.org/reference/autoplot.html" class="external-link">autoplot</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-8-1.png" width="720"></p>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-8-1.png" class="r-plt" alt="" width="720"></p>
</div>
<div class="section level3">
<h3 id="conclusion">
<strong>Conclusion</strong><a class="anchor" aria-label="anchor" href="#conclusion"></a>
</h3>
<p>In this post, we demonstrated how to build a machine learning
<p>In this example, we demonstrated how to build a machine learning
pipeline with the <code>tidymodels</code> framework and the
<code>AMR</code> package. By combining selector functions like
<code><a href="../reference/antimicrobial_selectors.html">aminoglycosides()</a></code> and <code><a href="../reference/antimicrobial_selectors.html">betalactams()</a></code> with
@@ -442,7 +451,7 @@ transformation to <code>log2</code> scale using
classification models.</p>
<p>This approach and idea formed the basis for the publication <a href="https://doi.org/10.3389/fmicb.2025.1582703" class="external-link">DOI:
10.3389/fmicb.2025.1582703</a> to model the presence of
extended-spectrum beta-lactamases (ESBL).</p>
extended-spectrum beta-lactamases (ESBL) based on MIC values.</p>
<div class="section level3">
<h3 id="objective-1">
<strong>Objective</strong><a class="anchor" aria-label="anchor" href="#objective-1"></a>
@@ -473,16 +482,16 @@ package.</p>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 500 × 19</span></span></span>
<span><span class="co">#&gt; esbl genus AMC AMP TZP CXM FOX CTX CAZ GEN TOB TMP SXT</span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;lgl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mic&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> FALSE Esch… 32 32 4 64 64 8<span style="color: #BBBBBB;">.00</span> 8<span style="color: #BBBBBB;">.00</span> 1 1 16<span style="color: #BBBBBB;">.0</span> 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> FALSE Esch… 32 32 4 64 64 4<span style="color: #BBBBBB;">.00</span> 8<span style="color: #BBBBBB;">.00</span> 1 1 16<span style="color: #BBBBBB;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> FALSE Esch… 4 2 64 8 4 8<span style="color: #BBBBBB;">.00</span> 0.12 16 16 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> FALSE Kleb… 32 32 16 64 64 8<span style="color: #BBBBBB;">.00</span> 8<span style="color: #BBBBBB;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> FALSE Esch… 32 32 4 4 4 0.25 2<span style="color: #BBBBBB;">.00</span> 1 1 16<span style="color: #BBBBBB;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> FALSE Citr… 32 32 16 64 64 64<span style="color: #BBBBBB;">.00</span> 32<span style="color: #BBBBBB;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> FALSE Morg… 32 32 4 64 64 16<span style="color: #BBBBBB;">.00</span> 2<span style="color: #BBBBBB;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> FALSE Prot… 16 32 4 1 4 8<span style="color: #BBBBBB;">.00</span> 0.12 1 1 16<span style="color: #BBBBBB;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> FALSE Ente… 32 32 8 64 64 32<span style="color: #BBBBBB;">.00</span> 4<span style="color: #BBBBBB;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> FALSE Citr… 32 32 32 64 64 8<span style="color: #BBBBBB;">.00</span> 64<span style="color: #BBBBBB;">.00</span> 1 1 16<span style="color: #BBBBBB;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> FALSE Esch… 32 32 4 64 64 8<span style="color: #949494;">.00</span> 8<span style="color: #949494;">.00</span> 1 1 16<span style="color: #949494;">.0</span> 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> FALSE Esch… 32 32 4 64 64 4<span style="color: #949494;">.00</span> 8<span style="color: #949494;">.00</span> 1 1 16<span style="color: #949494;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> FALSE Esch… 4 2 64 8 4 8<span style="color: #949494;">.00</span> 0.12 16 16 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> FALSE Kleb… 32 32 16 64 64 8<span style="color: #949494;">.00</span> 8<span style="color: #949494;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> FALSE Esch… 32 32 4 4 4 0.25 2<span style="color: #949494;">.00</span> 1 1 16<span style="color: #949494;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> FALSE Citr… 32 32 16 64 64 64<span style="color: #949494;">.00</span> 32<span style="color: #949494;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> FALSE Morg… 32 32 4 64 64 16<span style="color: #949494;">.00</span> 2<span style="color: #949494;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> FALSE Prot… 16 32 4 1 4 8<span style="color: #949494;">.00</span> 0.12 1 1 16<span style="color: #949494;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> FALSE Ente… 32 32 8 64 64 32<span style="color: #949494;">.00</span> 4<span style="color: #949494;">.00</span> 1 1 0.5 20</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> FALSE Citr… 32 32 32 64 64 8<span style="color: #949494;">.00</span> 64<span style="color: #949494;">.00</span> 1 1 16<span style="color: #949494;">.0</span> 320</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 490 more rows</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 6 more variables: NIT &lt;mic&gt;, FOS &lt;mic&gt;, CIP &lt;mic&gt;, IPM &lt;mic&gt;, MEM &lt;mic&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># COL &lt;mic&gt;</span></span></span>
@@ -521,10 +530,9 @@ predictors can easily and agnostically selected using the new
<span><span class="co"># Define the recipe</span></span>
<span><span class="va">mic_recipe</span> <span class="op">&lt;-</span> <span class="fu">recipe</span><span class="op">(</span><span class="va">esbl</span> <span class="op">~</span> <span class="va">.</span>, data <span class="op">=</span> <span class="va">training_data</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">remove_role</span><span class="op">(</span><span class="va">genus</span>, old_role <span class="op">=</span> <span class="st">"predictor"</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="co"># Remove non-informative variable</span></span>
<span> <span class="fu"><a href="../reference/amr-tidymodels.html">step_mic_log2</a></span><span class="op">(</span><span class="fu"><a href="../reference/amr-tidymodels.html">all_mic_predictors</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co">#%&gt;% # Log2 transform all MIC predictors</span></span>
<span> <span class="co"># prep()</span></span>
<span> <span class="fu"><a href="../reference/amr-tidymodels.html">step_mic_log2</a></span><span class="op">(</span><span class="fu"><a href="../reference/amr-tidymodels.html">all_mic_predictors</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># Log2 transform all MIC predictors</span></span>
<span></span>
<span><span class="va">mic_recipe</span></span>
<span><span class="fu">prep</span><span class="op">(</span><span class="va">mic_recipe</span><span class="op">)</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;">──</span> <span style="font-weight: bold;">Recipe</span> <span style="color: #00BBBB;">──────────────────────────────────────────────────────────────────────</span></span></span>
<span><span class="co">#&gt; </span></span>
@@ -534,8 +542,11 @@ predictors can easily and agnostically selected using the new
<span><span class="co">#&gt; predictor: 17</span></span>
<span><span class="co">#&gt; undeclared role: 1</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Training information</span></span>
<span><span class="co">#&gt; Training data contained 375 data points and no incomplete rows.</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ── Operations</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Log2 transformation of MIC columns: <span style="color: #0000BB;">all_mic_predictors()</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Log2 transformation of MIC columns: <span style="color: #0000BB;">AMC</span>, <span style="color: #0000BB;">AMP</span>, <span style="color: #0000BB;">TZP</span>, <span style="color: #0000BB;">CXM</span>, <span style="color: #0000BB;">FOX</span>, ... | <span style="font-style: italic;">Trained</span></span></span></code></pre></div>
<p><strong>Explanation:</strong></p>
<ul>
<li>
@@ -608,20 +619,24 @@ model.</li>
<span></span>
<span><span class="co"># Generate predictions</span></span>
<span><span class="va">predictions</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/predict.html" class="external-link">predict</a></span><span class="op">(</span><span class="va">fitted</span>, <span class="va">testing_data</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/bind_cols.html" class="external-link">bind_cols</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/predict.html" class="external-link">predict</a></span><span class="op">(</span><span class="va">fitted</span>, <span class="va">testing_data</span>, type <span class="op">=</span> <span class="st">"prob"</span><span class="op">)</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="co"># add probabilities</span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/bind_cols.html" class="external-link">bind_cols</a></span><span class="op">(</span><span class="va">testing_data</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Evaluate model performance</span></span>
<span><span class="va">our_metrics</span> <span class="op">&lt;-</span> <span class="fu">metric_set</span><span class="op">(</span><span class="va">accuracy</span>, <span class="va">kap</span>, <span class="va">ppv</span>, <span class="va">npv</span><span class="op">)</span></span>
<span><span class="va">our_metrics</span> <span class="op">&lt;-</span> <span class="fu">metric_set</span><span class="op">(</span><span class="va">accuracy</span>, <span class="va">recall</span>, <span class="va">precision</span>, <span class="va">sensitivity</span>, <span class="va">specificity</span>, <span class="va">ppv</span>, <span class="va">npv</span><span class="op">)</span></span>
<span><span class="va">metrics</span> <span class="op">&lt;-</span> <span class="fu">our_metrics</span><span class="op">(</span><span class="va">predictions</span>, truth <span class="op">=</span> <span class="va">esbl</span>, estimate <span class="op">=</span> <span class="va">.pred_class</span><span class="op">)</span></span>
<span></span>
<span><span class="va">metrics</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 4 × 3</span></span></span>
<span><span class="co">#&gt; .metric .estimator .estimate</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;dbl&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> accuracy binary 0.92 </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> kap binary 0.840</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> ppv binary 0.921</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> npv binary 0.919</span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 7 × 3</span></span></span>
<span><span class="co">#&gt; .metric .estimator .estimate</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;dbl&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> accuracy binary 0.92 </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> recall binary 0.921</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">3</span> precision binary 0.921</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">4</span> sensitivity binary 0.921</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">5</span> specificity binary 0.919</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">6</span> ppv binary 0.921</span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">7</span> npv binary 0.919</span></span></code></pre></div>
<p><strong>Explanation:</strong></p>
<ul>
<li>
@@ -632,11 +647,12 @@ data.</li>
data.</li>
<li>
<code>metric_set()</code>: Allows evaluating multiple classification
metrics.</li>
metrics. This will make <code>our_metrics</code> to become a function
that we can use to check the predictions with.</li>
</ul>
<p>It appears we can predict ESBL gene presence with a positive
predictive value (PPV) of 92.1% and a negative predictive value (NPV) of
91.9 using a simplistic logistic regression model.</p>
91.9% using a simplistic logistic regression model.</p>
</div>
<div class="section level3">
<h3 id="visualising-predictions">
@@ -653,7 +669,25 @@ status.</p>
<span> x <span class="op">=</span> <span class="st">"Actual ESBL"</span>,</span>
<span> y <span class="op">=</span> <span class="st">"Count"</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-14-1.png" width="720"></p>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-14-1.png" class="r-plt" alt="" width="720"></p>
<p>And plot the certainties too - how certain were the actual
predictions?</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">predictions</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html" class="external-link">mutate</a></span><span class="op">(</span>certainty <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/ifelse.html" class="external-link">ifelse</a></span><span class="op">(</span><span class="va">.pred_class</span> <span class="op">==</span> <span class="st">"FALSE"</span>,</span>
<span> <span class="va">.pred_FALSE</span>,</span>
<span> <span class="va">.pred_TRUE</span><span class="op">)</span>,</span>
<span> correct <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/ifelse.html" class="external-link">ifelse</a></span><span class="op">(</span><span class="va">esbl</span> <span class="op">==</span> <span class="va">.pred_class</span>, <span class="st">"Right"</span>, <span class="st">"Wrong"</span><span class="op">)</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://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq_len</a></span><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">predictions</span><span class="op">)</span><span class="op">)</span>,</span>
<span> y <span class="op">=</span> <span class="va">certainty</span>,</span>
<span> colour <span class="op">=</span> <span class="va">correct</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html" class="external-link">scale_colour_manual</a></span><span class="op">(</span>values <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>Right <span class="op">=</span> <span class="st">"green3"</span>, Wrong <span class="op">=</span> <span class="st">"red2"</span><span class="op">)</span>,</span>
<span> name <span class="op">=</span> <span class="st">"Correct?"</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_point.html" class="external-link">geom_point</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_continuous.html" class="external-link">scale_y_continuous</a></span><span class="op">(</span>labels <span class="op">=</span> <span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html" class="external-link">paste0</a></span><span class="op">(</span><span class="va">x</span> <span class="op">*</span> <span class="fl">100</span>, <span class="st">"%"</span><span class="op">)</span>,</span>
<span> limits <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="fl">0.5</span>, <span class="fl">1</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-15-1.png" class="r-plt" alt="" width="720"></p>
</div>
<div class="section level3">
<h3 id="conclusion-1">
@@ -662,8 +696,8 @@ status.</p>
<p>In this example, we showcased how the new <code>AMR</code>-specific
recipe steps simplify working with <code>&lt;mic&gt;</code> columns in
<code>tidymodels</code>. The <code><a href="../reference/amr-tidymodels.html">step_mic_log2()</a></code> transformation
converts ordered MICs to log2-transformed numerics, improving
compatibility with classification models.</p>
converts MICs (with or without operators) to log2-transformed numerics,
improving compatibility with classification models.</p>
<p>This pipeline enables realistic, reproducible, and interpretable
modelling of antimicrobial resistance data.</p>
<hr>
@@ -696,7 +730,7 @@ model.</li>
</h3>
<p>We start by transforming the <code>example_isolates</code> dataset
into a structured time-series format.</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Load required libraries</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://amr-for-r.org">AMR</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://tidymodels.tidymodels.org" class="external-link">tidymodels</a></span><span class="op">)</span></span>
@@ -712,7 +746,11 @@ into a structured time-series format.</p>
<span> .names <span class="op">=</span> <span class="st">"res_{.col}"</span><span class="op">)</span>, </span>
<span> .groups <span class="op">=</span> <span class="st">"drop"</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/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/NA.html" class="external-link">is.na</a></span><span class="op">(</span><span class="va">res_AMX</span><span class="op">)</span> <span class="op">&amp;</span> <span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/NA.html" class="external-link">is.na</a></span><span class="op">(</span><span class="va">res_AMC</span><span class="op">)</span> <span class="op">&amp;</span> <span class="op">!</span><span class="fu"><a href="https://rdrr.io/r/base/NA.html" class="external-link">is.na</a></span><span class="op">(</span><span class="va">res_CIP</span><span class="op">)</span><span class="op">)</span> <span class="co"># Drop missing values</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Using column '</span><span style="color: #0000BB; font-weight: bold;">mo</span><span style="color: #0000BB;">' as input for </span><span style="color: #0000BB; background-color: #EEEEEE;">`col_mo`</span><span style="color: #0000BB;">.</span></span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Using column <span style="color: #00BB00; font-weight: bold;">mo</span> as input for `col_mo`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> `resistance()` assumes the EUCAST guideline and thus considers the 'I'</span></span>
<span><span class="co">#&gt; category susceptible. Set the `guideline` argument or the `AMR_guideline`</span></span>
<span><span class="co">#&gt; option to either "CLSI" or "EUCAST", see `?AMR-options`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> This message will be shown once per session.</span></span>
<span></span>
<span><span class="va">data_time</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 32 × 5</span></span></span>
@@ -751,7 +789,7 @@ preprocessing step, a model specification, and the fitting process.</p>
<div class="section level4">
<h4 id="preprocessing-with-a-recipe-2">1. Preprocessing with a Recipe<a class="anchor" aria-label="anchor" href="#preprocessing-with-a-recipe-2"></a>
</h4>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Define the recipe</span></span>
<span><span class="va">resistance_recipe_time</span> <span class="op">&lt;-</span> <span class="fu">recipe</span><span class="op">(</span><span class="va">res_AMX</span> <span class="op">~</span> <span class="va">year</span> <span class="op">+</span> <span class="va">gramstain</span>, data <span class="op">=</span> <span class="va">data_time</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">step_dummy</span><span class="op">(</span><span class="va">gramstain</span>, one_hot <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="co"># Convert categorical to numerical</span></span>
@@ -787,7 +825,7 @@ variable.</li>
<h4 id="specifying-the-model-2">2. Specifying the Model<a class="anchor" aria-label="anchor" href="#specifying-the-model-2"></a>
</h4>
<p>We use a linear regression model to predict resistance trends.</p>
<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Define the linear regression model</span></span>
<span><span class="va">lm_model</span> <span class="op">&lt;-</span> <span class="fu">linear_reg</span><span class="op">(</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">set_engine</span><span class="op">(</span><span class="st">"lm"</span><span class="op">)</span> <span class="co"># Use linear regression</span></span>
@@ -809,7 +847,7 @@ engine.</li>
<h4 id="building-the-workflow-2">3. Building the Workflow<a class="anchor" aria-label="anchor" href="#building-the-workflow-2"></a>
</h4>
<p>We combine the preprocessing recipe and model into a workflow.</p>
<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Create workflow</span></span>
<span><span class="va">resistance_workflow_time</span> <span class="op">&lt;-</span> <span class="fu">workflow</span><span class="op">(</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">add_recipe</span><span class="op">(</span><span class="va">resistance_recipe_time</span><span class="op">)</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
@@ -839,7 +877,7 @@ engine.</li>
</h3>
<p>We split the data into training and testing sets, fit the model, and
evaluate performance.</p>
<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># Split the data</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">123</span><span class="op">)</span></span>
<span><span class="va">data_split_time</span> <span class="op">&lt;-</span> <span class="fu">initial_split</span><span class="op">(</span><span class="va">data_time</span>, prop <span class="op">=</span> <span class="fl">0.8</span><span class="op">)</span></span>
@@ -853,7 +891,7 @@ evaluate performance.</p>
<span><span class="co"># Make predictions</span></span>
<span><span class="va">predictions_time</span> <span class="op">&lt;-</span> <span class="va">fitted_workflow_time</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://rdrr.io/r/stats/predict.html" class="external-link">predict</a></span><span class="op">(</span><span class="va">test_time</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/bind_cols.html" class="external-link">bind_cols</a></span><span class="op">(</span><span class="va">test_time</span><span class="op">)</span> </span>
<span> <span class="fu"><a href="https://dplyr.tidyverse.org/reference/bind_cols.html" class="external-link">bind_cols</a></span><span class="op">(</span><span class="va">test_time</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Evaluate model</span></span>
<span><span class="va">metrics_time</span> <span class="op">&lt;-</span> <span class="va">predictions_time</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span></span>
@@ -884,7 +922,7 @@ sets.</li>
<strong>Visualising Predictions</strong><a class="anchor" aria-label="anchor" href="#visualising-predictions-1"></a>
</h3>
<p>We plot resistance trends over time for amoxicillin.</p>
<div class="sourceCode" id="cb21"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># Plot actual vs predicted resistance over time</span></span>
@@ -895,10 +933,10 @@ sets.</li>
<span> x <span class="op">=</span> <span class="st">"Year"</span>,</span>
<span> y <span class="op">=</span> <span class="st">"Resistance Proportion"</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-20-1.png" width="720"></p>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-21-1.png" class="r-plt" alt="" width="720"></p>
<p>Additionally, we can visualise resistance trends in
<code>ggplot2</code> and directly add linear models there:</p>
<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html" class="external-link">ggplot</a></span><span class="op">(</span><span class="va">data_time</span>, <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html" class="external-link">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">year</span>, y <span class="op">=</span> <span class="va">res_AMX</span>, color <span class="op">=</span> <span class="va">gramstain</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_path.html" class="external-link">geom_line</a></span><span class="op">(</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"AMX Resistance Trends"</span>,</span>
@@ -909,7 +947,7 @@ sets.</li>
<span> formula <span class="op">=</span> <span class="va">y</span> <span class="op">~</span> <span class="va">x</span>,</span>
<span> alpha <span class="op">=</span> <span class="fl">0.25</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggtheme.html" class="external-link">theme_minimal</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-21-1.png" width="720"></p>
<p><img src="AMR_with_tidymodels_files/figure-html/unnamed-chunk-22-1.png" class="r-plt" alt="" width="720"></p>
</div>
<div class="section level3">
<h3 id="conclusion-2">

View File

@@ -0,0 +1,852 @@
# AMR with tidymodels
> This page was almost entirely written by our [AMR for R
> Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained
> model able to answer any question about the `AMR` package.
Antimicrobial resistance (AMR) is a global health crisis, and
understanding resistance patterns is crucial for managing effective
treatments. The `AMR` R package provides robust tools for analysing AMR
data, including convenient antimicrobial selector functions like
[`aminoglycosides()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
and
[`betalactams()`](https://amr-for-r.org/reference/antimicrobial_selectors.md).
In this post, we will explore how to use the `tidymodels` framework to
predict resistance patterns in the `example_isolates` dataset in two
examples.
This post contains the following examples:
1. Using Antimicrobial Selectors
2. Predicting ESBL Presence Using Raw MICs
3. Predicting AMR Over Time
## Example 1: Using Antimicrobial Selectors
By leveraging the power of `tidymodels` and the `AMR` package, well
build a reproducible machine learning workflow to predict the Gramstain
of the microorganism to two important antibiotic classes:
aminoglycosides and beta-lactams.
### **Objective**
Our goal is to build a predictive model using the `tidymodels` framework
to determine the Gramstain of the microorganism based on microbial data.
We will:
1. Preprocess data using the selector functions
[`aminoglycosides()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
and
[`betalactams()`](https://amr-for-r.org/reference/antimicrobial_selectors.md).
2. Define a logistic regression model for prediction.
3. Use a structured `tidymodels` workflow to preprocess, train, and
evaluate the model.
### **Data Preparation**
We begin by loading the required libraries and preparing the
`example_isolates` dataset from the `AMR` package.
``` r
# Load required libraries
library(AMR) # For AMR data analysis
library(tidymodels) # For machine learning workflows, and data manipulation (dplyr, tidyr, ...)
```
Prepare the data:
``` r
# Your data could look like this:
example_isolates
#> # A tibble: 2,000 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
#> 1 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 2 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 3 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 4 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 5 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 6 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 7 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 8 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 9 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 10 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA
#> # 1,990 more rows
#> # 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
# Select relevant columns for prediction
data <- example_isolates %>%
# select AB results dynamically
select(mo, aminoglycosides(), betalactams()) %>%
# replace NAs with NI (not-interpretable)
mutate(across(where(is.sir),
~replace_na(.x, "NI")),
# make factors of SIR columns
across(where(is.sir),
as.integer),
# get Gramstain of microorganisms
mo = as.factor(mo_gramstain(mo))) %>%
# drop NAs - the ones without a Gramstain (fungi, etc.)
drop_na()
#> For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK
#> (amikacin), and KAN (kanamycin)
#> For `betalactams()` using columns PEN (benzylpenicillin), OXA (oxacillin),
#> FLC (flucloxacillin), AMX (amoxicillin), AMC (amoxicillin/clavulanic acid),
#> AMP (ampicillin), TZP (piperacillin/tazobactam), CZO (cefazolin), FEP
#> (cefepime), CXM (cefuroxime), FOX (cefoxitin), CTX (cefotaxime), CAZ
#> (ceftazidime), CRO (ceftriaxone), IPM (imipenem), and MEM (meropenem)
```
**Explanation:**
- [`aminoglycosides()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
and
[`betalactams()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
dynamically select columns for antimicrobials in these classes.
- `drop_na()` ensures the model receives complete cases for training.
### **Defining the Workflow**
We now define the `tidymodels` workflow, which consists of three steps:
preprocessing, model specification, and fitting.
#### 1. Preprocessing with a Recipe
We create a recipe to preprocess the data for modelling.
``` r
# Define the recipe for data preprocessing
resistance_recipe <- recipe(mo ~ ., data = data) %>%
step_corr(c(aminoglycosides(), betalactams()), threshold = 0.9)
resistance_recipe
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 20
#>
#> ── Operations
#> • Correlation filter on: c(aminoglycosides(), betalactams())
```
For a recipe that includes at least one preprocessing operation, like we
have with `step_corr()`, the necessary parameters can be estimated from
a training set using `prep()`:
``` r
prep(resistance_recipe)
#> For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK
#> (amikacin), and KAN (kanamycin)
#> For `betalactams()` using columns PEN (benzylpenicillin), OXA (oxacillin),
#> FLC (flucloxacillin), AMX (amoxicillin), AMC (amoxicillin/clavulanic acid),
#> AMP (ampicillin), TZP (piperacillin/tazobactam), CZO (cefazolin), FEP
#> (cefepime), CXM (cefuroxime), FOX (cefoxitin), CTX (cefotaxime), CAZ
#> (ceftazidime), CRO (ceftriaxone), IPM (imipenem), and MEM (meropenem)
#>
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#>
#>
#> ── Inputs
#>
#> Number of variables by role
#>
#> outcome: 1
#> predictor: 20
#>
#>
#>
#> ── Training information
#>
#> Training data contained 1968 data points and no incomplete rows.
#>
#>
#>
#> ── Operations
#>
#> • Correlation filter on: AMX CTX | Trained
```
**Explanation:**
- `recipe(mo ~ ., data = data)` will take the `mo` column as outcome and
all other columns as predictors.
- `step_corr()` removes predictors (i.e., antibiotic columns) that have
a higher correlation than 90%.
Notice how the recipe contains just the antimicrobial selector
functions - no need to define the columns specifically. In the
preparation (retrieved with `prep()`) we can see that the columns or
variables AMX and CTX were removed as they correlate too much with
existing, other variables.
#### 2. Specifying the Model
We define a logistic regression model since resistance prediction is a
binary classification task.
``` r
# Specify a logistic regression model
logistic_model <- logistic_reg() %>%
set_engine("glm") # Use the Generalised Linear Model engine
logistic_model
#> Logistic Regression Model Specification (classification)
#>
#> Computational engine: glm
```
**Explanation:**
- `logistic_reg()` sets up a logistic regression model.
- `set_engine("glm")` specifies the use of Rs built-in GLM engine.
#### 3. Building the Workflow
We bundle the recipe and model together into a `workflow`, which
organises the entire modelling process.
``` r
# Combine the recipe and model into a workflow
resistance_workflow <- workflow() %>%
add_recipe(resistance_recipe) %>% # Add the preprocessing recipe
add_model(logistic_model) # Add the logistic regression model
resistance_workflow
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: logistic_reg()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 1 Recipe Step
#>
#> • step_corr()
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> Logistic Regression Model Specification (classification)
#>
#> Computational engine: glm
```
### **Training and Evaluating the Model**
To train the model, we split the data into training and testing sets.
Then, we fit the workflow on the training set and evaluate its
performance.
``` r
# Split data into training and testing sets
set.seed(123) # For reproducibility
data_split <- initial_split(data, prop = 0.8) # 80% training, 20% testing
training_data <- training(data_split) # Training set
testing_data <- testing(data_split) # Testing set
# Fit the workflow to the training data
fitted_workflow <- resistance_workflow %>%
fit(training_data) # Train the model
```
**Explanation:**
- `initial_split()` splits the data into training and testing sets.
- `fit()` trains the workflow on the training set.
Notice how in `fit()`, the antimicrobial selector functions are
internally called again. For training, these functions are called since
they are stored in the recipe.
Next, we evaluate the model on the testing data.
``` r
# Make predictions on the testing set
predictions <- fitted_workflow %>%
predict(testing_data) # Generate predictions
probabilities <- fitted_workflow %>%
predict(testing_data, type = "prob") # Generate probabilities
predictions <- predictions %>%
bind_cols(probabilities) %>%
bind_cols(testing_data) # Combine with true labels
predictions
#> # A tibble: 394 × 24
#> .pred_class `.pred_Gram-negative` `.pred_Gram-positive` mo GEN TOB
#> <fct> <dbl> <dbl> <fct> <int> <int>
#> 1 Gram-positive 1.07e- 1 8.93 e- 1 Gram-p… 5 5
#> 2 Gram-positive 3.17e- 8 1.000e+ 0 Gram-p… 5 1
#> 3 Gram-negative 9.99e- 1 1.42 e- 3 Gram-n… 5 5
#> 4 Gram-positive 2.22e-16 1 e+ 0 Gram-p… 5 5
#> 5 Gram-negative 9.46e- 1 5.42 e- 2 Gram-n… 5 5
#> 6 Gram-positive 1.07e- 1 8.93 e- 1 Gram-p… 5 5
#> 7 Gram-positive 2.22e-16 1 e+ 0 Gram-p… 1 5
#> 8 Gram-positive 2.22e-16 1 e+ 0 Gram-p… 4 4
#> 9 Gram-negative 1 e+ 0 2.22 e-16 Gram-n… 1 1
#> 10 Gram-positive 6.05e-11 1.000e+ 0 Gram-p… 4 4
#> # 384 more rows
#> # 18 more variables: AMK <int>, KAN <int>, PEN <int>, OXA <int>, FLC <int>,
#> # AMX <int>, AMC <int>, AMP <int>, TZP <int>, CZO <int>, FEP <int>,
#> # CXM <int>, FOX <int>, CTX <int>, CAZ <int>, CRO <int>, IPM <int>, MEM <int>
# Evaluate model performance
metrics <- predictions %>%
metrics(truth = mo, estimate = .pred_class) # Calculate performance metrics
metrics
#> # A tibble: 2 × 3
#> .metric .estimator .estimate
#> <chr> <chr> <dbl>
#> 1 accuracy binary 0.995
#> 2 kap binary 0.989
# To assess some other model properties, you can make our own `metrics()` function
our_metrics <- metric_set(accuracy, kap, ppv, npv) # add Positive Predictive Value and Negative Predictive Value
metrics2 <- predictions %>%
our_metrics(truth = mo, estimate = .pred_class) # run again on our `our_metrics()` function
metrics2
#> # A tibble: 4 × 3
#> .metric .estimator .estimate
#> <chr> <chr> <dbl>
#> 1 accuracy binary 0.995
#> 2 kap binary 0.989
#> 3 ppv binary 0.987
#> 4 npv binary 1
```
**Explanation:**
- [`predict()`](https://rdrr.io/r/stats/predict.html) generates
predictions on the testing set.
- `metrics()` computes evaluation metrics like accuracy and kappa.
It appears we can predict the Gram stain with a 99.5% accuracy based on
AMR results of only aminoglycosides and beta-lactam antibiotics. The ROC
curve looks like this:
``` r
predictions %>%
roc_curve(mo, `.pred_Gram-negative`) %>%
autoplot()
```
![](AMR_with_tidymodels_files/figure-html/unnamed-chunk-8-1.png)
### **Conclusion**
In this example, we demonstrated how to build a machine learning
pipeline with the `tidymodels` framework and the `AMR` package. By
combining selector functions like
[`aminoglycosides()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
and
[`betalactams()`](https://amr-for-r.org/reference/antimicrobial_selectors.md)
with `tidymodels`, we efficiently prepared data, trained a model, and
evaluated its performance.
This workflow is extensible to other antimicrobial classes and
resistance patterns, empowering users to analyse AMR data systematically
and reproducibly.
------------------------------------------------------------------------
## Example 2: Predicting ESBL Presence Using Raw MICs
In this second example, we demonstrate how to use `<mic>` columns
directly in `tidymodels` workflows using AMR-specific recipe steps. This
includes a transformation to `log2` scale using
[`step_mic_log2()`](https://amr-for-r.org/reference/amr-tidymodels.md),
which prepares MIC values for use in classification models.
This approach and idea formed the basis for the publication [DOI:
10.3389/fmicb.2025.1582703](https://doi.org/10.3389/fmicb.2025.1582703)
to model the presence of extended-spectrum beta-lactamases (ESBL) based
on MIC values.
### **Objective**
Our goal is to:
1. Use raw MIC values to predict whether a bacterial isolate produces
ESBL.
2. Apply AMR-aware preprocessing in a `tidymodels` recipe.
3. Train a classification model and evaluate its predictive
performance.
### **Data Preparation**
We use the `esbl_isolates` dataset that comes with the AMR package.
``` r
# Load required libraries
library(AMR)
library(tidymodels)
# View the esbl_isolates data set
esbl_isolates
#> # A tibble: 500 × 19
#> esbl genus AMC AMP TZP CXM FOX CTX CAZ GEN TOB TMP SXT
#> <lgl> <chr> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic> <mic>
#> 1 FALSE Esch… 32 32 4 64 64 8.00 8.00 1 1 16.0 20
#> 2 FALSE Esch… 32 32 4 64 64 4.00 8.00 1 1 16.0 320
#> 3 FALSE Esch… 4 2 64 8 4 8.00 0.12 16 16 0.5 20
#> 4 FALSE Kleb… 32 32 16 64 64 8.00 8.00 1 1 0.5 20
#> 5 FALSE Esch… 32 32 4 4 4 0.25 2.00 1 1 16.0 320
#> 6 FALSE Citr… 32 32 16 64 64 64.00 32.00 1 1 0.5 20
#> 7 FALSE Morg… 32 32 4 64 64 16.00 2.00 1 1 0.5 20
#> 8 FALSE Prot… 16 32 4 1 4 8.00 0.12 1 1 16.0 320
#> 9 FALSE Ente… 32 32 8 64 64 32.00 4.00 1 1 0.5 20
#> 10 FALSE Citr… 32 32 32 64 64 8.00 64.00 1 1 16.0 320
#> # 490 more rows
#> # 6 more variables: NIT <mic>, FOS <mic>, CIP <mic>, IPM <mic>, MEM <mic>,
#> # COL <mic>
# Prepare a binary outcome and convert to ordered factor
data <- esbl_isolates %>%
mutate(esbl = factor(esbl, levels = c(FALSE, TRUE), ordered = TRUE))
```
**Explanation:**
- `esbl_isolates`: Contains MIC test results and ESBL status for each
isolate.
- `mutate(esbl = ...)`: Converts the target column to an ordered factor
for classification.
### **Defining the Workflow**
#### 1. Preprocessing with a Recipe
We use our
[`step_mic_log2()`](https://amr-for-r.org/reference/amr-tidymodels.md)
function to log2-transform MIC values, ensuring that MICs are numeric
and properly scaled. All MIC predictors can easily and agnostically
selected using the new
[`all_mic_predictors()`](https://amr-for-r.org/reference/amr-tidymodels.md):
``` r
# Split into training and testing sets
set.seed(123)
split <- initial_split(data)
training_data <- training(split)
testing_data <- testing(split)
# Define the recipe
mic_recipe <- recipe(esbl ~ ., data = training_data) %>%
remove_role(genus, old_role = "predictor") %>% # Remove non-informative variable
step_mic_log2(all_mic_predictors()) # Log2 transform all MIC predictors
prep(mic_recipe)
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 17
#> undeclared role: 1
#>
#> ── Training information
#> Training data contained 375 data points and no incomplete rows.
#>
#> ── Operations
#> • Log2 transformation of MIC columns: AMC, AMP, TZP, CXM, FOX, ... | Trained
```
**Explanation:**
- `remove_role()`: Removes irrelevant variables like genus.
- [`step_mic_log2()`](https://amr-for-r.org/reference/amr-tidymodels.md):
Applies `log2(as.numeric(...))` to all MIC predictors in one go.
- `prep()`: Finalises the recipe based on training data.
#### 2. Specifying the Model
We use a simple logistic regression to model ESBL presence, though
recent models such as xgboost ([link to `parsnip`
manual](https://parsnip.tidymodels.org/reference/details_boost_tree_xgboost.html))
could be much more precise.
``` r
# Define the model
model <- logistic_reg(mode = "classification") %>%
set_engine("glm")
model
#> Logistic Regression Model Specification (classification)
#>
#> Computational engine: glm
```
**Explanation:**
- `logistic_reg()`: Specifies a binary classification model.
- `set_engine("glm")`: Uses the base R GLM engine.
#### 3. Building the Workflow
``` r
# Create workflow
workflow_model <- workflow() %>%
add_recipe(mic_recipe) %>%
add_model(model)
workflow_model
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: logistic_reg()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 1 Recipe Step
#>
#> • step_mic_log2()
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> Logistic Regression Model Specification (classification)
#>
#> Computational engine: glm
```
### **Training and Evaluating the Model**
``` r
# Fit the model
fitted <- fit(workflow_model, training_data)
# Generate predictions
predictions <- predict(fitted, testing_data) %>%
bind_cols(predict(fitted, testing_data, type = "prob")) %>% # add probabilities
bind_cols(testing_data)
# Evaluate model performance
our_metrics <- metric_set(accuracy, recall, precision, sensitivity, specificity, ppv, npv)
metrics <- our_metrics(predictions, truth = esbl, estimate = .pred_class)
metrics
#> # A tibble: 7 × 3
#> .metric .estimator .estimate
#> <chr> <chr> <dbl>
#> 1 accuracy binary 0.92
#> 2 recall binary 0.921
#> 3 precision binary 0.921
#> 4 sensitivity binary 0.921
#> 5 specificity binary 0.919
#> 6 ppv binary 0.921
#> 7 npv binary 0.919
```
**Explanation:**
- `fit()`: Trains the model on the processed training data.
- [`predict()`](https://rdrr.io/r/stats/predict.html): Produces
predictions for unseen test data.
- `metric_set()`: Allows evaluating multiple classification metrics.
This will make `our_metrics` to become a function that we can use to
check the predictions with.
It appears we can predict ESBL gene presence with a positive predictive
value (PPV) of 92.1% and a negative predictive value (NPV) of 91.9%
using a simplistic logistic regression model.
### **Visualising Predictions**
We can visualise predictions by comparing predicted and actual ESBL
status.
``` r
library(ggplot2)
ggplot(predictions, aes(x = esbl, fill = .pred_class)) +
geom_bar(position = "stack") +
labs(title = "Predicted vs Actual ESBL Status",
x = "Actual ESBL",
y = "Count") +
theme_minimal()
```
![](AMR_with_tidymodels_files/figure-html/unnamed-chunk-14-1.png)
And plot the certainties too - how certain were the actual predictions?
``` r
predictions %>%
mutate(certainty = ifelse(.pred_class == "FALSE",
.pred_FALSE,
.pred_TRUE),
correct = ifelse(esbl == .pred_class, "Right", "Wrong")) %>%
ggplot(aes(x = seq_len(nrow(predictions)),
y = certainty,
colour = correct)) +
scale_colour_manual(values = c(Right = "green3", Wrong = "red2"),
name = "Correct?") +
geom_point() +
scale_y_continuous(labels = function(x) paste0(x * 100, "%"),
limits = c(0.5, 1)) +
theme_minimal()
```
![](AMR_with_tidymodels_files/figure-html/unnamed-chunk-15-1.png)
### **Conclusion**
In this example, we showcased how the new `AMR`-specific recipe steps
simplify working with `<mic>` columns in `tidymodels`. The
[`step_mic_log2()`](https://amr-for-r.org/reference/amr-tidymodels.md)
transformation converts MICs (with or without operators) to
log2-transformed numerics, improving compatibility with classification
models.
This pipeline enables realistic, reproducible, and interpretable
modelling of antimicrobial resistance data.
------------------------------------------------------------------------
## Example 3: Predicting AMR Over Time
In this third example, we aim to predict antimicrobial resistance (AMR)
trends over time using `tidymodels`. We will model resistance to three
antibiotics (amoxicillin `AMX`, amoxicillin-clavulanic acid `AMC`, and
ciprofloxacin `CIP`), based on historical data grouped by year and
hospital ward.
### **Objective**
Our goal is to:
1. Prepare the dataset by aggregating resistance data over time.
2. Define a regression model to predict AMR trends.
3. Use `tidymodels` to preprocess, train, and evaluate the model.
### **Data Preparation**
We start by transforming the `example_isolates` dataset into a
structured time-series format.
``` r
# Load required libraries
library(AMR)
library(tidymodels)
# Transform dataset
data_time <- example_isolates %>%
top_n_microorganisms(n = 10) %>% # Filter on the top #10 species
mutate(year = as.integer(format(date, "%Y")), # Extract year from date
gramstain = mo_gramstain(mo)) %>% # Get taxonomic names
group_by(year, gramstain) %>%
summarise(across(c(AMX, AMC, CIP),
function(x) resistance(x, minimum = 0),
.names = "res_{.col}"),
.groups = "drop") %>%
filter(!is.na(res_AMX) & !is.na(res_AMC) & !is.na(res_CIP)) # Drop missing values
#> Using column mo as input for `col_mo`.
#> `resistance()` assumes the EUCAST guideline and thus considers the 'I'
#> category susceptible. Set the `guideline` argument or the `AMR_guideline`
#> option to either "CLSI" or "EUCAST", see `?AMR-options`.
#> This message will be shown once per session.
data_time
#> # A tibble: 32 × 5
#> year gramstain res_AMX res_AMC res_CIP
#> <int> <chr> <dbl> <dbl> <dbl>
#> 1 2002 Gram-negative 1 0.105 0.0606
#> 2 2002 Gram-positive 0.838 0.182 0.162
#> 3 2003 Gram-negative 1 0.0714 0
#> 4 2003 Gram-positive 0.714 0.244 0.154
#> 5 2004 Gram-negative 0.464 0.0938 0
#> 6 2004 Gram-positive 0.849 0.299 0.244
#> 7 2005 Gram-negative 0.412 0.132 0.0588
#> 8 2005 Gram-positive 0.882 0.382 0.154
#> 9 2006 Gram-negative 0.379 0 0.1
#> 10 2006 Gram-positive 0.778 0.333 0.353
#> # 22 more rows
```
**Explanation:**
- `mo_name(mo)`: Converts microbial codes into proper species names.
- [`resistance()`](https://amr-for-r.org/reference/proportion.md):
Converts AMR results into numeric values (proportion of resistant
isolates).
- `group_by(year, ward, species)`: Aggregates resistance rates by year
and ward.
### **Defining the Workflow**
We now define the modelling workflow, which consists of a preprocessing
step, a model specification, and the fitting process.
#### 1. Preprocessing with a Recipe
``` r
# Define the recipe
resistance_recipe_time <- recipe(res_AMX ~ year + gramstain, data = data_time) %>%
step_dummy(gramstain, one_hot = TRUE) %>% # Convert categorical to numerical
step_normalize(year) %>% # Normalise year for better model performance
step_nzv(all_predictors()) # Remove near-zero variance predictors
resistance_recipe_time
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 2
#>
#> ── Operations
#> • Dummy variables from: gramstain
#> • Centering and scaling for: year
#> • Sparse, unbalanced variable filter on: all_predictors()
```
**Explanation:**
- `step_dummy()`: Encodes categorical variables (`ward`, `species`) as
numerical indicators.
- `step_normalize()`: Normalises the `year` variable.
- `step_nzv()`: Removes near-zero variance predictors.
#### 2. Specifying the Model
We use a linear regression model to predict resistance trends.
``` r
# Define the linear regression model
lm_model <- linear_reg() %>%
set_engine("lm") # Use linear regression
lm_model
#> Linear Regression Model Specification (regression)
#>
#> Computational engine: lm
```
**Explanation:**
- `linear_reg()`: Defines a linear regression model.
- `set_engine("lm")`: Uses Rs built-in linear regression engine.
#### 3. Building the Workflow
We combine the preprocessing recipe and model into a workflow.
``` r
# Create workflow
resistance_workflow_time <- workflow() %>%
add_recipe(resistance_recipe_time) %>%
add_model(lm_model)
resistance_workflow_time
#> ══ Workflow ════════════════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: linear_reg()
#>
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 3 Recipe Steps
#>
#> • step_dummy()
#> • step_normalize()
#> • step_nzv()
#>
#> ── Model ───────────────────────────────────────────────────────────────────────
#> Linear Regression Model Specification (regression)
#>
#> Computational engine: lm
```
### **Training and Evaluating the Model**
We split the data into training and testing sets, fit the model, and
evaluate performance.
``` r
# Split the data
set.seed(123)
data_split_time <- initial_split(data_time, prop = 0.8)
train_time <- training(data_split_time)
test_time <- testing(data_split_time)
# Train the model
fitted_workflow_time <- resistance_workflow_time %>%
fit(train_time)
# Make predictions
predictions_time <- fitted_workflow_time %>%
predict(test_time) %>%
bind_cols(test_time)
# Evaluate model
metrics_time <- predictions_time %>%
metrics(truth = res_AMX, estimate = .pred)
metrics_time
#> # A tibble: 3 × 3
#> .metric .estimator .estimate
#> <chr> <chr> <dbl>
#> 1 rmse standard 0.0774
#> 2 rsq standard 0.711
#> 3 mae standard 0.0704
```
**Explanation:**
- `initial_split()`: Splits data into training and testing sets.
- `fit()`: Trains the workflow.
- [`predict()`](https://rdrr.io/r/stats/predict.html): Generates
resistance predictions.
- `metrics()`: Evaluates model performance.
### **Visualising Predictions**
We plot resistance trends over time for amoxicillin.
``` r
library(ggplot2)
# Plot actual vs predicted resistance over time
ggplot(predictions_time, aes(x = year)) +
geom_point(aes(y = res_AMX, color = "Actual")) +
geom_line(aes(y = .pred, color = "Predicted")) +
labs(title = "Predicted vs Actual AMX Resistance Over Time",
x = "Year",
y = "Resistance Proportion") +
theme_minimal()
```
![](AMR_with_tidymodels_files/figure-html/unnamed-chunk-21-1.png)
Additionally, we can visualise resistance trends in `ggplot2` and
directly add linear models there:
``` r
ggplot(data_time, aes(x = year, y = res_AMX, color = gramstain)) +
geom_line() +
labs(title = "AMX Resistance Trends",
x = "Year",
y = "Resistance Proportion") +
# add a linear model directly in ggplot2:
geom_smooth(method = "lm",
formula = y ~ x,
alpha = 0.25) +
theme_minimal()
```
![](AMR_with_tidymodels_files/figure-html/unnamed-chunk-22-1.png)
### **Conclusion**
In this example, we demonstrated how to analyze AMR trends over time
using `tidymodels`. By aggregating resistance rates by year and hospital
ward, we built a predictive model to track changes in resistance to
amoxicillin (`AMX`), amoxicillin-clavulanic acid (`AMC`), and
ciprofloxacin (`CIP`).
This method can be extended to other antibiotics and resistance
patterns, providing valuable insights into AMR dynamics in healthcare
settings.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -118,7 +118,7 @@ resistant to ampicillin.</p>
<em>Klebsiella</em> being susceptible to ampicillin. This could be
because an antibiogram is available before an identification is
available, and the antibiogram is then not re-interpreted based on the
identification. The <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function resolves this,
identification. The <code><a href="../reference/interpretive_rules.html">eucast_rules()</a></code> function resolves this,
by applying the latest EUCAST Expected Resistant Phenotypes
guideline:</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
@@ -136,11 +136,11 @@ guideline:</p>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Klebsiella pneumoniae <span style="color: #080808; background-color: #5FD7AF;"> S </span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Escherichia coli <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span>
<span></span>
<span><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, overwrite <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="fu"><a href="../reference/interpretive_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">oops</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, overwrite <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: 2 × 2</span></span></span>
<span><span class="co">#&gt; mo ampicillin</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;sir&gt;</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Klebsiella pneumoniae <span style="color: #080808; background-color: #FFAFAF;"> R </span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">1</span> Klebsiella pneumoniae <span style="color: #080808; background-color: #FF5F5F;"> R </span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">2</span> Escherichia coli <span style="color: #080808; background-color: #5FD7AF;"> S </span></span></span></code></pre></div>
<p>A more convenient function is
<code><a href="../reference/mo_property.html">mo_is_intrinsic_resistant()</a></code> that uses the same guideline,
@@ -246,7 +246,7 @@ reading</em>, and is basically a form of imputation:</p>
</tbody>
</table>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span>, overwrite <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<code class="sourceCode R"><span><span class="fu"><a href="../reference/interpretive_rules.html">eucast_rules</a></span><span class="op">(</span><span class="va">data</span>, overwrite <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="left">mo</th>

126
articles/EUCAST.md Normal file
View File

@@ -0,0 +1,126 @@
# Apply EUCAST rules
## Introduction
What are EUCAST rules? The European Committee on Antimicrobial
Susceptibility Testing (EUCAST) states [on their
website](https://www.eucast.org/expert_rules_and_expected_phenotypes):
> *EUCAST expert rules (see below) are a tabulated collection of expert
> knowledge on interpretive rules, expected resistant phenotypes and
> expected susceptible phenotypes which should be applied to
> antimicrobial susceptibility testing in order to reduce testing,
> reduce errors and make appropriate recommendations for reporting
> particular resistances.*
In Europe, a lot of medical microbiological laboratories already apply
these rules ([Brown *et al.*,
2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)).
Our package features their latest insights on expected resistant
phenotypes (v1.2, 2023).
## Examples
These rules can be used to discard improbable bug-drug combinations in
your data. For example, *Klebsiella* produces beta-lactamase that
prevents ampicillin (or amoxicillin) from working against it. In other
words, practically every strain of *Klebsiella* is resistant to
ampicillin.
Sometimes, laboratory data can still contain such strains with
*Klebsiella* being susceptible to ampicillin. This could be because an
antibiogram is available before an identification is available, and the
antibiogram is then not re-interpreted based on the identification. The
[`eucast_rules()`](https://amr-for-r.org/reference/interpretive_rules.md)
function resolves this, by applying the latest EUCAST Expected
Resistant Phenotypes guideline:
``` r
oops <- tibble::tibble(
mo = c(
"Klebsiella pneumoniae",
"Escherichia coli"
),
ampicillin = as.sir("S")
)
oops
#> # A tibble: 2 × 2
#> mo ampicillin
#> <chr> <sir>
#> 1 Klebsiella pneumoniae S
#> 2 Escherichia coli S
eucast_rules(oops, info = FALSE, overwrite = TRUE)
#> # A tibble: 2 × 2
#> mo ampicillin
#> <chr> <sir>
#> 1 Klebsiella pneumoniae R
#> 2 Escherichia coli S
```
A more convenient function is
[`mo_is_intrinsic_resistant()`](https://amr-for-r.org/reference/mo_property.md)
that uses the same guideline, but allows to check for one or more
specific microorganisms or antimicrobials:
``` r
mo_is_intrinsic_resistant(
c("Klebsiella pneumoniae", "Escherichia coli"),
"ampicillin"
)
#> [1] TRUE FALSE
mo_is_intrinsic_resistant(
"Klebsiella pneumoniae",
c("ampicillin", "kanamycin")
)
#> [1] TRUE FALSE
```
EUCAST rules can not only be used for correction, they can also be used
for filling in known resistance and susceptibility based on results of
other antimicrobials drugs. This process is called *interpretive
reading*, and is basically a form of imputation:
``` r
data <- tibble::tibble(
mo = c(
"Staphylococcus aureus",
"Enterococcus faecalis",
"Escherichia coli",
"Klebsiella pneumoniae",
"Pseudomonas aeruginosa"
),
VAN = "-", # Vancomycin
AMX = "-", # Amoxicillin
COL = "-", # Colistin
CAZ = "-", # Ceftazidime
CXM = "-", # Cefuroxime
PEN = "S", # Benzylenicillin
FOX = "S" # Cefoxitin
)
```
``` r
data
```
| mo | VAN | AMX | COL | CAZ | CXM | PEN | FOX |
|:-----------------------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| Staphylococcus aureus | \- | \- | \- | \- | \- | S | S |
| Enterococcus faecalis | \- | \- | \- | \- | \- | S | S |
| Escherichia coli | \- | \- | \- | \- | \- | S | S |
| Klebsiella pneumoniae | \- | \- | \- | \- | \- | S | S |
| Pseudomonas aeruginosa | \- | \- | \- | \- | \- | S | S |
``` r
eucast_rules(data, overwrite = TRUE)
```
| mo | VAN | AMX | COL | CAZ | CXM | PEN | FOX |
|:-----------------------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| Staphylococcus aureus | \- | S | R | R | S | S | S |
| Enterococcus faecalis | \- | \- | R | R | R | S | R |
| Escherichia coli | R | \- | \- | \- | \- | R | S |
| Klebsiella pneumoniae | R | R | \- | \- | \- | R | S |
| Pseudomonas aeruginosa | R | R | \- | \- | R | R | R |

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -163,6 +163,10 @@ per taxonomic order and genus:</p>
<span> <span class="va">order</span>, <span class="va">genus</span>, <span class="va">AMC</span>, <span class="va">CXM</span>, <span class="va">CTX</span>,</span>
<span> <span class="va">CAZ</span>, <span class="va">GEN</span>, <span class="va">TOB</span>, <span class="va">TMP</span>, <span class="va">SXT</span></span>
<span> <span class="op">)</span> <span class="co"># and select only relevant columns</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> `resistance()` assumes the EUCAST guideline and thus considers the 'I'</span></span>
<span><span class="co">#&gt; category susceptible. Set the `guideline` argument or the `AMR_guideline`</span></span>
<span><span class="co">#&gt; option to either "CLSI" or "EUCAST", see `?AMR-options`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> This message will be shown once per session.</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/head.html" class="external-link">head</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 6 × 10</span></span></span>
@@ -184,8 +188,10 @@ that contain numeric values in all selected variables, so we now only
need to do:</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">pca_result</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/pca.html">pca</a></span><span class="op">(</span><span class="va">resistance_data</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;"> Columns selected for PCA: "</span><span style="color: #0000BB; font-weight: bold;">AMC</span><span style="color: #0000BB;">", "</span><span style="color: #0000BB; font-weight: bold;">CAZ</span><span style="color: #0000BB;">", "</span><span style="color: #0000BB; font-weight: bold;">CTX</span><span style="color: #0000BB;">", "</span><span style="color: #0000BB; font-weight: bold;">CXM</span><span style="color: #0000BB;">", "</span><span style="color: #0000BB; font-weight: bold;">GEN</span><span style="color: #0000BB;">", "</span><span style="color: #0000BB; font-weight: bold;">SXT</span><span style="color: #0000BB;">",</span></span></span>
<span><span class="co"><span style="color: #0000BB;">#&gt; "</span><span style="color: #0000BB; font-weight: bold;">TMP</span><span style="color: #0000BB;">", and "</span><span style="color: #0000BB; font-weight: bold;">TOB</span><span style="color: #0000BB;">". Total observations available: 7.</span></span></span></code></pre></div>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> Columns selected for PCA: <span style="color: #0000BB;">"\033[1mAMC\033[22m"</span>, <span style="color: #0000BB;">"\033[1mCAZ\033[22m"</span>,</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"\033[1mCTX\033[22m"</span>, <span style="color: #0000BB;">"\033[1mCXM\033[22m"</span>, <span style="color: #0000BB;">"\033[1mGEN\033[22m"</span>,</span></span>
<span><span class="co">#&gt; <span style="color: #0000BB;">"\033[1mSXT\033[22m"</span>, <span style="color: #0000BB;">"\033[1mTMP\033[22m"</span>, and <span style="color: #0000BB;">"\033[1mTOB\033[22m"</span>. Total</span></span>
<span><span class="co">#&gt; observations available: 7.</span></span></code></pre></div>
<p>The result can be reviewed with the good old <code><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary()</a></code>
function:</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
@@ -210,18 +216,18 @@ per drug explain the difference per microorganism.</p>
</h2>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/stats/biplot.html" class="external-link">biplot</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></span></code></pre></div>
<p><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" width="750"></p>
<p><img src="PCA_files/figure-html/unnamed-chunk-5-1.png" class="r-plt" alt="" width="750"></p>
<p>But we cant see the explanation of the points. Perhaps this works
better with our new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function, that
automatically adds the right labels and even groups:</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span><span class="op">)</span></span></code></pre></div>
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" width="750"></p>
<p><img src="PCA_files/figure-html/unnamed-chunk-6-1.png" class="r-plt" alt="" width="750"></p>
<p>You can also print an ellipse per group, and edit the appearance:</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../reference/ggplot_pca.html">ggplot_pca</a></span><span class="op">(</span><span class="va">pca_result</span>, ellipse <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> <span class="op">+</span></span>
<span> <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/labs.html" class="external-link">labs</a></span><span class="op">(</span>title <span class="op">=</span> <span class="st">"An AMR/PCA biplot!"</span><span class="op">)</span></span></code></pre></div>
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" width="750"></p>
<p><img src="PCA_files/figure-html/unnamed-chunk-7-1.png" class="r-plt" alt="" width="750"></p>
</div>
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
</nav></aside>

163
articles/PCA.md Normal file
View File

@@ -0,0 +1,163 @@
# Conduct principal component analysis (PCA) for AMR
**NOTE: This page will be updated soon, as the pca() function is
currently being developed.**
## Introduction
## Transforming
For PCA, we need to transform our AMR data first. This is what the
`example_isolates` data set in this package looks like:
``` r
library(AMR)
library(dplyr)
glimpse(example_isolates)
#> Rows: 2,000
#> Columns: 46
#> $ date <date> 2002-01-02, 2002-01-03, 2002-01-07, 2002-01-07, 2002-01-13, 2…
#> $ patient <chr> "A77334", "A77334", "067927", "067927", "067927", "067927", "4…
#> $ age <dbl> 65, 65, 45, 45, 45, 45, 78, 78, 45, 79, 67, 67, 71, 71, 75, 50…
#> $ gender <chr> "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M…
#> $ ward <chr> "Clinical", "Clinical", "ICU", "ICU", "ICU", "ICU", "Clinical"…
#> $ mo <mo> "B_ESCHR_COLI", "B_ESCHR_COLI", "B_STPHY_EPDR", "B_STPHY_EPDR",…
#> $ PEN <sir> R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, S,…
#> $ OXA <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ FLC <sir> NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA, NA, R, R…
#> $ AMX <sir> NA, NA, NA, NA, NA, NA, R, R, NA, NA, NA, NA, NA, NA, R, NA, N…
#> $ AMC <sir> I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I, I, NA, N…
#> $ AMP <sir> NA, NA, NA, NA, NA, NA, R, R, NA, NA, NA, NA, NA, NA, R, NA, N…
#> $ TZP <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ CZO <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, NA,…
#> $ FEP <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ CXM <sir> I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R, R, S, S…
#> $ FOX <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, NA,…
#> $ CTX <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, S, S…
#> $ CAZ <sir> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, S, R, R, …
#> $ CRO <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, S, S…
#> $ GEN <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ TOB <sir> NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, NA, NA, NA…
#> $ AMK <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ KAN <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ TMP <sir> R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, R, R, R, …
#> $ SXT <sir> R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S, S, NA, N…
#> $ NIT <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R,…
#> $ FOS <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ LNZ <sir> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R, R, R, N…
#> $ CIP <sir> NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, NA, S, S…
#> $ MFX <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ VAN <sir> R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, S, S, S, …
#> $ TEC <sir> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R, R, R, N…
#> $ TCY <sir> R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, S, I, R, …
#> $ TGC <sir> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R, R, S, NA…
#> $ DOX <sir> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R, R, S, NA…
#> $ ERY <sir> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R, R, R, S,…
#> $ CLI <sir> R, R, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, R, R, R, R, R, NA…
#> $ AZM <sir> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R, R, R, S,…
#> $ IPM <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, S, S…
#> $ MEM <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ MTR <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ CHL <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ COL <sir> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, R, R, R, …
#> $ MUP <sir> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ RIF <sir> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R, R, R, N…
```
Now to transform this to a data set with only resistance percentages per
taxonomic order and genus:
``` r
resistance_data <- example_isolates %>%
group_by(
order = mo_order(mo), # group on anything, like order
genus = mo_genus(mo)
) %>% # and genus as we do here
summarise_if(is.sir, resistance) %>% # then get resistance of all drugs
select(
order, genus, AMC, CXM, CTX,
CAZ, GEN, TOB, TMP, SXT
) # and select only relevant columns
#> `resistance()` assumes the EUCAST guideline and thus considers the 'I'
#> category susceptible. Set the `guideline` argument or the `AMR_guideline`
#> option to either "CLSI" or "EUCAST", see `?AMR-options`.
#> This message will be shown once per session.
head(resistance_data)
#> # A tibble: 6 × 10
#> # Groups: order [5]
#> order genus AMC CXM CTX CAZ GEN TOB TMP SXT
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 (unknown order) (unknown ge… NA NA NA NA NA NA NA NA
#> 2 Actinomycetales Schaalia NA NA NA NA NA NA NA NA
#> 3 Bacteroidales Bacteroides NA NA NA NA NA NA NA NA
#> 4 Campylobacterales Campylobact… NA NA NA NA NA NA NA NA
#> 5 Caryophanales Gemella NA NA NA NA NA NA NA NA
#> 6 Caryophanales Listeria NA NA NA NA NA NA NA NA
```
## Perform principal component analysis
The new [`pca()`](https://amr-for-r.org/reference/pca.md) function will
automatically filter on rows that contain numeric values in all selected
variables, so we now only need to do:
``` r
pca_result <- pca(resistance_data)
#> Columns selected for PCA: "\033[1mAMC\033[22m", "\033[1mCAZ\033[22m",
#> "\033[1mCTX\033[22m", "\033[1mCXM\033[22m", "\033[1mGEN\033[22m",
#> "\033[1mSXT\033[22m", "\033[1mTMP\033[22m", and "\033[1mTOB\033[22m". Total
#> observations available: 7.
```
The result can be reviewed with the good old
[`summary()`](https://rdrr.io/r/base/summary.html) function:
``` r
summary(pca_result)
#> Groups (n=4, named as 'order'):
#> [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"
#> Importance of components:
#> PC1 PC2 PC3 PC4 PC5 PC6 PC7
#> Standard deviation 2.1539 1.6807 0.6138 0.33879 0.20808 0.03140 1.232e-16
#> Proportion of Variance 0.5799 0.3531 0.0471 0.01435 0.00541 0.00012 0.000e+00
#> Cumulative Proportion 0.5799 0.9330 0.9801 0.99446 0.99988 1.00000 1.000e+00
```
#> Groups (n=4, named as 'order'):
#> [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales"
Good news. The first two components explain a total of 93.3% of the
variance (see the PC1 and PC2 values of the *Proportion of Variance*. We
can create a so-called biplot with the base R
[`biplot()`](https://rdrr.io/r/stats/biplot.html) function, to see which
antimicrobial resistance per drug explain the difference per
microorganism.
## Plotting the results
``` r
biplot(pca_result)
```
![](PCA_files/figure-html/unnamed-chunk-5-1.png)
But we cant see the explanation of the points. Perhaps this works
better with our new
[`ggplot_pca()`](https://amr-for-r.org/reference/ggplot_pca.md)
function, that automatically adds the right labels and even groups:
``` r
ggplot_pca(pca_result)
```
![](PCA_files/figure-html/unnamed-chunk-6-1.png)
You can also print an ellipse per group, and edit the appearance:
``` r
ggplot_pca(pca_result, ellipse = TRUE) +
ggplot2::labs(title = "An AMR/PCA biplot!")
```
![](PCA_files/figure-html/unnamed-chunk-7-1.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 115 KiB

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -254,15 +254,20 @@ Longest: 40</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># our transformed antibiotic columns</span></span>
<span><span class="co"># amoxicillin/clavulanic acid (J01CR02) as an example</span></span>
<span><span class="va">data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://msberends.github.io/cleaner/reference/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></span></code></pre></div>
<span><span class="va">data</span> <span class="op"><a href="https://magrittr.tidyverse.org/reference/pipe.html" class="external-link">%&gt;%</a></span> <span class="fu"><a href="https://msberends.github.io/cleaner/reference/freq.html" class="external-link">freq</a></span><span class="op">(</span><span class="va">AMC_ND2</span><span class="op">)</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> `susceptibility()` assumes the EUCAST guideline and thus considers the 'I'</span></span>
<span><span class="co">#&gt; category susceptible. Set the `guideline` argument or the `AMR_guideline`</span></span>
<span><span class="co">#&gt; option to either "CLSI" or "EUCAST", see `?AMR-options`.</span></span>
<span><span class="co">#&gt; <span style="color: #00BBBB;"></span> This message will be shown once per session.</span></span></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered &gt; sir (numeric)<br>
Length: 500<br>
Levels: 5: S &lt; SDD &lt; I &lt; R &lt; NI<br>
Levels: 8: S &lt; SDD &lt; I &lt; R &lt; NI &lt; WT &lt; NWT &lt;
NS<br>
Available: 481 (96.2%, NA: 19 = 3.8%)<br>
Unique: 3</p>
<p>Drug: Amoxicillin/clavulanic acid (AMC, J01CR02/QJ01CR02)<br>
Drug group: Beta-lactams/penicillins<br>
Drug group: Aminopenicillins<br>
%SI: 78.59%</p>
<table class="table">
<thead><tr class="header">
@@ -311,7 +316,7 @@ using the included <code><a href="../reference/ggplot_sir.html">ggplot_sir()</a>
<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">Country</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/select.html" class="external-link">select</a></span><span class="op">(</span><span class="va">Country</span>, <span class="va">AMP_ND2</span>, <span class="va">AMC_ED20</span>, <span class="va">CAZ_ED10</span>, <span class="va">CIP_ED5</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="../reference/ggplot_sir.html">ggplot_sir</a></span><span class="op">(</span>translate_ab <span class="op">=</span> <span class="st">"ab"</span>, facet <span class="op">=</span> <span class="st">"Country"</span>, datalabels <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
<p><img src="WHONET_files/figure-html/unnamed-chunk-7-1.png" class="r-plt" alt="" width="720"></p>
</div>
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
</nav></aside>

141
articles/WHONET.md Normal file
View File

@@ -0,0 +1,141 @@
# Work with WHONET data
### Import of data
This tutorial assumes you already imported the WHONET data with e.g. the
[`readxl` package](https://readxl.tidyverse.org/). In RStudio, this can
be done using the menu button Import Dataset in the tab Environment.
Choose the option From Excel and select your exported file. Make sure
date fields are imported correctly.
An example syntax could look like this:
``` r
library(readxl)
data <- read_excel(path = "path/to/your/file.xlsx")
```
This package comes with an [example data set
`WHONET`](https://amr-for-r.org/reference/WHONET.html). We will use it
for this analysis.
### Preparation
First, load the relevant packages if you did not yet did this. I use the
tidyverse for all of my analyses. All of them. If you dont know it yet,
I suggest you read about it on their website:
<https://www.tidyverse.org/>.
``` r
library(dplyr) # part of tidyverse
library(ggplot2) # part of tidyverse
library(AMR) # this package
library(cleaner) # to create frequency tables
```
We will have to transform some variables to simplify and automate the
analysis:
- Microorganisms should be transformed to our own microorganism codes
(called an `mo`) using [our Catalogue of Life reference data
set](https://amr-for-r.org/reference/catalogue_of_life), which
contains all ~70,000 microorganisms from the taxonomic kingdoms
Bacteria, Fungi and Protozoa. We do the tranformation with
[`as.mo()`](https://amr-for-r.org/reference/as.mo.md). This function
also recognises almost all WHONET abbreviations of microorganisms.
- Antimicrobial results or interpretations have to be clean and valid.
In other words, they should only contain values `"S"`, `"I"` or `"R"`.
That is exactly where the
[`as.sir()`](https://amr-for-r.org/reference/as.sir.md) function is
for.
``` r
# transform variables
data <- WHONET %>%
# get microbial ID based on given organism
mutate(mo = as.mo(Organism)) %>%
# transform everything from "AMP_ND10" to "CIP_EE" to the new `sir` class
mutate_at(vars(AMP_ND10:CIP_EE), as.sir)
```
No errors or warnings, so all values are transformed succesfully.
We also created a package dedicated to data cleaning and checking,
called the `cleaner` package. Its
[`freq()`](https://msberends.github.io/cleaner/reference/freq.html)
function can be used to create frequency tables.
So lets check our data, with a couple of frequency tables:
``` r
# our newly created `mo` variable, put in the mo_name() function
data %>% freq(mo_name(mo), nmax = 10)
```
**Frequency table**
Class: character
Length: 500
Available: 500 (100%, NA: 0 = 0%)
Unique: 38
Shortest: 11
Longest: 40
| | Item | Count | Percent | Cum. Count | Cum. Percent |
|:----|:-----------------------------------------|------:|--------:|-----------:|-------------:|
| 1 | Escherichia coli | 245 | 49.0% | 245 | 49.0% |
| 2 | Coagulase-negative Staphylococcus (CoNS) | 74 | 14.8% | 319 | 63.8% |
| 3 | Staphylococcus epidermidis | 38 | 7.6% | 357 | 71.4% |
| 4 | Streptococcus pneumoniae | 31 | 6.2% | 388 | 77.6% |
| 5 | Staphylococcus hominis | 21 | 4.2% | 409 | 81.8% |
| 6 | Proteus mirabilis | 9 | 1.8% | 418 | 83.6% |
| 7 | Enterococcus faecium | 8 | 1.6% | 426 | 85.2% |
| 8 | Staphylococcus capitis urealyticus | 8 | 1.6% | 434 | 86.8% |
| 9 | Enterobacter cloacae | 5 | 1.0% | 439 | 87.8% |
| 10 | Enterococcus columbae | 4 | 0.8% | 443 | 88.6% |
(omitted 28 entries, n = 57 \[11.4%\])
``` r
# our transformed antibiotic columns
# amoxicillin/clavulanic acid (J01CR02) as an example
data %>% freq(AMC_ND2)
#> `susceptibility()` assumes the EUCAST guideline and thus considers the 'I'
#> category susceptible. Set the `guideline` argument or the `AMR_guideline`
#> option to either "CLSI" or "EUCAST", see `?AMR-options`.
#> This message will be shown once per session.
```
**Frequency table**
Class: factor \> ordered \> sir (numeric)
Length: 500
Levels: 8: S \< SDD \< I \< R \< NI \< WT \< NWT \< NS
Available: 481 (96.2%, NA: 19 = 3.8%)
Unique: 3
Drug: Amoxicillin/clavulanic acid (AMC, J01CR02/QJ01CR02)
Drug group: Aminopenicillins
%SI: 78.59%
| | Item | Count | Percent | Cum. Count | Cum. Percent |
|:----|:-----|------:|--------:|-----------:|-------------:|
| 1 | S | 356 | 74.01% | 356 | 74.01% |
| 2 | R | 103 | 21.41% | 459 | 95.43% |
| 3 | I | 22 | 4.57% | 481 | 100.00% |
### A first glimpse at results
An easy `ggplot` will already give a lot of information, using the
included [`ggplot_sir()`](https://amr-for-r.org/reference/ggplot_sir.md)
function:
``` r
data %>%
group_by(Country) %>%
select(Country, AMP_ND2, AMC_ED20, CAZ_ED10, CIP_ED5) %>%
ggplot_sir(translate_ab = "ab", facet = "Country", datalabels = FALSE)
```
![](WHONET_files/figure-html/unnamed-chunk-7-1.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -253,16 +253,16 @@ I (intermediate [CLSI], or susceptible, increased exposure
<span><span class="co">#&gt; <span style="color: #949494;"># A tibble: 2,000 × 46</span></span></span>
<span><span class="co">#&gt; date patient age gender ward mo PEN OXA FLC AMX </span></span>
<span><span class="co">#&gt; <span style="color: #949494; font-style: italic;">&lt;date&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;dbl&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;chr&gt;</span> <span style="color: #949494; font-style: italic;">&lt;mo&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span> <span style="color: #949494; font-style: italic;">&lt;sir&gt;</span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FFAFAF;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FFAFAF;"> R </span> <span style="color: #B2B2B2;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #B2B2B2;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 1</span> 2002-01-02 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 2</span> 2002-01-03 A77334 65 F Clinical <span style="color: #949494;">B_</span>ESCHR<span style="color: #949494;">_</span>COLI <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 3</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 4</span> 2002-01-07 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 5</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 6</span> 2002-01-13 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 7</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 8</span> 2002-01-14 462729 78 M Clinical <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>AURS <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #080808; background-color: #FF5F5F;"> R </span></span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;"> 9</span> 2002-01-16 067927 45 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #BCBCBC;">10</span> 2002-01-17 858515 79 F ICU <span style="color: #949494;">B_</span>STPHY<span style="color: #949494;">_</span>EPDR <span style="color: #080808; background-color: #FF5F5F;"> R </span> <span style="color: #949494;"> NA</span> <span style="color: #080808; background-color: #5FD7AF;"> S </span> <span style="color: #949494;"> NA</span> </span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 1,990 more rows</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># 36 more variables: AMC &lt;sir&gt;, AMP &lt;sir&gt;, TZP &lt;sir&gt;, CZO &lt;sir&gt;, FEP &lt;sir&gt;,</span></span></span>
<span><span class="co">#&gt; <span style="color: #949494;"># CXM &lt;sir&gt;, FOX &lt;sir&gt;, CTX &lt;sir&gt;, CAZ &lt;sir&gt;, CRO &lt;sir&gt;, GEN &lt;sir&gt;,</span></span></span>

252
articles/WISCA.md Normal file
View File

@@ -0,0 +1,252 @@
# Estimating Empirical Coverage with WISCA
> This explainer was largely written by our [AMR for R
> Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained
> model able to answer any question about the `AMR` package.
## Introduction
Clinical guidelines for empirical antimicrobial therapy require
*probabilistic reasoning*: what is the chance that a regimen will cover
the likely infecting organisms, before culture results are available?
This is the purpose of **WISCA**, or **Weighted-Incidence Syndromic
Combination Antibiogram**.
WISCA is a Bayesian approach that integrates:
- **Pathogen prevalence** (how often each species causes the syndrome),
- **Regimen susceptibility** (how often a regimen works *if* the
pathogen is known),
to estimate the **overall empirical coverage** of antimicrobial
regimens, with quantified uncertainty.
This vignette explains how WISCA works, why it is useful, and how to
apply it using the `AMR` package.
## Why traditional antibiograms fall short
A standard antibiogram gives you:
Species → Antibiotic → Susceptibility %
But clinicians dont know the species *a priori*. They need to choose a
regimen that covers the **likely pathogens**, without knowing which one
is present.
Traditional antibiograms calculate the susceptibility % as just the
number of resistant isolates divided by the total number of tested
isolates. Therefore, traditional antibiograms:
- Fragment information by organism,
- Do not weight by real-world prevalence,
- Do not account for combination therapy or sample size,
- Do not provide uncertainty.
## The idea of WISCA
WISCA asks:
> “What is the **probability** that this regimen **will cover** the
> pathogen, given the syndrome?”
This means combining two things:
- **Incidence** of each pathogen in the syndrome,
- **Susceptibility** of each pathogen to the regimen.
We can write this as:
$$\text{Coverage} = \sum\limits_{i}\left( \text{Incidence}_{i} \times \text{Susceptibility}_{i} \right)$$
For example, suppose:
- *E. coli* causes 60% of cases, and 90% of *E. coli* are susceptible to
a drug.
- *Klebsiella* causes 40% of cases, and 70% of *Klebsiella* are
susceptible.
Then:
$$\text{Coverage} = (0.6 \times 0.9) + (0.4 \times 0.7) = 0.82$$
But in real data, incidence and susceptibility are **estimated from
samples**, so they carry uncertainty. WISCA models this
**probabilistically**, using conjugate Bayesian distributions.
## The Bayesian engine behind WISCA
### Pathogen incidence
Let:
- $K$ be the number of pathogens,
- $\alpha = (1,1,\ldots,1)$ be a **Dirichlet** prior (uniform),
- $n = \left( n_{1},\ldots,n_{K} \right)$ be the observed counts per
species.
Then the posterior incidence is:
$$p \sim \text{Dirichlet}\left( \alpha_{1} + n_{1},\ldots,\alpha_{K} + n_{K} \right)$$
To simulate from this, we use:
$$x_{i} \sim \text{Gamma}\left( \alpha_{i} + n_{i},\ 1 \right),\quad p_{i} = \frac{x_{i}}{\sum\limits_{j = 1}^{K}x_{j}}$$
### Susceptibility
Each pathogenregimen pair has a prior and data:
- Prior: $\text{Beta}\left( \alpha_{0},\beta_{0} \right)$, with default
$\alpha_{0} = \beta_{0} = 1$
- Data: $S$ susceptible out of $N$ tested
The $S$ category could also include values SDD (susceptible,
dose-dependent) and I (intermediate \[CLSI\], or susceptible, increased
exposure \[EUCAST\]).
Then the posterior is:
$$\theta \sim \text{Beta}\left( \alpha_{0} + S,\ \beta_{0} + N - S \right)$$
### Final coverage estimate
Putting it together:
1. Simulate pathogen incidence: $\mathbf{p} \sim \text{Dirichlet}$
2. Simulate susceptibility:
$\theta_{i} \sim \text{Beta}\left( 1 + S_{i},\ 1 + R_{i} \right)$
3. Combine:
$$\text{Coverage} = \sum\limits_{i = 1}^{K}p_{i} \cdot \theta_{i}$$
Repeat this simulation (e.g. 1000×) and summarise:
- **Mean** = expected coverage
- **Quantiles** = credible interval
## Practical use in the `AMR` package
### Prepare data and simulate synthetic syndrome
``` r
library(AMR)
data <- example_isolates
# Structure of our data
data
#> # A tibble: 2,000 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
#> 1 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 2 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 3 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 4 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 5 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 6 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 7 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 8 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 9 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 10 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA
#> # 1,990 more rows
#> # 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
# Add a fake syndrome column
data$syndrome <- ifelse(data$mo %like% "coli", "UTI", "No UTI")
```
### Basic WISCA antibiogram
``` r
wisca(data,
antimicrobials = c("AMC", "CIP", "GEN"))
```
| Amoxicillin/clavulanic acid | Ciprofloxacin | Gentamicin |
|:----------------------------|:-----------------|:-------------------|
| 73.7% (71.7-75.8%) | 77% (74.3-79.4%) | 72.8% (70.7-74.8%) |
### Use combination regimens
``` r
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"))
```
| Amoxicillin/clavulanic acid | Amoxicillin/clavulanic acid + Ciprofloxacin | Amoxicillin/clavulanic acid + Gentamicin |
|:----------------------------|:--------------------------------------------|:-----------------------------------------|
| 73.8% (71.8-75.7%) | 87.5% (85.9-89%) | 89.7% (88.2-91.1%) |
### Stratify by syndrome
``` r
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"),
syndromic_group = "syndrome")
```
| Syndromic Group | Amoxicillin/clavulanic acid | Amoxicillin/clavulanic acid + Ciprofloxacin | Amoxicillin/clavulanic acid + Gentamicin |
|:----------------|:----------------------------|:--------------------------------------------|:-----------------------------------------|
| No UTI | 70.1% (67.8-72.3%) | 85.2% (83.1-87.2%) | 87.1% (85.3-88.7%) |
| UTI | 80.9% (77.7-83.8%) | 88.2% (85.7-90.5%) | 90.9% (88.7-93%) |
The `AMR` package is available in 28 languages, which can all be used
for the [`wisca()`](https://amr-for-r.org/reference/antibiogram.md)
function too:
``` r
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"),
syndromic_group = gsub("UTI", "UCI", data$syndrome),
language = "Spanish")
```
| Grupo sindrómico | Amoxicilina/ácido clavulánico | Amoxicilina/ácido clavulánico + Ciprofloxacina | Amoxicilina/ácido clavulánico + Gentamicina |
|:-----------------|:------------------------------|:-----------------------------------------------|:--------------------------------------------|
| No UCI | 70% (67.8-72.4%) | 85.3% (83.3-87.2%) | 87% (85.3-88.8%) |
| UCI | 80.9% (77.7-83.9%) | 88.2% (85.5-90.6%) | 90.9% (88.7-93%) |
## Sensible defaults, which can be customised
- `simulations = 1000`: number of Monte Carlo draws
- `conf_interval = 0.95`: coverage interval width
- `combine_SI = TRUE`: count “I” and “SDD” as susceptible
## Limitations
- It assumes your data are representative
- No adjustment for patient-level covariates, although these could be
passed onto the `syndromic_group` argument
- WISCA does not model resistance over time, you might want to use
`tidymodels` for that, for which we [wrote a basic
introduction](https://amr-for-r.org/articles/AMR_with_tidymodels.html)
## Summary
WISCA enables:
- Empirical regimen comparison,
- Syndrome-specific coverage estimation,
- Fully probabilistic interpretation.
It is available in the `AMR` package via either:
``` r
wisca(...)
antibiogram(..., wisca = TRUE)
```
## Reference
Bielicki, JA, et al. (2016). *Selecting appropriate empirical antibiotic
regimens for paediatric bloodstream infections: application of a
Bayesian decision model to local and pooled antimicrobial resistance
surveillance data.* **J Antimicrob Chemother**. 71(3):794-802.
<https://doi.org/10.1093/jac/dkv397>

View File

@@ -30,7 +30,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -80,7 +80,7 @@
<main id="main" class="col-md-9"><div class="page-header">
<img src="../logo.svg" class="logo" alt=""><h1>Download data sets for download / own use</h1>
<h4 data-toc-skip class="date">01 September 2025</h4>
<h4 data-toc-skip class="date">02 April 2026</h4>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/main/vignettes/datasets.Rmd" class="external-link"><code>vignettes/datasets.Rmd</code></a></small>
<div class="d-none name"><code>datasets.Rmd</code></div>
@@ -115,7 +115,7 @@ column names:<br><em>mo</em>, <em>fullname</em>, <em>status</em>, <em>kingdom</e
<em>snomed</em>.</p>
<p>This data set is in R available as <code>microorganisms</code>, after
you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 18 September 2025 12:58:34 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/microorganisms.html">data set
here</a>.</p>
<p><strong>Direct download links:</strong></p>
@@ -127,10 +127,10 @@ R Data Structure (RDS) file</a> (1.8 MB)<br>
text file</a> (17.7 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.xlsx" class="external-link">Microsoft
Excel workbook</a> (8.7 MB)<br>
Excel workbook</a> (8.8 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.feather" class="external-link">Apache
Feather file</a> (8.3 MB)<br>
Feather file</a> (8.4 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.parquet" class="external-link">Apache
Parquet file</a> (3.8 MB)<br>
@@ -417,32 +417,32 @@ all SNOMED codes as comma separated values.</p>
<h2 id="antimicrobials-antibiotic-and-antifungal-drugs">
<code>antimicrobials</code>: Antibiotic and Antifungal Drugs<a class="anchor" aria-label="anchor" href="#antimicrobials-antibiotic-and-antifungal-drugs"></a>
</h2>
<p>A data set with 496 rows and 14 columns, containing the following
<p>A data set with 505 rows and 14 columns, containing the following
column names:<br><em>ab</em>, <em>cid</em>, <em>name</em>, <em>group</em>, <em>atc</em>,
<em>atc_group1</em>, <em>atc_group2</em>, <em>abbreviations</em>,
<em>synonyms</em>, <em>oral_ddd</em>, <em>oral_units</em>,
<em>iv_ddd</em>, <em>iv_units</em>, and <em>loinc</em>.</p>
<p>This data set is in R available as <code>antimicrobials</code>, after
you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 23 March 2026 09:38:28 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/antimicrobials.html">data set
here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.rds" class="external-link">original
R Data Structure (RDS) file</a> (45 kB)<br>
R Data Structure (RDS) file</a> (44 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.txt" class="external-link">tab-separated
text file</a> (0.1 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.xlsx" class="external-link">Microsoft
Excel workbook</a> (78 kB)<br>
Excel workbook</a> (79 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.feather" class="external-link">Apache
Feather file</a> (0.1 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.parquet" class="external-link">Apache
Parquet file</a> (0.1 MB)<br>
Parquet file</a> (94 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.sav" class="external-link">IBM
SPSS Statistics data file</a> (0.4 MB)<br>
@@ -454,22 +454,22 @@ DTA file</a> (10 kB)</li>
contain the ATC codes, common abbreviations, trade names and LOINC codes
as comma separated values.</p>
<p><strong>Example content</strong></p>
<table style="width:100%;" class="table">
<table class="table">
<colgroup>
<col width="1%">
<col width="2%">
<col width="7%">
<col width="7%">
<col width="9%">
<col width="12%">
<col width="16%">
<col width="6%">
<col width="16%">
<col width="8%">
<col width="11%">
<col width="15%">
<col width="5%">
<col width="15%">
<col width="2%">
<col width="3%">
<col width="2%">
<col width="2%">
<col width="9%">
<col width="8%">
</colgroup>
<thead><tr class="header">
<th align="center">ab</th>
@@ -508,7 +508,7 @@ as comma separated values.</p>
<td align="center">AMX</td>
<td align="center">33613</td>
<td align="center">Amoxicillin</td>
<td align="center">Beta-lactams/penicillins</td>
<td align="center">Aminopenicillins, Penicillins, Beta-lactams</td>
<td align="center">J01CA04, QG51AA03, QJ01CA04</td>
<td align="center">Beta-lactam antibacterials, penicillins</td>
<td align="center">Penicillins with extended spectrum</td>
@@ -524,7 +524,7 @@ as comma separated values.</p>
<td align="center">AMC</td>
<td align="center">23665637</td>
<td align="center">Amoxicillin/clavulanic acid</td>
<td align="center">Beta-lactams/penicillins</td>
<td align="center">Aminopenicillins, Penicillins, Beta-lactams, …</td>
<td align="center">J01CR02, QJ01CR02</td>
<td align="center">Beta-lactam antibacterials, penicillins</td>
<td align="center">Combinations of penicillins, incl. beta-lactamase
@@ -541,7 +541,7 @@ inhibitors</td>
<td align="center">AMP</td>
<td align="center">6249</td>
<td align="center">Ampicillin</td>
<td align="center">Beta-lactams/penicillins</td>
<td align="center">Aminopenicillins, Penicillins, Beta-lactams</td>
<td align="center">J01CA01, QJ01CA01, QJ51CA01, …</td>
<td align="center">Beta-lactam antibacterials, penicillins</td>
<td align="center">Penicillins with extended spectrum</td>
@@ -557,7 +557,7 @@ inhibitors</td>
<td align="center">AZM</td>
<td align="center">447043</td>
<td align="center">Azithromycin</td>
<td align="center">Macrolides/lincosamides</td>
<td align="center">Macrolides</td>
<td align="center">J01FA10, QJ01FA10, QS01AA26, …</td>
<td align="center">Macrolides, lincosamides and streptogramins</td>
<td align="center">Macrolides</td>
@@ -573,7 +573,7 @@ inhibitors</td>
<td align="center">PEN</td>
<td align="center">5904</td>
<td align="center">Benzylpenicillin</td>
<td align="center">Beta-lactams/penicillins</td>
<td align="center">Penicillins, Beta-lactams</td>
<td align="center">J01CE01, QJ01CE01, QJ51CE01, …</td>
<td align="center">Combinations of antibacterials</td>
<td align="center">Combinations of antibacterials</td>
@@ -595,38 +595,38 @@ inhibitors</td>
<code>clinical_breakpoints</code>: Interpretation from MIC values
&amp; disk diameters to SIR<a class="anchor" aria-label="anchor" href="#clinical_breakpoints-interpretation-from-mic-values-disk-diameters-to-sir"></a>
</h2>
<p>A data set with 40 217 rows and 14 columns, containing the following
<p>A data set with 45 730 rows and 14 columns, containing the following
column names:<br><em>guideline</em>, <em>type</em>, <em>host</em>, <em>method</em>,
<em>site</em>, <em>mo</em>, <em>rank_index</em>, <em>ab</em>,
<em>ref_tbl</em>, <em>disk_dose</em>, <em>breakpoint_S</em>,
<em>breakpoint_R</em>, <em>uti</em>, and <em>is_SDD</em>.</p>
<p>This data set is in R available as <code>clinical_breakpoints</code>,
after you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 2 April 2026 09:42:19 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/clinical_breakpoints.html">data
set here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.rds" class="external-link">original
R Data Structure (RDS) file</a> (88 kB)<br>
R Data Structure (RDS) file</a> (92 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.txt" class="external-link">tab-separated
text file</a> (3.7 MB)<br>
text file</a> (4.2 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.xlsx" class="external-link">Microsoft
Excel workbook</a> (2.4 MB)<br>
Excel workbook</a> (2.7 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.feather" class="external-link">Apache
Feather file</a> (1.8 MB)<br>
Feather file</a> (2 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.parquet" class="external-link">Apache
Parquet file</a> (0.1 MB)<br>
Parquet file</a> (0.2 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.sav" class="external-link">IBM
SPSS Statistics data file</a> (6.6 MB)<br>
SPSS Statistics data file</a> (7.5 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.dta" class="external-link">Stata
DTA file</a> (11.1 MB)</li>
DTA file</a> (12.6 MB)</li>
</ul>
<p><strong>Example content</strong></p>
<table class="table">
@@ -668,7 +668,7 @@ DTA file</a> (11.1 MB)</li>
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">DISK</td>
@@ -686,7 +686,7 @@ DTA file</a> (11.1 MB)</li>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">MIC</td>
@@ -704,7 +704,7 @@ DTA file</a> (11.1 MB)</li>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">DISK</td>
@@ -722,7 +722,7 @@ DTA file</a> (11.1 MB)</li>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">MIC</td>
@@ -740,7 +740,7 @@ DTA file</a> (11.1 MB)</li>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">DISK</td>
@@ -758,7 +758,7 @@ DTA file</a> (11.1 MB)</li>
<td align="center">FALSE</td>
</tr>
<tr class="even">
<td align="center">EUCAST 2025</td>
<td align="center">EUCAST 2026</td>
<td align="center">human</td>
<td align="center">human</td>
<td align="center">MIC</td>
@@ -790,7 +790,7 @@ column names:<br><em>mo_group</em>, <em>mo</em>, <em>mo_group_name</em>, and
<p>This data set is in R available as
<code>microorganisms.groups</code>, after you load the <code>AMR</code>
package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 26 March 2025 16:19:17 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/microorganisms.groups.html">data
set here</a>.</p>
<p><strong>Direct download links:</strong></p>
@@ -880,7 +880,7 @@ Resistance<a class="anchor" aria-label="anchor" href="#intrinsic_resistant-intri
column names:<br><em>mo</em> and <em>ab</em>.</p>
<p>This data set is in R available as <code>intrinsic_resistant</code>,
after you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 28 March 2025 10:17:49 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/intrinsic_resistant.html">data set
here</a>.</p>
<p><strong>Direct download links:</strong></p>
@@ -1156,7 +1156,7 @@ column names:<br><em>ab</em>, <em>name</em>, <em>type</em>, <em>dose</em>,
<em>original_txt</em>, and <em>eucast_version</em>.</p>
<p>This data set is in R available as <code>dosage</code>, after you
load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 20 April 2025 10:55:31 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/dosage.html">data set
here</a>.</p>
<p><strong>Direct download links:</strong></p>
@@ -1294,7 +1294,7 @@ column names:<br><em>date</em>, <em>patient</em>, <em>age</em>, <em>gender</em>,
<em>MUP</em>, and <em>RIF</em>.</p>
<p>This data set is in R available as <code>example_isolates</code>,
after you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 9 February 2026 12:16:36 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/example_isolates.html">data set
here</a>.</p>
<p><strong>Example content</strong></p>
@@ -1700,7 +1700,7 @@ column names:<br><em>patient_id</em>, <em>hospital</em>, <em>date</em>,
<p>This data set is in R available as
<code>example_isolates_unclean</code>, after you load the
<code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 27 August 2022 18:49:37 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/example_isolates_unclean.html">data
set here</a>.</p>
<p><strong>Example content</strong></p>
@@ -1794,17 +1794,17 @@ set here</a>.</p>
<h2 id="microorganisms-codes-common-laboratory-codes">
<code>microorganisms.codes</code>: Common Laboratory Codes<a class="anchor" aria-label="anchor" href="#microorganisms-codes-common-laboratory-codes"></a>
</h2>
<p>A data set with 6 036 rows and 2 columns, containing the following
<p>A data set with 6 050 rows and 2 columns, containing the following
column names:<br><em>code</em> and <em>mo</em>.</p>
<p>This data set is in R available as <code>microorganisms.codes</code>,
after you load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 30 March 2026 08:01:49 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/microorganisms.codes.html">data
set here</a>.</p>
<p><strong>Direct download links:</strong></p>
<ul>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.rds" class="external-link">original
R Data Structure (RDS) file</a> (27 kB)<br>
R Data Structure (RDS) file</a> (28 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.txt" class="external-link">tab-separated
text file</a> (0.1 MB)<br>
@@ -1816,7 +1816,7 @@ Excel workbook</a> (98 kB)<br>
Feather file</a> (0.1 MB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.parquet" class="external-link">Apache
Parquet file</a> (68 kB)<br>
Parquet file</a> (69 kB)<br>
</li>
<li>Download as <a href="https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.sav" class="external-link">IBM
SPSS Statistics data file</a> (0.2 MB)<br>
@@ -1870,7 +1870,7 @@ column names:<br><em>av</em>, <em>name</em>, <em>atc</em>, <em>cid</em>,
<em>loinc</em>.</p>
<p>This data set is in R available as <code>antivirals</code>, after you
load the <code>AMR</code> package.</p>
<p>It was last updated on 1 September 2025 15:00:00 UTC. Find more info
<p>It was last updated on 20 October 2023 12:51:48 UTC. Find more info
about the contents, (scientific) source, and structure of this <a href="https://amr-for-r.org/reference/antimicrobials.html">data set
here</a>.</p>
<p><strong>Direct download links:</strong></p>

561
articles/datasets.md Normal file
View File

@@ -0,0 +1,561 @@
# Download data sets for download / own use
All reference data (about microorganisms, antimicrobials, SIR
interpretation, EUCAST rules, etc.) in this `AMR` package are reliable,
up-to-date and freely available. We continually export our data sets to
formats for use in R, MS Excel, Apache Feather, Apache Parquet, SPSS,
and Stata. We also provide tab-separated text files that are
machine-readable and suitable for input in any software program, such as
laboratory information systems.
> If you are working in Python, be sure to use our [AMR for
> Python](https://amr-for-r.org/articles/AMR_for_Python.html) package.
> It allows all relevant AMR data sets to be natively available in
> Python.
## `microorganisms`: Full Microbial Taxonomy
A data set with 78 679 rows and 26 columns, containing the following
column names:
*mo*, *fullname*, *status*, *kingdom*, *phylum*, *class*, *order*,
*family*, *genus*, *species*, *subspecies*, *rank*, *ref*,
*oxygen_tolerance*, *source*, *lpsn*, *lpsn_parent*, *lpsn_renamed_to*,
*mycobank*, *mycobank_parent*, *mycobank_renamed_to*, *gbif*,
*gbif_parent*, *gbif_renamed_to*, *prevalence*, and *snomed*.
This data set is in R available as `microorganisms`, after you load the
`AMR` package.
It was last updated on 18 September 2025 12:58:34 UTC. Find more info
about the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/microorganisms.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.rds)
(1.8 MB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.txt)
(17.7 MB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.xlsx)
(8.8 MB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.feather)
(8.4 MB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.parquet)
(3.8 MB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.sav)
(28.4 MB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.dta)
(89.5 MB)
**NOTE: The exported files for SPSS and Stata contain only the first 50
SNOMED codes per record, as their file size would otherwise exceed 100
MB; the file size limit of GitHub.** Their file structures and
compression techniques are very inefficient. Advice? Use R instead. Its
free and much better in many ways.
The tab-separated text file and Microsoft Excel workbook both contain
all SNOMED codes as comma separated values.
**Example content**
Included (sub)species per taxonomic kingdom:
| Kingdom | Number of (sub)species |
|:-----------------:|:----------------------:|
| (unknown kingdom) | 1 |
| Animalia | 1 628 |
| Archaea | 1 419 |
| Bacteria | 39 249 |
| Chromista | 178 |
| Fungi | 28 137 |
First 6 rows when filtering on genus *Escherichia*:
| mo | fullname | status | kingdom | phylum | class | order | family | genus | species | subspecies | rank | ref | oxygen_tolerance | source | lpsn | lpsn_parent | lpsn_renamed_to | mycobank | mycobank_parent | mycobank_renamed_to | gbif | gbif_parent | gbif_renamed_to | prevalence | snomed |
|:-----------------:|:--------------------------:|:--------:|:--------:|:--------------:|:-------------------:|:----------------:|:------------------:|:-----------:|:--------------:|:----------:|:----------:|:-----------------------:|:---------------------------:|:------:|:------:|:-----------:|:---------------:|:--------:|:---------------:|:-------------------:|:--------:|:-----------:|:---------------:|:----------:|:-----------------------------------------:|
| B_ESCHR | Escherichia | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | | | genus | Castellani et al., 1919 | facultative anaerobe | LPSN | 515602 | 482 | | | | | | 11158430 | | 1 | 407310004, 407251000, 407281008, … |
| B_ESCHR_ADCR | Escherichia adecarboxylata | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | adecarboxylata | | species | Leclerc, 1962 | likely facultative anaerobe | LPSN | 776052 | 515602 | 777447 | | | | | | | 1 | |
| B_ESCHR_ALBR | Escherichia albertii | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | albertii | | species | Huys et al., 2003 | facultative anaerobe | LPSN | 776053 | 515602 | | | | | 5427575 | | | 1 | 419388003 |
| B_ESCHR_BLTT | Escherichia blattae | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | blattae | | species | Burgess et al., 1973 | likely facultative anaerobe | LPSN | 776056 | 515602 | 788468 | | | | | | | 1 | |
| B_ESCHR_COLI | Escherichia coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | | species | Castellani et al., 1919 | facultative anaerobe | LPSN | 776057 | 515602 | | | | | 11286021 | | | 1 | 1095001000112106, 715307006, 737528008, … |
| B_ESCHR_COLI_COLI | Escherichia coli coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | coli | subspecies | | | GBIF | | 776057 | | | | | 12233256 | 11286021 | | 1 | |
------------------------------------------------------------------------
## `antimicrobials`: Antibiotic and Antifungal Drugs
A data set with 505 rows and 14 columns, containing the following column
names:
*ab*, *cid*, *name*, *group*, *atc*, *atc_group1*, *atc_group2*,
*abbreviations*, *synonyms*, *oral_ddd*, *oral_units*, *iv_ddd*,
*iv_units*, and *loinc*.
This data set is in R available as `antimicrobials`, after you load the
`AMR` package.
It was last updated on 23 March 2026 09:38:28 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/antimicrobials.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.rds)
(44 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.txt)
(0.1 MB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.xlsx)
(79 kB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.feather)
(0.1 MB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.parquet)
(94 kB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.sav)
(0.4 MB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antimicrobials.dta)
(10 kB)
The tab-separated text, Microsoft Excel, SPSS, and Stata files all
contain the ATC codes, common abbreviations, trade names and LOINC codes
as comma separated values.
**Example content**
| ab | cid | name | group | atc | atc_group1 | atc_group2 | abbreviations | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc |
|:---:|:--------:|:---------------------------:|:----------------------------------------------:|:------------------------------:|:-------------------------------------------:|:------------------------------------------------------------:|:-------------------:|:-------------------------------------------------------:|:--------:|:----------:|:------:|:--------:|:------------------------------:|
| AMK | 37768 | Amikacin | Aminoglycosides | D06AX12, J01GB06, QD06AX12, … | Aminoglycoside antibacterials | Other aminoglycosides | ak, ami, amik, … | amikacillin, amikacina, amikacine, … | | | 1.0 | g | 101493-5, 11-7, 12-5, … |
| AMX | 33613 | Amoxicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA04, QG51AA03, QJ01CA04 | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | ac, amox, amoxic, … | acuotricina, alfamox, alfida, … | 1.5 | g | 3.0 | g | 101498-4, 15-8, 16-6, … |
| AMC | 23665637 | Amoxicillin/clavulanic acid | Aminopenicillins, Penicillins, Beta-lactams, … | J01CR02, QJ01CR02 | Beta-lactam antibacterials, penicillins | Combinations of penicillins, incl. beta-lactamase inhibitors | a/c, amcl, aml, … | amocla, amoclan, amoclav, … | 1.5 | g | 3.0 | g | |
| AMP | 6249 | Ampicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA01, QJ01CA01, QJ51CA01, … | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | am, amp, amp100, … | adobacillin, alpen, amblosin, … | 2.0 | g | 6.0 | g | 101477-8, 101478-6, 18864-9, … |
| AZM | 447043 | Azithromycin | Macrolides | J01FA10, QJ01FA10, QS01AA26, … | Macrolides, lincosamides and streptogramins | Macrolides | az, azi, azit, … | aritromicina, aruzilina, azasite, … | 0.3 | g | 0.5 | g | 100043-9, 16420-2, 16421-0, … |
| PEN | 5904 | Benzylpenicillin | Penicillins, Beta-lactams | J01CE01, QJ01CE01, QJ51CE01, … | Combinations of antibacterials | Combinations of antibacterials | bepe, pen, peni, … | bencilpenicilina, benzopenicillin, benzylpenicilline, … | | | 3.6 | g | |
------------------------------------------------------------------------
## `clinical_breakpoints`: Interpretation from MIC values & disk diameters to SIR
A data set with 45 730 rows and 14 columns, containing the following
column names:
*guideline*, *type*, *host*, *method*, *site*, *mo*, *rank_index*, *ab*,
*ref_tbl*, *disk_dose*, *breakpoint_S*, *breakpoint_R*, *uti*, and
*is_SDD*.
This data set is in R available as `clinical_breakpoints`, after you
load the `AMR` package.
It was last updated on 2 April 2026 09:42:19 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/clinical_breakpoints.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.rds)
(92 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.txt)
(4.2 MB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.xlsx)
(2.7 MB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.feather)
(2 MB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.parquet)
(0.2 MB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.sav)
(7.5 MB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/clinical_breakpoints.dta)
(12.6 MB)
**Example content**
| guideline | type | host | method | site | mo | mo_name | rank_index | ab | ab_name | ref_tbl | disk_dose | breakpoint_S | breakpoint_R | uti | is_SDD |
|:-----------:|:-----:|:-----:|:------:|:----:|:-------------:|:--------------------------:|:----------:|:---:|:-----------------------------:|:---------------:|:--------------:|:------------:|:------------:|:-----:|:------:|
| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | 10 mcg | 26.000 | 20.000 | FALSE | FALSE |
| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | | 1.000 | 4.000 | FALSE | FALSE |
| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | 1.25/23.75 mcg | 26.000 | 26.000 | FALSE | FALSE |
| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | | 0.125 | 0.125 | FALSE | FALSE |
| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | 30/6 mcg | 26.000 | 26.000 | FALSE | FALSE |
| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | | 4.000 | 4.000 | FALSE | FALSE |
------------------------------------------------------------------------
## `microorganisms.groups`: Species Groups and Microbiological Complexes
A data set with 534 rows and 4 columns, containing the following column
names:
*mo_group*, *mo*, *mo_group_name*, and *mo_name*.
This data set is in R available as `microorganisms.groups`, after you
load the `AMR` package.
It was last updated on 26 March 2025 16:19:17 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/microorganisms.groups.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.rds)
(6 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.txt)
(50 kB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.xlsx)
(20 kB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.feather)
(19 kB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.parquet)
(13 kB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.sav)
(65 kB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.groups.dta)
(83 kB)
**Example content**
| mo_group | mo | mo_group_name | mo_name |
|:--------------:|:------------:|:-------------------------------:|:---------------------------:|
| B_ACNTB_BMNN-C | B_ACNTB_BMNN | Acinetobacter baumannii complex | Acinetobacter baumannii |
| B_ACNTB_BMNN-C | B_ACNTB_CLCC | Acinetobacter baumannii complex | Acinetobacter calcoaceticus |
| B_ACNTB_BMNN-C | B_ACNTB_LCTC | Acinetobacter baumannii complex | Acinetobacter dijkshoorniae |
| B_ACNTB_BMNN-C | B_ACNTB_NSCM | Acinetobacter baumannii complex | Acinetobacter nosocomialis |
| B_ACNTB_BMNN-C | B_ACNTB_PITT | Acinetobacter baumannii complex | Acinetobacter pittii |
| B_ACNTB_BMNN-C | B_ACNTB_SFRT | Acinetobacter baumannii complex | Acinetobacter seifertii |
------------------------------------------------------------------------
## `intrinsic_resistant`: Intrinsic Bacterial Resistance
A data set with 271 905 rows and 2 columns, containing the following
column names:
*mo* and *ab*.
This data set is in R available as `intrinsic_resistant`, after you load
the `AMR` package.
It was last updated on 28 March 2025 10:17:49 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/intrinsic_resistant.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.rds)
(0.1 MB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.txt)
(10.1 MB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.xlsx)
(2.9 MB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.feather)
(2.3 MB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.parquet)
(0.3 MB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.sav)
(14.8 MB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/intrinsic_resistant.dta)
(22.6 MB)
**Example content**
Example rows when filtering on *Enterobacter cloacae*:
| microorganism | antibiotic |
|:--------------------:|:---------------------------:|
| Enterobacter cloacae | Acetylmidecamycin |
| Enterobacter cloacae | Acetylspiramycin |
| Enterobacter cloacae | Amoxicillin |
| Enterobacter cloacae | Amoxicillin/clavulanic acid |
| Enterobacter cloacae | Ampicillin |
| Enterobacter cloacae | Ampicillin/sulbactam |
| Enterobacter cloacae | Avoparcin |
| Enterobacter cloacae | Azithromycin |
| Enterobacter cloacae | Benzylpenicillin |
| Enterobacter cloacae | Bleomycin |
| Enterobacter cloacae | Cadazolid |
| Enterobacter cloacae | Cefadroxil |
| Enterobacter cloacae | Cefalexin |
| Enterobacter cloacae | Cefalotin |
| Enterobacter cloacae | Cefazolin |
| Enterobacter cloacae | Cefoxitin |
| Enterobacter cloacae | Clarithromycin |
| Enterobacter cloacae | Clindamycin |
| Enterobacter cloacae | Cycloserine |
| Enterobacter cloacae | Dalbavancin |
| Enterobacter cloacae | Dirithromycin |
| Enterobacter cloacae | Erythromycin |
| Enterobacter cloacae | Flurithromycin |
| Enterobacter cloacae | Fusidic acid |
| Enterobacter cloacae | Gamithromycin |
| Enterobacter cloacae | Josamycin |
| Enterobacter cloacae | Kitasamycin |
| Enterobacter cloacae | Lincomycin |
| Enterobacter cloacae | Linezolid |
| Enterobacter cloacae | Meleumycin |
| Enterobacter cloacae | Midecamycin |
| Enterobacter cloacae | Miocamycin |
| Enterobacter cloacae | Nafithromycin |
| Enterobacter cloacae | Norvancomycin |
| Enterobacter cloacae | Oleandomycin |
| Enterobacter cloacae | Oritavancin |
| Enterobacter cloacae | Pirlimycin |
| Enterobacter cloacae | Pristinamycin |
| Enterobacter cloacae | Quinupristin/dalfopristin |
| Enterobacter cloacae | Ramoplanin |
| Enterobacter cloacae | Rifampicin |
| Enterobacter cloacae | Rokitamycin |
| Enterobacter cloacae | Roxithromycin |
| Enterobacter cloacae | Solithromycin |
| Enterobacter cloacae | Spiramycin |
| Enterobacter cloacae | Tedizolid |
| Enterobacter cloacae | Teicoplanin |
| Enterobacter cloacae | Telavancin |
| Enterobacter cloacae | Telithromycin |
| Enterobacter cloacae | Thiacetazone |
| Enterobacter cloacae | Tildipirosin |
| Enterobacter cloacae | Tilmicosin |
| Enterobacter cloacae | Troleandomycin |
| Enterobacter cloacae | Tulathromycin |
| Enterobacter cloacae | Tylosin |
| Enterobacter cloacae | Tylvalosin |
| Enterobacter cloacae | Vancomycin |
------------------------------------------------------------------------
## `dosage`: Dosage Guidelines from EUCAST
A data set with 759 rows and 9 columns, containing the following column
names:
*ab*, *name*, *type*, *dose*, *dose_times*, *administration*, *notes*,
*original_txt*, and *eucast_version*.
This data set is in R available as `dosage`, after you load the `AMR`
package.
It was last updated on 20 April 2025 10:55:31 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/dosage.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.rds)
(4 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.txt)
(66 kB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.xlsx)
(37 kB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.feather)
(28 kB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.parquet)
(9 kB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.sav)
(97 kB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/dosage.dta)
(0.2 MB)
**Example content**
| ab | name | type | dose | dose_times | administration | notes | original_txt | eucast_version |
|:---:|:-----------:|:-----------------:|:-----------:|:----------:|:--------------:|:-----:|:------------------:|:--------------:|
| AMK | Amikacin | standard_dosage | 25-30 mg/kg | 1 | iv | | 25-30 mg/kg x 1 iv | 15 |
| AMX | Amoxicillin | high_dosage | 2 g | 6 | iv | | 2 g x 6 iv | 15 |
| AMX | Amoxicillin | standard_dosage | 1 g | 3 | iv | | 1 g x 3-4 iv | 15 |
| AMX | Amoxicillin | high_dosage | 0.75-1 g | 3 | oral | | 0.75-1 g x 3 oral | 15 |
| AMX | Amoxicillin | standard_dosage | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 |
| AMX | Amoxicillin | uncomplicated_uti | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 |
------------------------------------------------------------------------
## `example_isolates`: Example Data for Practice
A data set with 2 000 rows and 46 columns, containing the following
column names:
*date*, *patient*, *age*, *gender*, *ward*, *mo*, *PEN*, *OXA*, *FLC*,
*AMX*, *AMC*, *AMP*, *TZP*, *CZO*, *FEP*, *CXM*, *FOX*, *CTX*, *CAZ*,
*CRO*, *GEN*, *TOB*, *AMK*, *KAN*, *TMP*, *SXT*, *NIT*, *FOS*, *LNZ*,
*CIP*, *MFX*, *VAN*, *TEC*, *TCY*, *TGC*, *DOX*, *ERY*, *CLI*, *AZM*,
*IPM*, *MEM*, *MTR*, *CHL*, *COL*, *MUP*, and *RIF*.
This data set is in R available as `example_isolates`, after you load
the `AMR` package.
It was last updated on 9 February 2026 12:16:36 UTC. Find more info
about the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/example_isolates.html).
**Example content**
| date | patient | age | gender | ward | mo | PEN | OXA | FLC | AMX | AMC | AMP | TZP | CZO | FEP | CXM | FOX | CTX | CAZ | CRO | GEN | TOB | AMK | KAN | TMP | SXT | NIT | FOS | LNZ | CIP | MFX | VAN | TEC | TCY | TGC | DOX | ERY | CLI | AZM | IPM | MEM | MTR | CHL | COL | MUP | RIF |
|:----------:|:-------:|:---:|:------:|:--------:|:------------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| 2002-01-02 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R |
| 2002-01-03 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R |
| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | |
| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | |
| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | | R | | | | | R | | |
| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | R | R | | | | | R | | |
------------------------------------------------------------------------
## `example_isolates_unclean`: Example Data for Practice
A data set with 3 000 rows and 8 columns, containing the following
column names:
*patient_id*, *hospital*, *date*, *bacteria*, *AMX*, *AMC*, *CIP*, and
*GEN*.
This data set is in R available as `example_isolates_unclean`, after you
load the `AMR` package.
It was last updated on 27 August 2022 18:49:37 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/example_isolates_unclean.html).
**Example content**
| patient_id | hospital | date | bacteria | AMX | AMC | CIP | GEN |
|:----------:|:--------:|:----------:|:-------------:|:---:|:---:|:---:|:---:|
| J3 | A | 2012-11-21 | E. coli | R | I | S | S |
| R7 | A | 2018-04-03 | K. pneumoniae | R | I | S | S |
| P3 | A | 2014-09-19 | E. coli | R | S | S | S |
| P10 | A | 2015-12-10 | E. coli | S | I | S | S |
| B7 | A | 2015-03-02 | E. coli | S | S | S | S |
| W3 | A | 2018-03-31 | S. aureus | R | S | R | S |
------------------------------------------------------------------------
## `microorganisms.codes`: Common Laboratory Codes
A data set with 6 050 rows and 2 columns, containing the following
column names:
*code* and *mo*.
This data set is in R available as `microorganisms.codes`, after you
load the `AMR` package.
It was last updated on 30 March 2026 08:01:49 UTC. Find more info about
the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/microorganisms.codes.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.rds)
(28 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.txt)
(0.1 MB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.xlsx)
(98 kB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.feather)
(0.1 MB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.parquet)
(69 kB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.sav)
(0.2 MB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/microorganisms.codes.dta)
(0.2 MB)
**Example content**
| code | mo |
|:----:|:------------:|
| 1011 | B_GRAMP |
| 1012 | B_GRAMP |
| 1013 | B_GRAMN |
| 1014 | B_GRAMN |
| 1015 | F_YEAST |
| 103 | B_ESCHR_COLI |
------------------------------------------------------------------------
## `antivirals`: Antiviral Drugs
A data set with 120 rows and 11 columns, containing the following column
names:
*av*, *name*, *atc*, *cid*, *atc_group*, *synonyms*, *oral_ddd*,
*oral_units*, *iv_ddd*, *iv_units*, and *loinc*.
This data set is in R available as `antivirals`, after you load the
`AMR` package.
It was last updated on 20 October 2023 12:51:48 UTC. Find more info
about the contents, (scientific) source, and structure of this [data set
here](https://amr-for-r.org/reference/antimicrobials.html).
**Direct download links:**
- Download as [original R Data Structure (RDS)
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.rds)
(6 kB)
- Download as [tab-separated text
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.txt)
(17 kB)
- Download as [Microsoft Excel
workbook](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.xlsx)
(16 kB)
- Download as [Apache Feather
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.feather)
(16 kB)
- Download as [Apache Parquet
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.parquet)
(13 kB)
- Download as [IBM SPSS Statistics data
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.sav)
(32 kB)
- Download as [Stata DTA
file](https://github.com/msberends/AMR/raw/main/data-raw/datasets/antivirals.dta)
(78 kB)
The tab-separated text, Microsoft Excel, SPSS, and Stata files all
contain the trade names and LOINC codes as comma separated values.
**Example content**
| av | name | atc | cid | atc_group | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc |
|:---:|:------------------:|:-------:|:---------:|:------------------------------------------------------------------:|:-----------------------------------------------------:|:--------:|:----------:|:------:|:--------:|:----------------------------:|
| ABA | Abacavir | J05AF06 | 441300 | Nucleoside and nucleotide reverse transcriptase inhibitors | abacavir sulfate, avacavir, ziagen | 0.6 | g | | | 29113-8, 30273-7, 30287-7, … |
| ACI | Aciclovir | J05AB01 | 135398513 | Nucleosides and nucleotides excl. reverse transcriptase inhibitors | acicloftal, aciclovier, aciclovirum, … | 4.0 | g | 4 | g | |
| ADD | Adefovir dipivoxil | J05AF08 | 60871 | Nucleoside and nucleotide reverse transcriptase inhibitors | adefovir di, adefovir di ester, adefovir dipivoxyl, … | 10.0 | mg | | | |
| AME | Amenamevir | J05AX26 | 11397521 | Other antivirals | amenalief | 0.4 | g | | | |
| AMP | Amprenavir | J05AE05 | 65016 | Protease inhibitors | agenerase, carbamate, prozei | 1.2 | g | | | 29114-6, 30296-8, 30297-6, … |
| ASU | Asunaprevir | J05AP06 | 16076883 | Antivirals for treatment of HCV infections | sunvepra, sunvepratrade | 0.2 | g | | | |

View File

@@ -7,7 +7,7 @@
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">

16
articles/index.md Normal file
View File

@@ -0,0 +1,16 @@
# Articles
### All vignettes
- [AMR for Python](https://amr-for-r.org/articles/AMR_for_Python.md):
- [AMR with
tidymodels](https://amr-for-r.org/articles/AMR_with_tidymodels.md):
- [Conduct AMR data analysis](https://amr-for-r.org/articles/AMR.md):
- [Download data sets for download / own
use](https://amr-for-r.org/articles/datasets.md):
- [Apply EUCAST rules](https://amr-for-r.org/articles/EUCAST.md):
- [Conduct principal component analysis (PCA) for
AMR](https://amr-for-r.org/articles/PCA.md):
- [Work with WHONET data](https://amr-for-r.org/articles/WHONET.md):
- [Estimating Empirical Coverage with
WISCA](https://amr-for-r.org/articles/WISCA.md):

View File

@@ -7,7 +7,7 @@
<a class="navbar-brand me-2" href="index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.0.9019</small>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">3.0.1.9043</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
@@ -135,7 +135,7 @@
</p>
</li>
<li>
<p><strong>Matthew Saab</strong>. Contributor.
<p><strong>Matthew Saab</strong>. Contributor. <a href="https://orcid.org/0009-0008-6626-7919" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a>
</p>
</li>
<li>
@@ -147,7 +147,7 @@
</p>
</li>
<li>
<p><strong>Rogier P. Schade</strong>. Contributor.
<p><strong>Rogier P. Schade</strong>. Contributor. <a href="https://orcid.org/0000-0002-9487-4467" target="orcid.widget" aria-label="ORCID" class="external-link"><span class="fab fa-orcid orcid" aria-hidden="true"></span></a>
</p>
</li>
<li>

106
authors.md Normal file
View File

@@ -0,0 +1,106 @@
# Authors and Citation
## Authors
- **Matthijs S. Berends**. Author, maintainer.
[](https://orcid.org/0000-0001-7620-1800)
- **Dennis Souverein**. Author, contributor.
[](https://orcid.org/0000-0003-0455-0336)
- **Erwin E. A. Hassing**. Author, contributor.
- **Aislinn Cook**. Contributor.
[](https://orcid.org/0000-0002-9189-7815)
- **Andrew P. Norgan**. Contributor.
[](https://orcid.org/0000-0002-2955-2066)
- **Anita Williams**. Contributor.
[](https://orcid.org/0000-0002-5295-8451)
- **Annick Lenglet**. Contributor.
[](https://orcid.org/0000-0003-2013-8405)
- **Anthony Underwood**. Contributor.
[](https://orcid.org/0000-0002-8547-4277)
- **Anton Mymrikov**. Contributor.
- **Bart C. Meijer**. Contributor.
- **Christian F. Luz**. Contributor.
[](https://orcid.org/0000-0001-5809-5995)
- **Dmytro Mykhailenko**. Contributor.
- **Eric H. L. C. M. Hazenberg**. Contributor.
- **Gwen Knight**. Contributor.
[](https://orcid.org/0000-0002-7263-9896)
- **Jane Hawkey**. Contributor.
[](https://orcid.org/0000-0001-9661-5293)
- **Jason Stull**. Contributor.
[](https://orcid.org/0000-0002-9028-8153)
- **Javier Sanchez**. Contributor.
[](https://orcid.org/0000-0003-2605-8094)
- **Jonas Salm**. Contributor.
- **Judith M. Fonville**. Contributor.
- **Kathryn Holt**. Contributor.
[](https://orcid.org/0000-0003-3949-2471)
- **Larisse Bolton**. Contributor.
[](https://orcid.org/0000-0001-7879-2173)
- **Matthew Saab**. Contributor.
[](https://orcid.org/0009-0008-6626-7919)
- **Natacha Couto**. Contributor.
[](https://orcid.org/0000-0002-9152-5464)
- **Peter Dutey-Magni**. Contributor.
[](https://orcid.org/0000-0002-8942-9836)
- **Rogier P. Schade**. Contributor.
[](https://orcid.org/0000-0002-9487-4467)
- **Sofia Ny**. Contributor. [](https://orcid.org/0000-0002-2017-1363)
- **Alex W. Friedrich**. Thesis advisor.
[](https://orcid.org/0000-0003-4881-038X)
- **Bhanu N. M. Sinha**. Thesis advisor.
[](https://orcid.org/0000-0003-1634-0010)
- **Casper J. Albers**. Thesis advisor.
[](https://orcid.org/0000-0002-9213-6743)
- **Corinna Glasner**. Thesis advisor.
[](https://orcid.org/0000-0003-1241-1328)
## Citation
Source:
[`inst/CITATION`](https://github.com/msberends/AMR/blob/main/inst/CITATION)
Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C
(2022). “AMR: An R Package for Working with Antimicrobial Resistance
Data.” *Journal of Statistical Software*, **104**(3), 131.
[doi:10.18637/jss.v104.i03](https://doi.org/10.18637/jss.v104.i03).
@Article{,
title = {{AMR}: An {R} Package for Working with Antimicrobial Resistance Data},
author = {Matthijs S. Berends and Christian F. Luz and Alexander W. Friedrich and Bhanu N. M. Sinha and Casper J. Albers and Corinna Glasner},
journal = {Journal of Statistical Software},
year = {2022},
volume = {104},
number = {3},
pages = {1--31},
doi = {10.18637/jss.v104.i03},
}

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More