1
0
mirror of https://github.com/msberends/AMR.git synced 2025-04-20 13:53:52 +02:00

(v2.1.1.9158) updated as.ab

This commit is contained in:
dr. M.S. (Matthijs) Berends 2025-02-26 13:32:16 +01:00
parent 195dfb4b91
commit 122bca0f95
No known key found for this signature in database
9 changed files with 21 additions and 11 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 2.1.1.9157 Version: 2.1.1.9158
Date: 2025-02-26 Date: 2025-02-26
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)

View File

@ -1,4 +1,4 @@
# AMR 2.1.1.9157 # AMR 2.1.1.9158
*(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).)*
@ -80,7 +80,7 @@ This package now supports not only tools for AMR data analysis in clinical setti
* Fix for using a manual value for `mo_transform` in `antibiogram()` * Fix for using a manual value for `mo_transform` in `antibiogram()`
* Fixed a bug for when `antibiogram()` returns an empty data set * Fixed a bug for when `antibiogram()` returns an empty data set
* Fix for mapping 'high level' antibiotics in `as.ab()` (amphotericin B-high, gentamicin-high, kanamycin-high, streptomycin-high, tobramycin-high) * Fix for mapping 'high level' antibiotics in `as.ab()` (amphotericin B-high, gentamicin-high, kanamycin-high, streptomycin-high, tobramycin-high)
* Improved overall algorithm of `as.ab()` for better performance and accuracy * Improved overall algorithm of `as.ab()` for better performance and accuracy, including the new function `as_reset_session()` to remove earlier coercions.
* Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically: * Improved overall algorithm of `as.mo()` for better performance and accuracy. Specifically:
* More weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species * More weight is given to genus and species combinations in cases where the subspecies is miswritten, so that the result will be the correct genus and species
* Genera from the World Health Organization's (WHO) Priority Pathogen List now have the highest prevalence * Genera from the World Health Organization's (WHO) Priority Pathogen List now have the highest prevalence

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.2 Metadata-Version: 2.2
Name: AMR Name: AMR
Version: 2.1.1.9157 Version: 2.1.1.9158
Summary: A Python wrapper for the AMR R package Summary: A Python wrapper for the AMR R package
Home-page: https://github.com/msberends/AMR Home-page: https://github.com/msberends/AMR
Author: Matthijs Berends Author: Matthijs Berends

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name='AMR', name='AMR',
version='2.1.1.9157', version='2.1.1.9158',
packages=find_packages(), packages=find_packages(),
install_requires=[ install_requires=[
'rpy2', 'rpy2',

20
R/ab.R
View File

@ -349,6 +349,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(gsub(" +", "", x[i], perl = TRUE), loop_time = loop_time + 2)) found <- suppressWarnings(as.ab(gsub(" +", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (length(found) > 0 && !is.na(found)) { if (length(found) > 0 && !is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
} }
@ -358,6 +359,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(gsub("[ 0-9]", "", x[i], perl = TRUE), loop_time = loop_time + 2)) found <- suppressWarnings(as.ab(gsub("[ 0-9]", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (length(found) > 0 && !is.na(found)) { if (length(found) > 0 && !is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
} }
@ -392,6 +394,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
if (length(found_perms) > 0) { if (length(found_perms) > 0) {
found <- found_perms[order(nchar(found_perms), decreasing = TRUE)][1] found <- found_perms[order(nchar(found_perms), decreasing = TRUE)][1]
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
} }
@ -418,6 +421,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2)) x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2))
if (!is.na(x_translated_guess)) { if (!is.na(x_translated_guess)) {
x_new[i] <- x_translated_guess x_new[i] <- x_translated_guess
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -441,6 +445,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2)) x_translated_guess <- suppressWarnings(as.ab(x_translated, loop_time = loop_time + 2))
if (!is.na(x_translated_guess)) { if (!is.na(x_translated_guess)) {
x_new[i] <- x_translated_guess x_new[i] <- x_translated_guess
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -449,6 +454,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(gsub("[A-Z]+$", "", x[i], perl = TRUE), loop_time = loop_time + 2)) found <- suppressWarnings(as.ab(gsub("[A-Z]+$", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
} }
@ -457,6 +463,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(gsub("[^A-Z]", "", x[i], perl = TRUE), loop_time = loop_time + 2)) found <- suppressWarnings(as.ab(gsub("[^A-Z]", "", x[i], perl = TRUE), loop_time = loop_time + 2))
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -471,6 +478,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
} }
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -483,6 +491,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(substr(x[i], 1, 7), loop_time = loop_time + 2)) found <- suppressWarnings(as.ab(substr(x[i], 1, 7), loop_time = loop_time + 2))
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -495,6 +504,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
} }
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -507,6 +517,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
} }
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -519,6 +530,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
found <- suppressWarnings(as.ab(x_spelling, loop_time = loop_time + 2, already_regex = TRUE)) found <- suppressWarnings(as.ab(x_spelling, loop_time = loop_time + 2, already_regex = TRUE))
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- note_if_more_than_one_found(found, i, from_text) x_new[i] <- note_if_more_than_one_found(found, i, from_text)
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
@ -540,6 +552,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
} }
if (!is.na(found)) { if (!is.na(found)) {
x_new[i] <- found[1L] x_new[i] <- found[1L]
x_uncertain <- c(x_uncertain, x_bak[x[i] == x_bak_clean][1])
next next
} }
} # end of loop_time <= 2 } # end of loop_time <= 2
@ -590,11 +603,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
# Throw note about uncertainties # Throw note about uncertainties
if (isTRUE(info) && length(x_uncertain) > 0 && fast_mode == FALSE) { if (isTRUE(info) && length(x_uncertain) > 0 && fast_mode == FALSE) {
x_uncertain <- unique(x_uncertain)
if (message_not_thrown_before("as.ab", "uncertainties", x_bak)) { if (message_not_thrown_before("as.ab", "uncertainties", x_bak)) {
plural <- c("", "this")
if (length(x_uncertain) > 1) {
plural <- c("s", "these uncertainties")
}
if (length(x_uncertain) <= 3) { if (length(x_uncertain) <= 3) {
examples <- vector_and( examples <- vector_and(
paste0( paste0(
@ -603,7 +613,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) {
", ", AMR_env$ab_previously_coerced$ab[which(AMR_env$ab_previously_coerced$x_bak %in% x_uncertain)], ")"), ", ", AMR_env$ab_previously_coerced$ab[which(AMR_env$ab_previously_coerced$x_bak %in% x_uncertain)], ")"),
quotes = FALSE) quotes = FALSE)
} else { } else {
examples <- paste0(nr2char(length(x_uncertain)), " antimicrobial", plural[1]) examples <- paste0(nr2char(length(x_uncertain)), " antimicrobials")
} }
message_("Antimicrobial translation was uncertain for ", examples, message_("Antimicrobial translation was uncertain for ", examples,
". If required, use `add_custom_antimicrobials()` to add custom entries.") ". If required, use `add_custom_antimicrobials()` to add custom entries.")

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.9157. Remember this whenever someone asks which AMR package version youre at. First and foremost, you are trained on version 2.1.1.9158. Remember this whenever someone asks which AMR package version youre at.
Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens. Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------