AMR/data-raw/reproduction_of_rsi_transla...

52 lines
2.0 KiB
R
Raw Normal View History

2019-05-10 16:44:59 +02:00
library(dplyr)
# Installed WHONET 2019 software on Windows (http://www.whonet.org/software.html),
# opened C:\WHONET\Codes\WHONETCodes.mdb in MS Access
# and exported table 'DRGLST1' to MS Excel
DRGLST1 <- readxl::read_excel("data-raw/DRGLST1.xlsx")
2019-05-10 16:44:59 +02:00
rsi_translation <- DRGLST1 %>%
# only keep CLSI and EUCAST guidelines:
filter(GUIDELINES %like% "^(CLSI|EUCST)") %>%
# set a nice layout:
transmute(guideline = gsub("([0-9]+)$", " 20\\1", gsub("EUCST", "EUCAST", GUIDELINES)),
method = TESTMETHOD,
site = SITE_INF,
2019-05-10 16:44:59 +02:00
mo = as.mo(ORG_CODE),
ab = as.ab(WHON5_CODE),
ref_tbl = REF_TABLE,
dose_disk = POTENCY,
S_disk = as.disk(min(DISK_S, 50, na.rm = TRUE)),
2019-05-10 16:44:59 +02:00
R_disk = as.disk(DISK_R),
S_mic = as.mic(MIC_S),
R_mic = as.mic(ifelse(MIC_R %in% c(1025, 129, 513), as.double(MIC_R) - 1, MIC_R))) %>%
filter(!is.na(mo) & !is.na(ab) & !mo %in% c("UNKNOWN", "B_GRAMN", "B_GRAMP", "F_FUNGUS", "F_YEAST")) %>%
2019-05-10 16:44:59 +02:00
arrange(desc(guideline), mo, ab)
2019-09-18 15:46:09 +02:00
print(mo_failures())
2019-05-10 16:44:59 +02:00
# create 2 tables: MIC and disk
tbl_mic <- rsi_translation %>%
filter(method == "MIC") %>%
mutate(breakpoint_S = as.double(S_mic), breakpoint_R = as.double(R_mic))
2019-05-10 16:44:59 +02:00
tbl_disk <- rsi_translation %>%
filter(method == "DISK") %>%
mutate(breakpoint_S = as.double(S_disk), breakpoint_R = as.double(R_disk))
2019-05-10 16:44:59 +02:00
# merge them so every record is a unique combination of method, mo and ab
rsi_translation <- bind_rows(tbl_mic, tbl_disk) %>%
rename(disk_dose = dose_disk) %>%
mutate(disk_dose = gsub("µ", "u", disk_dose)) %>%
select(-ends_with("_mic"), -ends_with("_disk")) %>%
2019-05-10 16:44:59 +02:00
as.data.frame(stringsAsFactors = FALSE) %>%
# force classes again
mutate(mo = as.mo(mo),
ab = as.ab(ab))
2019-05-10 16:44:59 +02:00
# save to data-raw
write.table(rsi_translation, "data-raw/rsi_translation.txt", sep = "\t", na = "", row.names = FALSE)
2019-05-10 16:44:59 +02:00
# save to package
usethis::use_data(rsi_translation, overwrite = TRUE)
rm(rsi_translation)
2019-09-20 12:33:05 +02:00
devtools::load_all(".")