-
Hello, RE:
as.rsI() appears to convert D and U to I, which I don't actually want - Is there a way to switch this off, so that
leads to rather than Even better, is there any way that D can be retained as D? e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Not at the moment. The reason why it’s made I is here: Lines 350 to 351 in 05d536e Since EUCAST uses I as the dose-dependent interpretation since 2019, it’s considered I. What would be reasons to show D as well? We could add it of course, but then I would be curious for the reasons why. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your very helpful reply! Good question - It's for purely local reasons, so I wouldn't suggest changing your code. We are using a very old LIMS here in Newcastle, and we are limited with regards to the functionality of our system, including the values entered. Therefore, for purely historical reasons (which are not worth delving into), we have on occasion used "D" to signify something other than dose-dependent. Thankfully, we are upgrading our LIMS over the next two years or so, to Cerner PathNet/LIMS. Best wishes, Dan |
Beta Was this translation helpful? Give feedback.
-
Ah, tell me about it! Old lab systems are a pain! But right, then it would be quite hard to work with D in the AMR package. I even tried doing this for you: my_own_rsi <- function(x, include_these = c("S", "I", "D", "R")) {
structure(
factor(x, levels = include_these, ordered = TRUE),
class = c("rsi", "factor")
)
} And then tried whether it could be used to determine resistance, but it doesn't: x <- my_own_rsi(c(rep("S", 100), rep("D", 100), rep("R", 100)))
# this seems to work:
x
#> Class 'rsi'
#> [1] S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S S
#> [73] S S S S S S S S S S S S S S S S S S S S S S S S S S S S D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D
#> [145] D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D R R R R R R R R R R R R R R R R
#> [217] R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R R
#> [289] R R R R R R R R R R R R
# but then this doesn't - it's completely ignoring D:
resistance(x)
#> [1] 0.5 Maybe something like this is helpful then? data.frame(amox = x,
cipr = x,
gent = x,
tobr = x) %>%
summarise(across(aminoglycosides(),
function(x) sum(x == "D") / length(x)))
#> ℹ For aminoglycosides() using columns 'gent' (gentamicin) and 'tobr' (tobramycin)
#> gent tobr
#> 1 0.3333333 0.3333333 It calculates the proportion of D, but using antibiotic selectors so you can still use some of the AMR functions. Or for the proportion S + I + D with a manual function: my_susceptibility <- function(x) {
x <- x[!is.na(x)]
if (length(x) < 30) {
stop("You might not want to know the result with so few isolates!")
}
sum(x %in% c("S", "I", "D")) / length(x)
}
data.frame(amox = x,
cipr = x,
gent = x,
tobr = x) %>%
summarise(across(c(quinolones(), aminoglycosides()),
my_susceptibility))
#> ℹ For quinolones() using column 'cipr' (ciprofloxacin)
#> ℹ For aminoglycosides() using columns 'gent' (gentamicin) and 'tobr' (tobramycin)
#> cipr gent tobr
#> 1 0.6666667 0.6666667 0.6666667 |
Beta Was this translation helpful? Give feedback.
Ah, tell me about it! Old lab systems are a pain!
But right, then it would be quite hard to work with D in the AMR package.
I even tried doing this for you:
And then tried whether it could be used to determine resistance, but it doesn't: