1
0
mirror of https://github.com/msberends/AMR.git synced 2025-05-02 02:23:59 +02:00

Python wrapper update

This commit is contained in:
github-actions[bot] 2025-05-01 12:47:13 +00:00
commit 2002f2bb2a
12 changed files with 1398 additions and 0 deletions

212
AMR.egg-info/PKG-INFO Normal file
View File

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

10
AMR.egg-info/SOURCES.txt Normal file
View File

@ -0,0 +1,10 @@
README.md
setup.py
AMR/__init__.py
AMR/datasets.py
AMR/functions.py
AMR.egg-info/PKG-INFO
AMR.egg-info/SOURCES.txt
AMR.egg-info/dependency_links.txt
AMR.egg-info/requires.txt
AMR.egg-info/top_level.txt

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
rpy2
numpy
pandas

View File

@ -0,0 +1 @@
AMR

213
AMR/__init__.py Normal file
View File

@ -0,0 +1,213 @@
from .datasets import example_isolates
from .datasets import microorganisms
from .datasets import antimicrobials
from .datasets import clinical_breakpoints
from .functions import ab_class
from .functions import ab_selector
from .functions import ab_from_text
from .functions import ab_name
from .functions import ab_cid
from .functions import ab_synonyms
from .functions import ab_tradenames
from .functions import ab_group
from .functions import ab_atc
from .functions import ab_atc_group1
from .functions import ab_atc_group2
from .functions import ab_loinc
from .functions import ab_ddd
from .functions import ab_ddd_units
from .functions import ab_info
from .functions import ab_url
from .functions import ab_property
from .functions import add_custom_antimicrobials
from .functions import clear_custom_antimicrobials
from .functions import add_custom_microorganisms
from .functions import clear_custom_microorganisms
from .functions import age
from .functions import age_groups
from .functions import antibiogram
from .functions import wisca
from .functions import retrieve_wisca_parameters
from .functions import aminoglycosides
from .functions import aminopenicillins
from .functions import antifungals
from .functions import antimycobacterials
from .functions import betalactams
from .functions import betalactams_with_inhibitor
from .functions import carbapenems
from .functions import cephalosporins
from .functions import cephalosporins_1st
from .functions import cephalosporins_2nd
from .functions import cephalosporins_3rd
from .functions import cephalosporins_4th
from .functions import cephalosporins_5th
from .functions import fluoroquinolones
from .functions import glycopeptides
from .functions import isoxazolylpenicillins
from .functions import lincosamides
from .functions import lipoglycopeptides
from .functions import macrolides
from .functions import monobactams
from .functions import nitrofurans
from .functions import oxazolidinones
from .functions import penicillins
from .functions import phenicols
from .functions import polymyxins
from .functions import quinolones
from .functions import rifamycins
from .functions import streptogramins
from .functions import sulfonamides
from .functions import tetracyclines
from .functions import trimethoprims
from .functions import ureidopenicillins
from .functions import amr_class
from .functions import amr_selector
from .functions import administrable_per_os
from .functions import administrable_iv
from .functions import not_intrinsic_resistant
from .functions import as_ab
from .functions import is_ab
from .functions import ab_reset_session
from .functions import as_av
from .functions import is_av
from .functions import as_disk
from .functions import is_disk
from .functions import as_mic
from .functions import is_mic
from .functions import rescale_mic
from .functions import mic_p50
from .functions import mic_p90
from .functions import as_mo
from .functions import is_mo
from .functions import mo_uncertainties
from .functions import mo_renamed
from .functions import mo_failures
from .functions import mo_reset_session
from .functions import mo_cleaning_regex
from .functions import as_sir
from .functions import is_sir
from .functions import is_sir_eligible
from .functions import sir_interpretation_history
from .functions import atc_online_property
from .functions import atc_online_groups
from .functions import atc_online_ddd
from .functions import atc_online_ddd_units
from .functions import av_from_text
from .functions import av_name
from .functions import av_cid
from .functions import av_synonyms
from .functions import av_tradenames
from .functions import av_group
from .functions import av_atc
from .functions import av_loinc
from .functions import av_ddd
from .functions import av_ddd_units
from .functions import av_info
from .functions import av_url
from .functions import av_property
from .functions import availability
from .functions import bug_drug_combinations
from .functions import count_resistant
from .functions import count_susceptible
from .functions import count_S
from .functions import count_SI
from .functions import count_I
from .functions import count_IR
from .functions import count_R
from .functions import count_all
from .functions import n_sir
from .functions import count_df
from .functions import custom_eucast_rules
from .functions import eucast_rules
from .functions import eucast_dosage
from .functions import export_ncbi_biosample
from .functions import first_isolate
from .functions import filter_first_isolate
from .functions import g_test
from .functions import is_new_episode
from .functions import ggplot_pca
from .functions import ggplot_sir
from .functions import geom_sir
from .functions import guess_ab_col
from .functions import italicise_taxonomy
from .functions import italicize_taxonomy
from .functions import inner_join_microorganisms
from .functions import left_join_microorganisms
from .functions import right_join_microorganisms
from .functions import full_join_microorganisms
from .functions import semi_join_microorganisms
from .functions import anti_join_microorganisms
from .functions import key_antimicrobials
from .functions import all_antimicrobials
from .functions import kurtosis
from .functions import like
from .functions import mdro
from .functions import custom_mdro_guideline
from .functions import brmo
from .functions import mrgn
from .functions import mdr_tb
from .functions import mdr_cmi2012
from .functions import eucast_exceptional_phenotypes
from .functions import mean_amr_distance
from .functions import amr_distance_from_row
from .functions import mo_matching_score
from .functions import mo_name
from .functions import mo_fullname
from .functions import mo_shortname
from .functions import mo_subspecies
from .functions import mo_species
from .functions import mo_genus
from .functions import mo_family
from .functions import mo_order
from .functions import mo_class
from .functions import mo_phylum
from .functions import mo_kingdom
from .functions import mo_domain
from .functions import mo_type
from .functions import mo_status
from .functions import mo_pathogenicity
from .functions import mo_gramstain
from .functions import mo_is_gram_negative
from .functions import mo_is_gram_positive
from .functions import mo_is_yeast
from .functions import mo_is_intrinsic_resistant
from .functions import mo_oxygen_tolerance
from .functions import mo_is_anaerobic
from .functions import mo_snomed
from .functions import mo_ref
from .functions import mo_authors
from .functions import mo_year
from .functions import mo_lpsn
from .functions import mo_mycobank
from .functions import mo_gbif
from .functions import mo_rank
from .functions import mo_taxonomy
from .functions import mo_synonyms
from .functions import mo_current
from .functions import mo_group_members
from .functions import mo_info
from .functions import mo_url
from .functions import mo_property
from .functions import pca
from .functions import theme_sir
from .functions import labels_sir_count
from .functions import resistance
from .functions import susceptibility
from .functions import sir_confidence_interval
from .functions import proportion_R
from .functions import proportion_IR
from .functions import proportion_I
from .functions import proportion_SI
from .functions import proportion_S
from .functions import proportion_df
from .functions import sir_df
from .functions import random_mic
from .functions import random_disk
from .functions import random_sir
from .functions import resistance_predict
from .functions import sir_predict
from .functions import ggplot_sir_predict
from .functions import skewness
from .functions import top_n_microorganisms
from .functions import reset_AMR_locale
from .functions import translate_AMR

