mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 19:26:13 +01:00
29 lines
841 B
R
29 lines
841 B
R
library(dplyr)
|
|
example_isolates %>%
|
|
select(mo, where(is.rsi)) %>%
|
|
tidyr::pivot_longer(cols = where(is.rsi)) %>%
|
|
# remove intrisic R
|
|
filter(!paste(mo, name) %in% AMR:::INTRINSIC_R) %>%
|
|
mutate(name = as.ab(name),
|
|
value = ifelse(value == "R", 1, 0),
|
|
class = ab_group(name)) %>%
|
|
group_by(mo, class) %>%
|
|
summarise(n = n(),
|
|
res = mean(value, na.rm = TRUE)) %>%
|
|
filter(n > 30, !is.na(res))
|
|
|
|
|
|
|
|
df <- example_isolates
|
|
search_mo <- "B_ESCHR_COLI"
|
|
intrinsic_res <- INTRINSIC_R[INTRINSIC_R %like% search_mo]
|
|
intrinsic_res <- gsub(".* (.*)", "\\1", intrinsic_res)
|
|
|
|
x <- df %>%
|
|
select(mo, where(is.rsi)) %>%
|
|
filter(mo == search_mo) %>%
|
|
# at least 30 results available
|
|
select(function(x) sum(!is.na(x)) >= 30) %>%
|
|
# remove intrisic R
|
|
select(!matches(paste(intrinsic_res, collapse = "|")))
|