mirror of
https://github.com/msberends/AMR.git
synced 2025-04-15 13:10:32 +02:00
(v2.1.1.9223) allow +
ab
This commit is contained in:
parent
d147d6602d
commit
bb110646db
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9222
|
||||
Version: 2.1.1.9223
|
||||
Date: 2025-03-20
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
S3method("!=",amr_selector)
|
||||
S3method("&",amr_selector)
|
||||
S3method("+",ab)
|
||||
S3method("+",amr_selector)
|
||||
S3method("==",amr_selector)
|
||||
S3method("[",ab)
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 2.1.1.9222
|
||||
# AMR 2.1.1.9223
|
||||
|
||||
*(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).)*
|
||||
|
||||
|
@ -539,7 +539,7 @@ word_wrap <- function(...,
|
||||
)
|
||||
# text starting with `?` must also lead to the help page
|
||||
parts[parts %like% "^[?]"] <- font_url(
|
||||
url = paste0("ide:help:AMR::", parts[parts %like% "^[?]"]),
|
||||
url = paste0("ide:help:AMR::", gsub("?", "", parts[parts %like% "^[?]"], fixed = TRUE)),
|
||||
txt = parts[parts %like% "^[?]"]
|
||||
)
|
||||
msg <- paste0(parts, collapse = "`")
|
||||
|
10
R/ab.R
10
R/ab.R
@ -610,6 +610,16 @@ rep.ab <- function(x, ...) {
|
||||
y
|
||||
}
|
||||
|
||||
#' @method + ab
|
||||
#' @export
|
||||
#' @noRd
|
||||
`+.ab` <- function(e1, e2) {
|
||||
# this does not return ab class, it should just allow console usage of e.g., carbapenems() + c("", aminoglycosides())
|
||||
out <- as.character(outer(e1, e2, paste, sep = " + "))
|
||||
out <- gsub(" [+] $", "", out)
|
||||
out
|
||||
}
|
||||
|
||||
generalise_antibiotic_name <- function(x) {
|
||||
x <- toupper(x)
|
||||
# remove suffices
|
||||
|
@ -954,9 +954,10 @@ any.amr_selector_any_all <- function(..., na.rm = FALSE) {
|
||||
#' @noRd
|
||||
`+.amr_selector` <- function(e1, e2) {
|
||||
# this is useful for `antibiogram()`: antibiogram(example_isolates, carbapenems() + c("", "GEN", "TOB"))
|
||||
structure(as.character(outer(e1, e2, paste, sep = " + ")),
|
||||
class = c("amr_selector", "character")
|
||||
)
|
||||
# this is also implemented for ab class, to allow direct console usage
|
||||
out <- as.character(outer(e1, e2, paste, sep = " + "))
|
||||
out <- gsub(" [+] $", "", out)
|
||||
structure(out, class = c("amr_selector", "character"))
|
||||
}
|
||||
|
||||
is_any <- function(el1) {
|
||||
|
@ -42,8 +42,9 @@
|
||||
#' - `c(aminoglycosides(), "AMP", "AMC")`
|
||||
#' - `c(aminoglycosides(), carbapenems())`
|
||||
#' - Combination therapy, indicated by using `"+"`, with or without [antimicrobial selectors][antimicrobial_selectors], e.g.:
|
||||
#' - `"TZP+TOB"`
|
||||
#' - `"cipro + genta"`
|
||||
#' - `"TZP+TOB"`
|
||||
#' - `c("TZP", "TZP+GEN", "TZP+TOB")`
|
||||
#' - `carbapenems() + "GEN"`
|
||||
#' - `carbapenems() + c("", "GEN")`
|
||||
#' - `carbapenems() + c("", aminoglycosides())`
|
||||
|
@ -73,26 +73,23 @@ if not isinstalled('AMR', lib_loc=r_lib_path):
|
||||
print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True)
|
||||
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
||||
|
||||
# Retrieve Python AMR version
|
||||
try:
|
||||
python_amr_version = metadata.version('AMR')
|
||||
except metadata.PackageNotFoundError:
|
||||
python_amr_version = ''
|
||||
|
||||
# Retrieve R AMR version
|
||||
r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')
|
||||
r_amr_version = str(r_amr_version[0])
|
||||
|
||||
print(python_amr_version)
|
||||
print(r_amr_version)
|
||||
|
||||
# Compare R and Python package versions
|
||||
if r_amr_version != python_amr_version:
|
||||
try:
|
||||
print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True)
|
||||
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
||||
except Exception as e:
|
||||
print(f"AMR: Could not update: {e}", flush=True)
|
||||
# # Retrieve Python AMR version
|
||||
# try:
|
||||
# python_amr_version = metadata.version('AMR')
|
||||
# except metadata.PackageNotFoundError:
|
||||
# python_amr_version = ''
|
||||
#
|
||||
# # Retrieve R AMR version
|
||||
# r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')
|
||||
# r_amr_version = str(r_amr_version[0])
|
||||
#
|
||||
# # Compare R and Python package versions
|
||||
# if r_amr_version != python_amr_version:
|
||||
# try:
|
||||
# print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True)
|
||||
# utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
||||
# except Exception as e:
|
||||
# print(f"AMR: Could not update: {e}", flush=True)
|
||||
|
||||
print(f"AMR: Setting up R environment and AMR datasets...", flush=True)
|
||||
|
||||
|
@ -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.
|
||||
|
||||
First and foremost, you are trained on version 2.1.1.9222. Remember this whenever someone asks which AMR package version you’re at.
|
||||
First and foremost, you are trained on version 2.1.1.9223. Remember this whenever someone asks which AMR package version you’re 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.
|
||||
----------------------------------------------------------------------------------------------------
|
||||
@ -13,6 +13,7 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'NAMESPACE':
|
||||
|
||||
S3method("!=",amr_selector)
|
||||
S3method("&",amr_selector)
|
||||
S3method("+",ab)
|
||||
S3method("+",amr_selector)
|
||||
S3method("==",amr_selector)
|
||||
S3method("[",ab)
|
||||
@ -1713,8 +1714,9 @@ retrieve_wisca_parameters(wisca_model, ...)
|
||||
}
|
||||
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
||||
\itemize{
|
||||
\item \code{"TZP+TOB"}
|
||||
\item \code{"cipro + genta"}
|
||||
\item \code{"TZP+TOB"}
|
||||
\item \code{c("TZP", "TZP+GEN", "TZP+TOB")}
|
||||
\item \code{carbapenems() + "GEN"}
|
||||
\item \code{carbapenems() + c("", "GEN")}
|
||||
\item \code{carbapenems() + c("", aminoglycosides())}
|
@ -58,8 +58,9 @@ retrieve_wisca_parameters(wisca_model, ...)
|
||||
}
|
||||
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
||||
\itemize{
|
||||
\item \code{"TZP+TOB"}
|
||||
\item \code{"cipro + genta"}
|
||||
\item \code{"TZP+TOB"}
|
||||
\item \code{c("TZP", "TZP+GEN", "TZP+TOB")}
|
||||
\item \code{carbapenems() + "GEN"}
|
||||
\item \code{carbapenems() + c("", "GEN")}
|
||||
\item \code{carbapenems() + c("", aminoglycosides())}
|
||||
|
Loading…
x
Reference in New Issue
Block a user