82
AMR/datasets.py Normal file
View File

@ -0,0 +1,82 @@
import os
import sys
import pandas as pd
import importlib.metadata as metadata
# Get the path to the virtual environment
venv_path = sys.prefix
r_lib_path = os.path.join(venv_path, "R_libs")
os.makedirs(r_lib_path, exist_ok=True)
# Set environment variable before importing rpy2
os.environ['R_LIBS_SITE'] = r_lib_path
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr, isinstalled
# Import base and utils
base = importr('base')
utils = importr('utils')
base.options(warn=-1)
# Ensure library paths explicitly
base._libPaths(r_lib_path)
# Check if the AMR package is installed in R
if not isinstalled('AMR', lib_loc=r_lib_path):
print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True)
utils.install_packages('AMR', repos='beta.amr-for-r.org', quiet=True)
# Retrieve Python AMR version
try:
python_amr_version = str(metadata.version('AMR'))
except metadata.PackageNotFoundError:
python_amr_version = str('')
# Retrieve R AMR version
r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')
r_amr_version = str(r_amr_version[0])
print(python_amr_version, flush=True)
print(r_amr_version, flush=True)
print(r_amr_version != python_amr_version, flush=True)
# # Compare R and Python package versions
# if r_amr_version != python_amr_version:
# try:
# print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True)
# utils.install_packages('AMR', repos='beta.amr-for-r.org', quiet=True)
# except Exception as e:
# print(f"AMR: Could not update: {e}", flush=True)
print(f"AMR: Setting up R environment and AMR datasets...", flush=True)
# Activate the automatic conversion between R and pandas DataFrames
pandas2ri.activate()
# example_isolates
example_isolates = pandas2ri.rpy2py(robjects.r('''
df <- AMR::example_isolates
df[] <- lapply(df, function(x) {
if (inherits(x, c("Date", "POSIXt", "factor"))) {
as.character(x)
} else {
x
}
})
df <- df[, !sapply(df, is.list)]
df
'''))
example_isolates['date'] = pd.to_datetime(example_isolates['date'])
# microorganisms
microorganisms = pandas2ri.rpy2py(robjects.r('AMR::microorganisms[, !sapply(AMR::microorganisms, is.list)]'))
antimicrobials = pandas2ri.rpy2py(robjects.r('AMR::antimicrobials[, !sapply(AMR::antimicrobials, is.list)]'))
clinical_breakpoints = pandas2ri.rpy2py(robjects.r('AMR::clinical_breakpoints[, !sapply(AMR::clinical_breakpoints, is.list)]'))
base.options(warn = 0)
print(f"AMR: Done.", flush=True)

