1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-30 08:39:02 +02:00

(v2.1.1.9275) include guideline name in MDRO verbose output

This commit is contained in:
2025-05-13 18:56:12 +02:00
parent 7d45ca9fbf
commit 48a59ee31a
5 changed files with 30 additions and 14 deletions

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 2.1.1.9274 Version: 2.1.1.9275
Date: 2025-05-12 Date: 2025-05-13
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

@ -1,4 +1,4 @@
# AMR 2.1.1.9274 # AMR 2.1.1.9275
*(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://amr-for-r.org/#get-this-package).)* *(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://amr-for-r.org/#get-this-package).)*
@ -149,6 +149,7 @@ This package now supports not only tools for AMR data analysis in clinical setti
* MDRO determination (using `mdro()`) * MDRO determination (using `mdro()`)
* Implemented the new Dutch national MDRO guideline (SRI-richtlijn BRMO, Nov 2024) * Implemented the new Dutch national MDRO guideline (SRI-richtlijn BRMO, Nov 2024)
* Added arguments `esbl`, `carbapenemase`, `mecA`, `mecC`, `vanA`, `vanB` to denote column names or logical values indicating presence of these genes (or production of their proteins) * Added arguments `esbl`, `carbapenemase`, `mecA`, `mecC`, `vanA`, `vanB` to denote column names or logical values indicating presence of these genes (or production of their proteins)
* The Verbose Mode (`verbose = TRUE`) now includes the guideline name
* Added console colours support of `sir` class for Positron * Added console colours support of `sir` class for Positron
### Other ### Other

@ -141,6 +141,8 @@
#' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()]. #' The rules set (the `custom` object in this case) could be exported to a shared file location using [saveRDS()] if you collaborate with multiple users. The custom rules set could then be imported using [readRDS()].
#' @inheritSection as.sir Interpretation of SIR #' @inheritSection as.sir Interpretation of SIR
#' @return #' @return
#' - If `verbose` is set to `TRUE`:\cr
#' A [data.frame] containing columns `row_number`, `microorganism`, `MDRO`, `reason`, `all_nonsusceptible_columns`, `guideline`
#' - CMI 2012 paper - function [mdr_cmi2012()] or [mdro()]:\cr #' - CMI 2012 paper - function [mdr_cmi2012()] or [mdro()]:\cr
#' Ordered [factor] with levels `Negative` < `Multi-drug-resistant (MDR)` < `Extensively drug-resistant (XDR)` < `Pandrug-resistant (PDR)` #' Ordered [factor] with levels `Negative` < `Multi-drug-resistant (MDR)` < `Extensively drug-resistant (XDR)` < `Pandrug-resistant (PDR)`
#' - TB guideline - function [mdr_tb()] or [`mdro(..., guideline = "TB")`][mdro()]:\cr #' - TB guideline - function [mdr_tb()] or [`mdro(..., guideline = "TB")`][mdro()]:\cr
@ -148,7 +150,7 @@
#' - German guideline - function [mrgn()] or [`mdro(..., guideline = "MRGN")`][mdro()]:\cr #' - German guideline - function [mrgn()] or [`mdro(..., guideline = "MRGN")`][mdro()]:\cr
#' Ordered [factor] with levels `Negative` < `3MRGN` < `4MRGN` #' Ordered [factor] with levels `Negative` < `3MRGN` < `4MRGN`
#' - Everything else, except for custom guidelines:\cr #' - Everything else, except for custom guidelines:\cr
#' Ordered [factor] with levels `Negative` < `Positive, unconfirmed` < `Positive`. The value `"Positive, unconfirmed"` means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests #' Ordered [factor] with levels `Negative` < `Positive, unconfirmed` < `Positive`. The value `"Positive, unconfirmed"` means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. genotypic) tests
#' @rdname mdro #' @rdname mdro
#' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN #' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN
#' @export #' @export
@ -349,17 +351,26 @@ mdro <- function(x = NULL,
)))) ))))
} }
} }
if (isTRUE(verbose)) { if (isTRUE(verbose)) {
x$reason[is.na(x$reason)] <- "not covered by guideline"
x$microorganism <- NA_character_
x$guideline <- "Custom guideline"
return(x[, c( return(x[, c(
"row_number", "row_number",
"microorganism",
"MDRO", "MDRO",
"reason", "reason",
"all_nonsusceptible_columns" "all_nonsusceptible_columns",
)]) "guideline"
),
drop = FALSE
])
} else { } else {
return(x$MDRO) return(x$MDRO)
} }
} } # end of custom MDRO guideline
guideline <- tolower(gsub("[^a-zA-Z0-9.]+", "", guideline)) guideline <- tolower(gsub("[^a-zA-Z0-9.]+", "", guideline))
if (is.null(guideline)) { if (is.null(guideline)) {
# default to the paper by Magiorakos et al. (2012) # default to the paper by Magiorakos et al. (2012)
@ -772,10 +783,10 @@ mdro <- function(x = NULL,
function(y) y %in% search_result function(y) y %in% search_result
) )
paste( paste(
sort(c( unique(sort(c(
unlist(strsplit(x[row, "all_nonsusceptible_columns", drop = TRUE], ", ", fixed = TRUE)), unlist(strsplit(x[row, "all_nonsusceptible_columns", drop = TRUE], ", ", fixed = TRUE)),
names(cols_nonsus)[cols_nonsus] names(cols_nonsus)[cols_nonsus]
)), ))),
collapse = ", " collapse = ", "
) )
} }
@ -849,7 +860,7 @@ mdro <- function(x = NULL,
rows, rows,
function(row, group_vct = lst_vector) { function(row, group_vct = lst_vector) {
cols_nonsus <- vapply(FUN.VALUE = logical(1), x[row, group_vct, drop = FALSE], function(y) y %in% search_result) cols_nonsus <- vapply(FUN.VALUE = logical(1), x[row, group_vct, drop = FALSE], function(y) y %in% search_result)
paste(sort(names(cols_nonsus)[cols_nonsus]), collapse = ", ") paste(unique(sort(names(cols_nonsus)[cols_nonsus])), collapse = ", ")
} }
) )
} }
@ -1943,12 +1954,14 @@ mdro <- function(x = NULL,
# format data set # format data set
colnames(x)[colnames(x) == col_mo] <- "microorganism" colnames(x)[colnames(x) == col_mo] <- "microorganism"
x$microorganism <- mo_name(x$microorganism, language = NULL) x$microorganism <- mo_name(x$microorganism, language = NULL)
x$guideline <- paste0(guideline$author, " - ", guideline$name, ", ", guideline$version, ")")
x[, c( x[, c(
"row_number", "row_number",
"microorganism", "microorganism",
"MDRO", "MDRO",
"reason", "reason",
"all_nonsusceptible_columns" "all_nonsusceptible_columns",
"guideline"
), ),
drop = FALSE drop = FALSE
] ]
@ -2119,7 +2132,7 @@ run_custom_mdro_guideline <- function(df, guideline, info) {
all_nonsusceptible_columns <- vapply( all_nonsusceptible_columns <- vapply(
FUN.VALUE = character(1), FUN.VALUE = character(1),
all_nonsusceptible_columns, all_nonsusceptible_columns,
function(x) paste0(rownames(all_nonsusceptible_columns)[which(x)], collapse = " ") function(x) paste0(rownames(all_nonsusceptible_columns)[which(x)], collapse = ", ")
) )
all_nonsusceptible_columns[is.na(out)] <- NA_character_ all_nonsusceptible_columns[is.na(out)] <- NA_character_

@ -72,6 +72,8 @@ eucast_exceptional_phenotypes(x = NULL, only_sir_columns = FALSE,
} }
\value{ \value{
\itemize{ \itemize{
\item If \code{verbose} is set to \code{TRUE}:\cr
A \link{data.frame} containing columns \code{row_number}, \code{microorganism}, \code{MDRO}, \code{reason}, \code{all_nonsusceptible_columns}, \code{guideline}
\item CMI 2012 paper - function \code{\link[=mdr_cmi2012]{mdr_cmi2012()}} or \code{\link[=mdro]{mdro()}}:\cr \item CMI 2012 paper - function \code{\link[=mdr_cmi2012]{mdr_cmi2012()}} or \code{\link[=mdro]{mdro()}}:\cr
Ordered \link{factor} with levels \code{Negative} < \code{Multi-drug-resistant (MDR)} < \verb{Extensively drug-resistant (XDR)} < \code{Pandrug-resistant (PDR)} Ordered \link{factor} with levels \code{Negative} < \code{Multi-drug-resistant (MDR)} < \verb{Extensively drug-resistant (XDR)} < \code{Pandrug-resistant (PDR)}
\item TB guideline - function \code{\link[=mdr_tb]{mdr_tb()}} or \code{\link[=mdro]{mdro(..., guideline = "TB")}}:\cr \item TB guideline - function \code{\link[=mdr_tb]{mdr_tb()}} or \code{\link[=mdro]{mdro(..., guideline = "TB")}}:\cr
@ -79,7 +81,7 @@ Ordered \link{factor} with levels \code{Negative} < \code{Mono-resistant} < \cod
\item German guideline - function \code{\link[=mrgn]{mrgn()}} or \code{\link[=mdro]{mdro(..., guideline = "MRGN")}}:\cr \item German guideline - function \code{\link[=mrgn]{mrgn()}} or \code{\link[=mdro]{mdro(..., guideline = "MRGN")}}:\cr
Ordered \link{factor} with levels \code{Negative} < \verb{3MRGN} < \verb{4MRGN} Ordered \link{factor} with levels \code{Negative} < \verb{3MRGN} < \verb{4MRGN}
\item Everything else, except for custom guidelines:\cr \item Everything else, except for custom guidelines:\cr
Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed} < \code{Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed} < \code{Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. genotypic) tests
} }
} }
\description{ \description{

@ -284,7 +284,7 @@ test_that("test-mdro.R", {
expect_equal( expect_equal(
colnames(suppressWarnings(mdro(example_isolates[1:10, ], verbose = TRUE, info = FALSE))), colnames(suppressWarnings(mdro(example_isolates[1:10, ], verbose = TRUE, info = FALSE))),
c("row_number", "microorganism", "MDRO", "reason", "all_nonsusceptible_columns") c("row_number", "microorganism", "MDRO", "reason", "all_nonsusceptible_columns", "guideline")
) )
# print groups # print groups