mirror of https://github.com/msberends/AMR.git
auto-remove missing ABs in `antibiogram()`
This commit is contained in:
parent
c2cfc5ef84
commit
551aaf6517
|
@ -1,5 +1,5 @@
|
|||
Package: AMR
|
||||
Version: 1.8.2.9139
|
||||
Version: 1.8.2.9140
|
||||
Date: 2023-02-22
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
|
2
NEWS.md
2
NEWS.md
|
@ -1,4 +1,4 @@
|
|||
# AMR 1.8.2.9139
|
||||
# AMR 1.8.2.9140
|
||||
|
||||
*(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)*
|
||||
|
||||
|
|
|
@ -313,15 +313,19 @@ antibiogram <- function(x,
|
|||
df_ab <- get_column_abx(x, verbose = FALSE, info = FALSE)
|
||||
# get antibiotics from user
|
||||
user_ab <- suppressMessages(suppressWarnings(lapply(antibiotics, as.ab, flag_multiple_results = FALSE, info = FALSE)))
|
||||
user_ab <- lapply(user_ab, function(x) unname(df_ab[match(x, names(df_ab))]))
|
||||
|
||||
# remove non-existing columns
|
||||
# non_existing <- unlist(antibiotics)[is.na(unlist(abx_ab))]
|
||||
# if (length(non_existing) > 0) {
|
||||
# warning_("The following antibiotics were not available and ignored: ", vector_and(non_existing, sort = FALSE))
|
||||
# abx_user <- Map(antibiotics, abx_user, f = function(input, ab) input[!is.na(ab)])
|
||||
# }
|
||||
non_existing <- character(0)
|
||||
user_ab <- lapply(user_ab, function(x) {
|
||||
out <- unname(df_ab[match(x, names(df_ab))])
|
||||
non_existing <<- c(non_existing, x[is.na(out) & !is.na(x)])
|
||||
# remove non-existing columns
|
||||
out[!is.na(out)]
|
||||
})
|
||||
user_ab <- user_ab[unlist(lapply(user_ab, length)) > 0]
|
||||
|
||||
if (length(non_existing) > 0) {
|
||||
warning_("The following antibiotics were not available and ignored: ", vector_and(ab_name(non_existing, language = NULL, tolower = TRUE), quotes = FALSE))
|
||||
}
|
||||
|
||||
# make list unique
|
||||
antibiotics <- unique(user_ab)
|
||||
# go through list to set AMR in combinations
|
||||
|
|
2
index.md
2
index.md
|
@ -115,7 +115,7 @@ Like many other functions in this package, `antibiogram()` comes with support fo
|
|||
|
||||
```r
|
||||
antibiogram(example_isolates,
|
||||
antibiotics = c("CIP", "TOB", "GEN"),
|
||||
antibiotics = c("cipro", "tobra", "genta"), # any arbitrary name or code will work
|
||||
mo_transform = "gramstain",
|
||||
ab_transform = "name",
|
||||
language = "uk") # Ukrainian
|
||||
|
|
Loading…
Reference in New Issue