This is my full PhD thesis in R Markdown (using the bookdown package), containing a PDF and EPUB file, and a website in the ‘docs’ folder with the integral content of the book. https://git.io/PhDthesisAMR
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1009 lines
158 KiB

<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>4 AMR - An R Package for Working with Antimicrobial Resistance Data | A New Instrument for Microbial Epidemiology</title>
<meta name="description" content="This is the integral PhD thesis ‘A New Instrument for Microbial Epidemiology’ (DOI 10.33612/diss.177417131) by Matthijs S. Berends, which was defended publicly at the University of Groningen, the Netherlands, on 25 August 2021." />
<meta name="generator" content="bookdown 0.22 and GitBook 2.6.7" />
<meta property="og:title" content="4 AMR - An R Package for Working with Antimicrobial Resistance Data | A New Instrument for Microbial Epidemiology" />
<meta property="og:type" content="book" />
<meta property="og:url" content="https://msberends.github.io/a_new_instrument_for_microbial_epidemiology" />
<meta property="og:image" content="https://msberends.github.io/a_new_instrument_for_microbial_epidemiology/images/cover.jpg" />
<meta property="og:description" content="This is the integral PhD thesis ‘A New Instrument for Microbial Epidemiology’ (DOI 10.33612/diss.177417131) by Matthijs S. Berends, which was defended publicly at the University of Groningen, the Netherlands, on 25 August 2021." />
<meta name="github-repo" content="msberends/a_new_instrument_for_microbial_epidemiology" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="4 AMR - An R Package for Working with Antimicrobial Resistance Data | A New Instrument for Microbial Epidemiology" />
<meta name="twitter:description" content="This is the integral PhD thesis ‘A New Instrument for Microbial Epidemiology’ (DOI 10.33612/diss.177417131) by Matthijs S. Berends, which was defended publicly at the University of Groningen, the Netherlands, on 25 August 2021." />
<meta name="twitter:image" content="https://msberends.github.io/a_new_instrument_for_microbial_epidemiology/images/cover.jpg" />
<meta name="author" content="Matthijs S. Berends" />
<meta name="date" content="2021-08-25" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="ch03-introducing-new-method.html"/>
<link rel="next" href="ch05-radar.html"/>
<script src="libs/header-attrs-2.11/header-attrs.js"></script>
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.0.1/anchor-sections.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.0.1/anchor-sections.js"></script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="https://doi.org/10.33612/diss.177417131" target="blank"><img src="images/cover.jpg" style="width:90%; margin-left:5%;"></a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>Preamble</a>
<ul>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#short-summary-250-words"><i class="fa fa-check"></i>Short summary (250 words)</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="colophon.html"><a href="colophon.html"><i class="fa fa-check"></i>Colophon</a></li>
<li class="chapter" data-level="" data-path="contents.html"><a href="contents.html"><i class="fa fa-check"></i>Contents</a></li>
<li class="chapter" data-level="1" data-path="ch01-introduction.html"><a href="ch01-introduction.html"><i class="fa fa-check"></i><b>1</b> General Introduction</a>
<ul>
<li class="chapter" data-level="1.1" data-path="ch01-introduction.html"><a href="ch01-introduction.html#microbial-epidemiology"><i class="fa fa-check"></i><b>1.1</b> Microbial epidemiology</a></li>
<li class="chapter" data-level="1.2" data-path="ch01-introduction.html"><a href="ch01-introduction.html#antimicrobial-resistance-in-microorganisms"><i class="fa fa-check"></i><b>1.2</b> Antimicrobial resistance in microorganisms</a>
<ul>
<li class="chapter" data-level="1.2.1" data-path="ch01-introduction.html"><a href="ch01-introduction.html#laboratory-diagnostics"><i class="fa fa-check"></i><b>1.2.1</b> Laboratory diagnostics</a></li>
<li class="chapter" data-level="1.2.2" data-path="ch01-introduction.html"><a href="ch01-introduction.html#interpretation-of-raw-results"><i class="fa fa-check"></i><b>1.2.2</b> Interpretation of raw results</a></li>
<li class="chapter" data-level="1.2.3" data-path="ch01-introduction.html"><a href="ch01-introduction.html#multi-drug-resistant-organisms"><i class="fa fa-check"></i><b>1.2.3</b> Multi-drug resistant organisms</a></li>
<li class="chapter" data-level="1.2.4" data-path="ch01-introduction.html"><a href="ch01-introduction.html#surveillance-programs"><i class="fa fa-check"></i><b>1.2.4</b> Surveillance programs</a></li>
</ul></li>
<li class="chapter" data-level="1.3" data-path="ch01-introduction.html"><a href="ch01-introduction.html#data-analysis-using-r"><i class="fa fa-check"></i><b>1.3</b> Data analysis using R</a></li>
<li class="chapter" data-level="1.4" data-path="ch01-introduction.html"><a href="ch01-introduction.html#setting-for-this-thesis"><i class="fa fa-check"></i><b>1.4</b> Setting for this thesis</a></li>
<li class="chapter" data-level="1.5" data-path="ch01-introduction.html"><a href="ch01-introduction.html#aim-of-this-thesis-and-introduction-to-its-chapters"><i class="fa fa-check"></i><b>1.5</b> Aim of this thesis and introduction to its chapters</a></li>
<li class="chapter" data-level="" data-path="ch01-introduction.html"><a href="ch01-introduction.html#references"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html"><i class="fa fa-check"></i><b>2</b> Diagnostic Stewardship: Sense or Nonsense?!</a>
<ul>
<li class="chapter" data-level="" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#abstract"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="2.1" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#introduction"><i class="fa fa-check"></i><b>2.1</b> Introduction</a>
<ul>
<li class="chapter" data-level="2.1.1" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#case-1"><i class="fa fa-check"></i><b>2.1.1</b> Case 1</a></li>
<li class="chapter" data-level="2.1.2" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#case-2"><i class="fa fa-check"></i><b>2.1.2</b> Case 2</a></li>
</ul></li>
<li class="chapter" data-level="2.2" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#the-general-concept"><i class="fa fa-check"></i><b>2.2</b> The general concept</a>
<ul>
<li class="chapter" data-level="2.2.1" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#diagnostics"><i class="fa fa-check"></i><b>2.2.1</b> ‘Diagnostics’</a></li>
<li class="chapter" data-level="2.2.2" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#dsp-in-the-microbiological-laboratory"><i class="fa fa-check"></i><b>2.2.2</b> DSP in the microbiological laboratory</a></li>
<li class="chapter" data-level="2.2.3" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#dsp-as-process-optimisation"><i class="fa fa-check"></i><b>2.2.3</b> DSP as process optimisation</a></li>
<li class="chapter" data-level="2.2.4" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#multidisciplinary-aspects-of-dsp-and-infection-management"><i class="fa fa-check"></i><b>2.2.4</b> Multidisciplinary aspects of DSP and infection management</a></li>
</ul></li>
<li class="chapter" data-level="2.3" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#conclusion"><i class="fa fa-check"></i><b>2.3</b> Conclusion</a></li>
<li class="chapter" data-level="" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#financing"><i class="fa fa-check"></i>Financing</a></li>
<li class="chapter" data-level="" data-path="ch02-diagnostic-stewardship.html"><a href="ch02-diagnostic-stewardship.html#references-1"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html"><i class="fa fa-check"></i><b>3</b> Introducing a New, Free, and Independent Method for Standardised, Reproducible and Reliable Analyses of Antimicrobial Resistance Data</a>
<ul>
<li class="chapter" data-level="" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#abstract-1"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="3.1" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#background"><i class="fa fa-check"></i><b>3.1</b> Background</a></li>
<li class="chapter" data-level="3.2" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#standardising-amr-data-analysis"><i class="fa fa-check"></i><b>3.2</b> Standardising AMR data analysis</a></li>
<li class="chapter" data-level="3.3" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#comparison-with-existing-software-methods"><i class="fa fa-check"></i><b>3.3</b> Comparison with existing software methods</a></li>
<li class="chapter" data-level="3.4" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#user-feedback"><i class="fa fa-check"></i><b>3.4</b> User feedback</a></li>
<li class="chapter" data-level="3.5" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#conclusion-1"><i class="fa fa-check"></i><b>3.5</b> Conclusion</a></li>
<li class="chapter" data-level="" data-path="ch03-introducing-new-method.html"><a href="ch03-introducing-new-method.html#references-2"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html"><i class="fa fa-check"></i><b>4</b> <code>AMR</code> - An <code>R</code> Package for Working with Antimicrobial Resistance Data</a>
<ul>
<li class="chapter" data-level="" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#abstract-2"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="4.1" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#introduction-1"><i class="fa fa-check"></i><b>4.1</b> Introduction</a></li>
<li class="chapter" data-level="4.2" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#antimicrobial-resistance-data"><i class="fa fa-check"></i><b>4.2</b> Antimicrobial resistance data</a></li>
<li class="chapter" data-level="4.3" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#antimicrobial-resistance-data-transformation"><i class="fa fa-check"></i><b>4.3</b> Antimicrobial resistance data transformation</a>
<ul>
<li class="chapter" data-level="4.3.1" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#working-with-taxonomically-valid-microorganism-names"><i class="fa fa-check"></i><b>4.3.1</b> Working with taxonomically valid microorganism names</a></li>
<li class="chapter" data-level="4.3.2" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#working-with-antimicrobial-names-or-codes"><i class="fa fa-check"></i><b>4.3.2</b> Working with antimicrobial names or codes</a></li>
<li class="chapter" data-level="4.3.3" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#working-with-antimicrobial-susceptibility-test-results"><i class="fa fa-check"></i><b>4.3.3</b> Working with antimicrobial susceptibility test results</a></li>
<li class="chapter" data-level="4.3.4" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#interpretative-rules-by-eucast"><i class="fa fa-check"></i><b>4.3.4</b> Interpretative rules by EUCAST</a></li>
<li class="chapter" data-level="4.3.5" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#working-with-defined-daily-doses-ddd"><i class="fa fa-check"></i><b>4.3.5</b> Working with defined daily doses (DDD)</a></li>
</ul></li>
<li class="chapter" data-level="4.4" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#enhancing-antimicrobial-resistance-data"><i class="fa fa-check"></i><b>4.4</b> Enhancing antimicrobial resistance data</a>
<ul>
<li class="chapter" data-level="4.4.1" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#determining-first-isolates"><i class="fa fa-check"></i><b>4.4.1</b> Determining first isolates</a></li>
<li class="chapter" data-level="4.4.2" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#determining-multi-drug-resistant-organisms-mdro"><i class="fa fa-check"></i><b>4.4.2</b> Determining multi-drug resistant organisms (MDRO)</a></li>
</ul></li>
<li class="chapter" data-level="4.5" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#analysing-antimicrobial-resistance-data"><i class="fa fa-check"></i><b>4.5</b> Analysing antimicrobial resistance data</a>
<ul>
<li class="chapter" data-level="4.5.1" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#calculation-of-antimicrobial-resistance"><i class="fa fa-check"></i><b>4.5.1</b> Calculation of antimicrobial resistance</a></li>
</ul></li>
<li class="chapter" data-level="4.6" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#design-decisions"><i class="fa fa-check"></i><b>4.6</b> Design decisions</a></li>
<li class="chapter" data-level="4.7" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#reproducible-example"><i class="fa fa-check"></i><b>4.7</b> Reproducible example</a></li>
<li class="chapter" data-level="4.8" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#discussion"><i class="fa fa-check"></i><b>4.8</b> Discussion</a></li>
<li class="chapter" data-level="" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#computational-details"><i class="fa fa-check"></i>Computational Details</a></li>
<li class="chapter" data-level="" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#acknowledgements"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#references-3"><i class="fa fa-check"></i>References</a></li>
<li class="chapter" data-level="" data-path="ch04-amr-r-package.html"><a href="ch04-amr-r-package.html#appendix-a-included-data-sets"><i class="fa fa-check"></i>Appendix A: Included Data Sets</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="ch05-radar.html"><a href="ch05-radar.html"><i class="fa fa-check"></i><b>5</b> Rapid Analysis of Diagnostic and Antimicrobial Patterns in R (RadaR): Interactive Open-Source Software App for Infection Management and Antimicrobial Stewardship</a>
<ul>
<li class="chapter" data-level="" data-path="ch05-radar.html"><a href="ch05-radar.html#abstract-3"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="5.1" data-path="ch05-radar.html"><a href="ch05-radar.html#introduction-2"><i class="fa fa-check"></i><b>5.1</b> Introduction</a>
<ul>
<li class="chapter" data-level="5.1.1" data-path="ch05-radar.html"><a href="ch05-radar.html#background-1"><i class="fa fa-check"></i><b>5.1.1</b> Background</a></li>
<li class="chapter" data-level="5.1.2" data-path="ch05-radar.html"><a href="ch05-radar.html#objectives"><i class="fa fa-check"></i><b>5.1.2</b> Objectives</a></li>
</ul></li>
<li class="chapter" data-level="5.2" data-path="ch05-radar.html"><a href="ch05-radar.html#methods"><i class="fa fa-check"></i><b>5.2</b> Methods</a></li>
<li class="chapter" data-level="5.3" data-path="ch05-radar.html"><a href="ch05-radar.html#results"><i class="fa fa-check"></i><b>5.3</b> Results</a>
<ul>
<li class="chapter" data-level="5.3.1" data-path="ch05-radar.html"><a href="ch05-radar.html#overview"><i class="fa fa-check"></i><b>5.3.1</b> Overview</a></li>
<li class="chapter" data-level="5.3.2" data-path="ch05-radar.html"><a href="ch05-radar.html#application-design"><i class="fa fa-check"></i><b>5.3.2</b> Application Design</a></li>
<li class="chapter" data-level="5.3.3" data-path="ch05-radar.html"><a href="ch05-radar.html#development-process"><i class="fa fa-check"></i><b>5.3.3</b> Development Process</a></li>
<li class="chapter" data-level="5.3.4" data-path="ch05-radar.html"><a href="ch05-radar.html#workflow"><i class="fa fa-check"></i><b>5.3.4</b> Workflow</a></li>
<li class="chapter" data-level="5.3.5" data-path="ch05-radar.html"><a href="ch05-radar.html#customisation"><i class="fa fa-check"></i><b>5.3.5</b> Customisation</a></li>
</ul></li>
<li class="chapter" data-level="5.4" data-path="ch05-radar.html"><a href="ch05-radar.html#discussion-1"><i class="fa fa-check"></i><b>5.4</b> Discussion</a>
<ul>
<li class="chapter" data-level="5.4.1" data-path="ch05-radar.html"><a href="ch05-radar.html#principal-findings"><i class="fa fa-check"></i><b>5.4.1</b> Principal Findings</a></li>
<li class="chapter" data-level="5.4.2" data-path="ch05-radar.html"><a href="ch05-radar.html#conclusions"><i class="fa fa-check"></i><b>5.4.2</b> Conclusions</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="ch05-radar.html"><a href="ch05-radar.html#acknowledgements-1"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="ch05-radar.html"><a href="ch05-radar.html#conflicts-of-interests"><i class="fa fa-check"></i>Conflicts of interests</a></li>
<li class="chapter" data-level="" data-path="ch05-radar.html"><a href="ch05-radar.html#references-4"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="ch06-radar2.html"><a href="ch06-radar2.html"><i class="fa fa-check"></i><b>6</b> Better Antimicrobial Resistance Data Analysis and Reporting in Less Time</a>
<ul>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#abstract-4"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="6.1" data-path="ch06-radar2.html"><a href="ch06-radar2.html#introduction-3"><i class="fa fa-check"></i><b>6.1</b> Introduction</a></li>
<li class="chapter" data-level="6.2" data-path="ch06-radar2.html"><a href="ch06-radar2.html#methods-1"><i class="fa fa-check"></i><b>6.2</b> Methods</a>
<ul>
<li class="chapter" data-level="6.2.1" data-path="ch06-radar2.html"><a href="ch06-radar2.html#study-setup"><i class="fa fa-check"></i><b>6.2.1</b> Study setup</a></li>
<li class="chapter" data-level="6.2.2" data-path="ch06-radar2.html"><a href="ch06-radar2.html#amr-data"><i class="fa fa-check"></i><b>6.2.2</b> AMR data</a></li>
<li class="chapter" data-level="6.2.3" data-path="ch06-radar2.html"><a href="ch06-radar2.html#amr-data-analysis-and-reporting"><i class="fa fa-check"></i><b>6.2.3</b> AMR data analysis and reporting</a></li>
<li class="chapter" data-level="6.2.4" data-path="ch06-radar2.html"><a href="ch06-radar2.html#study-participants"><i class="fa fa-check"></i><b>6.2.4</b> Study participants</a></li>
<li class="chapter" data-level="6.2.5" data-path="ch06-radar2.html"><a href="ch06-radar2.html#study-execution-and-data"><i class="fa fa-check"></i><b>6.2.5</b> Study execution and data</a></li>
<li class="chapter" data-level="6.2.6" data-path="ch06-radar2.html"><a href="ch06-radar2.html#evaluation-and-study-data-analysis"><i class="fa fa-check"></i><b>6.2.6</b> Evaluation and study data analysis</a></li>
</ul></li>
<li class="chapter" data-level="6.3" data-path="ch06-radar2.html"><a href="ch06-radar2.html#results-1"><i class="fa fa-check"></i><b>6.3</b> Results</a>
<ul>
<li class="chapter" data-level="6.3.1" data-path="ch06-radar2.html"><a href="ch06-radar2.html#study-participants-1"><i class="fa fa-check"></i><b>6.3.1</b> Study participants</a></li>
<li class="chapter" data-level="6.3.2" data-path="ch06-radar2.html"><a href="ch06-radar2.html#effectiveness-and-accuracy"><i class="fa fa-check"></i><b>6.3.2</b> Effectiveness and accuracy</a></li>
<li class="chapter" data-level="6.3.3" data-path="ch06-radar2.html"><a href="ch06-radar2.html#efficiency"><i class="fa fa-check"></i><b>6.3.3</b> Efficiency</a></li>
<li class="chapter" data-level="6.3.4" data-path="ch06-radar2.html"><a href="ch06-radar2.html#satisfaction"><i class="fa fa-check"></i><b>6.3.4</b> Satisfaction</a></li>
</ul></li>
<li class="chapter" data-level="6.4" data-path="ch06-radar2.html"><a href="ch06-radar2.html#discussion-2"><i class="fa fa-check"></i><b>6.4</b> Discussion</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#acknowledgements-2"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#funding"><i class="fa fa-check"></i>Funding</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#conflict-of-interest"><i class="fa fa-check"></i>Conflict of interest</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#references-5"><i class="fa fa-check"></i>References</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#appendix"><i class="fa fa-check"></i>Appendix</a>
<ul>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#appendix-a1-task-lists-including-correct-results"><i class="fa fa-check"></i>Appendix A1: Task lists including correct results</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#appendix-a2-system-usability-scale-sus"><i class="fa fa-check"></i>Appendix A2: System Usability Scale (SUS)</a></li>
<li class="chapter" data-level="" data-path="ch06-radar2.html"><a href="ch06-radar2.html#appendix-a3-task-3-sub-analysis"><i class="fa fa-check"></i>Appendix A3: Task 3 sub-analysis</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="7" data-path="ch07-cons.html"><a href="ch07-cons.html"><i class="fa fa-check"></i><b>7</b> Trends in Occurrence and Phenotypic Resistance of Coagulase-Negative Staphylococci (CoNS) Found in Blood in the Northern Netherlands between 2013 and 2019</a>
<ul>
<li class="chapter" data-level="7.1" data-path="ch07-cons.html"><a href="ch07-cons.html#abstract-5"><i class="fa fa-check"></i><b>7.1</b> Abstract</a></li>
<li class="chapter" data-level="7.2" data-path="ch07-cons.html"><a href="ch07-cons.html#introduction-4"><i class="fa fa-check"></i><b>7.2</b> Introduction</a></li>
<li class="chapter" data-level="7.3" data-path="ch07-cons.html"><a href="ch07-cons.html#materials-methods"><i class="fa fa-check"></i><b>7.3</b> Materials &amp; methods</a>
<ul>
<li class="chapter" data-level="7.3.1" data-path="ch07-cons.html"><a href="ch07-cons.html#study-setting-and-patient-cohort"><i class="fa fa-check"></i><b>7.3.1</b> Study setting and patient cohort</a></li>
<li class="chapter" data-level="7.3.2" data-path="ch07-cons.html"><a href="ch07-cons.html#microbiological-and-demographic-data"><i class="fa fa-check"></i><b>7.3.2</b> Microbiological and demographic data</a></li>
<li class="chapter" data-level="7.3.3" data-path="ch07-cons.html"><a href="ch07-cons.html#species-determination-and-antibiotic-susceptibility-testing-ast"><i class="fa fa-check"></i><b>7.3.3</b> Species determination and antibiotic susceptibility testing (AST)</a></li>
<li class="chapter" data-level="7.3.4" data-path="ch07-cons.html"><a href="ch07-cons.html#selection-of-bacterial-isolates"><i class="fa fa-check"></i><b>7.3.4</b> Selection of bacterial isolates</a></li>
<li class="chapter" data-level="7.3.5" data-path="ch07-cons.html"><a href="ch07-cons.html#eucast-rules-and-antibiotic-resistance-analysis"><i class="fa fa-check"></i><b>7.3.5</b> EUCAST rules and antibiotic resistance analysis</a></li>
<li class="chapter" data-level="7.3.6" data-path="ch07-cons.html"><a href="ch07-cons.html#statistical-analysis"><i class="fa fa-check"></i><b>7.3.6</b> Statistical analysis</a></li>
<li class="chapter" data-level="7.3.7" data-path="ch07-cons.html"><a href="ch07-cons.html#ethical-considerations"><i class="fa fa-check"></i><b>7.3.7</b> Ethical considerations</a></li>
</ul></li>
<li class="chapter" data-level="7.4" data-path="ch07-cons.html"><a href="ch07-cons.html#results-2"><i class="fa fa-check"></i><b>7.4</b> Results</a>
<ul>
<li class="chapter" data-level="7.4.1" data-path="ch07-cons.html"><a href="ch07-cons.html#patients-and-included-isolates"><i class="fa fa-check"></i><b>7.4.1</b> Patients and included isolates</a></li>
<li class="chapter" data-level="7.4.2" data-path="ch07-cons.html"><a href="ch07-cons.html#occurrence-of-cons-species"><i class="fa fa-check"></i><b>7.4.2</b> Occurrence of CoNS species</a></li>
<li class="chapter" data-level="7.4.3" data-path="ch07-cons.html"><a href="ch07-cons.html#definition-of-cons-persistence"><i class="fa fa-check"></i><b>7.4.3</b> Definition of CoNS persistence</a></li>
<li class="chapter" data-level="7.4.4" data-path="ch07-cons.html"><a href="ch07-cons.html#antibiotic-resistance-analysis"><i class="fa fa-check"></i><b>7.4.4</b> Antibiotic resistance analysis</a></li>
</ul></li>
<li class="chapter" data-level="7.5" data-path="ch07-cons.html"><a href="ch07-cons.html#discussion-3"><i class="fa fa-check"></i><b>7.5</b> Discussion</a></li>
<li class="chapter" data-level="" data-path="ch07-cons.html"><a href="ch07-cons.html#supplementary-tables"><i class="fa fa-check"></i>Supplementary tables</a></li>
<li class="chapter" data-level="" data-path="ch07-cons.html"><a href="ch07-cons.html#references-6"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html"><i class="fa fa-check"></i><b>8</b> Defining Multidrug Resistance of Gram-Negative Bacteria in the Dutch-German Border Region: Impact of National Guidelines</a>
<ul>
<li class="chapter" data-level="" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#abstract-6"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="8.1" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#introduction-5"><i class="fa fa-check"></i><b>8.1</b> Introduction</a></li>
<li class="chapter" data-level="8.2" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#methods-2"><i class="fa fa-check"></i><b>8.2</b> Methods</a></li>
<li class="chapter" data-level="8.3" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#results-3"><i class="fa fa-check"></i><b>8.3</b> Results</a>
<ul>
<li class="chapter" data-level="8.3.1" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#number-of-antibiograms-and-patients"><i class="fa fa-check"></i><b>8.3.1</b> Number of Antibiograms and Patients</a></li>
<li class="chapter" data-level="8.3.2" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#results-of-mrgn-and-brmo-classification"><i class="fa fa-check"></i><b>8.3.2</b> Results of MRGN and BRMO Classification</a></li>
</ul></li>
<li class="chapter" data-level="8.4" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#discussion-4"><i class="fa fa-check"></i><b>8.4</b> Discussion</a></li>
<li class="chapter" data-level="" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#acknowledgements-3"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#conflicts-of-interest"><i class="fa fa-check"></i>Conflicts of interest</a></li>
<li class="chapter" data-level="" data-path="ch08-defining-mdr.html"><a href="ch08-defining-mdr.html#references-7"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html"><i class="fa fa-check"></i><b>9</b> Changing Epidemiology of Methicillin-Resistant <em>Staphylococcus aureus</em> in 42 Hospitals in the Dutch-German Border Region, 2012 to 2016: Results of the Search-and-Follow Policy</a>
<ul>
<li class="chapter" data-level="" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#abstract-7"><i class="fa fa-check"></i>Abstract</a></li>
<li class="chapter" data-level="9.1" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#introduction-6"><i class="fa fa-check"></i><b>9.1</b> Introduction</a></li>
<li class="chapter" data-level="9.2" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#methods-3"><i class="fa fa-check"></i><b>9.2</b> Methods</a>
<ul>
<li class="chapter" data-level="9.2.1" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#setting"><i class="fa fa-check"></i><b>9.2.1</b> Setting</a></li>
<li class="chapter" data-level="9.2.2" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#guidelines-for-patients-at-risk-for-mrsa-and-infection-prevention-and-control-measures"><i class="fa fa-check"></i><b>9.2.2</b> Guidelines for patients at risk for MRSA and infection prevention and control measures</a></li>
<li class="chapter" data-level="9.2.3" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#data-collection"><i class="fa fa-check"></i><b>9.2.3</b> Data collection</a></li>
<li class="chapter" data-level="9.2.4" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#ethical-statement"><i class="fa fa-check"></i><b>9.2.4</b> Ethical statement</a></li>
<li class="chapter" data-level="9.2.5" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#data-analysis"><i class="fa fa-check"></i><b>9.2.5</b> Data analysis</a></li>
</ul></li>
<li class="chapter" data-level="9.3" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#results-4"><i class="fa fa-check"></i><b>9.3</b> Results</a>
<ul>
<li class="chapter" data-level="9.3.1" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#trend-and-cross-border-comparison-of-mrsa-rates"><i class="fa fa-check"></i><b>9.3.1</b> Trend and cross-border comparison of MRSA rates</a></li>
<li class="chapter" data-level="9.3.2" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#cross-border-comparison-of-healthcare-utilisation"><i class="fa fa-check"></i><b>9.3.2</b> Cross-border comparison of healthcare utilisation</a></li>
</ul></li>
<li class="chapter" data-level="9.4" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#discussion-5"><i class="fa fa-check"></i><b>9.4</b> Discussion</a></li>
<li class="chapter" data-level="" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#acknowledgements-4"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#funding-1"><i class="fa fa-check"></i>Funding</a></li>
<li class="chapter" data-level="" data-path="ch09-changing-epidemiology.html"><a href="ch09-changing-epidemiology.html#references-8"><i class="fa fa-check"></i>References</a></li>
</ul></li>
<li class="divider"></li>
<li class="copyright">© 2021 Matthijs Berends</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">A New Instrument for Microbial Epidemiology</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="ch04-amr-r-package" class="section level1" number="4">
<h1><span class="header-section-number">4</span> <code>AMR</code> - An <code>R</code> Package for Working with Antimicrobial Resistance Data</h1>
<p>
Accepted in Journal of Statistical Software (ahead of print)
<note>
(as of date of PhD defence: 25 August 2021)
</note>
</p>
<p>Berends MS <sup>1,2</sup>*, Luz CF <sup>2</sup>*, Friedrich AW <sup>2</sup>, Sinha BNM <sup>2</sup>, Albers CJ <sup>3</sup>, Glasner C <sup>2</sup></p>
<ol style="list-style-type: decimal">
<li>Certe Medical Diagnostics and Advice Foundation, Groningen, the Netherlands</li>
<li>University of Groningen, University Medical Center Groningen, Department of Medical Microbiology and Infection Prevention, Groningen, the Netherlands</li>
<li>University of Groningen, Heymans Institute for Psychological Research, Groningen, the Netherlands</li>
</ol>
<p>* These authors contributed equally</p>
<div id="abstract-2" class="section level2 unnumbered">
<h2>Abstract</h2>
<p>Antimicrobial resistance is an increasing threat to global health. Evidence for this trend is generated in microbiological laboratories through testing microorganisms for resistance against antimicrobial agents. International standards and guidelines are in place for this process as well as for reporting data on (inter-)national levels. However, there is a gap in the availability of standardised and reproducible tools for working with laboratory data to produce the required reports. It is known that extensive efforts in data cleaning and validation are required when working with data from laboratory information systems. Furthermore, the global spread and relevance of antimicrobial resistance demands to incorporate international reference data in the analysis process. In this paper, we introduce the <code>AMR</code> package for<code>R</code> that aims at closing this gap by providing tools to simplify antimicrobial resistance data cleaning and analysis, while incorporating international guidelines and scientifically reliable reference data. The <code>AMR</code> package enables standardised and reproducible antimicrobial resistance analyses, including the application of evidence-based rules, determination of first isolates, translation of various codes for microorganisms and antimicrobial agents, determination of (multi-drug) resistant microorganisms, and calculation of antimicrobial resistance, prevalence and future trends. The <code>AMR</code> package works independently of any laboratory information system and provides several functions to integrate into international workflows (e.g., WHONET software provided by the World Health Organization).</p>
</div>
<div id="introduction-1" class="section level2" number="4.1">
<h2><span class="header-section-number">4.1</span> Introduction</h2>
<p>Antimicrobial resistance is a global health problem and of great concern for human medicine, veterinary medicine, and the environment alike. It is associated with significant burdens to both patients and health care systems. Current estimates show the immense dimensions we are already facing, such as claiming at least 50,000 lives due to antimicrobial resistance each year across Europe and the US alone <sup>[1]</sup>. Although estimates for the burden through antimicrobial resistance and their predictions are disputed <sup>[2]</sup> the rising trend is undeniable <sup>[3]</sup>, thus calling for worldwide efforts on tackling this problem.</p>
<p>Surveillance programs and reliable data are key for controlling and streamlining these efforts. Surveillance data of antimicrobial resistance at higher levels (national or international) usually comprise aggregated numbers. The basis of this information is generated and stored at local microbiological laboratories where isolated microorganisms are tested for their susceptibility to a whole range of antimicrobial agents. The efficacy of these agents against microorganisms is nowadays interpreted as follows <sup>[4]</sup>:</p>
<ul>
<li>R (“resistant”) - there is a high likelihood of therapeutic failure;</li>
<li>S (“susceptible, standard dosing regimen”) - there is a high likelihood of therapeutic success using a standard dosing regimen of an antimicrobial agent;</li>
<li>I (“susceptible, increased exposure”) - there is a high likelihood of therapeutic success, but only when exposure to an antimicrobial agent is increased by adjusting the dosing regimen or its concentration at the site of infection.</li>
</ul>
<p>Generally, antimicrobial resistance is defined as the proportion of resistant microorganisms (R) among all tested microorganisms of the same species (R + S + I). Today, the two major guideline institutes to define the international standards on antimicrobial resistance are the European Committee on Antimicrobial Susceptibility Testing (EUCAST) <sup>[5]</sup> and the Clinical and Laboratory Standards Institute (CLSI) <sup>[6]</sup>. The guidelines from these two institutes are adopted by 94% of all countries reporting antimicrobial resistance to the WHO <sup>[7]</sup>.</p>
<p>Although these standardised guidelines are in place on the laboratory level for the data generation process, stored data in laboratory information systems are often not yet suitable for data analysis. Laboratory information systems are often designed to fit billing purposes rather than epidemiological data analysis. Furthermore, (inter-)national surveillance is hindered by inadequate standardisation of epidemiological definitions, different types of samples and data collection, settings included, microbiological testing methods (including susceptibility testing), and data sharing policies <sup>[8]</sup>. The necessity of accurate data analysis in the field of antimicrobial resistance has just recently been further underlined <sup>[9]</sup>. Antimicrobial resistance analyses require a thorough understanding of microbiological tests and their results, the biological taxonomy of microorganisms, the clinical and epidemiological relevance of the results, their pharmaceutical implications, and (inter-)national standards and guidelines for working with and reporting antimicrobial resistance.</p>
<p>Here, we describe the <code>AMR</code> package for<code>R</code> <sup>[10]</sup>, which has been developed to standardise clean and reproducible antimicrobial resistance data analyses using international standardised recommendations <sup>[5,6]</sup> while incorporating scientifically reliable reference data about valid laboratory outcome, antimicrobial agents, and the complete biological taxonomy of microorganisms. The <code>AMR</code> package provides solutions and support for these aspects while being independent of underlying laboratory information systems, thereby democratising the analysis process. Developed in<code>R</code> and available on the Comprehensive<code>R</code> Archive Network (CRAN) since February 22nd 2018 <sup>[11]</sup>, the <code>AMR</code> package enables reproducible workflows as described in other fields, such as environmental science <sup>[12]</sup>. The <code>AMR</code> package provides a new technical instrument to aid in curbing the global threat of antimicrobial resistance. Furthermore, local, and regional data in the laboratories can now become relevant in any setting for public health.</p>
<p>While no other packages<code>R</code> package with the purpose of dealing with antimicrobial resistance data are available on CRAN or Bioconductor, the <code>AMR</code> package may be integrated in workflows of related packages. For example, the<code>R</code> Epidemics Consortium (RECON) provides high-quality packages for data analysis in infectious disease outbreaks or epidemics (for example incidence and epicontacts) <sup>[13,14]</sup>. In addition, on the laboratory side the antibioticR package provides approaches to work with disc diffusion zone diameter and minimum inhibitory concentration data from environment samples <sup>[15]</sup>. We aim at providing a comprehensive and standardised toolbox for antimicrobial resistance data processing and analysis, with a focus on microbiological, clinical, and epidemiological purposes that was yet missing.</p>
<p>The following sections describe the functionality of the <code>AMR</code> package according to its core functionalities for transforming, enhancing, and analysing antimicrobial resistance data using scientifically reliable reference data.</p>
</div>
<div id="antimicrobial-resistance-data" class="section level2" number="4.2">
<h2><span class="header-section-number">4.2</span> Antimicrobial resistance data</h2>
<p>Microbiological tests can be performed on different specimens, such as blood or urine samples or nasal swabs. After arrival at the microbiological laboratory, the specimens are traditionally cultured on specific media, such as blood agar. If a microorganism can be isolated from these media, it is tested against several antimicrobial agents. Based on the minimal inhibitory concentration (MIC) of the respective agent and interpretation guidelines, such as guidelines by EUCAST <sup>[5]</sup> and CLSI <sup>[6]</sup>, test results are reported as “resistant” (R), “susceptible” (S) or “susceptible, increased exposure” (I). A typical data structure is illustrated in Table 1 <sup>[5]</sup>.</p>
<p class="tbl-caption">
Table 1. Example of an antimicrobial resistance report.
</p>
<p><img src="images/04-t01.jpg" width="100%" style="display: block; margin: auto;" /></p>
<p class="tbl-caption">
Table 2. Example of an antimicrobial resistance report.
</p>
<p><img src="images/04-t02.jpg" width="100%" style="display: block; margin: auto;" /></p>
<p>The <code>AMR</code> package aims at providing a standardised and automated way of cleaning, transforming, and enhancing these typical data structures (Table 1 and 2), independent of the underlying data source. Processed data would be similar to Table 3 that highlights several package functionalities in the sections below.</p>
<p class="tbl-caption">
Table 3. Enhanced antimicrobial resistance report example.
</p>
<p><img src="images/04-t03.jpg" width="100%" style="display: block; margin: auto;" /></p>
</div>
<div id="antimicrobial-resistance-data-transformation" class="section level2" number="4.3">
<h2><span class="header-section-number">4.3</span> Antimicrobial resistance data transformation</h2>
<div id="working-with-taxonomically-valid-microorganism-names" class="section level3" number="4.3.1">
<h3><span class="header-section-number">4.3.1</span> Working with taxonomically valid microorganism names</h3>
<p>Coercing is a computational process of forcing output based on an input. For microorganism names, coercing user input to taxonomically valid microorganism names is crucial to ensure correct interpretation and to enable grouping based on taxonomic properties. To this end, the <code>AMR</code> package includes all microbial entries from The Catalogue of Life (<a href="http://www.catalogueoflife.org" class="uri">http://www.catalogueoflife.org</a>), the most comprehensive and authoritative global index of species currently available <sup>[16]</sup>. It holds essential information on the names, relationships, and distributions of more than 1.9 million species. The integration of it into the <code>AMR</code> package is described in Appendix A.</p>
<p>The <code>as.mo()</code> function makes use of this underlying data to transform a vector of characters to a new class `<code>‘mo’</code> of taxonomically valid microorganism name. The resulting values are microbial IDs, which are human-readable for the trained eye and contain information about the taxonomic kingdom, genus, species, and subspecies (Figure 1).</p>
<div class="figure" style="text-align: center"><span id="fig:fig4-1"></span>
<img src="images/04-01.jpg" alt="The structure of a typical microbial ID as used in the `AMR` package. An ID consists of two to four elements, separated by an underscore. The first element is the abbreviation of the taxonomic kingdom. The remaining elements consist of abbreviations of the lowest taxonomic levels of every microorganism: genus, species (if available) and subspecies (if available). Abbreviations used for the microbial IDs of microorganism names were created using the base` R` function `abbreviate()`." width="66%" />
<p class="caption">
Figure 4.1: The structure of a typical microbial ID as used in the <code>AMR</code> package. An ID consists of two to four elements, separated by an underscore. The first element is the abbreviation of the taxonomic kingdom. The remaining elements consist of abbreviations of the lowest taxonomic levels of every microorganism: genus, species (if available) and subspecies (if available). Abbreviations used for the microbial IDs of microorganism names were created using the base<code>R</code> function <code>abbreviate()</code>.
</p>
</div>
<p>The <code>as.mo()</code> function compares the user input with taxonomically valid microorganism names, rates the matching with a score and returns results based on the highest score. This matching score (<span class="math inline">\(m\)</span>), ranging from <span class="math inline">\(0\)</span> to <span class="math inline">\(1\)</span>, is calculated using the following equation:</p>
<p><span class="math display">\[m_{(x,n)} = \frac{l_{n} - 0.5 \cdot \min\{ l_n, \operatorname{lev}(x,n) \} }{l_{n} \cdot p_{n} \cdot k_{n}}\]</span></p>
<p>where:</p>
<ul>
<li><span class="math inline">\(x\)</span> is the user input;</li>
<li><span class="math inline">\(n\)</span> is a taxonomic name (genus, species, and subspecies);</li>
<li><span class="math inline">\(l_n\)</span> is the length of <span class="math inline">\(n\)</span>;</li>
<li>lev is the Levenshtein distance function <sup>[17]</sup>, which counts any insertion, deletion and substitution as <span class="math inline">\(1\)</span> that is needed to change <span class="math inline">\(x\)</span> into <span class="math inline">\(n\)</span>;</li>
<li><span class="math inline">\(p_n\)</span> is the human pathogenic prevalence group of <span class="math inline">\(n\)</span>, as described below;</li>
<li><span class="math inline">\(k_n\)</span> is the taxonomic kingdom of <span class="math inline">\(n\)</span>, set as Bacteria = 1, Fungi = 2, Protozoa = 3, Archaea = 4, others = 5.</li>
</ul>
<p>The grouping into human pathogenic prevalence (<span class="math inline">\(p\)</span>) is based on experience from several microbiological laboratories in the Netherlands in conjunction with international reports on pathogen prevalence <sup>[7,18,19]</sup>. <strong>Group 1</strong> (most prevalent microorganisms) consists of all microorganisms where the taxonomic class is Gammaproteobacteria or where the taxonomic genus is <em>Enterococcus</em>, <em>Staphylococcus</em> or <em>Streptococcus</em>. This group consequently contains all common Gram-negative bacteria, such as <em>Pseudomonas</em> and <em>Legionella</em> and all species within the order Enterobacterales. <strong>Group 2</strong> consists of all microorganisms where the taxonomic phylum is Proteobacteria, Firmicutes, Actinobacteria or Sarcomastigophora, or where the taxonomic genus is <em>Absidia</em>, <em>Acremonium</em>, <em>Actinotignum</em>, <em>Alternaria</em>, <em>Anaerosalibacter</em>, <em>Apophysomyces</em>, <em>Arachnia</em>, <em>Aspergillus</em>, <em>Aureobacterium</em>, <em>Aureobasidium</em>, <em>Bacteroides</em>, <em>Basidiobolus</em>, <em>Beauveria</em>, <em>Blastocystis</em>, <em>Branhamella</em>, <em>Calymmatobacterium</em>, <em>Candida</em>, <em>Capnocytophaga</em>, <em>Catabacter</em>, <em>Chaetomium</em>, <em>Chryseobacterium</em>, <em>Chryseomonas</em>, <em>Chrysonilia</em>, <em>Cladophialophora</em>, <em>Cladosporium</em>, <em>Conidiobolus</em>, <em>Cryptococcus</em>, <em>Curvularia</em>, <em>Exophiala</em>, <em>Exserohilum</em>, <em>Flavobacterium</em>, <em>Fonsecaea</em>, <em>Fusarium</em>, <em>Fusobacterium</em>, <em>Hendersonula</em>, <em>Hypomyces</em>, <em>Koserella</em>, <em>Lelliottia</em>, <em>Leptosphaeria</em>, <em>Leptotrichia</em>, <em>Malassezia</em>, <em>Malbranchea</em>, <em>Mortierella</em>, <em>Mucor</em>, <em>Mycocentrospora</em>, <em>Mycoplasma</em>, <em>Nectria</em>, <em>Ochroconis</em>, <em>Oidiodendron</em>, <em>Phoma</em>, <em>Piedraia</em>, <em>Pithomyces</em>, <em>Pityrosporum</em>, <em>Prevotella</em>, <em>Pseudallescheria</em>, <em>Rhizomucor</em>, <em>Rhizopus</em>, <em>Rhodotorula</em>, <em>Scolecobasidium</em>, <em>Scopulariopsis</em>, <em>Scytalidium</em>, <em>Sporobolomyces</em>, <em>Stachybotrys</em>, <em>Stomatococcus</em>, <em>Treponema</em>, <em>Trichoderma</em>, <em>Trichophyton</em>, <em>Trichosporon</em>, <em>Tritirachium</em> or <em>Ureaplasma</em>. <strong>Group 3</strong> consists of all other microorganisms.</p>
<p>This will lead to the effect that e.g., <code>"E. coli"</code> will return the microbial ID of <em>Escherichia coli</em> (<span class="math inline">\(m = 0.688\)</span>, a highly prevalent microorganism found in humans) and not <em>Entamoeba coli</em> (<span class="math inline">\(m = 0.079\)</span>, a less prevalent microorganism in humans), although the latter would alphabetically come first. The matching score function is for users available as <code>mo_matching_score()</code>.</p>
<p>If any coercion rules are applied, a warning is printed to the console and scores can be reviewed by calling <code>mo_uncertainties()</code>, that prints all other matches with their matching scores. Users can furthermore control the coercion rules by setting the allow_uncertain argument in the <code>as.mo()</code> function. The following values or levels can be used:</p>
<ul>
<li><code>0</code>: no additional rules are applied;</li>
<li><code>1</code>: allow previously accepted (but now invalid) taxonomic names and minor spelling errors;</li>
<li><code>2</code>: allow all of 1, strip values between brackets, inverse the words of the input, strip off text elements from the end keeping at least two elements;</li>
<li><code>3</code>: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name;</li>
<li><code>TRUE</code> (default): equivalent to <code>2</code>;</li>
<li><code>FALSE</code>: equivalent to <code>0</code>.</li>
</ul>
<p>To support organisation specific microbial IDs, users can specify a custom reference <code>‘data.frame’</code>, by using <code>as.mo(..., reference_df = ...)</code>. This process can also be automated by users with the <code>set_mo_source()</code> function.</p>
<div id="properties-of-microorganisms" class="section level4" number="4.3.1.1">
<h4><span class="header-section-number">4.3.1.1</span> Properties of microorganisms</h4>
<p>The package contains functions to return a specific (taxonomic) property of a microorganism from the <code>microorganisms</code> data set (see Appendix A). Functions that start with <code>mo_*</code> can be used to retrieve the most recently defined taxonomic properties of any microorganism quickly and conveniently. These functions rely on the <code>as.mo()</code> function internally: <code>mo_name()</code>, <code>mo_fullname()</code>, <code>mo_shortname()</code>, <code>mo_subspecies()</code>, <code>mo_species()</code>, <code>mo_genus()</code>, <code>mo_family()</code>, <code>mo_order()</code>, <code>mo_class()</code>, <code>mo_phylum()</code>, <code>mo_kingdom()</code>, <code>mo_type()</code>, <code>mo_gramstain()</code>, <code>mo_ref()</code>, <code>mo_authors()</code>, <code>mo_year()</code>, <code>mo_rank()</code>, <code>mo_taxonomy()</code>, <code>mo_synonyms()</code>, <code>mo_info()</code> and <code>mo_url()</code>. Determination of the Gram stain, by using <code>mo_gramstain()</code>, is based on the taxonomic subkingdom and phylum. According to Cavalier-Smith <sup>[20]</sup>, who defined the subkingdoms Negibacteria and Posibacteria, only the following phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. Bacteria from these phyla are considered Gram-positive - all other bacteria are considered Gram-negative. Gram stains are only relevant for species within the kingdom of Bacteria. For species outside this kingdom, <code>mo_gramstain()</code> will return <code>NA</code>.</p>
</div>
</div>
<div id="working-with-antimicrobial-names-or-codes" class="section level3" number="4.3.2">
<h3><span class="header-section-number">4.3.2</span> Working with antimicrobial names or codes</h3>
<p>The <code>AMR</code> package includes the <code>antibiotics</code> data set, which comprises common laboratory information system codes, official names, ATC (Anatomical Therapeutic Chemical) codes, defined daily doses (DDD) and more than 5,000 trade names of 456 antimicrobial agents (see Appendix A). The ATC code system and the reference list for DDDs have been developed and made available by the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC) to standardise pharmaceutical classifications <sup>[21]</sup>. All agents in the <code>antibiotics</code> data set have a unique antimicrobial ID, which is based on abbreviations used by the European Antimicrobial Resistance Surveillance Network (EARS-Net), the largest publicly funded system for antimicrobial resistance surveillance in Europe <sup>[22]</sup>. Furthermore, the <code>AMR</code> package includes the antivirals data seta containing antiviral agents, which is also described in Appendix A.</p>
<div id="properties-of-antimicrobial-agents" class="section level4" number="4.3.2.1">
<h4><span class="header-section-number">4.3.2.1</span> Properties of antimicrobial agents</h4>
<p>It is a common task in microbiological data analyses (and other clinical or epidemiological fields) to work with different antimicrobial agents. The <code>AMR</code> package provides several functions to translate inputs such as ATC codes, abbreviations, or names in any direction. Using <code>as.ab()</code>, any input will be transformed to an antimicrobial ID of class <code>‘ab’</code>. Helper functions are available to get specific properties of antimicrobial IDs, such as <code>ab_name()</code> for getting the official name, <code>ab_atc()</code> for the ATC code, or <code>ab_cid()</code> for the CID (Compound ID) used by PubChem <sup>[23]</sup>. Trade names can be also used as input. For example, the input values “Amoxil,” “dispermox,” “amox” and “J01CA04” all return the ID of amoxicillin (AMX):</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="ch04-amr-r-package.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">as.ab</span>(<span class="st">&quot;Amoxicillin&quot;</span>)</span>
<span id="cb1-2"><a href="ch04-amr-r-package.html#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Class &lt;ab&gt;</span></span>
<span id="cb1-3"><a href="ch04-amr-r-package.html#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] AMX</span></span>
<span id="cb1-4"><a href="ch04-amr-r-package.html#cb1-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-5"><a href="ch04-amr-r-package.html#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">as.ab</span>(<span class="fu">c</span>(<span class="st">&quot;Amoxil&quot;</span>, <span class="st">&quot;dispermox&quot;</span>, <span class="st">&quot;amox&quot;</span>, <span class="st">&quot;J01CA04&quot;</span>))</span>
<span id="cb1-6"><a href="ch04-amr-r-package.html#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Class &lt;ab&gt;</span></span>
<span id="cb1-7"><a href="ch04-amr-r-package.html#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] AMX AMX AMX AMX</span></span>
<span id="cb1-8"><a href="ch04-amr-r-package.html#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="ch04-amr-r-package.html#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">ab_name</span>(<span class="st">&quot;Amoxil&quot;</span>)</span>
<span id="cb1-10"><a href="ch04-amr-r-package.html#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Amoxicillin&quot; </span></span>
<span id="cb1-11"><a href="ch04-amr-r-package.html#cb1-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-12"><a href="ch04-amr-r-package.html#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="fu">ab_atc</span>(<span class="st">&quot;amox&quot;</span>)</span>
<span id="cb1-13"><a href="ch04-amr-r-package.html#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;J01CA04&quot;</span></span>
<span id="cb1-14"><a href="ch04-amr-r-package.html#cb1-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-15"><a href="ch04-amr-r-package.html#cb1-15" aria-hidden="true" tabindex="-1"></a><span class="fu">ab_name</span>(<span class="st">&quot;J01CA04&quot;</span>)</span>
<span id="cb1-16"><a href="ch04-amr-r-package.html#cb1-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Amoxicillin&quot;</span></span></code></pre></div>
<p>If more than one antimicrobial agent is found in the input string, a warning with the additional findings is printed to the console.</p>
</div>
<div id="filtering-data-based-on-classes-of-antimicrobial-agents" class="section level4" number="4.3.2.2">
<h4><span class="header-section-number">4.3.2.2</span> Filtering data based on classes of antimicrobial agents</h4>
<p>The application of the ATC classification system also enables grouping of antimicrobial agents for data analyses. Data sets with microbial isolates can be filtered on isolates with specific results for tested antimicrobial agents in a specific antimicrobial class. For example, using <code>filter_carbapenems(result = "R")</code> returns data of all isolates with tested resistance to any of the 14 available antimicrobial agents in in the group of carbapenems according to the <code>antibiotics</code> data set.</p>
</div>
</div>
<div id="working-with-antimicrobial-susceptibility-test-results" class="section level3" number="4.3.3">
<h3><span class="header-section-number">4.3.3</span> Working with antimicrobial susceptibility test results</h3>
<p>Minimal inhibitory concentrations (MIC) are susceptibility test results measured by microbiological laboratory equipment to determine at which minimum antimicrobial drug concentration 99.9% of a microorganism is inhibited in growth. These concentrations are often capped at a minimum and maximum, for example ≤0.02 µg/ml and ≥32 µg/ml, respectively. The <code>‘mic’</code> class, an ordered <code>‘factor’</code> containing valid MIC values, keeps these operators while still ordering all possible outcomes correctly so that e.g., “&lt;=0.02” will be considered lower than “0.04.”</p>
<p>Another susceptibility testing method is the use of drug diffusion disks, which are small tablets containing a specified concentration of an antimicrobial agent. These disks are applied onto a solid growth medium or a specific agar plate. After 24 hours of incubation, the diameter of the growth inhibition around a disk can be measured in millimetres with a ruler. The <code>‘disk’</code> class can be used to clean these kinds of measurements, since they should always be valid numeric values between 6 and 50. The supported minima and maxima of valid values for both classes, <code>‘mic’</code> and <code>‘disk’</code>, are displayed in Table 4.</p>
<p class="tbl-caption">
Table 4. Antimicrobial susceptibility test classes.
</p>
<p><img src="images/04-t04.jpg" width="100%" style="display: block; margin: auto;" /></p>
<p>The higher the MIC or the smaller the growth inhibition diameter, the more active substance of an antimicrobial agent is needed to inhibit cell growth, i.e. the higher the antimicrobial resistance against the tested antimicrobial agent. At high MICs and small diameters, guidelines interpret the microorganism as “resistant” (R) to the tested antimicrobial agent. At low MICs and wide diameters, guidelines interpret the microorganism as “susceptible” (S) to the tested antimicrobial agent. In between, the microorganism is classified as “susceptible, increased exposure” (I). For these three interpretations the <code>‘rsi’</code> class has been developed. When using <code>as.rsi()</code> on MIC values (of class <code>‘mic’</code>) or disk diffusion diameters (of class <code>‘disk’</code>), the values will be interpreted according to the guidelines from the CLSI or EUCAST (all guidelines between 2011 and 2020 are included in the <code>AMR</code> package) <sup>[24,25]</sup>. Guidelines can be changed by setting the guidelines argument.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="ch04-amr-r-package.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Low MIC value</span></span>
<span id="cb2-2"><a href="ch04-amr-r-package.html#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">as.rsi</span>(<span class="fu">as.mic</span>(<span class="dv">2</span>), <span class="st">&quot;E. coli&quot;</span>, <span class="st">&quot;ampicillin&quot;</span>, <span class="at">guideline =</span> <span class="st">&quot;EUCAST 2020&quot;</span>)</span>
<span id="cb2-3"><a href="ch04-amr-r-package.html#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Class &lt;rsi&gt;</span></span>
<span id="cb2-4"><a href="ch04-amr-r-package.html#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] S</span></span>
<span id="cb2-5"><a href="ch04-amr-r-package.html#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-6"><a href="ch04-amr-r-package.html#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="co"># High MIC value</span></span>
<span id="cb2-7"><a href="ch04-amr-r-package.html#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="fu">as.rsi</span>(<span class="fu">as.mic</span>(<span class="dv">32</span>), <span class="st">&quot;E. coli&quot;</span>, <span class="st">&quot;ampicillin&quot;</span>, <span class="at">guideline =</span> <span class="st">&quot;EUCAST 2020&quot;</span>)</span>
<span id="cb2-8"><a href="ch04-amr-r-package.html#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Class &lt;rsi&gt;</span></span>
<span id="cb2-9"><a href="ch04-amr-r-package.html#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] R</span></span></code></pre></div>
<p>When using the <code>as.rsi()</code> function on existing antimicrobial interpretations, it tries to coerce the input to the values “R,” “S” or “I.” These values can in turn be used to calculate the proportion of antimicrobial resistance.</p>
</div>
<div id="interpretative-rules-by-eucast" class="section level3" number="4.3.4">
<h3><span class="header-section-number">4.3.4</span> Interpretative rules by EUCAST</h3>
<p>Next to supplying guidelines to interpret raw MIC values, EUCAST has developed a set of expert rules to assist clinical microbiologists in the interpretation and reporting of antimicrobial susceptibility tests <sup>[5]</sup>. The rules comprise assistance on intrinsic resistance, exceptional phenotypes, and interpretive rules. The <code>AMR</code> package covers intrinsic resistant and interpretive rules for data transformation and standardisation purposes. The first prevents false susceptibility reporting by providing a list of organisms with known intrinsic resistance to specific antimicrobial agents (e.g., cephalosporin resistance of all enterococci). Interpretative rules apply inference from established resistance mechanisms <sup>[26-29]</sup>. Both groups of rules are based on classic IF THEN statements (e.g., IF Enterococcus spp. resistant to ampicillin THEN also report as resistant to imipenem). Some rules provide assistance for further actions when certain resistance has been detected, i.e., performing additional testing of the isolated microorganism. The <code>AMR</code> package function <code>eucast_rules()</code> can apply all EUCAST rules that do not rely on additional clinical information, such as additional information on patients’ diagnoses. Table 2 and 3 highlight the transformation for the reporting of AMX = S in patient_id = 000003 to the correct report according to EUCAST rules of AMX = R. Of note, however, EUCAST rules overwrite original data to correct for the difference in how antimicrobial agents affect the tested microorganism in vitro (in the laboratory) and in vivo (in the human body). This requires users to closely collaborate with the data source provider to ensure correct versioning, backward compatibility, reproducibility, and taking into account specific local regulation for resistance reporting. Typical scenarios where changes to the original data points apply include in vitro test results indicating susceptibility when resistance in vivo is known. The changes are based on scientific consensus to ensure reliable high-quality reporting of antimicrobial susceptibility results. All changes to the data are printed to the console and can also be reviewed in detail by setting the argument <code>eucast_rules(..., verbose = TRUE)</code>.</p>
<p>EUCAST rules are subject to regular updates which are implemented into the <code>AMR</code> package by the <code>AMR</code> maintenance team shortly after publication. The <code>eucast_rules()</code> function supports versioning of the rules. The arguments version_breakpoints and version_expertrules can be set to current or previous versions. By default, the <code>eucast_rules()</code> function uses the latest implemented version.</p>
</div>
<div id="working-with-defined-daily-doses-ddd" class="section level3" number="4.3.5">
<h3><span class="header-section-number">4.3.5</span> Working with defined daily doses (DDD)</h3>
<p>DDDs are essential for standardising antimicrobial consumption analysis, for inter-institutional or international comparison. The official DDDs are published by the WHOCC <sup>[36]</sup>. Updates to the official publication are monitored by the <code>AMR</code> maintenance team and implemented in the <code>antibiotics</code> data set included in the <code>AMR</code> package. Other metrics exist such as the recommended daily dose (RDD) or the prescribed daily dose (PDD). However, DDDs are the only metric that is independent of a patient’s disease and therapeutic choices and thus suitable for the <code>AMR</code> package.</p>
<p>Functions from the <code>atc_online_*()</code> family take any text as input that can be coerced with <code>as.ab()</code> (i.e., to class <code>‘ab’</code>). Next, the functions access the WHOCC online registry <sup>[30]</sup> (internet connection required) and download the property defined in the arguments (e.g., administration = “O” or administration = “P” for oral or parenteral administration and property = “ddd” or property = “groups” to get DDD or the group of the selected antimicrobial defined by its ATC code).</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="ch04-amr-r-package.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">atc_online_ddd</span>(<span class="st">&quot;amoxicillin&quot;</span>, <span class="at">administration =</span> <span class="st">&quot;O&quot;</span>)</span>
<span id="cb3-2"><a href="ch04-amr-r-package.html#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 1.5</span></span>
<span id="cb3-3"><a href="ch04-amr-r-package.html#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="ch04-amr-r-package.html#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="fu">atc_online_groups</span>(<span class="st">&quot;amoxicillin&quot;</span>)</span>
<span id="cb3-5"><a href="ch04-amr-r-package.html#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;ANTIINFECTIVES FOR SYSTEMIC USE&quot;</span></span>
<span id="cb3-6"><a href="ch04-amr-r-package.html#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [2] &quot;ANTIBACTERIALS FOR SYSTEMIC USE&quot;</span></span>
<span id="cb3-7"><a href="ch04-amr-r-package.html#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [3] &quot;BETA-LACTAM ANTIBACTERIALS, PENICILLINS&quot;</span></span>
<span id="cb3-8"><a href="ch04-amr-r-package.html#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [4] &quot;Penicillins with extended spectrum&quot;</span></span></code></pre></div>
</div>
</div>
<div id="enhancing-antimicrobial-resistance-data" class="section level2" number="4.4">
<h2><span class="header-section-number">4.4</span> Enhancing antimicrobial resistance data</h2>
<div id="determining-first-isolates" class="section level3" number="4.4.1">
<h3><span class="header-section-number">4.4.1</span> Determining first isolates</h3>
<p>Determining antimicrobial resistance or susceptibility can be done for a single agent (mono- therapy) or multiple agents (combination therapy). The calculation of antimicrobial resistance statistics is dependent on two prerequisites: the data should only comprise the first isolates and a minimum required number of 30 isolates should be met for every stratum in further analysis <sup>[6]</sup>.</p>
<p>An isolate is a microorganism strain cultivated on specified growth media in a laboratory, so its phenotype can be determined. First isolates are isolates of any species found first in a patient per episode, regardless of the body site or the type of specimen (such as blood or urine) <sup>[6]</sup>. The selection on first isolates (using function <code>first_isolate()</code>) is important to prevent selection bias, as it would lead to overestimated or underestimated resistance to an antimicrobial agent. For example, if a patient is admitted with a multi-drug resistant microorganism and that microorganism is found in five different blood cultures the following week, it would overestimate resistance if all isolates were to be included in the analysis.</p>
<p>The episode in days can be set with the argument episode_days, which defaults to 365 as suggested by the CLSI guideline <sup>[6]</sup>.</p>
</div>
<div id="determining-multi-drug-resistant-organisms-mdro" class="section level3" number="4.4.2">
<h3><span class="header-section-number">4.4.2</span> Determining multi-drug resistant organisms (MDRO)</h3>
<p>Definitions of multi-drug resistant organisms (MDRO) are regulated by national and international expert groups and differ between nations. The <code>AMR</code> package provides the functionality to quickly identify MDROs in a data set using the <code>mdro()</code> function. Guidelines can be set with the argument guideline. At default, it applies the guideline as proposed by Magiorakos <em>et al.</em> <sup>[31]</sup>. Their work describes the definitions for bacteria being <code>‘MDR’</code> (multi-drug-resistant), <code>‘XDR’</code> (extensively drug-resistant) or <code>‘PDR’</code> (pan-drug-resistant). These definitions are widely adopted <sup>[32]</sup> and known in the field of medical microbiology.</p>
<p>Other guidelines currently supported are the international EUCAST guideline (guideline = “EUCAST” <sup>[33]</sup>), the international WHO guideline on the management of drug-resistant tuberculosis (guideline = “TB” <sup>[34]</sup>), and the national guidelines of The Netherlands (guideline = “NL” <sup>[35]</sup>), and Germany (guideline = “DE” <sup>[36]</sup>).</p>
<p>Some guidelines require a minimum availability of tested antimicrobial agents per isolate. This is needed to prevent false-negatives, since no reliable determination can be performed on only a few test results. This required minimum defaults to 50%, but can be set by the user with the pct_minimum_classes. Isolates that do not meet this requirement will be skipped for determination and will return <code>NA</code> (not applicable), with an informative warning printed to the console.</p>
<p>The rules are applied per row of the data. The <code>mdro()</code> function automatically identifies the variables containing the microorganism codes and antimicrobial agents based on the <code>guess_ab_col()</code> function. Following the guideline set by the user, it analyses the specific antimicrobial resistance of a microorganism and flags that microorganism accordingly. The outcome is demonstrated in Table 5, where the first row is an MDRO according to the Dutch guidelines <sup>[35]</sup>.</p>
<p class="tbl-caption">
Table 5. Example of a multi-drug resistant organism (MDRO) in a data set identified by applying Dutch guidelines.
</p>
<p><img src="images/04-t05.jpg" width="100%" style="display: block; margin: auto;" /></p>
<div id="multi-drug-resistant-tuberculosis" class="section level4" number="4.4.2.1">
<h4><span class="header-section-number">4.4.2.1</span> Multi-drug resistant tuberculosis</h4>
<p>Tuberculosis is a major threat to global health caused by Mycobacterium tuberculosis (MTB) and is one of the top ten causes of death worldwide <sup>[37]</sup>. Exceptional antimicrobial resistance in MTB is therefore of special interest. To this end, the international WHO guideline for the classification of drug resistance in MTB <sup>[34]</sup> is included in the <code>AMR</code> package. The <code>mdr_tb()</code> function is a convenient wrapper around <code>mdro(..., guideline = "TB")</code>, which returns an other ordered <code>‘factor’</code> than other <code>mdro()</code> functions. The output will contain the <code>‘factor’</code> levels <code>‘Negative’</code> &lt; <code>‘Mono-resistant’</code> &lt; <code>‘Poly-resistant’</code> &lt; <code>‘Multi-drug-resistant’</code> &lt; <code>‘Extensively drug-resistant’</code>, following the WHO guideline.</p>
</div>
</div>
</div>
<div id="analysing-antimicrobial-resistance-data" class="section level2" number="4.5">
<h2><span class="header-section-number">4.5</span> Analysing antimicrobial resistance data</h2>
<div id="calculation-of-antimicrobial-resistance" class="section level3" number="4.5.1">
<h3><span class="header-section-number">4.5.1</span> Calculation of antimicrobial resistance</h3>
<p>The <code>AMR</code> package contains several functions for fast and simple resistance calculations of bacterial or fungal isolates. A minimum number of available isolates is needed for the reliability of the outcome. The CLSI guideline suggests a minimum of 30 available first isolates irrespective of the type of statistical analysis <sup>[6]</sup>. Therefore, this number is used as the default setting for any function in the package that calculates antimicrobial resistance or susceptibility, which can be changed with the minimum argument in all applicable functions.</p>
<div id="counts" class="section level4" number="4.5.1.1">
<h4><span class="header-section-number">4.5.1.1</span> Counts</h4>
<p>The <code>AMR</code> package relies on the concept of tidy data <sup>[38]</sup>, although not strictly following its rules (one row per test rather than one row per observation). Function names to calculate the number of available isolates follow these general resistance interpretation standards with <code>count_S()</code>, <code>count_I()</code>, and <code>count_R()</code> respectively. Combinations of antimicrobial resistance interpretations can be counted with <code>count_SI()</code> and <code>count_IR()</code>. All these functions take a vector of interpretations of the class <code>‘rsi’</code> (as discussed above) or are internally transformed with <code>as.rsi()</code>. The returned value is the sum of the respective interpretation in the selected test column. All <code>count_*()</code> functions support quasi-quotation with pipes, grouped variables, and can be used with <code>dplyr::summarise()</code> <sup>[39]</sup>.</p>
</div>
<div id="proportions" class="section level4" number="4.5.1.2">
<h4><span class="header-section-number">4.5.1.2</span> Proportions</h4>
<p>Calculation of antimicrobial resistance is carried out by counting the number of first resistant isolates (interpretation of “R”) and dividing it by the number of all first isolates, see Equation 2. This is implemented in the <code>proportion_R()</code> function. To calculate antimicrobial susceptibility, the number of susceptible first isolates (interpretation of “S” and “I”) has to be counted and divided by the number of all first isolates, which is implemented in the <code>proportion_SI()</code> function. For convenience, the <code>resistance()</code> function is an alias of the <code>proportion_R()</code> function, and the <code>susceptibility()</code> function is an alias of the <code>proportion_SI()</code> function.</p>
<p>The functions <code>proportion_R()</code>, <code>proportion_IR()</code>, <code>proportion_I()</code>, <code>proportion_SI()</code>, and <code>proportion_S()</code> follow the same logic as the <code>count_*()</code> functions and all return a vector of class <code>‘double’</code> with a value between 0 and 1. The argument <code>minimum</code> defines the minimal allowed number of available (tested) isolates (default: <code>minimum</code> = 30). Any number below the set minimum will return <code>NA</code> with a warning.</p>
<p>For calculating the proportion (<span class="math inline">\(P\)</span>) of antimicrobial resistance or susceptibility to one antimicrobial agent, the following equation is used:</p>
<p><span class="math display">\[P_{(x, o)} = \frac{\sum_{i=1}^k [x_i \in o]}{\sum_{i=1}^k [x_i \in \{R,S,I\}]}\]</span></p>
<p>where <span class="math inline">\(P\)</span> is the proportion of outcome <span class="math inline">\(o\)</span> (that is either “R,” “S,” “I,” or a combination of two of them), where <span class="math inline">\(x\)</span> is a character vector of length <span class="math inline">\(k\)</span> only consisting of values “R,” “S,” or “I” and <span class="math inline">\([x_i \in o]\)</span> is the indicator function, returning <span class="math inline">\(1\)</span> if the indicator function is true and <span class="math inline">\(0\)</span> otherwise. The denominator must include the collection <span class="math inline">\(\{R,S,I\}\)</span> so that ’<code>wrong’</code> elements in <span class="math inline">\(x\)</span> (i.e., elements not being “R,” “S,” or “I”) will not be counted. Thus, the theoretical antimicrobial susceptibility of the vector <span class="math inline">\(x = \{S,S,I,R,R\}\)</span> is:</p>
<p><span class="math display">\[P_{(x, o = \{S, I\})} = \frac{3}{5} = 0.6\]</span></p>
<p>For the proportion of empiric susceptibility (<span class="math inline">\(s\)</span>) for more than one antimicrobial agent, the calculation can be carried out in two ways (Table 6).</p>
<p class="tbl-caption">
Table 6. Example calculation for determining empiric susceptibility (%SI) for more than one antimicrobial agent.
</p>
<p><img src="images/04-t06.jpg" width="100%" style="display: block; margin: auto;" /></p>
<p>The first method is to count the total number of first isolates where at least one agent was tested as “S” or “I” and divide it by the number of first isolates tested where any of the agents was tested (Equation 4). This method will be used when setting <code>only_all_tested = FALSE</code> in the <code>susceptibility()</code> function:</p>
<p><span class="math display">\[s_{(x, y)} = \frac{\sum_{i=1}^k [x_i \in \{S,I\} \lor y_i \in \{S,I\}]}{\sum_{i=1}^k [x_i \in \{R,S,I\} \lor y_i \in \{R,S,I\}]}\]</span></p>
<p>where <span class="math inline">\(x\)</span> is a character vector only consisting of values “R,” “S,” or “I” (i.e., ’<code>agent A’</code>) and <span class="math inline">\(y\)</span> is another character vector only consisting of values “R,” “S,” or “I” (i.e., ’<code>agent B’</code>).</p>
<p>The second method is to count the total number of first isolates where at least one agent was tested as “S” or “I” and where all agents were tested divided by the number of first isolates tested where all of the agents were tested (Equation 5). This method will be used when setting <code>only_all_tested = TRUE</code> in the <code>susceptibility()</code> function:</p>
<p><span class="math display">\[s&#39;_{(x, y)} = \frac{\sum_{i=1}^k [(x_i \in \{S,I\} \lor y_i \in \{S,I\}) \, \land x_i \in \{R,S,I\} \land y_i \in \{R,S,I\}]}{\sum_{i=1}^k [x_i \in \{R,S,I\} \land y_i \in \{R,S,I\}]}\]</span></p>
<p>Based on Equation 2, the overall resistance and susceptibility of antimicrobial agents like gentamicin (GEN) and amoxicillin (AMX) can be calculated using the following syntax. The <code>example_isolates</code> data set is an example data set included in the <code>AMR</code> package, see Appendix A. The <code>n_rsi()</code> function is analogous to the <code>n()</code> function of the <code>dplyr</code> package. It counts the number of available isolates, but only includes observations with valid antimicrobial results (i.e., “R,” “S,” or “I”):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="ch04-amr-r-package.html#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">&quot;dplyr&quot;</span>)</span>
<span id="cb4-2"><a href="ch04-amr-r-package.html#cb4-2" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%&gt;%</span></span>
<span id="cb4-3"><a href="ch04-amr-r-package.html#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">r_gen =</span> <span class="fu">proportion_R</span>(GEN),</span>
<span id="cb4-4"><a href="ch04-amr-r-package.html#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="at">r_amx =</span> <span class="fu">proportion_R</span>(AMX),</span>
<span id="cb4-5"><a href="ch04-amr-r-package.html#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="at">n_gen =</span> <span class="fu">n_rsi</span>(GEN),</span>
<span id="cb4-6"><a href="ch04-amr-r-package.html#cb4-6" aria-hidden="true" tabindex="-1"></a> <span class="at">n_amx =</span> <span class="fu">n_rsi</span>(AMX),</span>
<span id="cb4-7"><a href="ch04-amr-r-package.html#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="at">n_total =</span> <span class="fu">n</span>())</span>
<span id="cb4-8"><a href="ch04-amr-r-package.html#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; r_gen r_amx n_gen n_amx n_total</span></span>
<span id="cb4-9"><a href="ch04-amr-r-package.html#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 0.2458221 0.5955556 1855 1350 2000</span></span></code></pre></div>
<p>This output reads: the resistance to gentamicin of all isolates in the <code>example_isolates</code> data set is <span class="math inline">\(P{(x = GEN, o = \{R\})} = 24.6\%\)</span>, based on <span class="math inline">\(1855\)</span> out of <span class="math inline">\(2000\)</span> available isolates. This means that the susceptibility is <span class="math inline">\(P{(x = GEN, o = \{S,I\})} = 75.4\%\)</span>. The susceptibility to amoxicillin is <span class="math inline">\(P{(x = AMX, o = \{S,I\})} = 40.4\%\)</span> based on <span class="math inline">\(1350\)</span> isolates.</p>
<p>To calculate the effect of combination therapy, i.e., treating patients with multiple agents at the same time, all <code>proportion_*()</code> functions can handle multiple variables as arguments as defined in Equation 4 and 5. For example, to calculate the empiric susceptibility of a combination therapy comprising gentamicin (GEN) and amoxicillin (AMX):</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="ch04-amr-r-package.html#cb5-1" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%&gt;%</span></span>
<span id="cb5-2"><a href="ch04-amr-r-package.html#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">si_gen_amx =</span> <span class="fu">proportion_SI</span>(GEN, AMX),</span>
<span id="cb5-3"><a href="ch04-amr-r-package.html#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="at">n_gen_amx =</span> <span class="fu">n_rsi</span>(GEN, AMX),</span>
<span id="cb5-4"><a href="ch04-amr-r-package.html#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="at">n_total =</span> <span class="fu">n</span>())</span>
<span id="cb5-5"><a href="ch04-amr-r-package.html#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; si_gen_amx n_gen_amx n_total</span></span>
<span id="cb5-6"><a href="ch04-amr-r-package.html#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 0.931843 1921 2000</span></span></code></pre></div>
<p>This leads to the conclusion that combining gentamicin with amoxicillin would cover <span class="math inline">\(s{(x = GEN, y = AMX)} = 93.2\%\)</span> based on <span class="math inline">\(1921\)</span> out of <span class="math inline">\(2000\)</span> available isolates, which is <span class="math inline">\(17.8\%\)</span> more than when treating with gentamicin alone (<span class="math inline">\(P{(x = GEN, o = \{S,I\})} = 75.4\%\)</span>). With these functions, exact calculations can be done to evaluate the empiric success of treating infections with one or more antimicrobial agents.</p>
</div>
</div>
</div>
<div id="design-decisions" class="section level2" number="4.6">
<h2><span class="header-section-number">4.6</span> Design decisions</h2>
<p>The <code>AMR</code> package follows the rationale of tidyverse packages as authored by Wickham <em>et al.</em> <sup>[40]</sup>. Most functions take a <code>‘data.frame’</code> or <code>‘tibble’</code> as input, support piping (%&gt;%) operations, can work with quasi-quotations, and can be integrated into <code>dplyr</code> workflows, such as <code>mutate()</code> to create new variables and <code>group_by()</code> to group by variables. Although the <code>AMR</code> package integrates well into tidyverse workflows, it can also be used with base <code>R</code>only. To this extent, the <code>AMR</code> package was developed to be independent of any other <code>R</code>package to ensure and maintain sustainability.</p>
<p>The <code>AMR</code> package supports multiple languages. Currently supported languages are English, Dutch, French, German, Italian, Portuguese, and Spanish. The system language will be used if the language is supported but can be overwritten with <code>options(AMR_locale = ...)</code>. Multi-language support affects language-dependent output of functions such as <code>mo_name()</code>, <code>mo_gramstain()</code>, <code>mo_type()</code>, and <code>ab_name()</code>.</p>
<p>The <code>AMR</code> package uses S3 classes, object oriented (OO) systems available in R. They allow different types of output based on the user input. The <code>AMR</code> package introduces 5 S3 classes (<code>‘mo’</code>, <code>‘ab’</code>, <code>‘rsi’</code>, <code>‘mic’</code>, and <code>‘disk’</code>) to increase the convenience when working with antimicrobial susceptibility data.</p>
</div>
<div id="reproducible-example" class="section level2" number="4.7">
<h2><span class="header-section-number">4.7</span> Reproducible example</h2>
<p>We consider the problem of working with antimicrobial resistance data from three different hospitals between 2011-01-01 and 2020-01-01. After loading the <code>AMR</code> package and additional tidyverse packages to allow transformation and plotting, we load the <code>example_isolates</code>_unclean example data from the <code>AMR</code> package into the global environment and assign it a new name.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="ch04-amr-r-package.html#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">&quot;dplyr&quot;</span>)</span>
<span id="cb6-2"><a href="ch04-amr-r-package.html#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">&quot;tidyr&quot;</span>)</span>
<span id="cb6-3"><a href="ch04-amr-r-package.html#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">&quot;AMR&quot;</span>)</span>
<span id="cb6-4"><a href="ch04-amr-r-package.html#cb6-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-5"><a href="ch04-amr-r-package.html#cb6-5" aria-hidden="true" tabindex="-1"></a><span class="fu">options</span>(<span class="at">AMR_locale =</span> <span class="st">&quot;en&quot;</span>)</span>
<span id="cb6-6"><a href="ch04-amr-r-package.html#cb6-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-7"><a href="ch04-amr-r-package.html#cb6-7" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> example_isolates_unclean</span>
<span id="cb6-8"><a href="ch04-amr-r-package.html#cb6-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-9"><a href="ch04-amr-r-package.html#cb6-9" aria-hidden="true" tabindex="-1"></a><span class="fu">glimpse</span>(data)</span>
<span id="cb6-10"><a href="ch04-amr-r-package.html#cb6-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Rows: 3,000</span></span>
<span id="cb6-11"><a href="ch04-amr-r-package.html#cb6-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Columns: 8</span></span>
<span id="cb6-12"><a href="ch04-amr-r-package.html#cb6-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ patient_id &lt;chr&gt; &quot;J3&quot;, &quot;R7&quot;, &quot;P3&quot;, &quot;P10&quot;, &quot;B7&quot;, &quot;W3&quot;, &quot;J8&quot;, &quot;M3&quot;,…</span></span>
<span id="cb6-13"><a href="ch04-amr-r-package.html#cb6-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ hospital &lt;chr&gt; &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;</span></span>
<span id="cb6-14"><a href="ch04-amr-r-package.html#cb6-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ date &lt;date&gt; 2012-11-21, 2018-04-03, 2014-09-19, 2015-12-10,…</span></span>
<span id="cb6-15"><a href="ch04-amr-r-package.html#cb6-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ bacteria &lt;chr&gt; &quot;E. coli&quot;, &quot;K. pneumoniae&quot;, &quot;E. coli&quot;, &quot;E. coli&quot;</span></span>
<span id="cb6-16"><a href="ch04-amr-r-package.html#cb6-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ AMX &lt;chr&gt; &quot;R&quot;, &quot;R&quot;, &quot;R&quot;, &quot;S&quot;, &quot;S&quot;, &quot;R&quot;, &quot;R&quot;, &quot;R&quot;, &quot;S&quot;, &quot;S&quot;</span></span>
<span id="cb6-17"><a href="ch04-amr-r-package.html#cb6-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ AMC &lt;chr&gt; &quot;I&quot;, &quot;I&quot;, &quot;S&quot;, &quot;I&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;</span></span>
<span id="cb6-18"><a href="ch04-amr-r-package.html#cb6-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ CIP &lt;chr&gt; &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;R&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;</span></span>
<span id="cb6-19"><a href="ch04-amr-r-package.html#cb6-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ GEN &lt;chr&gt; &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;, &quot;S&quot;</span></span>
<span id="cb6-20"><a href="ch04-amr-r-package.html#cb6-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-21"><a href="ch04-amr-r-package.html#cb6-21" aria-hidden="true" tabindex="-1"></a><span class="fu">unique</span>(data<span class="sc">$</span>hospital)</span>
<span id="cb6-22"><a href="ch04-amr-r-package.html#cb6-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;A&quot; &quot;B&quot; &quot;C&quot;</span></span>
<span id="cb6-23"><a href="ch04-amr-r-package.html#cb6-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-24"><a href="ch04-amr-r-package.html#cb6-24" aria-hidden="true" tabindex="-1"></a><span class="fu">unique</span>(data<span class="sc">$</span>bacteria)</span>
<span id="cb6-25"><a href="ch04-amr-r-package.html#cb6-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;E. coli&quot; &quot;K. pneumoniae&quot; </span></span>
<span id="cb6-26"><a href="ch04-amr-r-package.html#cb6-26" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [3] &quot;S. aureus&quot; &quot;S. pneumoniae&quot; </span></span>
<span id="cb6-27"><a href="ch04-amr-r-package.html#cb6-27" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [5] &quot;klepne&quot; &quot;strpne&quot; </span></span>
<span id="cb6-28"><a href="ch04-amr-r-package.html#cb6-28" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [7] &quot;esccol&quot; &quot;staaur&quot; </span></span>
<span id="cb6-29"><a href="ch04-amr-r-package.html#cb6-29" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [9] &quot;Escherichia coli&quot; &quot;Staphylococcus aureus&quot; </span></span>
<span id="cb6-30"><a href="ch04-amr-r-package.html#cb6-30" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [11] &quot;Streptococcus pneumoniae&quot; &quot;Klebsiella pneumoniae&quot; </span></span>
<span id="cb6-31"><a href="ch04-amr-r-package.html#cb6-31" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-32"><a href="ch04-amr-r-package.html#cb6-32" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb6-33"><a href="ch04-amr-r-package.html#cb6-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(bacteria)</span>
<span id="cb6-34"><a href="ch04-amr-r-package.html#cb6-34" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; bacteria n</span></span>
<span id="cb6-35"><a href="ch04-amr-r-package.html#cb6-35" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 E. coli 494</span></span>
<span id="cb6-36"><a href="ch04-amr-r-package.html#cb6-36" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 esccol 508</span></span>
<span id="cb6-37"><a href="ch04-amr-r-package.html#cb6-37" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 Escherichia coli 516</span></span>
<span id="cb6-38"><a href="ch04-amr-r-package.html#cb6-38" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4 K. pneumoniae 108</span></span>
<span id="cb6-39"><a href="ch04-amr-r-package.html#cb6-39" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 5 Klebsiella pneumoniae 102</span></span>
<span id="cb6-40"><a href="ch04-amr-r-package.html#cb6-40" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 6 klepne 116</span></span>
<span id="cb6-41"><a href="ch04-amr-r-package.html#cb6-41" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 7 S. aureus 247</span></span>
<span id="cb6-42"><a href="ch04-amr-r-package.html#cb6-42" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 8 S. pneumoniae 151</span></span>
<span id="cb6-43"><a href="ch04-amr-r-package.html#cb6-43" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 9 staaur 240</span></span>
<span id="cb6-44"><a href="ch04-amr-r-package.html#cb6-44" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 10 Staphylococcus aureus 243</span></span>
<span id="cb6-45"><a href="ch04-amr-r-package.html#cb6-45" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 11 Streptococcus pneumoniae 139</span></span>
<span id="cb6-46"><a href="ch04-amr-r-package.html#cb6-46" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 12 strpne 136</span></span></code></pre></div>
<p>The data contains 3,000 observations of 8 variables from 3 hospitals. The “bacteria” variable comprises 12 unique elements. However, they appear to encode the same information in different formats (’<code>E. coli’</code>, ’<code>K. pneumoniae’</code>, ’<code>S. aureus’</code>, ’<code>S. pneumoniae’</code>, ’<code>klepne’</code>, ’<code>strpne’</code>, ’<code>esccol’</code>, ’<code>staaur’</code>, ’<code>Escherichia coli’</code>, ’<code>Staphylococcus aureus’</code>, ’<code>Streptococcus pneumoniae’</code>, ’<code>Klebsiella pneumoniae’</code>). We can use the <code>as.mo()</code> function to standardise the bacterial codes and add a variable with the official scientific name. The correct transformation of the bacterial codes can be reviewed by calling the <code>mo_uncertainties()</code> function.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="ch04-amr-r-package.html#cb7-1" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb7-2"><a href="ch04-amr-r-package.html#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">bacteria =</span> <span class="fu">as.mo</span>(bacteria),</span>
<span id="cb7-3"><a href="ch04-amr-r-package.html#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="at">bacteria_name =</span> <span class="fu">mo_name</span>(bacteria))</span>
<span id="cb7-4"><a href="ch04-amr-r-package.html#cb7-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-5"><a href="ch04-amr-r-package.html#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="fu">mo_uncertainties</span>()</span>
<span id="cb7-6"><a href="ch04-amr-r-package.html#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; &quot;E. coli&quot; -&gt; Escherichia coli (B_ESCHR_COLI, matching score =</span></span>
<span id="cb7-7"><a href="ch04-amr-r-package.html#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 0.688)</span></span>
<span id="cb7-8"><a href="ch04-amr-r-package.html#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Also matched: Entamoeba coli (0.079)</span></span>
<span id="cb7-9"><a href="ch04-amr-r-package.html#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; &quot;K. pneumoniae&quot; -&gt; Klebsiella pneumoniae (B_KLBSL_PNMN, matching</span></span>
<span id="cb7-10"><a href="ch04-amr-r-package.html#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; score = 0.786)</span></span>
<span id="cb7-11"><a href="ch04-amr-r-package.html#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Also matched: Klebsiella pneumoniae ozaenae</span></span>
<span id="cb7-12"><a href="ch04-amr-r-package.html#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; (0.707), Klebsiella pneumoniae rhinoscleromatis</span></span>
<span id="cb7-13"><a href="ch04-amr-r-package.html#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; (0.658)</span></span>
<span id="cb7-14"><a href="ch04-amr-r-package.html#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb7-15"><a href="ch04-amr-r-package.html#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; &quot;S. aureus&quot; -&gt; Staphylococcus aureus (B_STPHY_AURS, matching score</span></span>
<span id="cb7-16"><a href="ch04-amr-r-package.html#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; = 0.690)</span></span>
<span id="cb7-17"><a href="ch04-amr-r-package.html#cb7-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Also matched: Staphylococcus aureus anaerobius</span></span>
<span id="cb7-18"><a href="ch04-amr-r-package.html#cb7-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; (0.625), Streptomyces aureus (0.355), Stentor aureus</span></span>
<span id="cb7-19"><a href="ch04-amr-r-package.html#cb7-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; (0.052)</span></span>
<span id="cb7-20"><a href="ch04-amr-r-package.html#cb7-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-21"><a href="ch04-amr-r-package.html#cb7-21" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb7-22"><a href="ch04-amr-r-package.html#cb7-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(bacteria, bacteria_name)</span>
<span id="cb7-23"><a href="ch04-amr-r-package.html#cb7-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; bacteria bacteria_name n</span></span>
<span id="cb7-24"><a href="ch04-amr-r-package.html#cb7-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 B_ESCHR_COLI Escherichia coli 1518</span></span>
<span id="cb7-25"><a href="ch04-amr-r-package.html#cb7-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 B_KLBSL_PNMN Klebsiella pneumoniae 326</span></span>
<span id="cb7-26"><a href="ch04-amr-r-package.html#cb7-26" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 B_STPHY_AURS Staphylococcus aureus 730</span></span>
<span id="cb7-27"><a href="ch04-amr-r-package.html#cb7-27" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4 B_STRPT_PNMN Streptococcus pneumoniae 426</span></span></code></pre></div>
<p>In a next step, we can further enrich the data with additional microbial taxonomic data based on the “bacteria” variable, such as Gram-stain and microorganism family.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="ch04-amr-r-package.html#cb8-1" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb8-2"><a href="ch04-amr-r-package.html#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gram_stain =</span> <span class="fu">mo_gramstain</span>(bacteria),</span>
<span id="cb8-3"><a href="ch04-amr-r-package.html#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="at">family =</span> <span class="fu">mo_family</span>(bacteria))</span>
<span id="cb8-4"><a href="ch04-amr-r-package.html#cb8-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-5"><a href="ch04-amr-r-package.html#cb8-5" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb8-6"><a href="ch04-amr-r-package.html#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(gram_stain)</span>
<span id="cb8-7"><a href="ch04-amr-r-package.html#cb8-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; gram_stain n</span></span>
<span id="cb8-8"><a href="ch04-amr-r-package.html#cb8-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 Gram-negative 1844</span></span>
<span id="cb8-9"><a href="ch04-amr-r-package.html#cb8-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 Gram-positive 1156</span></span>
<span id="cb8-10"><a href="ch04-amr-r-package.html#cb8-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-11"><a href="ch04-amr-r-package.html#cb8-11" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb8-12"><a href="ch04-amr-r-package.html#cb8-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(family)</span>
<span id="cb8-13"><a href="ch04-amr-r-package.html#cb8-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; family n</span></span>
<span id="cb8-14"><a href="ch04-amr-r-package.html#cb8-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 Enterobacteriaceae 1844</span></span>
<span id="cb8-15"><a href="ch04-amr-r-package.html#cb8-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 Staphylococcaceae 730</span></span>
<span id="cb8-16"><a href="ch04-amr-r-package.html#cb8-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 Streptococcaceae 426</span></span></code></pre></div>
<p>The variables “AMX,” “AMC,” “CIP,” and “GEN” contain antimicrobial susceptibility test results. The abbreviations stand for the tested antimicrobial agent. The official names and additional information about the antimicrobial agents can be checked with the <code>ab_info()</code> function from the <code>AMR</code> package.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="ch04-amr-r-package.html#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ab_info</span>(<span class="st">&quot;AMX&quot;</span>)</span>
<span id="cb9-2"><a href="ch04-amr-r-package.html#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ab</span></span>
<span id="cb9-3"><a href="ch04-amr-r-package.html#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;AMX&quot;</span></span>
<span id="cb9-4"><a href="ch04-amr-r-package.html#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-5"><a href="ch04-amr-r-package.html#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $atc</span></span>
<span id="cb9-6"><a href="ch04-amr-r-package.html#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;J01CA04&quot;</span></span>
<span id="cb9-7"><a href="ch04-amr-r-package.html#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-8"><a href="ch04-amr-r-package.html#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $cid</span></span>
<span id="cb9-9"><a href="ch04-amr-r-package.html#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 33613</span></span>
<span id="cb9-10"><a href="ch04-amr-r-package.html#cb9-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-11"><a href="ch04-amr-r-package.html#cb9-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $name</span></span>
<span id="cb9-12"><a href="ch04-amr-r-package.html#cb9-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Amoxicillin&quot;</span></span>
<span id="cb9-13"><a href="ch04-amr-r-package.html#cb9-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-14"><a href="ch04-amr-r-package.html#cb9-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $group</span></span>
<span id="cb9-15"><a href="ch04-amr-r-package.html#cb9-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Beta-lactams/penicillins&quot;</span></span>
<span id="cb9-16"><a href="ch04-amr-r-package.html#cb9-16" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-17"><a href="ch04-amr-r-package.html#cb9-17" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $atc_group1</span></span>
<span id="cb9-18"><a href="ch04-amr-r-package.html#cb9-18" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Beta-lactam antibacterials, penicillins&quot;</span></span>
<span id="cb9-19"><a href="ch04-amr-r-package.html#cb9-19" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-20"><a href="ch04-amr-r-package.html#cb9-20" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $atc_group2</span></span>
<span id="cb9-21"><a href="ch04-amr-r-package.html#cb9-21" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;Penicillins with extended spectrum&quot;</span></span>
<span id="cb9-22"><a href="ch04-amr-r-package.html#cb9-22" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-23"><a href="ch04-amr-r-package.html#cb9-23" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $tradenames</span></span>
<span id="cb9-24"><a href="ch04-amr-r-package.html#cb9-24" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;actimoxi&quot; &quot;amoclen&quot; &quot;amolin&quot; </span></span>
<span id="cb9-25"><a href="ch04-amr-r-package.html#cb9-25" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [4] &quot;amopen&quot; &quot;amopenixin&quot; &quot;amoxibiotic&quot; </span></span>
<span id="cb9-26"><a href="ch04-amr-r-package.html#cb9-26" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [7] &quot;amoxicaps&quot; &quot;amoxicilina&quot; &quot;amoxicillin&quot; </span></span>
<span id="cb9-27"><a href="ch04-amr-r-package.html#cb9-27" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [10] &quot;amoxicilline&quot; &quot;amoxicillinum&quot; &quot;amoxiden&quot; </span></span>
<span id="cb9-28"><a href="ch04-amr-r-package.html#cb9-28" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [13] &quot;amoxil&quot; &quot;amoxivet&quot; &quot;amoxy&quot; </span></span>
<span id="cb9-29"><a href="ch04-amr-r-package.html#cb9-29" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [16] &quot;amoxycillin&quot; &quot;anemolin&quot; &quot;aspenil&quot; </span></span>
<span id="cb9-30"><a href="ch04-amr-r-package.html#cb9-30" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [19] &quot;biomox&quot; &quot;bristamox&quot; &quot;cemoxin&quot; </span></span>
<span id="cb9-31"><a href="ch04-amr-r-package.html#cb9-31" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [22] &quot;clamoxyl&quot; &quot;delacillin&quot; &quot;dispermox&quot; </span></span>
<span id="cb9-32"><a href="ch04-amr-r-package.html#cb9-32" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [25] &quot;efpenix&quot; &quot;flemoxin&quot; &quot;hiconcil&quot; </span></span>
<span id="cb9-33"><a href="ch04-amr-r-package.html#cb9-33" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [28] &quot;histocillin&quot; &quot;hydroxyampicillin&quot; &quot;ibiamox&quot; </span></span>
<span id="cb9-34"><a href="ch04-amr-r-package.html#cb9-34" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [31] &quot;imacillin&quot; &quot;lamoxy&quot; &quot;metafarma capsules&quot;</span></span>
<span id="cb9-35"><a href="ch04-amr-r-package.html#cb9-35" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [34] &quot;metifarma capsules&quot; &quot;moxacin&quot; &quot;moxatag&quot; </span></span>
<span id="cb9-36"><a href="ch04-amr-r-package.html#cb9-36" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [37] &quot;ospamox&quot; &quot;pamoxicillin&quot; &quot;piramox&quot; </span></span>
<span id="cb9-37"><a href="ch04-amr-r-package.html#cb9-37" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [40] &quot;robamox&quot; &quot;sawamox pm&quot; &quot;tolodina&quot; </span></span>
<span id="cb9-38"><a href="ch04-amr-r-package.html#cb9-38" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [43] &quot;unicillin&quot; &quot;utimox&quot; &quot;vetramox&quot; </span></span>
<span id="cb9-39"><a href="ch04-amr-r-package.html#cb9-39" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-40"><a href="ch04-amr-r-package.html#cb9-40" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd</span></span>
<span id="cb9-41"><a href="ch04-amr-r-package.html#cb9-41" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$oral</span></span>
<span id="cb9-42"><a href="ch04-amr-r-package.html#cb9-42" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$oral$amount</span></span>
<span id="cb9-43"><a href="ch04-amr-r-package.html#cb9-43" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 1.5</span></span>
<span id="cb9-44"><a href="ch04-amr-r-package.html#cb9-44" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-45"><a href="ch04-amr-r-package.html#cb9-45" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$oral$units</span></span>
<span id="cb9-46"><a href="ch04-amr-r-package.html#cb9-46" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;g&quot;</span></span>
<span id="cb9-47"><a href="ch04-amr-r-package.html#cb9-47" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-48"><a href="ch04-amr-r-package.html#cb9-48" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-49"><a href="ch04-amr-r-package.html#cb9-49" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$iv</span></span>
<span id="cb9-50"><a href="ch04-amr-r-package.html#cb9-50" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$iv$amount</span></span>
<span id="cb9-51"><a href="ch04-amr-r-package.html#cb9-51" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] 3</span></span>
<span id="cb9-52"><a href="ch04-amr-r-package.html#cb9-52" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb9-53"><a href="ch04-amr-r-package.html#cb9-53" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; $ddd$iv$units</span></span>
<span id="cb9-54"><a href="ch04-amr-r-package.html#cb9-54" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;g&quot;</span></span></code></pre></div>
<p>In a data set containing antimicrobial names or codes (e.g., antimicrobial prescription data), the <code>as.ab()</code> function can be used to transform all values to valid antimicrobial codes. Extra columns with the official name and the defined daily dose (DDD) for intravenous administration could be added using <code>ab_name()</code> and <code>ab_ddd()</code>.</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="ch04-amr-r-package.html#cb10-1" aria-hidden="true" tabindex="-1"></a>antimicrobial_example <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(<span class="at">agents =</span> <span class="fu">c</span>(<span class="st">&quot;AMX&quot;</span>,</span>
<span id="cb10-2"><a href="ch04-amr-r-package.html#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Ceftriaxon&quot;</span>,</span>
<span id="cb10-3"><a href="ch04-amr-r-package.html#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;Cipro&quot;</span>))</span>
<span id="cb10-4"><a href="ch04-amr-r-package.html#cb10-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-5"><a href="ch04-amr-r-package.html#cb10-5" aria-hidden="true" tabindex="-1"></a>antimicrobial_example <span class="sc">%&gt;%</span> </span>
<span id="cb10-6"><a href="ch04-amr-r-package.html#cb10-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">agents =</span> <span class="fu">as.ab</span>(agents), </span>
<span id="cb10-7"><a href="ch04-amr-r-package.html#cb10-7" aria-hidden="true" tabindex="-1"></a> <span class="at">agent_names =</span> <span class="fu">ab_name</span>(agents),</span>
<span id="cb10-8"><a href="ch04-amr-r-package.html#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="at">ddd_iv =</span> <span class="fu">ab_ddd</span>(agents, <span class="at">administration =</span> <span class="st">&quot;iv&quot;</span>))</span>
<span id="cb10-9"><a href="ch04-amr-r-package.html#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; agents agent_names ddd_iv</span></span>
<span id="cb10-10"><a href="ch04-amr-r-package.html#cb10-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 AMX Amoxicillin 3.0</span></span>
<span id="cb10-11"><a href="ch04-amr-r-package.html#cb10-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 CRO Ceftriaxone 2.0</span></span>
<span id="cb10-12"><a href="ch04-amr-r-package.html#cb10-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 CIP Ciprofloxacin 0.8</span></span></code></pre></div>
<p>Coming back to the cleaning of the data, the columns for the antimicrobial susceptibility test results (“AMX,” “AMC,” “CIP,” “GEN”) need to be checked to contain only standard values (“R,” “S,” “I”).</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="ch04-amr-r-package.html#cb11-1" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb11-2"><a href="ch04-amr-r-package.html#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(AMX<span class="sc">:</span>GEN) <span class="sc">%&gt;%</span></span>
<span id="cb11-3"><a href="ch04-amr-r-package.html#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(<span class="fu">everything</span>(),</span>
<span id="cb11-4"><a href="ch04-amr-r-package.html#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="at">names_to =</span> <span class="st">&quot;antimicrobials&quot;</span>,</span>
<span id="cb11-5"><a href="ch04-amr-r-package.html#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="at">values_to =</span> <span class="st">&quot;interpretation&quot;</span>) <span class="sc">%&gt;%</span></span>
<span id="cb11-6"><a href="ch04-amr-r-package.html#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(interpretation)</span>
<span id="cb11-7"><a href="ch04-amr-r-package.html#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; # A tibble: 4 x 2</span></span>
<span id="cb11-8"><a href="ch04-amr-r-package.html#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; interpretation n</span></span>
<span id="cb11-9"><a href="ch04-amr-r-package.html#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; &lt;chr&gt; &lt;int&gt;</span></span>
<span id="cb11-10"><a href="ch04-amr-r-package.html#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 &lt; 0.5 S 143</span></span>
<span id="cb11-11"><a href="ch04-amr-r-package.html#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 I 1105</span></span>
<span id="cb11-12"><a href="ch04-amr-r-package.html#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 R 4607</span></span>
<span id="cb11-13"><a href="ch04-amr-r-package.html#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4 S 6145</span></span></code></pre></div>
<p>The values contain some mixed values. The <code>as.rsi()</code> function can be used to clean these values and to assign a new class (<code>‘rsi’</code>) for further use of AMR functions.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="ch04-amr-r-package.html#cb12-1" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb12-2"><a href="ch04-amr-r-package.html#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate_at</span>(<span class="fu">vars</span>(AMX<span class="sc">:</span>GEN), as.rsi)</span>
<span id="cb12-3"><a href="ch04-amr-r-package.html#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="ch04-amr-r-package.html#cb12-4" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb12-5"><a href="ch04-amr-r-package.html#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(AMX<span class="sc">:</span>GEN) <span class="sc">%&gt;%</span></span>
<span id="cb12-6"><a href="ch04-amr-r-package.html#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_longer</span>(<span class="fu">everything</span>(),</span>
<span id="cb12-7"><a href="ch04-amr-r-package.html#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="at">names_to =</span> <span class="st">&quot;antimicrobials&quot;</span>,</span>
<span id="cb12-8"><a href="ch04-amr-r-package.html#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="at">values_to =</span> <span class="st">&quot;interpretation&quot;</span>) <span class="sc">%&gt;%</span></span>
<span id="cb12-9"><a href="ch04-amr-r-package.html#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(interpretation)</span>
<span id="cb12-10"><a href="ch04-amr-r-package.html#cb12-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; # A tibble: 3 x 2</span></span>
<span id="cb12-11"><a href="ch04-amr-r-package.html#cb12-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; interpretation n</span></span>
<span id="cb12-12"><a href="ch04-amr-r-package.html#cb12-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; &lt;rsi&gt; &lt;int&gt;</span></span>
<span id="cb12-13"><a href="ch04-amr-r-package.html#cb12-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 S 6288</span></span>
<span id="cb12-14"><a href="ch04-amr-r-package.html#cb12-14" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 I 1105</span></span>
<span id="cb12-15"><a href="ch04-amr-r-package.html#cb12-15" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 R 4607</span></span></code></pre></div>
<p>After this transformation, the <code>eucast_rules()</code> function can be applied to apply the latest resistance reporting guidelines.</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="ch04-amr-r-package.html#cb13-1" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb13-2"><a href="ch04-amr-r-package.html#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">eucast_rules</span>()</span></code></pre></div>
<p>The output to the console lists the changes made to data:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="ch04-amr-r-package.html#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; The rules affected 508 out of 3,000 rows, making a total of 657 edits</span></span>
<span id="cb14-2"><a href="ch04-amr-r-package.html#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; =&gt; added 0 test results</span></span>
<span id="cb14-3"><a href="ch04-amr-r-package.html#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb14-4"><a href="ch04-amr-r-package.html#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; =&gt; changed 657 test results</span></span>
<span id="cb14-5"><a href="ch04-amr-r-package.html#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 11 test results changed from &quot;S&quot; to &quot;I&quot;</span></span>
<span id="cb14-6"><a href="ch04-amr-r-package.html#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 473 test results changed from &quot;S&quot; to &quot;R&quot;</span></span>
<span id="cb14-7"><a href="ch04-amr-r-package.html#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 85 test results changed from &quot;I&quot; to &quot;R&quot;</span></span>
<span id="cb14-8"><a href="ch04-amr-r-package.html#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 19 test results changed from &quot;I&quot; to &quot;S&quot;</span></span>
<span id="cb14-9"><a href="ch04-amr-r-package.html#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 33 test results changed from &quot;R&quot; to &quot;I&quot;</span></span>
<span id="cb14-10"><a href="ch04-amr-r-package.html#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; - 36 test results changed from &quot;R&quot; to &quot;S&quot;</span></span></code></pre></div>
<p>The data is now clean and ready for further analysis, for example, the identification of multi-drug resistant microorganisms. In this example, we use the Dutch guideline to determine multi-drug resistance <sup>[35]</sup>.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="ch04-amr-r-package.html#cb15-1" aria-hidden="true" tabindex="-1"></a>data <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb15-2"><a href="ch04-amr-r-package.html#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mdro =</span> <span class="fu">mdro</span>(., <span class="at">guideline =</span> <span class="st">&quot;nl&quot;</span>))</span>
<span id="cb15-3"><a href="ch04-amr-r-package.html#cb15-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-4"><a href="ch04-amr-r-package.html#cb15-4" aria-hidden="true" tabindex="-1"></a>data <span class="sc">%&gt;%</span></span>
<span id="cb15-5"><a href="ch04-amr-r-package.html#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">count</span>(bacteria_name, mdro)</span>
<span id="cb15-6"><a href="ch04-amr-r-package.html#cb15-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; bacteria_name mdro n</span></span>
<span id="cb15-7"><a href="ch04-amr-r-package.html#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 Escherichia coli Negative 1123</span></span>
<span id="cb15-8"><a href="ch04-amr-r-package.html#cb15-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 Escherichia coli Positive 395</span></span>
<span id="cb15-9"><a href="ch04-amr-r-package.html#cb15-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 Klebsiella pneumoniae Negative 237</span></span>
<span id="cb15-10"><a href="ch04-amr-r-package.html#cb15-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 4 Klebsiella pneumoniae Positive 89</span></span>
<span id="cb15-11"><a href="ch04-amr-r-package.html#cb15-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 5 Staphylococcus aureus Negative 730</span></span>
<span id="cb15-12"><a href="ch04-amr-r-package.html#cb15-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 6 Streptococcus pneumoniae Negative 426</span></span></code></pre></div>
<p>According to the Dutch guideline, 484 (395 + 89) multi-drug resistant microorganisms were found in 3,000 tested isolates. No multi-drug resistance was found in Staphylococcus aureus and Streptococcus pneumoniae.</p>
<p>As described in Section 4.4.1, the identification of first isolates is essential for the reporting of resistance patterns. Using the <code>filter_first_isolate()</code> function and <code>proportion_df()</code> in combination with <code>group_by()</code>, we get a complete resistance analysis per hospital, bacteria, first isolate, and tested antimicrobial agent in one call:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="ch04-amr-r-package.html#cb16-1" aria-hidden="true" tabindex="-1"></a>resistance_proportion <span class="ot">&lt;-</span> data <span class="sc">%&gt;%</span></span>
<span id="cb16-2"><a href="ch04-amr-r-package.html#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter_first_isolate</span>() <span class="sc">%&gt;%</span></span>
<span id="cb16-3"><a href="ch04-amr-r-package.html#cb16-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(hospital) <span class="sc">%&gt;%</span></span>
<span id="cb16-4"><a href="ch04-amr-r-package.html#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">proportion_df</span>()</span>