665
AMR/functions.py Normal file
View File

@ -0,0 +1,665 @@
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.vectors import StrVector, FactorVector, IntVector, FloatVector, DataFrame
from rpy2.robjects import pandas2ri
import pandas as pd
import numpy as np
# Activate automatic conversion between R data frames and pandas data frames
pandas2ri.activate()
# Import the AMR R package
amr_r = importr('AMR')
def convert_to_python(r_output):
# Check if it's a StrVector (R character vector)
if isinstance(r_output, StrVector):
return list(r_output) # Convert to a Python list of strings
# Check if it's a FactorVector (R factor)
elif isinstance(r_output, FactorVector):
return list(r_output) # Convert to a list of integers (factor levels)
# Check if it's an IntVector or FloatVector (numeric R vectors)
elif isinstance(r_output, (IntVector, FloatVector)):
return list(r_output) # Convert to a Python list of integers or floats
# Check if it's a pandas-compatible R data frame
elif isinstance(r_output, pd.DataFrame):
return r_output # Return as pandas DataFrame (already converted by pandas2ri)
elif isinstance(r_output, DataFrame):
return pandas2ri.rpy2py(r_output) # Return as pandas DataFrame
# Check if the input is a NumPy array and has a string data type
if isinstance(r_output, np.ndarray) and np.issubdtype(r_output.dtype, np.str_):
return r_output.tolist() # Convert to a regular Python list
# Fall-back
return r_output
def ab_class(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_class(*args, **kwargs))
def ab_selector(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_selector(*args, **kwargs))
def ab_from_text(text, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_from_text(text, *args, **kwargs))
def ab_name(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_name(x, *args, **kwargs))
def ab_cid(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_cid(x, *args, **kwargs))
def ab_synonyms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_synonyms(x, *args, **kwargs))
def ab_tradenames(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_tradenames(x, *args, **kwargs))
def ab_group(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_group(x, *args, **kwargs))
def ab_atc(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_atc(x, *args, **kwargs))
def ab_atc_group1(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_atc_group1(x, *args, **kwargs))
def ab_atc_group2(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_atc_group2(x, *args, **kwargs))
def ab_loinc(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_loinc(x, *args, **kwargs))
def ab_ddd(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_ddd(x, *args, **kwargs))
def ab_ddd_units(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_ddd_units(x, *args, **kwargs))
def ab_info(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_info(x, *args, **kwargs))
def ab_url(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_url(x, *args, **kwargs))
def ab_property(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_property(x, *args, **kwargs))
def add_custom_antimicrobials(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.add_custom_antimicrobials(x))
def clear_custom_antimicrobials(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.clear_custom_antimicrobials(*args, **kwargs))
def add_custom_microorganisms(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.add_custom_microorganisms(x))
def clear_custom_microorganisms(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.clear_custom_microorganisms(*args, **kwargs))
def age(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.age(x, *args, **kwargs))
def age_groups(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.age_groups(x, *args, **kwargs))
def antibiogram(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.antibiogram(x, *args, **kwargs))
def wisca(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.wisca(x, *args, **kwargs))
def retrieve_wisca_parameters(wisca_model, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.retrieve_wisca_parameters(wisca_model, *args, **kwargs))
def aminoglycosides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.aminoglycosides(only_sir_columns = False, *args, **kwargs))
def aminopenicillins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.aminopenicillins(only_sir_columns = False, *args, **kwargs))
def antifungals(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.antifungals(only_sir_columns = False, *args, **kwargs))
def antimycobacterials(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.antimycobacterials(only_sir_columns = False, *args, **kwargs))
def betalactams(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.betalactams(only_sir_columns = False, *args, **kwargs))
def betalactams_with_inhibitor(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.betalactams_with_inhibitor(only_sir_columns = False, *args, **kwargs))
def carbapenems(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.carbapenems(only_sir_columns = False, *args, **kwargs))
def cephalosporins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins(only_sir_columns = False, *args, **kwargs))
def cephalosporins_1st(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins_1st(only_sir_columns = False, *args, **kwargs))
def cephalosporins_2nd(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins_2nd(only_sir_columns = False, *args, **kwargs))
def cephalosporins_3rd(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins_3rd(only_sir_columns = False, *args, **kwargs))
def cephalosporins_4th(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins_4th(only_sir_columns = False, *args, **kwargs))
def cephalosporins_5th(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.cephalosporins_5th(only_sir_columns = False, *args, **kwargs))
def fluoroquinolones(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.fluoroquinolones(only_sir_columns = False, *args, **kwargs))
def glycopeptides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.glycopeptides(only_sir_columns = False, *args, **kwargs))
def isoxazolylpenicillins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.isoxazolylpenicillins(only_sir_columns = False, *args, **kwargs))
def lincosamides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.lincosamides(only_sir_columns = False, *args, **kwargs))
def lipoglycopeptides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.lipoglycopeptides(only_sir_columns = False, *args, **kwargs))
def macrolides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.macrolides(only_sir_columns = False, *args, **kwargs))
def monobactams(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.monobactams(only_sir_columns = False, *args, **kwargs))
def nitrofurans(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.nitrofurans(only_sir_columns = False, *args, **kwargs))
def oxazolidinones(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.oxazolidinones(only_sir_columns = False, *args, **kwargs))
def penicillins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.penicillins(only_sir_columns = False, *args, **kwargs))
def phenicols(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.phenicols(only_sir_columns = False, *args, **kwargs))
def polymyxins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.polymyxins(only_sir_columns = False, *args, **kwargs))
def quinolones(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.quinolones(only_sir_columns = False, *args, **kwargs))
def rifamycins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.rifamycins(only_sir_columns = False, *args, **kwargs))
def streptogramins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.streptogramins(only_sir_columns = False, *args, **kwargs))
def sulfonamides(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.sulfonamides(only_sir_columns = False, *args, **kwargs))
def tetracyclines(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.tetracyclines(only_sir_columns = False, *args, **kwargs))
def trimethoprims(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.trimethoprims(only_sir_columns = False, *args, **kwargs))
def ureidopenicillins(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ureidopenicillins(only_sir_columns = False, *args, **kwargs))
def amr_class(amr_class, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.amr_class(amr_class, *args, **kwargs))
def amr_selector(filter, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.amr_selector(filter, *args, **kwargs))
def administrable_per_os(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.administrable_per_os(only_sir_columns = False, *args, **kwargs))
def administrable_iv(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.administrable_iv(only_sir_columns = False, *args, **kwargs))
def not_intrinsic_resistant(only_sir_columns = False, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.not_intrinsic_resistant(only_sir_columns = False, *args, **kwargs))
def as_ab(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_ab(x, *args, **kwargs))
def is_ab(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_ab(x))
def ab_reset_session(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ab_reset_session(*args, **kwargs))
def as_av(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_av(x, *args, **kwargs))
def is_av(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_av(x))
def as_disk(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_disk(x, *args, **kwargs))
def is_disk(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_disk(x))
def as_mic(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_mic(x, *args, **kwargs))
def is_mic(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_mic(x))
def rescale_mic(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.rescale_mic(x, *args, **kwargs))
def mic_p50(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mic_p50(x, *args, **kwargs))
def mic_p90(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mic_p90(x, *args, **kwargs))
def as_mo(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_mo(x, *args, **kwargs))
def is_mo(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_mo(x))
def mo_uncertainties(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_uncertainties(*args, **kwargs))
def mo_renamed(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_renamed(*args, **kwargs))
def mo_failures(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_failures(*args, **kwargs))
def mo_reset_session(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_reset_session(*args, **kwargs))
def mo_cleaning_regex(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_cleaning_regex(*args, **kwargs))
def as_sir(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.as_sir(x, *args, **kwargs))
def is_sir(x):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_sir(x))
def is_sir_eligible(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_sir_eligible(x, *args, **kwargs))
def sir_interpretation_history(clean):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.sir_interpretation_history(clean))
def atc_online_property(atc_code, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.atc_online_property(atc_code, *args, **kwargs))
def atc_online_groups(atc_code, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.atc_online_groups(atc_code, *args, **kwargs))
def atc_online_ddd(atc_code, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.atc_online_ddd(atc_code, *args, **kwargs))
def atc_online_ddd_units(atc_code, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.atc_online_ddd_units(atc_code, *args, **kwargs))
def av_from_text(text, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_from_text(text, *args, **kwargs))
def av_name(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_name(x, *args, **kwargs))
def av_cid(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_cid(x, *args, **kwargs))
def av_synonyms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_synonyms(x, *args, **kwargs))
def av_tradenames(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_tradenames(x, *args, **kwargs))
def av_group(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_group(x, *args, **kwargs))
def av_atc(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_atc(x, *args, **kwargs))
def av_loinc(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_loinc(x, *args, **kwargs))
def av_ddd(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_ddd(x, *args, **kwargs))
def av_ddd_units(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_ddd_units(x, *args, **kwargs))
def av_info(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_info(x, *args, **kwargs))
def av_url(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_url(x, *args, **kwargs))
def av_property(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.av_property(x, *args, **kwargs))
def availability(tbl, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.availability(tbl, *args, **kwargs))
def bug_drug_combinations(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.bug_drug_combinations(x, *args, **kwargs))
def count_resistant(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_resistant(*args, **kwargs))
def count_susceptible(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_susceptible(*args, **kwargs))
def count_S(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_S(*args, **kwargs))
def count_SI(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_SI(*args, **kwargs))
def count_I(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_I(*args, **kwargs))
def count_IR(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_IR(*args, **kwargs))
def count_R(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_R(*args, **kwargs))
def count_all(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_all(*args, **kwargs))
def n_sir(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.n_sir(*args, **kwargs))
def count_df(data, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.count_df(data, *args, **kwargs))
def custom_eucast_rules(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.custom_eucast_rules(*args, **kwargs))
def eucast_rules(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.eucast_rules(x, *args, **kwargs))
def eucast_dosage(ab, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.eucast_dosage(ab, *args, **kwargs))
def export_ncbi_biosample(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.export_ncbi_biosample(x, *args, **kwargs))
def first_isolate(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.first_isolate(x = None, *args, **kwargs))
def filter_first_isolate(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.filter_first_isolate(x = None, *args, **kwargs))
def g_test(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.g_test(x, *args, **kwargs))
def is_new_episode(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.is_new_episode(x, *args, **kwargs))
def ggplot_pca(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ggplot_pca(x, *args, **kwargs))
def ggplot_sir(data, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ggplot_sir(data, *args, **kwargs))
def geom_sir(position = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.geom_sir(position = None, *args, **kwargs))
def guess_ab_col(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.guess_ab_col(x = None, *args, **kwargs))
def italicise_taxonomy(string, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.italicise_taxonomy(string, *args, **kwargs))
def italicize_taxonomy(string, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.italicize_taxonomy(string, *args, **kwargs))
def inner_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.inner_join_microorganisms(x, *args, **kwargs))
def left_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.left_join_microorganisms(x, *args, **kwargs))
def right_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.right_join_microorganisms(x, *args, **kwargs))
def full_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.full_join_microorganisms(x, *args, **kwargs))
def semi_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.semi_join_microorganisms(x, *args, **kwargs))
def anti_join_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.anti_join_microorganisms(x, *args, **kwargs))
def key_antimicrobials(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.key_antimicrobials(x = None, *args, **kwargs))
def all_antimicrobials(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.all_antimicrobials(x = None, *args, **kwargs))
def kurtosis(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.kurtosis(x, *args, **kwargs))
def like(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.like(x, *args, **kwargs))
def mdro(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mdro(x = None, *args, **kwargs))
def custom_mdro_guideline(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.custom_mdro_guideline(*args, **kwargs))
def brmo(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.brmo(x = None, *args, **kwargs))
def mrgn(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mrgn(x = None, *args, **kwargs))
def mdr_tb(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mdr_tb(x = None, *args, **kwargs))
def mdr_cmi2012(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mdr_cmi2012(x = None, *args, **kwargs))
def eucast_exceptional_phenotypes(x = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.eucast_exceptional_phenotypes(x = None, *args, **kwargs))
def mean_amr_distance(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mean_amr_distance(x, *args, **kwargs))
def amr_distance_from_row(amr_distance, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.amr_distance_from_row(amr_distance, *args, **kwargs))
def mo_matching_score(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_matching_score(x, *args, **kwargs))
def mo_name(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_name(x, *args, **kwargs))
def mo_fullname(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_fullname(x, *args, **kwargs))
def mo_shortname(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_shortname(x, *args, **kwargs))
def mo_subspecies(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_subspecies(x, *args, **kwargs))
def mo_species(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_species(x, *args, **kwargs))
def mo_genus(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_genus(x, *args, **kwargs))
def mo_family(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_family(x, *args, **kwargs))
def mo_order(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_order(x, *args, **kwargs))
def mo_class(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_class(x, *args, **kwargs))
def mo_phylum(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_phylum(x, *args, **kwargs))
def mo_kingdom(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_kingdom(x, *args, **kwargs))
def mo_domain(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_domain(x, *args, **kwargs))
def mo_type(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_type(x, *args, **kwargs))
def mo_status(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_status(x, *args, **kwargs))
def mo_pathogenicity(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_pathogenicity(x, *args, **kwargs))
def mo_gramstain(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_gramstain(x, *args, **kwargs))
def mo_is_gram_negative(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_is_gram_negative(x, *args, **kwargs))
def mo_is_gram_positive(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_is_gram_positive(x, *args, **kwargs))
def mo_is_yeast(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_is_yeast(x, *args, **kwargs))
def mo_is_intrinsic_resistant(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_is_intrinsic_resistant(x, *args, **kwargs))
def mo_oxygen_tolerance(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_oxygen_tolerance(x, *args, **kwargs))
def mo_is_anaerobic(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_is_anaerobic(x, *args, **kwargs))
def mo_snomed(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_snomed(x, *args, **kwargs))
def mo_ref(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_ref(x, *args, **kwargs))
def mo_authors(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_authors(x, *args, **kwargs))
def mo_year(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_year(x, *args, **kwargs))
def mo_lpsn(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_lpsn(x, *args, **kwargs))
def mo_mycobank(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_mycobank(x, *args, **kwargs))
def mo_gbif(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_gbif(x, *args, **kwargs))
def mo_rank(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_rank(x, *args, **kwargs))
def mo_taxonomy(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_taxonomy(x, *args, **kwargs))
def mo_synonyms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_synonyms(x, *args, **kwargs))
def mo_current(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_current(x, *args, **kwargs))
def mo_group_members(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_group_members(x, *args, **kwargs))
def mo_info(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_info(x, *args, **kwargs))
def mo_url(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_url(x, *args, **kwargs))
def mo_property(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.mo_property(x, *args, **kwargs))
def pca(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.pca(x, *args, **kwargs))
def theme_sir(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.theme_sir(*args, **kwargs))
def labels_sir_count(position = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.labels_sir_count(position = None, *args, **kwargs))
def resistance(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.resistance(*args, **kwargs))
def susceptibility(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.susceptibility(*args, **kwargs))
def sir_confidence_interval(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.sir_confidence_interval(*args, **kwargs))
def proportion_R(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_R(*args, **kwargs))
def proportion_IR(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_IR(*args, **kwargs))
def proportion_I(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_I(*args, **kwargs))
def proportion_SI(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_SI(*args, **kwargs))
def proportion_S(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_S(*args, **kwargs))
def proportion_df(data, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.proportion_df(data, *args, **kwargs))
def sir_df(data, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.sir_df(data, *args, **kwargs))
def random_mic(size = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.random_mic(size = None, *args, **kwargs))
def random_disk(size = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.random_disk(size = None, *args, **kwargs))
def random_sir(size = None, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.random_sir(size = None, *args, **kwargs))
def resistance_predict(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.resistance_predict(x, *args, **kwargs))
def sir_predict(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.sir_predict(x, *args, **kwargs))
def ggplot_sir_predict(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.ggplot_sir_predict(x, *args, **kwargs))
def skewness(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.skewness(x, *args, **kwargs))
def top_n_microorganisms(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.top_n_microorganisms(x, *args, **kwargs))
def reset_AMR_locale(*args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.reset_AMR_locale(*args, **kwargs))
def translate_AMR(x, *args, **kwargs):
"""Please see our website of the R package for the full manual: https://amr-for-r.org"""
return convert_to_python(amr_r.translate_AMR(x, *args, **kwargs))

184
README.md Executable file
View File

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

BIN
dist/amr-2.1.1.9268-py3-none-any.whl vendored Normal file

Binary file not shown.

BIN
dist/amr-2.1.1.9268.tar.gz vendored Normal file

Binary file not shown.

27
setup.py Normal file
View File

@ -0,0 +1,27 @@
from setuptools import setup, find_packages
setup(
name='AMR',
version='2.1.1.9268',
packages=find_packages(),
install_requires=[
'rpy2',
'numpy',
'pandas',
],
author='Matthijs Berends',
author_email='m.s.berends@umcg.nl',
description='A Python wrapper for the AMR R package',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
url='https://github.com/msberends/AMR',
project_urls={
'Bug Tracker': 'https://github.com/msberends/AMR/issues',
},
license='GPL 2',
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
)