@@ -208,33 +209,33 @@
Examples
These rules can be used to discard impossible bug-drug combinations in your data. For example, Klebsiella produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of Klebsiella is resistant to ampicillin.
Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, Klebsiella). EUCAST expert rules solve this, that can be used with eucast_rules()
:
-
oops <- data.frame(mo = c("Klebsiella",
- "Escherichia"),
- ampicillin = "S")
-oops
-# mo ampicillin
-# 1 Klebsiella S
-# 2 Escherichia S
-
-eucast_rules(oops, info = FALSE)
-# mo ampicillin
-# 1 Klebsiella R
-# 2 Escherichia S
+
oops <- data.frame(mo = c("Klebsiella",
+ "Escherichia"),
+ ampicillin = "S")
+oops
+# mo ampicillin
+# 1 Klebsiella S
+# 2 Escherichia S
+
+eucast_rules(oops, info = FALSE)
+# mo ampicillin
+# 1 Klebsiella R
+# 2 Escherichia S
EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called interpretive reading and is part of the eucast_rules()
function as well:
-
data <- data.frame(mo = c("Staphylococcus aureus",
- "Enterococcus faecalis",
- "Escherichia coli",
- "Klebsiella pneumoniae",
- "Pseudomonas aeruginosa"),
- VAN = "-", # Vancomycin
- AMX = "-", # Amoxicillin
- COL = "-", # Colistin
- CAZ = "-", # Ceftazidime
- CXM = "-", # Cefuroxime
- PEN = "S", # Penicillin G
- FOX = "S", # Cefoxitin
- stringsAsFactors = FALSE)
-
+
data <- data.frame(mo = c("Staphylococcus aureus",
+ "Enterococcus faecalis",
+ "Escherichia coli",
+ "Klebsiella pneumoniae",
+ "Pseudomonas aeruginosa"),
+ VAN = "-", # Vancomycin
+ AMX = "-", # Amoxicillin
+ COL = "-", # Colistin
+ CAZ = "-", # Ceftazidime
+ CXM = "-", # Cefuroxime
+ PEN = "S", # Penicillin G
+ FOX = "S", # Cefoxitin
+ stringsAsFactors = FALSE)
+
-
+
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 S R R I R R
-# 2 I R R R S R
-# 3 R R R S R S
-# 4 S S R R R S
-# 5 S R S R S S
-# 6 R S S S R S
-# kanamycin
-# 1 S
-# 2 S
-# 3 R
-# 4 R
-# 5 R
-# 6 R
+
head(my_TB_data)
+# rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
+# 1 S I R R S I
+# 2 R S S R S S
+# 3 R S S R R I
+# 4 I S S R R S
+# 5 R R S R I R
+# 6 R I S I R S
+# kanamycin
+# 1 S
+# 2 S
+# 3 R
+# 4 S
+# 5 I
+# 6 I
We can now add the interpretation of MDR-TB to our data set. You can use:
-
mdro(my_TB_data, guideline = "TB")
+
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)
+
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:
-
+
Frequency table
Class: factor > ordered (numeric)
Length: 5,000
@@ -345,40 +346,40 @@ Unique: 5
1 |
Mono-resistant |
-3312 |
-66.24% |
-3312 |
-66.24% |
+3310 |
+66.20% |
+3310 |
+66.20% |
2 |
Negative |
-634 |
-12.68% |
-3946 |
-78.92% |
+637 |
+12.74% |
+3947 |
+78.94% |
3 |
Multi-drug-resistant |
-554 |
-11.08% |
-4500 |
-90.00% |
+569 |
+11.38% |
+4516 |
+90.32% |
4 |
Poly-resistant |
-291 |
-5.82% |
-4791 |
-95.82% |
+283 |
+5.66% |
+4799 |
+95.98% |
5 |
Extensively drug-resistant |
-209 |
-4.18% |
+201 |
+4.02% |
5000 |
100.00% |
@@ -400,7 +401,7 @@ Unique: 5
diff --git a/docs/articles/PCA.html b/docs/articles/PCA.html
index 1e02fa61e..86d60ae85 100644
--- a/docs/articles/PCA.html
+++ b/docs/articles/PCA.html
@@ -39,7 +39,7 @@