1
0
mirror of https://github.com/msberends/AMR.git synced 2025-04-22 06:03:47 +02:00

Compare commits

..

No commits in common. "d147d6602dbad4d9d2a079162a52168d9f8b3c44" and "79f56ad8a421ceb6a03e50af0906b3a817270aea" have entirely different histories.

5 changed files with 23 additions and 26 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 2.1.1.9222 Version: 2.1.1.9220
Date: 2025-03-20 Date: 2025-03-19
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)
data analysis and to work with microbial and antimicrobial properties by data analysis and to work with microbial and antimicrobial properties by

View File

@ -1,4 +1,4 @@
# AMR 2.1.1.9222 # AMR 2.1.1.9220
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*
@ -46,7 +46,6 @@ This package now supports not only tools for AMR data analysis in clinical setti
* It is now possible to use column names for argument `ab`, `mo`, and `uti`: `as.sir(..., ab = "column1", mo = "column2", uti = "column3")`. This greatly improves the flexibility for users. * It is now possible to use column names for argument `ab`, `mo`, and `uti`: `as.sir(..., ab = "column1", mo = "column2", uti = "column3")`. This greatly improves the flexibility for users.
* Users can now set their own criteria (using regular expressions) as to what should be considered S, I, R, SDD, and NI. * Users can now set their own criteria (using regular expressions) as to what should be considered S, I, R, SDD, and NI.
* To get quantitative values, `as.double()` on a `sir` object will return 1 for S, 2 for SDD/I, and 3 for R (NI will become `NA`). Other functions using `sir` classes (e.g., `summary()`) are updated to reflect the change to contain NI and SDD. * To get quantitative values, `as.double()` on a `sir` object will return 1 for S, 2 for SDD/I, and 3 for R (NI will become `NA`). Other functions using `sir` classes (e.g., `summary()`) are updated to reflect the change to contain NI and SDD.
* Combined MIC values (e.g., from CLSI) are now supported
* The argument `conserve_capped_values` in `as.sir()` has been replaced with `capped_mic_handling`, which allows greater flexibility in handling capped MIC values (`<`, `<=`, `>`, `>=`). The four available options (`"standard"`, `"strict"`, `"relaxed"`, `"inverse"`) provide full control over whether these values should be interpreted conservatively or ignored. Using `conserve_capped_values` is now deprecated and returns a warning. * The argument `conserve_capped_values` in `as.sir()` has been replaced with `capped_mic_handling`, which allows greater flexibility in handling capped MIC values (`<`, `<=`, `>`, `>=`). The four available options (`"standard"`, `"strict"`, `"relaxed"`, `"inverse"`) provide full control over whether these values should be interpreted conservatively or ignored. Using `conserve_capped_values` is now deprecated and returns a warning.
* `antibiogram()` function * `antibiogram()` function
* Argument `antibiotics` has been renamed to `antimicrobials`. Using `antibiotics` will still work, but now returns a warning. * Argument `antibiotics` has been renamed to `antimicrobials`. Using `antibiotics` will still work, but now returns a warning.

View File

@ -201,10 +201,6 @@ as.mic <- function(x, na.rm = FALSE, keep_operators = "all") {
# transform Unicode for >= and <= # transform Unicode for >= and <=
x <- gsub("\u2264", "<=", x, fixed = TRUE) x <- gsub("\u2264", "<=", x, fixed = TRUE)
x <- gsub("\u2265", ">=", x, fixed = TRUE) x <- gsub("\u2265", ">=", x, fixed = TRUE)
if (any(x %like% "[0-9]/.*[0-9]", na.rm = TRUE)) {
warning_("Some MICs were combined values, only the first values are kept")
x[x %like% "[0-9]/.*[0-9]"] <- gsub("/.*", "", x[x %like% "[0-9]/.*[0-9]"])
}
# remove other invalid characters # remove other invalid characters
x <- gsub("[^a-zA-Z0-9.><= -]+", "", x, perl = TRUE) x <- gsub("[^a-zA-Z0-9.><= -]+", "", x, perl = TRUE)
# transform => to >= and =< to <= # transform => to >= and =< to <=

View File

@ -44,44 +44,46 @@ description_file="../DESCRIPTION"
cat <<EOL > "$datasets_file" cat <<EOL > "$datasets_file"
import os import os
import sys import sys
from rpy2 import robjects
from rpy2.robjects import pandas2ri
from rpy2.robjects.packages import importr, isinstalled
import pandas as pd import pandas as pd
import importlib.metadata as metadata import importlib.metadata as metadata
# Get the path to the virtual environment # Get the path to the virtual environment
venv_path = sys.prefix venv_path = sys.prefix
# Define R library path within the venv
r_lib_path = os.path.join(venv_path, "R_libs") r_lib_path = os.path.join(venv_path, "R_libs")
# Ensure the R library path exists
os.makedirs(r_lib_path, exist_ok=True) 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 # Import base and utils
base = importr('base') base = importr('base')
utils = importr('utils') utils = importr('utils')
base.options(warn=-1) base.options(warn = -1)
# Ensure library paths explicitly # Override R library paths globally for the session
base._libPaths(r_lib_path) robjects.r(f'.Library.site <- "{r_lib_path}"') # Replace site-specific library
base._libPaths(r_lib_path) # Override .libPaths() as well
# Get the effective library path
r_amr_lib_path = base._libPaths()[0]
# Check if the AMR package is installed in R # Check if the AMR package is installed in R
if not isinstalled('AMR', lib_loc=r_lib_path): if not isinstalled('AMR', lib_loc=r_amr_lib_path):
print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True) print(f"AMR: Installing latest AMR R package to {r_amr_lib_path}...", flush=True)
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
# Retrieve Python AMR version # Python package version of AMR
try: try:
python_amr_version = metadata.version('AMR') python_amr_version = metadata.version('AMR')
except metadata.PackageNotFoundError: except metadata.PackageNotFoundError:
python_amr_version = '' python_amr_version = ''
# Retrieve R AMR version # R package version of AMR
r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))') r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_amr_lib_path}"))')
r_amr_version = str(r_amr_version[0])
print(python_amr_version) print(python_amr_version)
print(r_amr_version) print(r_amr_version)
@ -89,7 +91,7 @@ print(r_amr_version)
# Compare R and Python package versions # Compare R and Python package versions
if r_amr_version != python_amr_version: if r_amr_version != python_amr_version:
try: try:
print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True) print(f"AMR: Updating AMR package in {r_amr_lib_path}...", flush=True)
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True) utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
except Exception as e: except Exception as e:
print(f"AMR: Could not update: {e}", flush=True) print(f"AMR: Could not update: {e}", flush=True)

View File

@ -1,6 +1,6 @@
This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse.
First and foremost, you are trained on version 2.1.1.9222. Remember this whenever someone asks which AMR package version youre at. First and foremost, you are trained on version 2.1.1.9220. Remember this whenever someone asks which AMR package version youre at.
Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens. Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------