Repository navigation
Replies: 1 comment
|
Antibiotic class selectors are available here: https://msberends.github.io/AMR/reference/antibiotic_class_selectors.html You can use |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have developed a treatment outcome checking function in R, which determines treatment success or failure based on susceptible antibiotics (from AST results) and previous empiric therapy.
The function iterates over each row of the dataset and performs checks to determine the outcome. The outcome returns true the germs is susceptible to one or more of the antibiotics in the previous empiric therapy. However i wanted first to extract names of susceptible antibiotics from AST results and check if the given antibiotic is member of an antibiotic class(es) prescribed in empiric therapy (i converted treatment combination as class combiantions rather than antibiotics combinations). While the current implementation looks good, I'm looking for advice on how to optimize it, especially is there a way to directly detect if a susceptible antibiotic belong to a class previously prescribed to a patient and then return SUCCESS or, if otherwise, return FAILURE.
find the function below
`# Function to check treatment outcome based on susceptible antibiotics and previous empiric therapy
check_treatment_outcome <- function(row) {
Extract the names of susceptible antibiotics
susceptible_antibiotics <- names(row[row == 1])
Extract the names of antibiotics in previous empiric therapy
previous_empiric_therapy <- row[["previous_empiric_therapy"]]
Define antibiotic classes based on susceptibility results
antibiotic_classes <- list(
penicillins = c("PEN"),
cephalosporins = c("FOX", "AMP", "CEF"), # Define all cephalosporins here
quinolones = c("CIP"),
macrolides = c("ERY"),
sulfonamides = c("SMX"),
tetracyclines = c("TCY")
# Add more antibiotic classes as needed
)
Function to identify the correct antibiotic class for a given antibiotic
get_antibiotic_class <- function(antibiotic) {
for (class in names(antibiotic_classes)) {
if (antibiotic %in% antibiotic_classes[[class]]) {
return(class)
}
}
return(NULL) # Return NULL if antibiotic class is not found
}
Check if any susceptible antibiotic belongs to the correct antibiotic class in previous empiric therapy
for (susceptible_abx in susceptible_antibiotics) {
susceptible_class <- get_antibiotic_class(susceptible_abx)
if (!is.null(susceptible_class) && any(previous_empiric_therapy %in% antibiotic_classes[[susceptible_class]])) {
return("Success") # Return success if correct antibiotic class is present in previous empiric therapy
}
}
return("Failure") # Return failure if no suitable match is found
}
Apply the function to each row to determine treatment outcome
staph_cermel_new$treatment_outcome <- apply(staph_cermel_new, 1, check_treatment_outcome)
`
All reactions