mirror of
https://github.com/msberends/AMR.git
synced 2025-06-07 21:54:00 +02:00
(v2.1.1.9275) include guideline name in MDRO verbose output
This commit is contained in:
parent
7d45ca9fbf
commit
48a59ee31a
@ -1,6 +1,6 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9274
|
||||
Date: 2025-05-12
|
||||
Version: 2.1.1.9275
|
||||
Date: 2025-05-13
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
data analysis and to work with microbial and antimicrobial properties by
|
||||
|
3
NEWS.md
3
NEWS.md
@ -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).)*
|
||||
|
||||
@ -149,6 +149,7 @@ This package now supports not only tools for AMR data analysis in clinical setti
|
||||
* MDRO determination (using `mdro()`)
|
||||
* 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)
|
||||
* The Verbose Mode (`verbose = TRUE`) now includes the guideline name
|
||||
* Added console colours support of `sir` class for Positron
|
||||
|
||||
### Other
|
||||
|
31
R/mdro.R
31
R/mdro.R
@ -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()].
|
||||
#' @inheritSection as.sir Interpretation of SIR
|
||||
#' @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
|
||||
#' 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
|
||||
@ -148,7 +150,7 @@
|
||||
#' - German guideline - function [mrgn()] or [`mdro(..., guideline = "MRGN")`][mdro()]:\cr
|
||||
#' Ordered [factor] with levels `Negative` < `3MRGN` < `4MRGN`
|
||||
#' - 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
|
||||
#' @aliases MDR XDR PDR BRMO 3MRGN 4MRGN
|
||||
#' @export
|
||||
@ -349,17 +351,26 @@ mdro <- function(x = NULL,
|
||||
))))
|
||||
}
|
||||
}
|
||||
|
||||
if (isTRUE(verbose)) {
|
||||
x$reason[is.na(x$reason)] <- "not covered by guideline"
|
||||
x$microorganism <- NA_character_
|
||||
x$guideline <- "Custom guideline"
|
||||
return(x[, c(
|
||||
"row_number",
|
||||
"microorganism",
|
||||
"MDRO",
|
||||
"reason",
|
||||
"all_nonsusceptible_columns"
|
||||
)])
|
||||
"all_nonsusceptible_columns",
|
||||
"guideline"
|
||||
),
|
||||
drop = FALSE
|
||||
])
|
||||
} else {
|
||||
return(x$MDRO)
|
||||
}
|
||||
}
|
||||
} # end of custom MDRO guideline
|
||||
|
||||
guideline <- tolower(gsub("[^a-zA-Z0-9.]+", "", guideline))
|
||||
if (is.null(guideline)) {
|
||||
# default to the paper by Magiorakos et al. (2012)
|
||||
@ -772,10 +783,10 @@ mdro <- function(x = NULL,
|
||||
function(y) y %in% search_result
|
||||
)
|
||||
paste(
|
||||
sort(c(
|
||||
unique(sort(c(
|
||||
unlist(strsplit(x[row, "all_nonsusceptible_columns", drop = TRUE], ", ", fixed = TRUE)),
|
||||
names(cols_nonsus)[cols_nonsus]
|
||||
)),
|
||||
))),
|
||||
collapse = ", "
|
||||
)
|
||||
}
|
||||
@ -849,7 +860,7 @@ mdro <- function(x = NULL,
|
||||
rows,
|
||||
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)
|
||||
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
|
||||
colnames(x)[colnames(x) == col_mo] <- "microorganism"
|
||||
x$microorganism <- mo_name(x$microorganism, language = NULL)
|
||||
x$guideline <- paste0(guideline$author, " - ", guideline$name, ", ", guideline$version, ")")
|
||||
x[, c(
|
||||
"row_number",
|
||||
"microorganism",
|
||||
"MDRO",
|
||||
"reason",
|
||||
"all_nonsusceptible_columns"
|
||||
"all_nonsusceptible_columns",
|
||||
"guideline"
|
||||
),
|
||||
drop = FALSE
|
||||
]
|
||||
@ -2119,7 +2132,7 @@ run_custom_mdro_guideline <- function(df, guideline, info) {
|
||||
all_nonsusceptible_columns <- vapply(
|
||||
FUN.VALUE = character(1),
|
||||
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_
|
||||
|
||||
|
@ -72,6 +72,8 @@ eucast_exceptional_phenotypes(x = NULL, only_sir_columns = FALSE,
|
||||
}
|
||||
\value{
|
||||
\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
|
||||
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
|
||||
@ -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
|
||||
Ordered \link{factor} with levels \code{Negative} < \verb{3MRGN} < \verb{4MRGN}
|
||||
\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{
|
||||
|
@ -284,7 +284,7 @@ test_that("test-mdro.R", {
|
||||
|
||||
expect_equal(
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user