key_antibiotics.Rd
These function can be used to determine first isolates (see first_isolate
). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates.
key_antibiotics(tbl, col_mo = NULL, universal_1 = "amox", universal_2 = "amcl", universal_3 = "cfur", universal_4 = "pita", universal_5 = "cipr", universal_6 = "trsu", GramPos_1 = "vanc", GramPos_2 = "teic", GramPos_3 = "tetr", GramPos_4 = "eryt", GramPos_5 = "oxac", GramPos_6 = "rifa", GramNeg_1 = "gent", GramNeg_2 = "tobr", GramNeg_3 = "coli", GramNeg_4 = "cfot", GramNeg_5 = "cfta", GramNeg_6 = "mero", warnings = TRUE, ...) key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"), ignore_I = TRUE, points_threshold = 2, info = FALSE)
tbl | table with antibiotics coloms, like |
---|---|
col_mo | column name of the unique IDs of the microorganisms (see |
universal_1, universal_2, universal_3, universal_4, universal_5, universal_6 | column names of broad-spectrum antibiotics, case-insensitive |
GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6 | column names of antibiotics for Gram positives, case-insensitive |
GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6 | column names of antibiotics for Gram negatives, case-insensitive |
warnings | give warning about missing antibiotic columns, they will anyway be ignored |
... | other parameters passed on to function |
x, y | characters to compare |
type | type to determine weighed isolates; can be |
ignore_I | logical to determine whether antibiotic interpretations with |
points_threshold | points until the comparison of key antibiotics will lead to inclusion of an isolate when |
info | print progress |
The function key_antibiotics
returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using key_antibiotics_equal
, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot ("."
). The first_isolate
function only uses this function on the same microbial species from the same patient. Using this, an MRSA will be included after a susceptible S. aureus (MSSA) found within the same episode (see episode
parameter of first_isolate
). Without key antibiotic comparison it wouldn't.
At default, the antibiotics that are used for Gram positive bacteria are (colum names):
"amox"
, "amcl"
, "cfur"
, "pita"
, "cipr"
, "trsu"
(until here is universal), "vanc"
, "teic"
, "tetr"
, "eryt"
, "oxac"
, "rifa"
.
At default, the antibiotics that are used for Gram negative bacteria are (colum names):
"amox"
, "amcl"
, "cfur"
, "pita"
, "cipr"
, "trsu"
(until here is universal), "gent"
, "tobr"
, "coli"
, "cfot"
, "cfta"
, "mero"
.
The function key_antibiotics_equal
checks the characters returned by key_antibiotics
for equality, and returns a logical vector.
There are two ways to determine whether isolates can be included as first weighted isolates which will give generally the same results:
1. Using type = "keyantibiotics"
and parameter ignore_I
Any difference from S to R (or vice versa) will (re)select an isolate as a first weighted isolate. With ignore_I = FALSE
, also differences from I to S|R (or vice versa) will lead to this. This is a reliable method and 30-35 times faster than method 2.
2. Using type = "points"
and parameter points_threshold
A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds points_threshold
, an isolate will be (re)selected as a first weighted isolate.
# septic_patients is a dataset available in the AMR package ?septic_patients#>library(dplyr) # set key antibiotics to a new variable my_patients <- septic_patients %>% mutate(keyab = key_antibiotics(.)) %>% mutate( # now calculate first isolates first_regular = first_isolate(., col_keyantibiotics = FALSE), # and first WEIGHTED isolates first_weighted = first_isolate(., col_keyantibiotics = "keyab") )#>#> NOTE: Using column `mo` as input for `col_mo`.#> NOTE: Using column `date` as input for `col_date`.#> NOTE: Using column `patient_id` as input for `col_patient_id`.#> 1,317 first isolates (65.9% of total)#> NOTE: Using column `mo` as input for `col_mo`.#> NOTE: Using column `date` as input for `col_date`.#> NOTE: Using column `patient_id` as input for `col_patient_id`.#> [Criterion] Inclusion based on key antibiotics, ignoring I.#> 1,413 first weighted isolates (70.7% of total)# Check the difference, in this data set it results in 7% more isolates: sum(my_patients$first_regular, na.rm = TRUE)#> [1] 1317#> [1] 1413# output of the `key_antibiotics` function could be like this: strainA <- "SSSRR.S.R..S" strainB <- "SSSIRSSSRSSS" key_antibiotics_equal(strainA, strainB)#> [1] TRUE# TRUE, because I is ignored (as well as missing values) key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)#> [1] FALSE# FALSE, because I is not ignored and so the 4th value differs