Prepare for using AMR version 1.8.2: remove left_join(intrinsic_info), recognize co-trimoxazol
This commit is contained in:
parent
61aa1661ab
commit
e72cd49274
5
global.R
5
global.R
|
@ -39,7 +39,8 @@ tAntibiotics = readxl::read_xlsx('data/ab_mapping.xlsx') %>%
|
|||
# radar_data <- readGlimsArchive(ymdStartDate = ymdStartDate,
|
||||
# ymdEndDate = ymdEndDate,
|
||||
# readPreprocessed = T)
|
||||
radar_data <- readGlimsFinalResults()
|
||||
radar_data <- readGlimsFinalResults() %>%
|
||||
mutate_if(is.rsi, as.sir)
|
||||
|
||||
if (!'CRO' %in% colnames(radar_data))
|
||||
radar_data <- radar_data %>% add_column('CRO' = '')
|
||||
|
@ -85,7 +86,7 @@ suppressMessages(
|
|||
)
|
||||
|
||||
intrinsic_info <- AMR::intrinsic_resistant %>%
|
||||
mutate(mo = as.mo(microorganism),
|
||||
mutate(#mo = as.mo(microorganism),
|
||||
intrinsic_r = TRUE)
|
||||
|
||||
|
||||
|
|
35
server.R
35
server.R
|
@ -696,13 +696,28 @@ server <- function(input, output, session) {
|
|||
"Vancomycin")
|
||||
|
||||
get_resistance_df <- function(.data, mo_selected, abx, language = "en") {
|
||||
.data %>%
|
||||
filter(mo == as.mo(mo_selected)) %>%
|
||||
{if (nrow(.) != 0) {
|
||||
group_by_at(., input$box1.2_group) %>%
|
||||
select(group_vars(.), as.character(as.ab(abx))) %>%
|
||||
count_df(., translate_ab = "name", language = language)
|
||||
}}
|
||||
|
||||
out <- .data %>%
|
||||
filter(mo == as.mo(mo_selected))
|
||||
|
||||
print(paste("rijen voor ", mo_selected, ":", nrow(out)))
|
||||
abx <- gsub("Co-trimoxazole", "Trimetoprim / sufamethoxazole", abx)
|
||||
|
||||
if (nrow(out) > 0) {
|
||||
out %>%
|
||||
select(mo, as.character(as.ab(abx))) %>%
|
||||
count_df(., translate_ab = "name", language = language)
|
||||
} else {
|
||||
out
|
||||
}
|
||||
|
||||
# .data %>%
|
||||
# filter(mo == as.mo(mo_selected)) %>%
|
||||
# {if (nrow(.) != 0) {
|
||||
# group_by_at(., input$box1.2_group) %>%
|
||||
# select(group_vars(.), as.character(as.ab(abx))) %>%
|
||||
# count_df(., translate_ab = "name", language = language)
|
||||
# }}
|
||||
}
|
||||
|
||||
cat('Implicit join in get_resistance_df(..) @server.R:692\n')
|
||||
|
@ -735,8 +750,9 @@ server <- function(input, output, session) {
|
|||
percent_si = percent(SI/all, 0.1)) %>%
|
||||
pivot_longer(cols = c("SI", "R"), names_to = "interpretation", values_to = "value") %>%
|
||||
mutate(mo = as.mo(input$patho_plot_selected)) %>%
|
||||
left_join(intrinsic_info) %>%
|
||||
mutate(flag = if_else(intrinsic_r == TRUE, "(intrinsic resistance)", NA_character_))
|
||||
mutate(flag = "")
|
||||
# left_join(intrinsic_info) %>%
|
||||
# mutate(flag = if_else(intrinsic_r == TRUE, "(intrinsic resistance)", NA_character_))
|
||||
|
||||
})
|
||||
|
||||
|
@ -761,6 +777,7 @@ server <- function(input, output, session) {
|
|||
values = c("#FDE725FF", "#440154FF"),
|
||||
na.value = "lightgrey") +
|
||||
scale_x_continuous(labels = percent) +
|
||||
# flag not used at the moment - for intrinsic resistance
|
||||
geom_text(data = isolate_prop_data(), aes(0.5, reorder(antibiotic, value_r), label = flag), colour = "red") +
|
||||
ggtitle(label = paste0("Selected isolates: *", mo_fullname(as.mo(input$patho_plot_selected)), "*"),
|
||||
subtitle = if (any(isolate_prop_data()$all < 30)) {
|
||||
|
|
Loading…
Reference in New Issue