From 87271d261a548ff1555352ef5dfba700a8292c65 Mon Sep 17 00:00:00 2001 From: Matthijs Berends Date: Thu, 21 Nov 2024 10:06:26 +0100 Subject: [PATCH] add Python package to repo --- .Rbuildignore | 1 + .gitignore | 1 - PythonPackage/AMR/AMR.egg-info/PKG-INFO | 213 ++++++ PythonPackage/AMR/AMR.egg-info/SOURCES.txt | 10 + .../AMR/AMR.egg-info/dependency_links.txt | 1 + PythonPackage/AMR/AMR.egg-info/requires.txt | 3 + PythonPackage/AMR/AMR.egg-info/top_level.txt | 1 + PythonPackage/AMR/AMR/__init__.py | 201 ++++++ PythonPackage/AMR/AMR/datasets.py | 73 ++ PythonPackage/AMR/AMR/functions.py | 629 ++++++++++++++++++ PythonPackage/AMR/README.md | 196 ++++++ .../AMR/dist/AMR-2.1.1.9103-py3-none-any.whl | Bin 0 -> 9967 bytes PythonPackage/AMR/dist/amr-2.1.1.9103.tar.gz | Bin 0 -> 9758 bytes PythonPackage/AMR/setup.py | 27 + R/sir.R | 24 +- data-raw/_generate_python_wrapper.sh | 71 +- 16 files changed, 1417 insertions(+), 34 deletions(-) create mode 100644 PythonPackage/AMR/AMR.egg-info/PKG-INFO create mode 100644 PythonPackage/AMR/AMR.egg-info/SOURCES.txt create mode 100644 PythonPackage/AMR/AMR.egg-info/dependency_links.txt create mode 100644 PythonPackage/AMR/AMR.egg-info/requires.txt create mode 100644 PythonPackage/AMR/AMR.egg-info/top_level.txt create mode 100644 PythonPackage/AMR/AMR/__init__.py create mode 100644 PythonPackage/AMR/AMR/datasets.py create mode 100644 PythonPackage/AMR/AMR/functions.py create mode 100755 PythonPackage/AMR/README.md create mode 100644 PythonPackage/AMR/dist/AMR-2.1.1.9103-py3-none-any.whl create mode 100644 PythonPackage/AMR/dist/amr-2.1.1.9103.tar.gz create mode 100644 PythonPackage/AMR/setup.py diff --git a/.Rbuildignore b/.Rbuildignore index 1cfb547e..19b952f7 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -35,3 +35,4 @@ ^vignettes/WHONET\.Rmd$ ^logo.svg$ ^CRAN-SUBMISSION$ +^PythonPackage$ diff --git a/.gitignore b/.gitignore index 0dbdf30b..7aa85485 100755 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,3 @@ data-raw/country_analysis_url_token.R data-raw/country_analysis2.R data-raw/taxonomy.csv data-raw/WHONET/* -data-raw/python_wrapper/* diff --git a/PythonPackage/AMR/AMR.egg-info/PKG-INFO b/PythonPackage/AMR/AMR.egg-info/PKG-INFO new file mode 100644 index 00000000..0caea059 --- /dev/null +++ b/PythonPackage/AMR/AMR.egg-info/PKG-INFO @@ -0,0 +1,213 @@ +Metadata-Version: 2.1 +Name: AMR +Version: 2.1.1.9103 +Summary: A Python wrapper for the AMR R package +Home-page: https://github.com/msberends/AMR +Author: Dr. 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 + +--- +title: "AMR for Python" +output: + rmarkdown::html_vignette: + toc: true + toc_depth: 3 +vignette: > + %\VignetteIndexEntry{AMR for Python} + %\VignetteEncoding{UTF-8} + %\VignetteEngine{knitr::rmarkdown} +editor_options: + chunk_output_type: console +--- + +```{r setup, include = FALSE, results = 'markup'} +knitr::opts_chunk$set( + warning = FALSE, + collapse = TRUE, + comment = "#>", + fig.width = 7.5, + fig.height = 5 +) +``` + +# Introduction + +The `AMR` package for R is a powerful tool for antimicrobial resistance (AMR) analysis. It provides extensive features for handling microbial and antimicrobial data. However, for those who work primarily in Python, we now have a more intuitive option available: the [`AMR` Python Package Index](https://pypi.org/project/AMR/). + +This Python package is a wrapper round 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. + +# Install + +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 + +Here’s 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". + + +## 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`, `antibiotics`, `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.antibiotics +``` + +| 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 | + + +## 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. Here’s 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. + +# 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. diff --git a/PythonPackage/AMR/AMR.egg-info/SOURCES.txt b/PythonPackage/AMR/AMR.egg-info/SOURCES.txt new file mode 100644 index 00000000..f37c1484 --- /dev/null +++ b/PythonPackage/AMR/AMR.egg-info/SOURCES.txt @@ -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 \ No newline at end of file diff --git a/PythonPackage/AMR/AMR.egg-info/dependency_links.txt b/PythonPackage/AMR/AMR.egg-info/dependency_links.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/PythonPackage/AMR/AMR.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/PythonPackage/AMR/AMR.egg-info/requires.txt b/PythonPackage/AMR/AMR.egg-info/requires.txt new file mode 100644 index 00000000..fb2bcf68 --- /dev/null +++ b/PythonPackage/AMR/AMR.egg-info/requires.txt @@ -0,0 +1,3 @@ +rpy2 +numpy +pandas diff --git a/PythonPackage/AMR/AMR.egg-info/top_level.txt b/PythonPackage/AMR/AMR.egg-info/top_level.txt new file mode 100644 index 00000000..18f3926f --- /dev/null +++ b/PythonPackage/AMR/AMR.egg-info/top_level.txt @@ -0,0 +1 @@ +AMR diff --git a/PythonPackage/AMR/AMR/__init__.py b/PythonPackage/AMR/AMR/__init__.py new file mode 100644 index 00000000..5a6fef0b --- /dev/null +++ b/PythonPackage/AMR/AMR/__init__.py @@ -0,0 +1,201 @@ +from .datasets import example_isolates +from .datasets import microorganisms +from .datasets import antibiotics +from .datasets import clinical_breakpoints +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 ab_class +from .functions import ab_selector +from .functions import aminoglycosides +from .functions import aminopenicillins +from .functions import antifungals +from .functions import antimycobacterials +from .functions import betalactams +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 lincosamides +from .functions import lipoglycopeptides +from .functions import macrolides +from .functions import nitrofurans +from .functions import oxazolidinones +from .functions import penicillins +from .functions import polymyxins +from .functions import quinolones +from .functions import rifamycins +from .functions import streptogramins +from .functions import tetracyclines +from .functions import trimethoprims +from .functions import ureidopenicillins +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 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 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 theme_sir +from .functions import labels_sir_count +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 antimicrobials_equal +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 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 reset_AMR_locale +from .functions import translate_AMR diff --git a/PythonPackage/AMR/AMR/datasets.py b/PythonPackage/AMR/AMR/datasets.py new file mode 100644 index 00000000..e4729108 --- /dev/null +++ b/PythonPackage/AMR/AMR/datasets.py @@ -0,0 +1,73 @@ +BLUE = '\033[94m' +GREEN = '\033[32m' +RESET = '\033[0m' + +print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True) + + +import os +from rpy2 import robjects +from rpy2.robjects import pandas2ri +from rpy2.robjects.packages import importr, isinstalled +import pandas as pd +import importlib.metadata as metadata + +# Get the path to the virtual environment +venv_path = os.getenv('VIRTUAL_ENV') # Path to the active virtual environment +if not venv_path: + raise EnvironmentError("No virtual environment detected. Please activate your Python virtual environment.") + +# Define R library path within the venv +r_lib_path = os.path.join(venv_path, "R_libs") +# Ensure the R library path exists +os.makedirs(r_lib_path, exist_ok=True) +# Set the R library path in .libPaths +base = importr('base') +base._libPaths(r_lib_path) + +# Check if the AMR package is installed in R +if not isinstalled('AMR'): + utils = importr('utils') + utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) + +# Python package version of AMR +try: + python_amr_version = metadata.version('AMR') +except metadata.PackageNotFoundError: + python_amr_version = None + +# R package version of AMR +r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')[0] + +# Compare R and Python package versions +if python_amr_version and r_amr_version != python_amr_version: + try: + utils = importr('utils') + utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) + except Exception as e: + print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", 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)]')) +antibiotics = pandas2ri.rpy2py(robjects.r('AMR::antibiotics[, !sapply(AMR::antibiotics, is.list)]')) +clinical_breakpoints = pandas2ri.rpy2py(robjects.r('AMR::clinical_breakpoints[, !sapply(AMR::clinical_breakpoints, is.list)]')) + +print(f"{BLUE}AMR:{RESET} {GREEN}Done.{RESET}", flush=True) diff --git a/PythonPackage/AMR/AMR/functions.py b/PythonPackage/AMR/AMR/functions.py new file mode 100644 index 00000000..1536b209 --- /dev/null +++ b/PythonPackage/AMR/AMR/functions.py @@ -0,0 +1,629 @@ +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_from_text(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_from_text(*args, **kwargs)) +def ab_name(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_name(x, *args, **kwargs)) +def ab_cid(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_cid(x, *args, **kwargs)) +def ab_synonyms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_synonyms(x, *args, **kwargs)) +def ab_tradenames(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_tradenames(x, *args, **kwargs)) +def ab_group(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_group(x, *args, **kwargs)) +def ab_atc(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_atc(x, *args, **kwargs)) +def ab_atc_group1(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_atc_group1(x, *args, **kwargs)) +def ab_atc_group2(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_atc_group2(x, *args, **kwargs)) +def ab_loinc(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_loinc(x, *args, **kwargs)) +def ab_ddd(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_ddd(x, *args, **kwargs)) +def ab_ddd_units(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_ddd_units(x, *args, **kwargs)) +def ab_info(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_info(x, *args, **kwargs)) +def ab_url(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_url(x, *args, **kwargs)) +def ab_property(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_property(x, *args, **kwargs)) +def add_custom_antimicrobials(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.add_custom_antimicrobials(x)) +def clear_custom_antimicrobials(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.clear_custom_antimicrobials(*args, **kwargs)) +def add_custom_microorganisms(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.add_custom_microorganisms(x)) +def clear_custom_microorganisms(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.clear_custom_microorganisms(*args, **kwargs)) +def age(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.age(x, *args, **kwargs)) +def age_groups(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.age_groups(x, *args, **kwargs)) +def antibiogram(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.antibiogram(*args, **kwargs)) +def ab_class(ab_class, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_class(ab_class, *args, **kwargs)) +def ab_selector(filter, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ab_selector(filter, *args, **kwargs)) +def aminoglycosides(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.aminoglycosides(only_sir_columns = False, *args, **kwargs)) +def aminopenicillins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.aminopenicillins(only_sir_columns = False, *args, **kwargs)) +def antifungals(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.antifungals(only_sir_columns = False, *args, **kwargs)) +def antimycobacterials(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.antimycobacterials(only_sir_columns = False, *args, **kwargs)) +def betalactams(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.betalactams(only_sir_columns = False, *args, **kwargs)) +def carbapenems(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.carbapenems(only_sir_columns = False, *args, **kwargs)) +def cephalosporins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins(only_sir_columns = False, *args, **kwargs)) +def cephalosporins_1st(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins_1st(only_sir_columns = False, *args, **kwargs)) +def cephalosporins_2nd(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins_2nd(only_sir_columns = False, *args, **kwargs)) +def cephalosporins_3rd(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins_3rd(only_sir_columns = False, *args, **kwargs)) +def cephalosporins_4th(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins_4th(only_sir_columns = False, *args, **kwargs)) +def cephalosporins_5th(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.cephalosporins_5th(only_sir_columns = False, *args, **kwargs)) +def fluoroquinolones(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.fluoroquinolones(only_sir_columns = False, *args, **kwargs)) +def glycopeptides(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.glycopeptides(only_sir_columns = False, *args, **kwargs)) +def lincosamides(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.lincosamides(only_sir_columns = False, *args, **kwargs)) +def lipoglycopeptides(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.lipoglycopeptides(only_sir_columns = False, *args, **kwargs)) +def macrolides(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.macrolides(only_sir_columns = False, *args, **kwargs)) +def nitrofurans(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.nitrofurans(only_sir_columns = False, *args, **kwargs)) +def oxazolidinones(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.oxazolidinones(only_sir_columns = False, *args, **kwargs)) +def penicillins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.penicillins(only_sir_columns = False, *args, **kwargs)) +def polymyxins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.polymyxins(only_sir_columns = False, *args, **kwargs)) +def quinolones(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.quinolones(only_sir_columns = False, *args, **kwargs)) +def rifamycins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.rifamycins(only_sir_columns = False, *args, **kwargs)) +def streptogramins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.streptogramins(only_sir_columns = False, *args, **kwargs)) +def tetracyclines(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.tetracyclines(only_sir_columns = False, *args, **kwargs)) +def trimethoprims(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.trimethoprims(only_sir_columns = False, *args, **kwargs)) +def ureidopenicillins(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ureidopenicillins(only_sir_columns = False, *args, **kwargs)) +def administrable_per_os(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.administrable_per_os(only_sir_columns = False, *args, **kwargs)) +def administrable_iv(only_sir_columns = False, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.administrable_iv(only_sir_columns = False, *args, **kwargs)) +def not_intrinsic_resistant(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.not_intrinsic_resistant(*args, **kwargs)) +def as_ab(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_ab(x, *args, **kwargs)) +def is_ab(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_ab(x)) +def as_av(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_av(x, *args, **kwargs)) +def is_av(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_av(x)) +def as_disk(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_disk(x, *args, **kwargs)) +def is_disk(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_disk(x)) +def as_mic(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_mic(x, *args, **kwargs)) +def is_mic(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_mic(x)) +def rescale_mic(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.rescale_mic(x, *args, **kwargs)) +def as_mo(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_mo(*args, **kwargs)) +def is_mo(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_mo(x)) +def mo_uncertainties(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_uncertainties(*args, **kwargs)) +def mo_renamed(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_renamed(*args, **kwargs)) +def mo_failures(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_failures(*args, **kwargs)) +def mo_reset_session(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_reset_session(*args, **kwargs)) +def mo_cleaning_regex(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_cleaning_regex(*args, **kwargs)) +def as_sir(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.as_sir(x, *args, **kwargs)) +def is_sir(x): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_sir(x)) +def is_sir_eligible(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_sir_eligible(x, *args, **kwargs)) +def sir_interpretation_history(clean): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.sir_interpretation_history(clean)) +def atc_online_property(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.atc_online_property(*args, **kwargs)) +def atc_online_groups(atc_code, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.atc_online_groups(atc_code, *args, **kwargs)) +def atc_online_ddd(atc_code, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.atc_online_ddd(atc_code, *args, **kwargs)) +def atc_online_ddd_units(atc_code, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.atc_online_ddd_units(atc_code, *args, **kwargs)) +def av_from_text(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_from_text(*args, **kwargs)) +def av_name(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_name(x, *args, **kwargs)) +def av_cid(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_cid(x, *args, **kwargs)) +def av_synonyms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_synonyms(x, *args, **kwargs)) +def av_tradenames(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_tradenames(x, *args, **kwargs)) +def av_group(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_group(x, *args, **kwargs)) +def av_atc(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_atc(x, *args, **kwargs)) +def av_loinc(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_loinc(x, *args, **kwargs)) +def av_ddd(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_ddd(x, *args, **kwargs)) +def av_ddd_units(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_ddd_units(x, *args, **kwargs)) +def av_info(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_info(x, *args, **kwargs)) +def av_url(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_url(x, *args, **kwargs)) +def av_property(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.av_property(x, *args, **kwargs)) +def availability(tbl, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.availability(tbl, *args, **kwargs)) +def bug_drug_combinations(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.bug_drug_combinations(x, *args, **kwargs)) +def count_resistant(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_resistant(*args, **kwargs)) +def count_susceptible(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_susceptible(*args, **kwargs)) +def count_S(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_S(*args, **kwargs)) +def count_SI(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_SI(*args, **kwargs)) +def count_I(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_I(*args, **kwargs)) +def count_IR(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_IR(*args, **kwargs)) +def count_R(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_R(*args, **kwargs)) +def count_all(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_all(*args, **kwargs)) +def n_sir(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.n_sir(*args, **kwargs)) +def count_df(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.count_df(*args, **kwargs)) +def custom_eucast_rules(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.custom_eucast_rules(*args, **kwargs)) +def eucast_rules(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.eucast_rules(*args, **kwargs)) +def eucast_dosage(ab, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.eucast_dosage(ab, *args, **kwargs)) +def export_ncbi_biosample(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.export_ncbi_biosample(*args, **kwargs)) +def first_isolate(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.first_isolate(*args, **kwargs)) +def filter_first_isolate(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.filter_first_isolate(*args, **kwargs)) +def g_test(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.g_test(x, *args, **kwargs)) +def is_new_episode(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.is_new_episode(x, *args, **kwargs)) +def ggplot_pca(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ggplot_pca(*args, **kwargs)) +def ggplot_sir(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ggplot_sir(*args, **kwargs)) +def geom_sir(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.geom_sir(*args, **kwargs)) +def theme_sir(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.theme_sir(*args, **kwargs)) +def labels_sir_count(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.labels_sir_count(*args, **kwargs)) +def guess_ab_col(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.guess_ab_col(*args, **kwargs)) +def italicise_taxonomy(string, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.italicise_taxonomy(string, *args, **kwargs)) +def italicize_taxonomy(string, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.italicize_taxonomy(string, *args, **kwargs)) +def inner_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.inner_join_microorganisms(x, *args, **kwargs)) +def left_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.left_join_microorganisms(x, *args, **kwargs)) +def right_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.right_join_microorganisms(x, *args, **kwargs)) +def full_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.full_join_microorganisms(x, *args, **kwargs)) +def semi_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.semi_join_microorganisms(x, *args, **kwargs)) +def anti_join_microorganisms(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.anti_join_microorganisms(x, *args, **kwargs)) +def key_antimicrobials(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.key_antimicrobials(*args, **kwargs)) +def all_antimicrobials(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.all_antimicrobials(x = None, *args, **kwargs)) +def antimicrobials_equal(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.antimicrobials_equal(*args, **kwargs)) +def kurtosis(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.kurtosis(x, *args, **kwargs)) +def like(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.like(x, *args, **kwargs)) +def mdro(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mdro(*args, **kwargs)) +def custom_mdro_guideline(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.custom_mdro_guideline(*args, **kwargs)) +def brmo(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.brmo(x = None, *args, **kwargs)) +def mrgn(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mrgn(x = None, *args, **kwargs)) +def mdr_tb(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mdr_tb(x = None, *args, **kwargs)) +def mdr_cmi2012(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mdr_cmi2012(x = None, *args, **kwargs)) +def eucast_exceptional_phenotypes(x = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.eucast_exceptional_phenotypes(x = None, *args, **kwargs)) +def mean_amr_distance(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mean_amr_distance(x, *args, **kwargs)) +def amr_distance_from_row(amr_distance, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.amr_distance_from_row(amr_distance, *args, **kwargs)) +def mo_matching_score(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_matching_score(x, *args, **kwargs)) +def mo_name(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_name(*args, **kwargs)) +def mo_fullname(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_fullname(*args, **kwargs)) +def mo_shortname(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_shortname(*args, **kwargs)) +def mo_subspecies(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_subspecies(*args, **kwargs)) +def mo_species(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_species(*args, **kwargs)) +def mo_genus(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_genus(*args, **kwargs)) +def mo_family(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_family(*args, **kwargs)) +def mo_order(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_order(*args, **kwargs)) +def mo_class(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_class(*args, **kwargs)) +def mo_phylum(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_phylum(*args, **kwargs)) +def mo_kingdom(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_kingdom(*args, **kwargs)) +def mo_domain(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_domain(*args, **kwargs)) +def mo_type(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_type(*args, **kwargs)) +def mo_status(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_status(*args, **kwargs)) +def mo_pathogenicity(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_pathogenicity(*args, **kwargs)) +def mo_gramstain(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_gramstain(*args, **kwargs)) +def mo_is_gram_negative(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_is_gram_negative(*args, **kwargs)) +def mo_is_gram_positive(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_is_gram_positive(*args, **kwargs)) +def mo_is_yeast(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_is_yeast(*args, **kwargs)) +def mo_is_intrinsic_resistant(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_is_intrinsic_resistant(*args, **kwargs)) +def mo_oxygen_tolerance(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_oxygen_tolerance(*args, **kwargs)) +def mo_is_anaerobic(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_is_anaerobic(*args, **kwargs)) +def mo_snomed(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_snomed(*args, **kwargs)) +def mo_ref(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_ref(*args, **kwargs)) +def mo_authors(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_authors(*args, **kwargs)) +def mo_year(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_year(*args, **kwargs)) +def mo_lpsn(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_lpsn(*args, **kwargs)) +def mo_mycobank(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_mycobank(*args, **kwargs)) +def mo_gbif(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_gbif(*args, **kwargs)) +def mo_rank(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_rank(*args, **kwargs)) +def mo_taxonomy(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_taxonomy(*args, **kwargs)) +def mo_synonyms(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_synonyms(*args, **kwargs)) +def mo_current(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_current(x, *args, **kwargs)) +def mo_group_members(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_group_members(*args, **kwargs)) +def mo_info(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_info(*args, **kwargs)) +def mo_url(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_url(*args, **kwargs)) +def mo_property(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.mo_property(*args, **kwargs)) +def pca(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.pca(*args, **kwargs)) +def resistance(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.resistance(*args, **kwargs)) +def susceptibility(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.susceptibility(*args, **kwargs)) +def sir_confidence_interval(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.sir_confidence_interval(*args, **kwargs)) +def proportion_R(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_R(*args, **kwargs)) +def proportion_IR(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_IR(*args, **kwargs)) +def proportion_I(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_I(*args, **kwargs)) +def proportion_SI(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_SI(*args, **kwargs)) +def proportion_S(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_S(*args, **kwargs)) +def proportion_df(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.proportion_df(*args, **kwargs)) +def sir_df(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.sir_df(*args, **kwargs)) +def random_mic(size = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.random_mic(size = None, *args, **kwargs)) +def random_disk(size = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.random_disk(size = None, *args, **kwargs)) +def random_sir(size = None, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.random_sir(size = None, *args, **kwargs)) +def resistance_predict(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.resistance_predict(*args, **kwargs)) +def sir_predict(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.sir_predict(*args, **kwargs)) +def ggplot_sir_predict(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.ggplot_sir_predict(*args, **kwargs)) +def skewness(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.skewness(x, *args, **kwargs)) +def reset_AMR_locale(*args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.reset_AMR_locale(*args, **kwargs)) +def translate_AMR(x, *args, **kwargs): + """See our website of the R package for the manual: https://msberends.github.io/AMR/index.html""" + return convert_to_python(amr_r.translate_AMR(x, *args, **kwargs)) diff --git a/PythonPackage/AMR/README.md b/PythonPackage/AMR/README.md new file mode 100755 index 00000000..c28f0999 --- /dev/null +++ b/PythonPackage/AMR/README.md @@ -0,0 +1,196 @@ +--- +title: "AMR for Python" +output: + rmarkdown::html_vignette: + toc: true + toc_depth: 3 +vignette: > + %\VignetteIndexEntry{AMR for Python} + %\VignetteEncoding{UTF-8} + %\VignetteEngine{knitr::rmarkdown} +editor_options: + chunk_output_type: console +--- + +```{r setup, include = FALSE, results = 'markup'} +knitr::opts_chunk$set( + warning = FALSE, + collapse = TRUE, + comment = "#>", + fig.width = 7.5, + fig.height = 5 +) +``` + +# Introduction + +The `AMR` package for R is a powerful tool for antimicrobial resistance (AMR) analysis. It provides extensive features for handling microbial and antimicrobial data. However, for those who work primarily in Python, we now have a more intuitive option available: the [`AMR` Python Package Index](https://pypi.org/project/AMR/). + +This Python package is a wrapper round 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. + +# Install + +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 + +Here’s 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". + + +## 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`, `antibiotics`, `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.antibiotics +``` + +| 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 | + + +## 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. Here’s 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. + +# 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. diff --git a/PythonPackage/AMR/dist/AMR-2.1.1.9103-py3-none-any.whl b/PythonPackage/AMR/dist/AMR-2.1.1.9103-py3-none-any.whl new file mode 100644 index 0000000000000000000000000000000000000000..896d006629dbb2ecf16a6d6b039aa7e84a331f08 GIT binary patch literal 9967 zcmaJ{1#lcok{!t!F*7qWgT-VqGc%8v$+DO&W@cGv;n-qkW|qawj6VOpyV%_yciR;e z-CY&$byak~?8?eimiqvO2><|K0l02%I+Gk;V=zDfAc+tFK>5=us-VhZWMt!D<7Q;U z?Bt!2A?LBijVgIy7^)SI!7vQTK1PaR1;Io=i7e#o?@UiI^{orNus&PxddW%LVoCjI|sh4_{1p*r=+9NFUO!|!spYvcT z(G)y?wBR4kVwFz=yuK{IFLs`5gQ&C#oR4=(FEn*nW>`ozE7a#f>xR&0z*4#R>88{Y zSdD|SE3o{!l;}D6Xrp>E$qVkAaFLy83|BF1)0)mcE8J@WOGc}aDb)-xk|TukzKr+x z6eX?_$%PbJ#I0zc#0F$@4L)4{@(y-SsmCr1thmdsLdVR4iFQp0Qf|>EL3me2eotUG zit<`~6%hi~C4VLj7_}PSJlUgs3YS;x=qK#tf|?j44ZkOTmH1|RB{h~nHUya>b2Vof zEqUb?+qIXpGgqJT0o(E3cN5A;>B)sgm0PltX;p#jtADz8{g91CoGM3~ORZ&SMF{s! z^9J!=`1}~cyqx?aWxvsneli;3PoCFy(Whl*T*mQ+I2ld%0k6t{=Rjs^_KeNAHm{|O_#z9RJd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L_SAeTU_Ad)6&N?8NqM5Rlhz}CZn z6s*uM{<{^l9FbEyGmB%petO6T<#M1EjQewMaql*-|5k~#Q2#_*-QET6^lZ5TUxqE+ zfmMV-c+VS0b${R%2l!xk<02i`=n}X#T%J!_T4D(!NV~a39ZZM+_#Ar?pgTqIJ^p{qCs-jsKm>LQ>1`Q zR^Tgi^Uol<-6xrXwH)CCt+ z*lvLRVI+1k2;Y*uP$+9MC{;3&T8CQ=3.6', +) diff --git a/R/sir.R b/R/sir.R index 6c4060eb..5c818f31 100755 --- a/R/sir.R +++ b/R/sir.R @@ -970,6 +970,7 @@ as_sir_method <- function(method_short, warning_("The following animal host(s) could not be coerced: ", vector_and(host.bak[is.na(host) & !is.na(host.bak)]), immediate = TRUE) message() # new line } + # TODO add a switch to turn this off? In interactive sessions perhaps ask the user. Default should be On. if (breakpoint_type == "animal" && message_not_thrown_before("as.sir", "host_missing_breakpoints")) { if (guideline_coerced %like% "CLSI") { message_("Please note that in the absence of specific veterinary breakpoints for certain animal hosts, the CLSI guideline VET09 will be applied where possible.\n\n") @@ -1053,6 +1054,8 @@ as_sir_method <- function(method_short, ) } } + # TODO set uti to specimen column here + if (length(ab) == 1 && ab %like% paste0("as.", method_short)) { stop_("No unambiguous name was supplied about the antibiotic (argument `ab`). See ?as.sir.", call = FALSE) @@ -1238,6 +1241,8 @@ as_sir_method <- function(method_short, new_sir <- rep(NA_sir_, length(rows)) # find different mo properties, as fast as possible + # TODO in case of VET09, we need to keep E. coli, also when users have Proteus in their data set + # TODO look up which species, at least E. coli - also Staph or Strep? mo_current_genus <- AMR_env$MO_lookup$mo[match(AMR_env$MO_lookup$genus[match(mo_current, AMR_env$MO_lookup$mo)], AMR_env$MO_lookup$fullname)] mo_current_family <- AMR_env$MO_lookup$mo[match(AMR_env$MO_lookup$family[match(mo_current, AMR_env$MO_lookup$mo)], AMR_env$MO_lookup$fullname)] mo_current_order <- AMR_env$MO_lookup$mo[match(AMR_env$MO_lookup$order[match(mo_current, AMR_env$MO_lookup$mo)], AMR_env$MO_lookup$fullname)] @@ -1262,6 +1267,7 @@ as_sir_method <- function(method_short, ) # gather all available breakpoints for current MO + # TODO for VET09 do not filter out E. coli and such breakpoints_current <- breakpoints %pm>% subset(ab == ab_current) %pm>% subset(mo %in% c( @@ -1271,14 +1277,17 @@ as_sir_method <- function(method_short, mo_current_other )) + # TODO are operators considered?? + # This seems to not work well: as.sir(as.mic(c(4, ">4", ">=4", 8, ">8", ">=8")), ab = "AMC", mo = "E. coli", breakpoint_type = "animal", host = "dogs", guideline = "CLSI 2024") + ## fall-back methods for veterinary guidelines ---- if (breakpoint_type == "animal" && !host_current %in% breakpoints_current$host) { if (guideline_coerced %like% "CLSI") { # VET09 says that staph/strep/enterococcus BP can be extrapolated to all Gr+ cocci except for intrinsic resistance, so take all Gr+ cocci: - all_gram_pos_genera <- c("B_STPHY", "B_STRPT", "B_PPTST", "B_AERCC", "B_MCRCCC", "B_TRPRL") + gram_plus_cocci_vet09 <- microorganisms$mo[microorganisms$genus %in% c("Staphylococcus", "Streptococcus", "Peptostreptococcus", "Aerococcus", "Micrococcus") & microorganisms$rank == "genus"] # TODO should probably include genera that were either of these before # HUMAN SUBSTITUTES - if (ab_current == "AZM" && mo_current_genus %in% all_gram_pos_genera && host_current %in% c("dogs", "cats", "horse")) { + if (ab_current == "AZM" && mo_current_genus %in% gram_plus_cocci_vet09 && host_current %in% c("dogs", "cats", "horse")) { # azithro can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in Gram-positive cocci based on CLSI VET09.")) @@ -1290,7 +1299,7 @@ as_sir_method <- function(method_short, # cefta can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in Enterobacterales and ", font_italic("P. aeruginosa"), " based on CLSI VET09.")) - } else if (ab_current == "ERY" && mo_current_genus %in% all_gram_pos_genera && host_current %in% c("dogs", "cats", "horse")) { + } else if (ab_current == "ERY" && mo_current_genus %in% gram_plus_cocci_vet09 && host_current %in% c("dogs", "cats", "horse")) { # erythro can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in Gram-positive cocci based on CLSI VET09.")) @@ -1298,7 +1307,7 @@ as_sir_method <- function(method_short, # imipenem can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in Enterobacterales and ", font_italic("P. aeruginosa"), " based on CLSI VET09.")) - } else if (ab_current == "LNZ" && mo_current_genus %in% all_gram_pos_genera && host_current %in% c("dogs", "cats")) { + } else if (ab_current == "LNZ" && mo_current_genus %in% gram_plus_cocci_vet09 && host_current %in% c("dogs", "cats")) { # linezolid can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in staphylococci/enterococci based on CLSI VET09.")) @@ -1306,11 +1315,11 @@ as_sir_method <- function(method_short, # nitro can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " based on CLSI VET09.")) - } else if (ab_current == "PEN" && mo_current_genus %in% all_gram_pos_genera && host_current %in% c("dogs", "cats")) { + } else if (ab_current == "PEN" && mo_current_genus %in% gram_plus_cocci_vet09 && host_current %in% c("dogs", "cats")) { # penicillin can take human breakpoints for these agents breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in Gram-positive cocci based on CLSI VET09.")) - } else if (ab_current == "RIF" && mo_current_genus %in% all_gram_pos_genera && host_current %in% c("dogs", "cats")) { + } else if (ab_current == "RIF" && mo_current_genus %in% gram_plus_cocci_vet09 && host_current %in% c("dogs", "cats")) { # rifampicin can take human breakpoints for staphylococci breakpoints_current <- breakpoints_current %pm>% subset(host == "human") notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", ab_formatted, " in staphylococci based on CLSI VET09.")) @@ -1325,7 +1334,8 @@ as_sir_method <- function(method_short, } else if (host_current %in% c("dogs", "cats") && (mo_current_genus %in% c("B_AMYCS", "B_NOCRD", "B_CMPYL", "B_CRYNB", "B_ENTRC", "B_MYCBC", "B_PSDMN", "B_AERMN") | mo_current_class == "B_[CLS]_BTPRTBCT" | mo_current == "B_LISTR_MNCY")) { # dog breakpoints if no canine/feline - breakpoints_current <- breakpoints_current %pm>% subset(host == "human") + # TODO do we still have dogs breakpoints at this point??? + breakpoints_current <- breakpoints_current %pm>% subset(host == "human") # WRONG notes_current <- c(notes_current, paste0("Using ", font_bold("human"), " breakpoints for ", mo_formatted, " based on CLSI VET09.")) } else { diff --git a/data-raw/_generate_python_wrapper.sh b/data-raw/_generate_python_wrapper.sh index 389c4abb..5a2cb994 100644 --- a/data-raw/_generate_python_wrapper.sh +++ b/data-raw/_generate_python_wrapper.sh @@ -30,13 +30,15 @@ # ==================================================================== # # Clean up -rm -rf python_wrapper/AMR/* -mkdir -p python_wrapper/AMR/AMR +rm -rf ../PythonPackage/AMR/* +mkdir -p ../PythonPackage/AMR/AMR # Output Python file -functions_file="python_wrapper/AMR/AMR/functions.py" -datasets_file="python_wrapper/AMR/AMR/datasets.py" -init_file="python_wrapper/AMR/AMR/__init__.py" +setup_file="../PythonPackage/AMR/setup.py" +functions_file="../PythonPackage/AMR/AMR/functions.py" +datasets_file="../PythonPackage/AMR/AMR/datasets.py" +init_file="../PythonPackage/AMR/AMR/__init__.py" + # Write header to the datasets Python file, including the convert_to_python function cat < "$datasets_file" @@ -46,31 +48,48 @@ RESET = '\033[0m' print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True) + +import os from rpy2 import robjects from rpy2.robjects import pandas2ri from rpy2.robjects.packages import importr, isinstalled import pandas as pd -# import importlib.metadata as metadata +import importlib.metadata as metadata -# Check if AMR package is installed in R +# Get the path to the virtual environment +venv_path = os.getenv('VIRTUAL_ENV') # Path to the active virtual environment +if not venv_path: + raise EnvironmentError("No virtual environment detected. Please activate your Python virtual environment.") + +# Define R library path within the venv +r_lib_path = os.path.join(venv_path, "R_libs") +# Ensure the R library path exists +os.makedirs(r_lib_path, exist_ok=True) +# Set the R library path in .libPaths +base = importr('base') +base._libPaths(r_lib_path) + +# Check if the AMR package is installed in R if not isinstalled('AMR'): utils = importr('utils') - utils.install_packages('AMR', repos='https://msberends.r-universe.dev') + utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) # Python package version of AMR -python_amr_version = metadata.version('AMR') +try: + python_amr_version = metadata.version('AMR') +except metadata.PackageNotFoundError: + python_amr_version = None + # R package version of AMR -# r_amr_version = robjects.r('packageVersion("AMR")')[0] +r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')[0] # Compare R and Python package versions -# if r_amr_version != python_amr_version: -# print(f"{BLUE}AMR:{RESET} Version mismatch detected. Updating AMR R package version to {python_amr_version}...", flush=True) -# try: -# # Re-install the specific version of AMR in R -# utils = importr('utils') -# utils.install_packages('AMR', repos='https://msberends.r-universe.dev') -# except Exception as e: -# print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True) +if python_amr_version and r_amr_version != python_amr_version: + try: + utils = importr('utils') + utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) + except Exception as e: + print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True) # Activate the automatic conversion between R and pandas DataFrames pandas2ri.activate() @@ -237,22 +256,20 @@ done echo "Python wrapper functions generated in $functions_file." echo "Python wrapper functions listed in $init_file." -cp ../vignettes/AMR_for_Python.Rmd python_wrapper/AMR/README.md -sed -i '1,/^# Introduction$/d' python_wrapper/AMR/README.md +cp ../vignettes/AMR_for_Python.Rmd ../PythonPackage/AMR/README.md +sed -i '1,/^# Introduction$/d' ../PythonPackage/AMR/README.md echo "README copied" # Path to your DESCRIPTION file description_file="../DESCRIPTION" -# Output setup.py file -functions_file="python_wrapper/AMR/setup.py" # Extract the relevant fields from DESCRIPTION version=$(grep "^Version:" "$description_file" | awk '{print $2}') # Write the setup.py file -cat < "$functions_file" +cat < "$setup_file" from setuptools import setup, find_packages setup( @@ -283,8 +300,10 @@ setup( EOL # Output completion message -echo "setup.py has been generated in $functions_file." +echo "setup.py has been generated in $setup_file." -cd python_wrapper/AMR -python3 setup.py sdist bdist_wheel +cd ../PythonPackage/AMR +pip3 install build +python3 -m build +# python3 setup.py sdist bdist_wheel