Replies: 1 comment 3 replies
-
This is a lot of code to just get the empiric coverage of prescribed antibiotics. You might want to read about analysing data in our manual: https://msberends.github.io/AMR/reference/index.html#analysing-data More specifically, I think |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I am working on a project that involves analyzing the therapeutic coverage of empirically prescribed antibiotics based on susceptibility results from an antibiogram. I have a dataset containing patient information, prescribed antibiotics, and the corresponding antibiogram results.
Objective
The goal is to determine if the empirically prescribed antibiotics are effective against the organisms identified in the antibiogram. Specifically, I want to perform a coverage analysis that returns a binary output:
"therapeutic coverage" if the empirically prescribed antibiotic is found effective (the organism is susceptible).
"therapeutic failure" if the empirically prescribed antibiotic is not effective (the organism is resistant).
Dataset
The dataset contains the following columns:
participant_id: Unique identifier for each participant.
gender: Gender of the participant.
specimen: Type of specimen collected.
origin: Origin of the specimen.
emp_thp: Indicates if empiric therapy was given.
t1 to t5: Empirically prescribed antibiotics.
infection: Type of infection.
organisms: Organism identified.
Antibiotic sensitivity columns (pen, fox, amp, etc.): Susceptibility results for various antibiotics.
status_update: Status update for the participant.
Here is a bit of what i did, it would be very helpful if i could get help
Load necessary libraries
library(dplyr)
library(tidyr)
library(AMR)
Create the dataset
data <- tibble::tribble(
~participant_id, ~gender, ~specimen, ~origin, ~emp_thp, ~t1, ~t2, ~t3, ~t4, ~t5, ~infection, ~organisms, ~pen, ~fox, ~amp, ~gen, ~cip, ~cli, ~ery, ~tcy, ~sxt, ~fac, ~lzd, ~status_update,
"1811STPH3522", "Female", "tissue samples", "Surgery", "Yes", "Amo_Clav", "Metronidazole", NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", NA, NA, NA, "S", "R", "S", NA, NA, "MSSA",
"1812STPH3538", "Female", "throat", "Community", "Yes", "Amo_Clav", NA, NA, NA, NA, "Others", "B_STPHY_AURS", "R", "S", "R", "S", "S", "S", "S", "S", "S", "S", "S", "MSSA",
"1812STPH3539", "Female", "tissue samples", "Surgery", "Yes", "Amo_Clav", "Ciprofloxacin", "Metronidazole", NA, NA, "SSTI", "B_STPHY_AURS", "R", "R", "R", "S", "R", "S", "S", "S", "S", "R", "S", "MRSA",
"1812STPH3541", "Female", "blood", "Paediatric", "Yes", "Ampicillin", "Gentamicin", NA, NA, NA, "Bacteremia", "B_STPHY_AURS", "R", "S", "R", "S", "S", "S", "S", "R", "R", "S", "S", "MSSA",
"1901STPH3578", "Female", "tissue samples", "Community", "Yes", "Flucloxacillin", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", NA, "R", NA, NA, NA, "R", NA, "S", NA, NA, "MSSA",
"1902STPH3582", "Male", "swabs", "Community", "Yes", "Amo_Clav", NA, NA, NA, NA, "Others", "B_STPHY_AURS", NA, "S", "S", "S", "R", NA, NA, "R", "S", "S", "S", "MSSA",
"1902STPH3586", "Male", "tissue samples", "Community", "Yes", "Oxacillin", "Metronidazole", NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", NA, NA, NA, "S", "R", "S", NA, NA, "MSSA",
"1902STPH3587", "Male", "tissue samples", "Paediatric", "Yes", "Cloxacillin", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", NA, NA, NA, "R", "S", "S", NA, NA, "MSSA",
"1902STPH3616", "Female", "tissue samples", "Community", "Yes", "Ampicillin", "Gentamicin", NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "S", "S", "S", "S", "MSSA",
"1903STPH3637", "Male", "tissue samples", "Community", "Yes", "Ceftriaxone", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "R", "S", "S", "S", "MSSA",
"1903STPH3648", "Female", "swabs", "Community", "Yes", "Ampicillin", "Ceftriaxone", "Gentamycin", NA, NA, "Others", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "R", "S", "S", "S", "MSSA",
"1904STPH3661", "Male", "tissue samples", "Community", "Yes", "Amo_Clav", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", NA, NA, NA, NA, "S", "R", "S", NA, NA, "MSSA",
"1904STPH3663", "Male", "tissue samples", "Community", "Yes", "Ciprofloxacin", "Azithomycin", "Gentamycin", "Amo_Clav", NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", "S", "R", NA, "S", "R", "S", "S", "S", "MSSA",
"1904STPH3677", "Male", "blood", "Paediatric", "Yes", "Ampicillin", "Gentamicin", NA, NA, NA, "Bacteremia", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "S", "S", "S", "S", "MSSA",
"1904STPH3681", "Male", "throat", "Community", "Yes", "Amo_Clav", "Ceftriaxone", "Cefixime", NA, NA, "Others", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "R", "S", "S", "S", "MSSA",
"1905STPH3704", "Male", "tissue samples", "Community", "Yes", "Metronidazole", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "S", "S", "R", "S", "S", "R", "S", "S", "S", "MSSA",
"2002STPH3887", "Male", "fluid aspirates", "Internal", "Yes", "Amo_Clav", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", NA, NA, NA, "S", "I", "S", NA, NA, "MSSA",
"2003STPH3901", "Female", "fluid aspirates", "Surgery", "Yes", "Amo_Clav", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "S", "S", "S", "S", "MSSA",
"2008STPH3964", "Male", "tissue samples", "Community", "Yes", "Flucloxacillin", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "S", "S", "S", "S", "R", "S", "S", "S", "S", "R", "S", "MSSA",
"2012STPH4022", "Male", "tissue samples", "Community", "Yes", "Bacitracin", NA, NA, NA, NA, "SSTI", "B_STPHY_AURS", "R", "S", "R", "S", "R", "S", "S", "R", "S", "R", "S", "MSSA"
)
Define function to check therapeutic coverage
check_coverage <- function(emp_thp, antibiogram) {
if (emp_thp %in% antibiogram && antibiogram[emp_thp] == "S") {
return("therapeutic coverage")
} else {
return("therapeutic failure")
}
}
Reshape data to long format for antibiotic sensitivity columns
data_long <- data %>%
pivot_longer(cols = starts_with("pen"):starts_with("lzd"), names_to = "antibiotic", values_to = "sensitivity") %>%
filter(!is.na(sensitivity))
Perform coverage analysis
coverage_results <- data %>%
rowwise() %>%
mutate(coverage_result = check_coverage(emp_thp, c(pen = pen, fox = fox, amp = amp, gen = gen, cip = cip, cli = cli, ery = ery, tcy = tcy, sxt = sxt, fac = fac, lzd = lzd)))
View the results
print(coverage_results)
Beta Was this translation helpful? Give feedback.
All reactions