1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-25 19:26:13 +01:00

complexes

This commit is contained in:
dr. M.S. (Matthijs) Berends 2022-11-17 15:23:29 +01:00
parent f6862a139d
commit 05d536ebb7
7 changed files with 23 additions and 6 deletions

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 1.8.2.9051 Version: 1.8.2.9052
Date: 2022-11-14 Date: 2022-11-17
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

View File

@ -1,4 +1,4 @@
# AMR 1.8.2.9051 # AMR 1.8.2.9052
This version will eventually become v2.0! We're happy to reach a new major milestone soon! This version will eventually become v2.0! We're happy to reach a new major milestone soon!

6
R/mo.R
View File

@ -181,6 +181,10 @@ as.mo <- function(x,
x_lower <- tolower(x) x_lower <- tolower(x)
if (any(trimws2(x_lower) %like_case% "complex$", na.rm = TRUE)) {
warning_("in `as.mo()`: translation of complexes is not supported at the moment - the input text 'complex' was ignored.", call = FALSE)
}
# WHONET: xxx = no growth # WHONET: xxx = no growth
x[x_lower %in% c("", "xxx", "na", "nan")] <- NA_character_ x[x_lower %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -521,7 +525,7 @@ mo_cleaning_regex <- function() {
"|", "|",
"([({]|\\[).+([})]|\\])", "([({]|\\[).+([})]|\\])",
"|", "|",
"(^| )(e?spp|e?ssp|e?ss|e?sp|e?subsp|sube?species|biovar|biotype|serovar|e?species)[.]*( |$))" "(^| )(e?spp|e?ssp|e?ss|e?sp|e?subsp|sube?species|biovar|biotype|serovar|serogr.?up|e?species|complex)[.]*( |$))"
) )
} }

View File

@ -298,6 +298,10 @@ as.rsi.default <- function(x, ...) {
x[x.bak == 2] <- "I" x[x.bak == 2] <- "I"
x[x.bak == 3] <- "R" x[x.bak == 3] <- "R"
} }
} else if (inherits(x.bak, "character") && all(x %in% c("1", "2", "3", "S", "I", "R", NA_character_))) {
x[x.bak == "1"] <- "S"
x[x.bak == "2"] <- "I"
x[x.bak == "3"] <- "R"
} else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) { } else if (!all(is.na(x)) && !identical(levels(x), c("R", "S", "I")) && !all(x %in% c("R", "S", "I", NA))) {
if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) { if (all(x %unlike% "(R|S|I)", na.rm = TRUE)) {
# check if they are actually MICs or disks # check if they are actually MICs or disks
@ -312,6 +316,7 @@ as.rsi.default <- function(x, ...) {
x <- trimws2(as.character(unlist(x))) x <- trimws2(as.character(unlist(x)))
x[x %in% c(NA, "", "-", "NULL")] <- NA_character_ x[x %in% c(NA, "", "-", "NULL")] <- NA_character_
x.bak <- x x.bak <- x
na_before <- length(x[is.na(x)]) na_before <- length(x[is.na(x)])
# correct for translations # correct for translations

View File

@ -1,6 +1,6 @@
# `AMR` (for R) # `AMR` (for R)
<a href="https://msberends.github.io/AMR/"><img src="https://msberends.github.io/AMR/AMR_intro.svg" align="center"></a> <a href="https://msberends.github.io/AMR/"><img src="https://msberends.github.io/AMR/AMR_intro.png" align="center"></a>
---- ----

View File

@ -80,6 +80,8 @@ expect_equal(as.character(as.mo("streptococcus milleri")), "B_STRPT_MILL")
expect_equal(as.character(as.mo(c("Gram negative", "Gram positive"))), c("B_GRAMN", "B_GRAMP")) expect_equal(as.character(as.mo(c("Gram negative", "Gram positive"))), c("B_GRAMN", "B_GRAMP"))
expect_warning(as.mo("Acinetobacter calcoaceticus/baumannii complex"))
# prevalent MO # prevalent MO
expect_identical( expect_identical(
suppressWarnings(as.character( suppressWarnings(as.character(

View File

@ -81,6 +81,12 @@ if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0")) {
expect_equal(sum(is.rsi(example_isolates)), 40) expect_equal(sum(is.rsi(example_isolates)), 40)
expect_stdout(print(tibble(ab = as.rsi("S")))) expect_stdout(print(tibble(ab = as.rsi("S"))))
expect_true(example_isolates %>%
select(AMC, MEM) %>%
mutate(MEM = as.rsi(ifelse(AMC == "S", "S", MEM))) %>%
pull(MEM) %>%
is.rsi())
} }
if (AMR:::pkg_is_available("skimr", min_version = "2.0.0")) { if (AMR:::pkg_is_available("skimr", min_version = "2.0.0")) {
expect_inherits( expect_inherits(