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

645 lines
24 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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

<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>AMR for Python • AMR (for R)</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet">
<script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/Lato-0.4.9/font.css" rel="stylesheet">
<link href="../deps/Fira_Code-0.4.9/font.css" rel="stylesheet">
<link href="../deps/font-awesome-6.5.2/css/all.min.css" rel="stylesheet">
<link href="../deps/font-awesome-6.5.2/css/v4-shims.min.css" rel="stylesheet">
<script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script><meta property="og:title" content="AMR for Python">
</head>
<body>
<a href="#main" class="visually-hidden-focusable">Skip to contents</a>
<nav class="navbar navbar-expand-lg fixed-top bg-primary" data-bs-theme="dark" aria-label="Site navigation"><div class="container">
<a class="navbar-brand me-2" href="../index.html">AMR (for R)</a>
<small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.1.1.9122</small>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar" class="collapse navbar-collapse ms-3">
<ul class="navbar-nav me-auto">
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle" type="button" id="dropdown-how-to" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true"><span class="fa fa-question-circle"></span> How to</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-how-to">
<li><a class="dropdown-item" href="../articles/AMR.html"><span class="fa fa-directions"></span> Conduct AMR Analysis</a></li>
<li><a class="dropdown-item" href="../reference/antibiogram.html"><span class="fa fa-file-prescription"></span> Generate Antibiogram (Trad./Syndromic/WISCA)</a></li>
<li><a class="dropdown-item" href="../articles/resistance_predict.html"><span class="fa fa-dice"></span> Predict Antimicrobial Resistance</a></li>
<li><a class="dropdown-item" href="../articles/datasets.html"><span class="fa fa-database"></span> Download Data Sets for Own Use</a></li>
<li><a class="dropdown-item" href="../articles/AMR_with_tidymodels.html"><span class="fa fa-square-root-variable"></span> Use AMR for Predictive Modelling (tidymodels)</a></li>
<li><a class="dropdown-item" href="../reference/AMR-options.html"><span class="fa fa-gear"></span> Set User- Or Team-specific Package Settings</a></li>
<li><a class="dropdown-item" href="../articles/PCA.html"><span class="fa fa-compress"></span> Conduct Principal Component Analysis for AMR</a></li>
<li><a class="dropdown-item" href="../articles/MDR.html"><span class="fa fa-skull-crossbones"></span> Determine Multi-Drug Resistance (MDR)</a></li>
<li><a class="dropdown-item" href="../articles/WHONET.html"><span class="fa fa-globe-americas"></span> Work with WHONET Data</a></li>
<li><a class="dropdown-item" href="../articles/EUCAST.html"><span class="fa fa-exchange-alt"></span> Apply Eucast Rules</a></li>
<li><a class="dropdown-item" href="../reference/mo_property.html"><span class="fa fa-bug"></span> Get Taxonomy of a Microorganism</a></li>
<li><a class="dropdown-item" href="../reference/ab_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antibiotic Drug</a></li>
<li><a class="dropdown-item" href="../reference/av_property.html"><span class="fa fa-capsules"></span> Get Properties of an Antiviral Drug</a></li>
</ul>
</li>
<li class="active nav-item"><a class="nav-link" href="../articles/AMR_for_Python.html"><span class="fa fab fa-python"></span> AMR for Python</a></li>
<li class="nav-item"><a class="nav-link" href="../reference/index.html"><span class="fa fa-book-open"></span> Manual</a></li>
<li class="nav-item"><a class="nav-link" href="../authors.html"><span class="fa fa-users"></span> Authors</a></li>
</ul>
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="../news/index.html"><span class="fa far fa-newspaper"></span> Changelog</a></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/msberends/AMR"><span class="fa fab fa-github"></span> Source Code</a></li>
</ul>
</div>
</div>
</nav><div class="container template-article">
<div class="row">
<main id="main" class="col-md-9"><div class="page-header">
<img src="../logo.svg" class="logo" alt=""><h1>AMR for Python</h1>
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/main/vignettes/AMR_for_Python.Rmd" class="external-link"><code>vignettes/AMR_for_Python.Rmd</code></a></small>
<div class="d-none name"><code>AMR_for_Python.Rmd</code></div>
</div>
<div class="section level2">
<h2 id="introduction">Introduction<a class="anchor" aria-label="anchor" href="#introduction"></a>
</h2>
<p>The <code>AMR</code> package for R is a powerful tool for
antimicrobial resistance (AMR) analysis. It provides extensive features
for handling microbial and antimicrobial data. However, for those who
work primarily in Python, we now have a more intuitive option available:
the <a href="https://pypi.org/project/AMR/" class="external-link"><code>AMR</code> Python
Package Index</a>.</p>
<p>This Python package is a wrapper round the <code>AMR</code> R
package. It uses the <code>rpy2</code> package internally. Despite the
need to have R installed, Python users can now easily work with AMR data
directly through Python code.</p>
</div>
<div class="section level2">
<h2 id="install">Install<a class="anchor" aria-label="anchor" href="#install"></a>
</h2>
<ol style="list-style-type: decimal">
<li>
<p>Since the Python package is available on the official <a href="https://pypi.org/project/AMR/" class="external-link">Python Package Index</a>, you can
just run:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="ex">pip</span> install AMR</span></code></pre></div>
</li>
<li>
<p>Make sure you have R installed. There is <strong>no need to
install the <code>AMR</code> R package</strong>, as it will be installed
automatically.</p>
<p>For Linux:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a><span class="co"># Ubuntu / Debian</span></span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a><span class="fu">sudo</span> apt install r-base</span>
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a><span class="co"># Fedora:</span></span>
<span id="cb2-4"><a href="#cb2-4" tabindex="-1"></a><span class="fu">sudo</span> dnf install R</span>
<span id="cb2-5"><a href="#cb2-5" tabindex="-1"></a><span class="co"># CentOS/RHEL</span></span>
<span id="cb2-6"><a href="#cb2-6" tabindex="-1"></a><span class="fu">sudo</span> yum install R</span></code></pre></div>
<p>For macOS (using <a href="https://brew.sh" class="external-link">Homebrew</a>):</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="ex">brew</span> install r</span></code></pre></div>
<p>For Windows, visit the <a href="https://cran.r-project.org" class="external-link">CRAN
download page</a> to download and install R.</p>
</li>
</ol>
</div>
<div class="section level2">
<h2 id="examples-of-usage">Examples of Usage<a class="anchor" aria-label="anchor" href="#examples-of-usage"></a>
</h2>
<div class="section level3">
<h3 id="cleaning-taxonomy">Cleaning Taxonomy<a class="anchor" aria-label="anchor" href="#cleaning-taxonomy"></a>
</h3>
<p>Heres an example that demonstrates how to clean microorganism and
drug names using the <code>AMR</code> Python package:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd</span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a><span class="im">import</span> AMR</span>
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a></span>
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a><span class="co"># Sample data</span></span>
<span id="cb4-5"><a href="#cb4-5" tabindex="-1"></a>data <span class="op">=</span> {</span>
<span id="cb4-6"><a href="#cb4-6" tabindex="-1"></a> <span class="st">"MOs"</span>: [<span class="st">'E. coli'</span>, <span class="st">'ESCCOL'</span>, <span class="st">'esco'</span>, <span class="st">'Esche coli'</span>],</span>
<span id="cb4-7"><a href="#cb4-7" tabindex="-1"></a> <span class="st">"Drug"</span>: [<span class="st">'Cipro'</span>, <span class="st">'CIP'</span>, <span class="st">'J01MA02'</span>, <span class="st">'Ciproxin'</span>]</span>
<span id="cb4-8"><a href="#cb4-8" tabindex="-1"></a>}</span>
<span id="cb4-9"><a href="#cb4-9" tabindex="-1"></a>df <span class="op">=</span> pd.DataFrame(data)</span>
<span id="cb4-10"><a href="#cb4-10" tabindex="-1"></a></span>
<span id="cb4-11"><a href="#cb4-11" tabindex="-1"></a><span class="co"># Use AMR functions to clean microorganism and drug names</span></span>
<span id="cb4-12"><a href="#cb4-12" tabindex="-1"></a>df[<span class="st">'MO_clean'</span>] <span class="op">=</span> AMR.mo_name(df[<span class="st">'MOs'</span>])</span>
<span id="cb4-13"><a href="#cb4-13" tabindex="-1"></a>df[<span class="st">'Drug_clean'</span>] <span class="op">=</span> AMR.ab_name(df[<span class="st">'Drug'</span>])</span>
<span id="cb4-14"><a href="#cb4-14" tabindex="-1"></a></span>
<span id="cb4-15"><a href="#cb4-15" tabindex="-1"></a><span class="co"># Display the results</span></span>
<span id="cb4-16"><a href="#cb4-16" tabindex="-1"></a><span class="bu">print</span>(df)</span></code></pre></div>
<table class="table">
<thead><tr class="header">
<th>MOs</th>
<th>Drug</th>
<th>MO_clean</th>
<th>Drug_clean</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>E. coli</td>
<td>Cipro</td>
<td>Escherichia coli</td>
<td>Ciprofloxacin</td>
</tr>
<tr class="even">
<td>ESCCOL</td>
<td>CIP</td>
<td>Escherichia coli</td>
<td>Ciprofloxacin</td>
</tr>
<tr class="odd">
<td>esco</td>
<td>J01MA02</td>
<td>Escherichia coli</td>
<td>Ciprofloxacin</td>
</tr>
<tr class="even">
<td>Esche coli</td>
<td>Ciproxin</td>
<td>Escherichia coli</td>
<td>Ciprofloxacin</td>
</tr>
</tbody>
</table>
<div class="section level4">
<h4 id="explanation">Explanation<a class="anchor" aria-label="anchor" href="#explanation"></a>
</h4>
<ul>
<li><p><strong>mo_name:</strong> This function standardises
microorganism names. Here, different variations of <em>Escherichia
coli</em> (such as “E. coli”, “ESCCOL”, “esco”, and “Esche coli”) are
all converted into the correct, standardised form, “Escherichia
coli”.</p></li>
<li><p><strong>ab_name</strong>: Similarly, this function standardises
antimicrobial names. The different representations of ciprofloxacin
(e.g., “Cipro”, “CIP”, “J01MA02”, and “Ciproxin”) are all converted to
the standard name, “Ciprofloxacin”.</p></li>
</ul>
</div>
</div>
<div class="section level3">
<h3 id="taxonomic-data-sets-now-in-python">Taxonomic Data Sets Now in Python!<a class="anchor" aria-label="anchor" href="#taxonomic-data-sets-now-in-python"></a>
</h3>
<p>As a Python user, you might like that the most important data sets of
the <code>AMR</code> R package, <code>microorganisms</code>,
<code>antibiotics</code>, <code>clinical_breakpoints</code>, and
<code>example_isolates</code>, are now available as regular Python data
frames:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a>AMR.microorganisms</span></code></pre></div>
<table class="table">
<colgroup>
<col width="11%">
<col width="29%">
<col width="8%">
<col width="8%">
<col width="8%">
<col width="10%">
<col width="13%">
<col width="9%">
</colgroup>
<thead><tr class="header">
<th>mo</th>
<th>fullname</th>
<th>status</th>
<th>kingdom</th>
<th>gbif</th>
<th>gbif_parent</th>
<th>gbif_renamed_to</th>
<th>prevalence</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>B_GRAMN</td>
<td>(unknown Gram-negatives)</td>
<td>unknown</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="even">
<td>B_GRAMP</td>
<td>(unknown Gram-positives)</td>
<td>unknown</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="odd">
<td>B_ANAER-NEG</td>
<td>(unknown anaerobic Gram-negatives)</td>
<td>unknown</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="even">
<td>B_ANAER-POS</td>
<td>(unknown anaerobic Gram-positives)</td>
<td>unknown</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="odd">
<td>B_ANAER</td>
<td>(unknown anaerobic bacteria)</td>
<td>unknown</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="even">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="odd">
<td>B_ZYMMN_POMC</td>
<td>Zymomonas pomaceae</td>
<td>accepted</td>
<td>Bacteria</td>
<td>10744418</td>
<td>3221412</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="even">
<td>B_ZYMPH</td>
<td>Zymophilus</td>
<td>synonym</td>
<td>Bacteria</td>
<td>None</td>
<td>9475166</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="odd">
<td>B_ZYMPH_PCVR</td>
<td>Zymophilus paucivorans</td>
<td>synonym</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="even">
<td>B_ZYMPH_RFFN</td>
<td>Zymophilus raffinosivorans</td>
<td>synonym</td>
<td>Bacteria</td>
<td>None</td>
<td>None</td>
<td>None</td>
<td>2.0</td>
</tr>
<tr class="odd">
<td>F_ZYZYG</td>
<td>Zyzygomyces</td>
<td>unknown</td>
<td>Fungi</td>
<td>None</td>
<td>7581</td>
<td>None</td>
<td>2.0</td>
</tr>
</tbody>
</table>
<div class="sourceCode" id="cb6"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a>AMR.antibiotics</span></code></pre></div>
<table style="width:100%;" class="table">
<colgroup>
<col width="4%">
<col width="12%">
<col width="20%">
<col width="25%">
<col width="9%">
<col width="11%">
<col width="7%">
<col width="9%">
</colgroup>
<thead><tr class="header">
<th>ab</th>
<th>cid</th>
<th>name</th>
<th>group</th>
<th>oral_ddd</th>
<th>oral_units</th>
<th>iv_ddd</th>
<th>iv_units</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>AMA</td>
<td>4649.0</td>
<td>4-aminosalicylic acid</td>
<td>Antimycobacterials</td>
<td>12.00</td>
<td>g</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="even">
<td>ACM</td>
<td>6450012.0</td>
<td>Acetylmidecamycin</td>
<td>Macrolides/lincosamides</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="odd">
<td>ASP</td>
<td>49787020.0</td>
<td>Acetylspiramycin</td>
<td>Macrolides/lincosamides</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="even">
<td>ALS</td>
<td>8954.0</td>
<td>Aldesulfone sodium</td>
<td>Other antibacterials</td>
<td>0.33</td>
<td>g</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="odd">
<td>AMK</td>
<td>37768.0</td>
<td>Amikacin</td>
<td>Aminoglycosides</td>
<td>NaN</td>
<td>None</td>
<td>1.0</td>
<td>g</td>
</tr>
<tr class="even">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="odd">
<td>VIR</td>
<td>11979535.0</td>
<td>Virginiamycine</td>
<td>Other antibacterials</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="even">
<td>VOR</td>
<td>71616.0</td>
<td>Voriconazole</td>
<td>Antifungals/antimycotics</td>
<td>0.40</td>
<td>g</td>
<td>0.4</td>
<td>g</td>
</tr>
<tr class="odd">
<td>XBR</td>
<td>72144.0</td>
<td>Xibornol</td>
<td>Other antibacterials</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="even">
<td>ZID</td>
<td>77846445.0</td>
<td>Zidebactam</td>
<td>Other antibacterials</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
<tr class="odd">
<td>ZFD</td>
<td>NaN</td>
<td>Zoliflodacin</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
<td>NaN</td>
<td>None</td>
</tr>
</tbody>
</table>
</div>
<div class="section level3">
<h3 id="calculating-amr">Calculating AMR<a class="anchor" aria-label="anchor" href="#calculating-amr"></a>
</h3>
<div class="sourceCode" id="cb7"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a><span class="im">import</span> AMR</span>
<span id="cb7-2"><a href="#cb7-2" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd</span>
<span id="cb7-3"><a href="#cb7-3" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" tabindex="-1"></a>df <span class="op">=</span> AMR.example_isolates</span>
<span id="cb7-5"><a href="#cb7-5" tabindex="-1"></a>result <span class="op">=</span> AMR.resistance(df[<span class="st">"AMX"</span>])</span>
<span id="cb7-6"><a href="#cb7-6" tabindex="-1"></a><span class="bu">print</span>(result)</span></code></pre></div>
<pre><code>[0.59555556]</code></pre>
</div>
<div class="section level3">
<h3 id="generating-antibiograms">Generating Antibiograms<a class="anchor" aria-label="anchor" href="#generating-antibiograms"></a>
</h3>
<p>One of the core functions of the <code>AMR</code> package is
generating an antibiogram, a table that summarises the antimicrobial
susceptibility of bacterial isolates. Heres how you can generate an
antibiogram from Python:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a>result2a <span class="op">=</span> AMR.antibiogram(df[[<span class="st">"mo"</span>, <span class="st">"AMX"</span>, <span class="st">"CIP"</span>, <span class="st">"TZP"</span>]])</span>
<span id="cb9-2"><a href="#cb9-2" tabindex="-1"></a><span class="bu">print</span>(result2a)</span></code></pre></div>
<table class="table">
<colgroup>
<col width="22%">
<col width="22%">
<col width="22%">
<col width="33%">
</colgroup>
<thead><tr class="header">
<th>Pathogen</th>
<th>Amoxicillin</th>
<th>Ciprofloxacin</th>
<th>Piperacillin/tazobactam</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>CoNS</td>
<td>7% (10/142)</td>
<td>73% (183/252)</td>
<td>30% (10/33)</td>
</tr>
<tr class="even">
<td>E. coli</td>
<td>50% (196/392)</td>
<td>88% (399/456)</td>
<td>94% (393/416)</td>
</tr>
<tr class="odd">
<td>K. pneumoniae</td>
<td>0% (0/58)</td>
<td>96% (53/55)</td>
<td>89% (47/53)</td>
</tr>
<tr class="even">
<td>P. aeruginosa</td>
<td>0% (0/30)</td>
<td>100% (30/30)</td>
<td>None</td>
</tr>
<tr class="odd">
<td>P. mirabilis</td>
<td>None</td>
<td>94% (34/36)</td>
<td>None</td>
</tr>
<tr class="even">
<td>S. aureus</td>
<td>6% (8/131)</td>
<td>90% (171/191)</td>
<td>None</td>
</tr>
<tr class="odd">
<td>S. epidermidis</td>
<td>1% (1/91)</td>
<td>64% (87/136)</td>
<td>None</td>
</tr>
<tr class="even">
<td>S. hominis</td>
<td>None</td>
<td>80% (56/70)</td>
<td>None</td>
</tr>
<tr class="odd">
<td>S. pneumoniae</td>
<td>100% (112/112)</td>
<td>None</td>
<td>100% (112/112)</td>
</tr>
</tbody>
</table>
<div class="sourceCode" id="cb10"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" tabindex="-1"></a>result2b <span class="op">=</span> AMR.antibiogram(df[[<span class="st">"mo"</span>, <span class="st">"AMX"</span>, <span class="st">"CIP"</span>, <span class="st">"TZP"</span>]], mo_transform <span class="op">=</span> <span class="st">"gramstain"</span>)</span>
<span id="cb10-2"><a href="#cb10-2" tabindex="-1"></a><span class="bu">print</span>(result2b)</span></code></pre></div>
<table class="table">
<colgroup>
<col width="20%">
<col width="22%">
<col width="23%">
<col width="33%">
</colgroup>
<thead><tr class="header">
<th>Pathogen</th>
<th>Amoxicillin</th>
<th>Ciprofloxacin</th>
<th>Piperacillin/tazobactam</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>Gram-negative</td>
<td>36% (226/631)</td>
<td>91% (621/684)</td>
<td>88% (565/641)</td>
</tr>
<tr class="even">
<td>Gram-positive</td>
<td>43% (305/703)</td>
<td>77% (560/724)</td>
<td>86% (296/345)</td>
</tr>
</tbody>
</table>
<p>In this example, we generate an antibiogram by selecting various
antibiotics.</p>
</div>
</div>
<div class="section level2">
<h2 id="conclusion">Conclusion<a class="anchor" aria-label="anchor" href="#conclusion"></a>
</h2>
<p>With the <code>AMR</code> Python package, Python users can now
effortlessly call R functions from the <code>AMR</code> R package. This
eliminates the need for complex <code>rpy2</code> configurations and
provides a clean, easy-to-use interface for antimicrobial resistance
analysis. The examples provided above demonstrate how this can be
applied to typical workflows, such as standardising microorganism and
antimicrobial names or calculating resistance.</p>
<p>By just running <code>import AMR</code>, users can seamlessly
integrate the robust features of the R <code>AMR</code> package into
Python workflows.</p>
<p>Whether youre cleaning data or analysing resistance patterns, the
<code>AMR</code> Python package makes it easy to work with AMR data in
Python.</p>
</div>
</main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
</nav></aside>
</div>
<footer><div class="pkgdown-footer-left">
<p><code>AMR</code> (for R). Free and open-source, licenced under the <a target="_blank" href="https://github.com/msberends/AMR/blob/main/LICENSE" class="external-link">GNU General Public License version 2.0 (GPL-2)</a>.<br>Developed at the <a target="_blank" href="https://www.rug.nl" class="external-link">University of Groningen</a> and <a target="_blank" href="https://www.umcg.nl" class="external-link">University Medical Center Groningen</a> in The Netherlands.</p>
</div>
<div class="pkgdown-footer-right">
<p><a target="_blank" href="https://www.rug.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_rug.svg" style="max-width: 150px;"></a><a target="_blank" href="https://www.umcg.nl" class="external-link"><img src="https://github.com/msberends/AMR/raw/main/pkgdown/assets/logo_umcg.svg" style="max-width: 150px;"></a></p>
</div>
</footer>
</div>
</body>
</html>