How to determine multi-drug resistance (MDR)

Matthijs S. Berends

15 October 2019

With the function mdro(), you can determine multi-drug resistant organisms (MDRO). It currently support these guidelines:

As an example, I will make 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())

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())

The data set looks like this now:

head(my_TB_data)
#   rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
# 1          R         R            S          S            S            R
# 2          S         R            I          R            S            S
# 3          R         R            I          R            R            S
# 4          S         S            S          R            R            R
# 5          S         R            I          S            R            R
# 6          R         S            I          I            S            R
#   kanamycin
# 1         R
# 2         R
# 3         S
# 4         S
# 5         R
# 6         R

We can now add the interpretation of MDR-TB to our data set:

my_TB_data$mdr <- mdr_tb(my_TB_data)
# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
# 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/
# NOTE: Auto-guessing columns suitable for analysis...
# NOTE: Reliability might be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)

We also created a package dedicated to data cleaning and checking, called the clean package. It gets automatically installed with the AMR package, so we only have to load it:

library(clean)

It contains the freq() function, to create a frequency table:

freq(my_TB_data$mdr)

Frequency table

Class: factor > ordered (numeric)
Length: 5,000 (of which NA: 0 = 0%)
Levels: 5: Negative < Mono-resistant < Poly-resistant < Multi-drug-resistant <…
Unique: 5

Item Count Percent Cum. Count Cum. Percent
1 Mono-resistant 3279 65.58% 3279 65.58%
2 Negative 642 12.84% 3921 78.42%
3 Multi-drug-resistant 582 11.64% 4503 90.06%
4 Poly-resistant 285 5.70% 4788 95.76%
5 Extensive drug-resistant 212 4.24% 5000 100.00%