1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 04:02:19 +02:00

Replace RSI with SIR

This commit is contained in:
Dr. Matthijs Berends
2023-01-21 23:47:20 +01:00
committed by GitHub
parent 24b12024ce
commit 98e62c9af2
127 changed files with 1746 additions and 1648 deletions

View File

@ -144,21 +144,6 @@ create_species_cons_cops <- function(type = c("CoNS", "CoPS")) {
]
}
}
create_MO_fullname_lower <- function() {
AMR_env$MO_lookup <- AMR::microorganisms
# use this paste instead of `fullname` to work with Viridans Group Streptococci, etc.
AMR_env$MO_lookup$fullname_lower <- tolower(trimws(paste(
AMR_env$MO_lookup$genus,
AMR_env$MO_lookup$species,
AMR_env$MO_lookup$subspecies
)))
ind <- AMR_env$MO_lookup$genus == "" | grepl("^[(]unknown ", AMR_env$MO_lookup$fullname, perl = TRUE)
AMR_env$MO_lookup[ind, "fullname_lower"] <- tolower(AMR_env$MO_lookup[ind, "fullname", drop = TRUE])
AMR_env$MO_lookup$fullname_lower <- trimws(gsub("[^.a-z0-9/ \\-]+", "", AMR_env$MO_lookup$fullname_lower, perl = TRUE))
# special for Salmonella - they have cities as subspecies but not the species (enterica) in the fullname:
AMR_env$MO_lookup$fullname_lower[which(AMR_env$MO_lookup$subspecies %like_case% "^[A-Z]")] <- gsub(" enterica ", " ", AMR_env$MO_lookup$fullname_lower[which(AMR_env$MO_lookup$subspecies %like_case% "^[A-Z]")], fixed = TRUE)
AMR_env$MO_lookup$fullname_lower
}
MO_CONS <- create_species_cons_cops("CoNS")
MO_COPS <- create_species_cons_cops("CoPS")
MO_STREP_ABCG <- AMR_env$MO_lookup$mo[which(AMR_env$MO_lookup$genus == "Streptococcus" &
@ -166,7 +151,6 @@ MO_STREP_ABCG <- AMR_env$MO_lookup$mo[which(AMR_env$MO_lookup$genus == "Streptoc
"pyogenes", "agalactiae", "dysgalactiae", "equi", "canis",
"group A", "group B", "group C", "group G"
))]
MO_FULLNAME_LOWER <- create_MO_fullname_lower()
MO_PREVALENT_GENERA <- c(
"Absidia", "Acanthamoeba", "Acremonium", "Aedes", "Alternaria", "Amoeba", "Ancylostoma", "Angiostrongylus",
"Anisakis", "Anopheles", "Apophysomyces", "Aspergillus", "Aureobasidium", "Basidiobolus", "Beauveria",
@ -298,7 +282,6 @@ suppressMessages(usethis::use_data(EUCAST_RULES_DF,
MO_CONS,
MO_COPS,
MO_STREP_ABCG,
MO_FULLNAME_LOWER,
MO_PREVALENT_GENERA,
AB_LOOKUP,
AV_LOOKUP,
@ -369,20 +352,20 @@ changed_md5 <- function(object) {
}
# give official names to ABs and MOs
rsi <- rsi_translation %>%
clin_break <- clinical_breakpoints %>%
mutate(mo_name = mo_name(mo, language = NULL, keep_synonyms = TRUE, info = FALSE), .after = mo) %>%
mutate(ab_name = ab_name(ab, language = NULL), .after = ab)
if (changed_md5(rsi)) {
usethis::ui_info(paste0("Saving {usethis::ui_value('rsi_translation')} to {usethis::ui_value('data-raw/')}"))
write_md5(rsi)
try(saveRDS(rsi, "data-raw/rsi_translation.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(rsi, "data-raw/rsi_translation.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_sas(rsi, "data-raw/rsi_translation.sas"), silent = TRUE)
try(haven::write_sav(rsi, "data-raw/rsi_translation.sav"), silent = TRUE)
try(haven::write_dta(rsi, "data-raw/rsi_translation.dta"), silent = TRUE)
try(openxlsx::write.xlsx(rsi, "data-raw/rsi_translation.xlsx"), silent = TRUE)
try(arrow::write_feather(rsi, "data-raw/rsi_translation.feather"), silent = TRUE)
try(arrow::write_parquet(rsi, "data-raw/rsi_translation.parquet"), silent = TRUE)
if (changed_md5(clin_break)) {
usethis::ui_info(paste0("Saving {usethis::ui_value('clinical_breakpoints')} to {usethis::ui_value('data-raw/')}"))
write_md5(clin_break)
try(saveRDS(clin_break, "data-raw/clinical_breakpoints.rds", version = 2, compress = "xz"), silent = TRUE)
try(write.table(clin_break, "data-raw/clinical_breakpoints.txt", sep = "\t", na = "", row.names = FALSE), silent = TRUE)
try(haven::write_sas(clin_break, "data-raw/clinical_breakpoints.sas"), silent = TRUE)
try(haven::write_sav(clin_break, "data-raw/clinical_breakpoints.sav"), silent = TRUE)
try(haven::write_dta(clin_break, "data-raw/clinical_breakpoints.dta"), silent = TRUE)
try(openxlsx::write.xlsx(clin_break, "data-raw/clinical_breakpoints.xlsx"), silent = TRUE)
try(arrow::write_feather(clin_break, "data-raw/clinical_breakpoints.feather"), silent = TRUE)
try(arrow::write_parquet(clin_break, "data-raw/clinical_breakpoints.parquet"), silent = TRUE)
}
if (changed_md5(microorganisms)) {

Binary file not shown.

View File

@ -45554,7 +45554,7 @@
"B_STRPT_ORLX" "Streptococcus oriloxodontae" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "oriloxodontae" "" "species" "Shinozaki-Kuwahara et al., 2014" "LPSN" "792340" "517118" 1.5 ""
"B_STRPT_ORSS" "Streptococcus orisasini" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "orisasini" "" "species" "Takada et al., 2013" "LPSN" "790987" "517118" 1.5 ""
"B_STRPT_ORSR" "Streptococcus orisratti" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "orisratti" "" "species" "Zhu et al., 2000" "LPSN" "781365" "517118" 1.5 "438034004"
"B_STRPT_RSIS" "Streptococcus orisuis" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "orisuis" "" "species" "Takada et al., 2007" "LPSN" "781314" "517118" 1.5 "6441000146108"
"B_STRPT_sirS" "Streptococcus orisuis" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "orisuis" "" "species" "Takada et al., 2007" "LPSN" "781314" "517118" 1.5 "6441000146108"
"B_STRPT_OVIS" "Streptococcus ovis" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "ovis" "" "species" "Collins et al., 2001" "LPSN" "781366" "517118" 1.5 "438035003"
"B_STRPT_OVBR" "Streptococcus ovuberis" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "ovuberis" "" "species" "Zamora et al., 2017" "LPSN" "796216" "517118" 1.5 ""
"B_STRPT_PCFC" "Streptococcus pacificus" "accepted" "Bacteria" "Bacillota" "Bacilli" "Lactobacillales" "Streptococcaceae" "Streptococcus" "pacificus" "" "species" "Volokhov et al., 2021" "LPSN" "19573" "517118" 1.5 ""

View File

@ -230,7 +230,7 @@ read_EUCAST <- function(sheet, file, guideline_name) {
mo = ifelse(mo == "", mo_sheet, mo)
) %>%
filter(!(is.na(breakpoint_S) & is.na(breakpoint_R))) %>%
# comply with rsi_translation for now
# comply with clinical_breakpoints for now
transmute(guideline,
method,
site = case_when(
@ -285,7 +285,7 @@ for (i in 2:length(sheets_to_analyse)) {
}
# 2021-07-12 fix for Morganellaceae (check other lines too next time)
morg <- rsi_translation %>%
morg <- clinical_breakpoints %>%
as_tibble() %>%
filter(
ab == "IPM",
@ -298,7 +298,7 @@ morg[which(morg$method == "MIC"), "breakpoint_R"] <- 4
morg[which(morg$method == "DISK"), "breakpoint_S"] <- 50
morg[which(morg$method == "DISK"), "breakpoint_R"] <- 19
rsi_translation <- rsi_translation %>%
clinical_breakpoints <- clinical_breakpoints %>%
bind_rows(morg) %>%
bind_rows(morg %>%
mutate(guideline = "EUCAST 2020")) %>%

View File

@ -28,7 +28,7 @@
# ==================================================================== #
# This script runs in under a minute and renews all guidelines of CLSI and EUCAST!
# Run it with source("data-raw/reproduction_of_rsi_translation.R")
# Run it with source("data-raw/reproduction_of_clinical_breakpoints.R")
library(dplyr)
library(readr)
@ -206,11 +206,11 @@ breakpoints_new[which(is.na(breakpoints_new$breakpoint_R)), "breakpoint_R"] <- b
# check again
breakpoints_new %>% filter(guideline == "EUCAST 2022", ab == "AMC", mo == "B_[ORD]_ENTRBCTR", method == "MIC")
# compare with current version
rsi_translation %>% filter(guideline == "EUCAST 2022", ab == "AMC", mo == "B_[ORD]_ENTRBCTR", method == "MIC")
clinical_breakpoints %>% filter(guideline == "EUCAST 2022", ab == "AMC", mo == "B_[ORD]_ENTRBCTR", method == "MIC")
# Save to package ----
rsi_translation <- breakpoints_new
usethis::use_data(rsi_translation, overwrite = TRUE, compress = "xz", version = 2)
rm(rsi_translation)
clinical_breakpoints <- breakpoints_new
usethis::use_data(clinical_breakpoints, overwrite = TRUE, compress = "xz", version = 2)
rm(clinical_breakpoints)
devtools::load_all(".")

View File

@ -31,7 +31,7 @@ library(AMR)
library(dplyr)
int_resis <- data.frame(mo = microorganisms$mo, stringsAsFactors = FALSE)
for (i in seq_len(nrow(antibiotics))) {
int_resis$new <- as.rsi("S")
int_resis$new <- as.sir("S")
colnames(int_resis)[ncol(int_resis)] <- antibiotics$ab[i]
}
@ -43,7 +43,7 @@ int_resis <- eucast_rules(int_resis,
info = FALSE
)
int_resis2 <- int_resis[, sapply(int_resis, function(x) any(!is.rsi(x) | x == "R")), drop = FALSE] %>%
int_resis2 <- int_resis[, sapply(int_resis, function(x) any(!is.sir(x) | x == "R")), drop = FALSE] %>%
tidyr::pivot_longer(-mo) %>%
filter(value == "R") %>%
select(mo, ab = name)

View File

@ -1333,7 +1333,7 @@ rm(microorganisms)
# and check: these codes should not be missing (will otherwise throw a unit test error):
AMR::microorganisms.codes %>% filter(!mo %in% taxonomy$mo)
AMR::rsi_translation %>% filter(!mo %in% taxonomy$mo)
AMR::clinical_breakpoints %>% filter(!mo %in% taxonomy$mo)
AMR::example_isolates %>% filter(!mo %in% taxonomy$mo)
AMR::intrinsic_resistant %>% filter(!mo %in% taxonomy$mo)
@ -1342,10 +1342,10 @@ devtools::load_all(".")
# reset previously changed mo codes
if (!identical(rsi_translation$mo, as.mo(rsi_translation$mo, language = NULL))) {
rsi_translation$mo <- as.mo(rsi_translation$mo, language = NULL)
usethis::use_data(rsi_translation, overwrite = TRUE, version = 2, compress = "xz")
rm(rsi_translation)
if (!identical(clinical_breakpoints$mo, as.mo(clinical_breakpoints$mo, language = NULL))) {
clinical_breakpoints$mo <- as.mo(clinical_breakpoints$mo, language = NULL)
usethis::use_data(clinical_breakpoints, overwrite = TRUE, version = 2, compress = "xz")
rm(clinical_breakpoints)
}
if (!identical(microorganisms.codes$mo, as.mo(microorganisms.codes$mo, language = NULL))) {

Binary file not shown.