Prepare for using AMR version 1.8.2: remove left_join(intrinsic_info), recognize co-trimoxazol

This commit is contained in:
Gerolf de Boer 2023-03-06 13:51:19 +01:00
parent 61aa1661ab
commit e72cd49274
2 changed files with 29 additions and 11 deletions

View File

@ -39,7 +39,8 @@ tAntibiotics = readxl::read_xlsx('data/ab_mapping.xlsx') %>%
# radar_data <- readGlimsArchive(ymdStartDate = ymdStartDate, # radar_data <- readGlimsArchive(ymdStartDate = ymdStartDate,
# ymdEndDate = ymdEndDate, # ymdEndDate = ymdEndDate,
# readPreprocessed = T) # readPreprocessed = T)
radar_data <- readGlimsFinalResults() radar_data <- readGlimsFinalResults() %>%
mutate_if(is.rsi, as.sir)
if (!'CRO' %in% colnames(radar_data)) if (!'CRO' %in% colnames(radar_data))
radar_data <- radar_data %>% add_column('CRO' = '') radar_data <- radar_data %>% add_column('CRO' = '')
@ -85,7 +86,7 @@ suppressMessages(
) )
intrinsic_info <- AMR::intrinsic_resistant %>% intrinsic_info <- AMR::intrinsic_resistant %>%
mutate(mo = as.mo(microorganism), mutate(#mo = as.mo(microorganism),
intrinsic_r = TRUE) intrinsic_r = TRUE)

View File

@ -696,13 +696,28 @@ server <- function(input, output, session) {
"Vancomycin") "Vancomycin")
get_resistance_df <- function(.data, mo_selected, abx, language = "en") { get_resistance_df <- function(.data, mo_selected, abx, language = "en") {
.data %>%
filter(mo == as.mo(mo_selected)) %>% out <- .data %>%
{if (nrow(.) != 0) { filter(mo == as.mo(mo_selected))
group_by_at(., input$box1.2_group) %>%
select(group_vars(.), as.character(as.ab(abx))) %>% print(paste("rijen voor ", mo_selected, ":", nrow(out)))
count_df(., translate_ab = "name", language = language) 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') 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)) %>% percent_si = percent(SI/all, 0.1)) %>%
pivot_longer(cols = c("SI", "R"), names_to = "interpretation", values_to = "value") %>% pivot_longer(cols = c("SI", "R"), names_to = "interpretation", values_to = "value") %>%
mutate(mo = as.mo(input$patho_plot_selected)) %>% mutate(mo = as.mo(input$patho_plot_selected)) %>%
left_join(intrinsic_info) %>% mutate(flag = "")
mutate(flag = if_else(intrinsic_r == TRUE, "(intrinsic resistance)", NA_character_)) # 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"), values = c("#FDE725FF", "#440154FF"),
na.value = "lightgrey") + na.value = "lightgrey") +
scale_x_continuous(labels = percent) + 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") + 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)), "*"), ggtitle(label = paste0("Selected isolates: *", mo_fullname(as.mo(input$patho_plot_selected)), "*"),
subtitle = if (any(isolate_prop_data()$all < 30)) { subtitle = if (any(isolate_prop_data()$all < 30)) {