diff --git a/DESCRIPTION b/DESCRIPTION index ed049c34..d54190df 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.0.0.9007 +Version: 1.0.1 Date: 2020-02-22 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 64d2dcac..bfd37ce9 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,8 @@ -# AMR 1.0.0.9007 -## Last updated: 22-Feb-2020 +# AMR 1.0.1 ### Changed -* Fixed floating point error for some MIC compa in EUCAST 2020 guideline -* Interpretation from MIC values to R/SI can now be used with `mutate_at()` of the dplyr package: +* Fixed important floating point error for some MIC comparisons in EUCAST 2020 guideline +* Interpretation from MIC values (and disk zones) to R/SI can now be used with `mutate_at()` of the `dplyr` package: ```r yourdata %>% mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli") diff --git a/docs/404.html b/docs/404.html index 770a4d9d..abfa2ad2 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 563d34d0..503dd3c6 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 00ecff0f..2385945f 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ @@ -179,7 +179,7 @@AMR.Rmd
Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 20 February 2020.
+Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 23 February 2020.
Finally, we will apply EUCAST rules on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the eucast_rules()
function can also apply additional rules, like forcing
Because the amoxicillin (column AMX
) and amoxicillin/clavulanic acid (column AMC
) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The eucast_rules()
fixes this:
data <- eucast_rules(data, col_mo = "bacteria")
-#
-# Other rules by this AMR package
-# Non-EUCAST: inherit amoxicillin results for unavailable ampicillin (no changes)
-# Non-EUCAST: inherit ampicillin results for unavailable amoxicillin (no changes)
-# Non-EUCAST: set amoxicillin/clav acid = S where ampicillin = S (2,986 values changed)
-# Non-EUCAST: set ampicillin = R where amoxicillin/clav acid = R (157 values changed)
-# Non-EUCAST: set piperacillin = R where piperacillin/tazobactam = R (no changes)
-# Non-EUCAST: set piperacillin/tazobactam = S where piperacillin = S (no changes)
-# Non-EUCAST: set trimethoprim = R where trimethoprim/sulfa = R (no changes)
-# Non-EUCAST: set trimethoprim/sulfa = S where trimethoprim = S (no changes)
-#
-# ----
-# Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
-# http://eucast.org/
-#
-# EUCAST Clinical Breakpoints (v10.0, 2020)
-# Aerococcus sanguinicola (no changes)
-# Aerococcus urinae (no changes)
-# Anaerobic Gram-negatives (no changes)
-# Anaerobic Gram-positives (no changes)
-# Burkholderia pseudomallei (no changes)
-# Campylobacter coli (no changes)
-# Campylobacter jejuni (no changes)
-# Enterobacterales (Order) (no changes)
-# Enterococcus (no changes)
-# Haemophilus influenzae (no changes)
-# Kingella kingae (no changes)
-# Moraxella catarrhalis (no changes)
-# Pasteurella multocida (no changes)
-# Staphylococcus (no changes)
-# Streptococcus groups A, B, C, G (no changes)
-# Streptococcus pneumoniae (1,017 values changed)
-# Viridans group streptococci (no changes)
-#
-# EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-# Table 01: Intrinsic resistance in Enterobacteriaceae (1,297 values changed)
-# Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
-# Table 03: Intrinsic resistance in other Gram-negative bacteria (no changes)
-# Table 04: Intrinsic resistance in Gram-positive bacteria (2,752 values changed)
-# Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
-# Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
-# Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)
-# Table 12: Interpretive rules for aminoglycosides (no changes)
-# Table 13: Interpretive rules for quinolones (no changes)
-#
-# -------------------------------------------------------------------------------
-# EUCAST rules affected 6,502 out of 20,000 rows, making a total of 8,209 edits
-# => added 0 test results
-#
-# => changed 8,209 test results
-# - 124 test results changed from S to I
-# - 4,743 test results changed from S to R
-# - 1,209 test results changed from I to S
-# - 356 test results changed from I to R
-# - 1,777 test results changed from R to S
-# -------------------------------------------------------------------------------
-#
-# Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.
data <- eucast_rules(data, col_mo = "bacteria")
So only 28.5% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.4% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
data_1st <- data %>%
filter(first == TRUE)
For future use, the above two syntaxes can be shortened with the filter_first_isolate()
function:
We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient N2, sorted on date:
+We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient Q2, sorted on date:
isolate | @@ -557,8 +498,8 @@ Unique: 2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-02-09 | -N2 | +2010-02-26 | +Q2 | B_ESCHR_COLI | R | S | @@ -568,52 +509,63 @@ Unique: 2|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | -2010-03-02 | -N2 | +2010-03-25 | +Q2 | B_ESCHR_COLI | S | S | -S | R | +S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3 | -2010-04-05 | -N2 | +2010-05-23 | +Q2 | B_ESCHR_COLI | -S | -S | +R | +R | S | S | FALSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 | -2010-05-19 | -N2 | +2010-05-24 | +Q2 | B_ESCHR_COLI | -R | -I | +S | +S | S | S | FALSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | -2010-07-08 | -N2 | +2010-09-08 | +Q2 | B_ESCHR_COLI | R | -I | +S | S | S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
6 | -2010-08-09 | -N2 | +2011-03-19 | +Q2 | +B_ESCHR_COLI | +S | +S | +R | +S | +TRUE | +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | +2011-04-02 | +Q2 | B_ESCHR_COLI | S | S | @@ -621,45 +573,34 @@ Unique: 2S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
7 | -2011-05-26 | -N2 | -B_ESCHR_COLI | -S | -S | -S | -S | -TRUE | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
8 | -2011-05-26 | -N2 | +2011-04-05 | +Q2 | B_ESCHR_COLI | -R | -R | +I | S | +R | S | FALSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
9 | -2011-06-19 | -N2 | +2011-11-13 | +Q2 | B_ESCHR_COLI | S | S | -R | +S | S | FALSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 | -2011-07-29 | -N2 | +2011-11-28 | +Q2 | B_ESCHR_COLI | -R | +S | S | S | S | @@ -676,9 +617,7 @@ Unique: 2 # NOTE: Using column `bacteria` 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`. -# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this. -# [Criterion] Inclusion based on key antibiotics, ignoring I -# => Found 15,096 first weighted isolates (75.5% of total) +# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
isolate | @@ -695,8 +634,8 @@ Unique: 2||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-02-09 | -N2 | +2010-02-26 | +Q2 | B_ESCHR_COLI | R | S | @@ -707,23 +646,23 @@ Unique: 2|||||||
2 | -2010-03-02 | -N2 | +2010-03-25 | +Q2 | B_ESCHR_COLI | S | S | -S | R | +S | FALSE | TRUE | ||
3 | -2010-04-05 | -N2 | +2010-05-23 | +Q2 | B_ESCHR_COLI | -S | -S | +R | +R | S | S | FALSE | @@ -731,11 +670,11 @@ Unique: 2||
4 | -2010-05-19 | -N2 | +2010-05-24 | +Q2 | B_ESCHR_COLI | -R | -I | +S | +S | S | S | FALSE | @@ -743,83 +682,83 @@ Unique: 2||
5 | -2010-07-08 | -N2 | +2010-09-08 | +Q2 | B_ESCHR_COLI | R | -I | +S | S | S | FALSE | -FALSE | +TRUE | |
6 | -2010-08-09 | -N2 | +2011-03-19 | +Q2 | B_ESCHR_COLI | S | S | R | S | -FALSE | +TRUE | TRUE | ||
7 | -2011-05-26 | -N2 | +2011-04-02 | +Q2 | B_ESCHR_COLI | S | S | +R | S | -S | -TRUE | -TRUE | +FALSE | +FALSE |
8 | -2011-05-26 | -N2 | +2011-04-05 | +Q2 | B_ESCHR_COLI | -R | -R | +I | S | +R | S | FALSE | -TRUE | +FALSE |
9 | -2011-06-19 | -N2 | +2011-11-13 | +Q2 | B_ESCHR_COLI | S | S | -R | +S | S | FALSE | TRUE | ||
10 | -2011-07-29 | -N2 | +2011-11-28 | +Q2 | B_ESCHR_COLI | -R | +S | S | S | S | FALSE | -TRUE | +FALSE |
Instead of 2, now 9 isolates are flagged. In total, 75.5% of all isolates are marked ‘first weighted’ - 47.0% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
+Instead of 2, now 7 isolates are flagged. In total, 74.8% of all isolates are marked ‘first weighted’ - 46.4% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
As with filter_first_isolate()
, there’s a shortcut for this new algorithm too:
data_1st <- data %>%
filter_first_weighted_isolate()
So we end up with 15,096 isolates for analysis.
+So we end up with 14,960 isolates for analysis.
We can remove unneeded columns:
@@ -827,7 +766,6 @@ Unique: 2head(data_1st)
date | patient_id | hospital | @@ -844,61 +782,87 @@ Unique: 2|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-05 | -F4 | -Hospital A | -B_STRPT_PNMN | +2014-10-31 | +B4 | +Hospital B | +B_STPHY_AURS | +S | +S | +S | +S | +M | +Gram-positive | +Staphylococcus | +aureus | +TRUE | +
2012-02-24 | +E10 | +Hospital B | +B_ESCHR_COLI | +R | +I | +S | +S | +M | +Gram-negative | +Escherichia | +coli | +TRUE | +|||||
2017-11-04 | +G1 | +Hospital B | +B_ESCHR_COLI | +S | +S | +R | +S | +M | +Gram-negative | +Escherichia | +coli | +TRUE | +|||||
2011-10-08 | +V4 | +Hospital B | +B_ESCHR_COLI | +R | +S | +S | +S | +F | +Gram-negative | +Escherichia | +coli | +TRUE | +|||||
2016-02-16 | +K6 | +Hospital D | +B_STPHY_AURS | S | S | S | R | M | Gram-positive | -Streptococcus | -pneumoniae | +Staphylococcus | +aureus | TRUE | |||
6 | -2016-11-05 | -G9 | +2014-05-28 | +N6 | Hospital C | B_ESCHR_COLI | S | S | -R | -S | -M | -Gram-negative | -Escherichia | -coli | -TRUE | -||
7 | -2016-05-20 | -A10 | -Hospital D | -B_ESCHR_COLI | -S | -S | -S | -S | -M | -Gram-negative | -Escherichia | -coli | -TRUE | -||||
9 | -2015-10-02 | -R3 | -Hospital C | -B_ESCHR_COLI | -R | -S | S | S | F | @@ -907,38 +871,6 @@ Unique: 2coli | TRUE | ||||||
10 | -2016-03-04 | -B10 | -Hospital A | -B_ESCHR_COLI | -R | -R | -S | -S | -M | -Gram-negative | -Escherichia | -coli | -TRUE | -||||
11 | -2013-09-10 | -P4 | -Hospital B | -B_KLBSL_PNMN | -R | -S | -S | -S | -F | -Gram-negative | -Klebsiella | -pneumoniae | -TRUE | -
Time for the analysis!
@@ -958,8 +890,8 @@ Unique: 2data_1st %>% freq(genus, species)
Frequency table
Class: character
-Length: 15,096
-Available: 15,096 (100%, NA: 0 = 0%)
+Length: 14,960
+Available: 14,960 (100%, NA: 0 = 0%)
Unique: 4
Shortest: 16
Longest: 24
The functions resistance()
and susceptibility()
can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions proportion_S()
, proportion_SI()
, proportion_I()
, proportion_IR()
and proportion_R()
can be used to determine the proportion of a specific antimicrobial outcome.
As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (proportion_R()
, equal to resistance()
) and susceptibility as the proportion of S and I (proportion_SI()
, equal to susceptibility()
). These functions can be used on their own:
data_1st %>% resistance(AMX)
-# [1] 0.4681373
Or can be used in conjuction with group_by()
and summarise()
, both from the dplyr
package:
data_1st %>%
group_by(hospital) %>%
@@ -1027,19 +959,19 @@ Longest: 24
Hospital A
-0.4648446
+0.4490022
Hospital B
-0.4689223
+0.4746786
Hospital C
-0.4656180
+0.4505104
Hospital D
-0.4734787
+0.4760039
EUCAST.Rmd
MDR.Rmd
guideline = "CMI2012"
(default)
Magiorakos AP, Srinivasan A et al. “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012) (link)
+guideline = "EUCAST"
The European international guideline - EUCAST Expert Rules Version 3.1 “Intrinsic Resistance and Exceptional Phenotypes Tables” (link)
+guideline = "TB"
The international guideline for multi-drug resistant tuberculosis - World Health Organization “Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis” (link)
+guideline = "MRGN"
The German national guideline - Mueller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. (link)
+guideline = "BRMO"
The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu “WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) [ZKH]” (link)
@@ -231,24 +227,20 @@ The German national guideline - Mueller et al. (2015) Antimicrobial Resistance a ExamplesThe mdro()
function always returns an ordered factor
. For example, the output of the default guideline by Magiorakos et al. returns a factor
with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.
The next example uses the example_isolates
data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:
example_isolates %>%
- mdro() %>%
- freq() # show frequency table of the result
-# NOTE: Using column `mo` as input for `col_mo`.
-# NOTE: Auto-guessing columns suitable for analysis...OK.
-# NOTE: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)
-# Table 1 - Staphylococcus aureus ... OK
-# Table 2 - Enterococcus spp. ... OK
-# Table 3 - Enterobacteriaceae ... OK
-# Table 4 - Pseudomonas aeruginosa ... OK
-# Table 5 - Acinetobacter spp. ... OK
-# Warning in mdro(.): NA introduced for isolates where the available percentage of
-# antimicrobial classes was below 50% (set with `pct_required_classes`)
library(dplyr) # to support pipes: %>%
example_isolates %>%
+ mdro() %>%
+ freq() # show frequency table of the result
+# NOTE: Using column `mo` as input for `col_mo`.
+# NOTE: Auto-guessing columns suitable for analysis...OK.
+# NOTE: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)
+# Warning in mdro(.): NA introduced for isolates where the available percentage of
+# antimicrobial classes was below 50% (set with `pct_required_classes`)
Frequency table
Class: factor > ordered (numeric)
-Length: 2,000 (of which NA: 289 = 14.45%)
+Length: 2,000
Levels: 4: Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant …
+Available: 1,711 (85.55%, NA: 289 = 14.45%)
Unique: 2
For another example, I will create a data set to determine multi-drug resistant TB:
-# a helper function to get a random vector with values S, I and R
-# with the probabilities 50% - 10% - 40%
-sample_rsi <- function() {
- sample(c("S", "I", "R"),
- size = 5000,
- prob = c(0.5, 0.1, 0.4),
- replace = TRUE)
-}
-
-my_TB_data <- data.frame(rifampicin = sample_rsi(),
- isoniazid = sample_rsi(),
- gatifloxacin = sample_rsi(),
- ethambutol = sample_rsi(),
- pyrazinamide = sample_rsi(),
- moxifloxacin = sample_rsi(),
- kanamycin = sample_rsi())
# a helper function to get a random vector with values S, I and R
+# with the probabilities 50% - 10% - 40%
+sample_rsi <- function() {
+ sample(c("S", "I", "R"),
+ size = 5000,
+ prob = c(0.5, 0.1, 0.4),
+ replace = TRUE)
+}
+
+my_TB_data <- data.frame(rifampicin = sample_rsi(),
+ isoniazid = sample_rsi(),
+ gatifloxacin = sample_rsi(),
+ ethambutol = sample_rsi(),
+ pyrazinamide = sample_rsi(),
+ moxifloxacin = sample_rsi(),
+ kanamycin = sample_rsi())
Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:
-my_TB_data <- data.frame(RIF = sample_rsi(),
- INH = sample_rsi(),
- GAT = sample_rsi(),
- ETH = sample_rsi(),
- PZA = sample_rsi(),
- MFX = sample_rsi(),
- KAN = sample_rsi())
my_TB_data <- data.frame(RIF = sample_rsi(),
+ INH = sample_rsi(),
+ GAT = sample_rsi(),
+ ETH = sample_rsi(),
+ PZA = sample_rsi(),
+ MFX = sample_rsi(),
+ KAN = sample_rsi())
The data set now looks like this:
-head(my_TB_data)
-# rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1 I S R S S R
-# 2 S R R R S S
-# 3 S S R S R I
-# 4 S S S R S R
-# 5 R S S S S I
-# 6 S S R R R S
-# kanamycin
-# 1 S
-# 2 S
-# 3 R
-# 4 I
-# 5 S
-# 6 R
head(my_TB_data)
+# rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
+# 1 S R S R R I
+# 2 S R S S R S
+# 3 I S R R S R
+# 4 S S S S S R
+# 5 S S S I R R
+# 6 I I R R S S
+# kanamycin
+# 1 S
+# 2 I
+# 3 R
+# 4 R
+# 5 R
+# 6 I
We can now add the interpretation of MDR-TB to our data set. You can use:
- +mdro(my_TB_data, guideline = "TB")
or its shortcut mdr_tb()
:
my_TB_data$mdr <- mdr_tb(my_TB_data)
-# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
-# NOTE: Auto-guessing columns suitable for analysis...OK.
-# NOTE: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)
-#
-# Only results with 'R' are considered as resistance. Use `combine_SI = FALSE` to also consider 'I' as resistance.
-#
-# Determining multidrug-resistant organisms (MDRO), according to:
-# Guideline: Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis
-# Version: WHO/HTM/TB/2014.11
-# Author: WHO (World Health Organization)
-# Source: https://www.who.int/tb/publications/pmdt_companionhandbook/en/
-#
-# => Found 4338 MDROs out of 5000 tested isolates (86.8%)
my_TB_data$mdr <- mdr_tb(my_TB_data)
+# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
+# NOTE: Auto-guessing columns suitable for analysis...OK.
+# NOTE: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)
Create a frequency table of the results:
- +freq(my_TB_data$mdr)
Frequency table
Class: factor > ordered (numeric)
-Length: 5,000 (of which NA: 0 = 0%)
+Length: 5,000
Levels: 5: Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant <…
+Available: 5,000 (100%, NA: 0 = 0%)
Unique: 5
1 | Mono-resistant | -3217 | -64.34% | -3217 | -64.34% | +3274 | +65.48% | +3274 | +65.48% |
2 | Negative | -662 | -13.24% | -3879 | -77.58% | +651 | +13.02% | +3925 | +78.50% |
3 | Multi-drug-resistant | -632 | -12.64% | -4511 | -90.22% | +612 | +12.24% | +4537 | +90.74% |
4 | Poly-resistant | -280 | -5.60% | -4791 | -95.82% | +288 | +5.76% | +4825 | +96.50% |
5 | Extensively drug-resistant | -209 | -4.18% | +175 | +3.50% | 5000 | 100.00% |