knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This documents is an introduction to the package ECOFFBayes
. The aim of this package is to find cutoff points between resistant and non-resistant antibiotics.
Therefore, first load the package ECOFFBayes
.
library(ECOFFBayes)
The package provides simulated data to try out the different functions.
data("Antibiotics")
If you do not have any prior knowledge just apply this function to your data and it will come up with the number of components and the estimated parameter.
bayes.density <- TheBayesteApproach(Antibiotics)
If you have prior knowledge for your data, you can include this either through some prior parameter and/or through fixing the number of components k.
In this case, both information are included.
prior <- list(a.prior = 1, b.prior = 1, e0.prior = 1, b0.prior = 5, B0.prior = 0.01, c0.prior = 5, C0.prior = 10) k <- 3 bayes.density.with.prior <- TheBayesteApproach(data = Antibiotics, prior = prior, k = k)
The output is of type TheBayesteApproach
and includes the following components:
k
bayes.density$k bayes.density.with.prior$k
bayes.density$normal.params bayes.density.with.prior$normal.params
bayes.density$binom.res bayes.density.with.prior$binom.res
As we are also interested in the cutoff point between wildtype and non-wildtype bacteria (ECOFF), we can also calculate this value. Therefore we
FindECOFF(bayes.density, pi.level = 0.3, quantile = 0.01) FindECOFF(bayes.density.with.prior, pi.level = 0.3, quantile = 0.01)
For this object, also a plotting function is provided, which plots the histogram of the data and the estimated density.
A line that shows the ECOFF value can also be included in the graph. Therefore the parameter ECOFF
, which is by default FALSE
, needs to be set to TRUE
.
Also here the quantile
and pi.level
parameter can be changed.
plot(bayes.density, ECOFF = TRUE, quantile = 0.01, pi.level = 0.3)
plot(bayes.density.with.prior, ECOFF = TRUE, quantile = 0.01, pi.level = 0.3)
Get the data of the zone diameter from the external package EUCASTData
.
data("ZD", package = "EUCASTData")
The code for three examples is included. Due to the required run-times for larger samples only the results for the second example are included, while the other examples are not evaluated.
For one example dataset, first only selected the antimicrobial and bacteria you are interested in. Afterwards, you can run you analysis using the following functions:
data1 <- subset(ZD, Antimicrobial == "Ampicillin" & Bacterium == "Escherichia coli", grepl("^Z", colnames(ZD))) res1 <- TheBayesteApproach(data = data1) FindECOFF(res1 pi.level = 0.3, quantile = 0.01) plot(res1, ECOFF = TRUE, quantile = 0.01, pi.level = 0.3)
data2 <- subset(ZD, Antimicrobial == "Piperacillin" & Bacterium == "Escherichia coli", grepl("^Z", colnames(ZD))) res2 <- TheBayesteApproach(data = data2) ```r FindECOFF(res2, pi.level = 0.3, quantile = 0.01) ```r plot(res2, ECOFF = TRUE, quantile = 0.01, pi.level = 0.3)
data3 <- subset(ZD, Antimicrobial == "Mecillinam" & Bacterium == "Escherichia coli", grepl("^Z", colnames(ZD))) res3 <- TheBayesteApproach(data = data3) FindECOFF(res3, pi.level = 0.3, quantile = 0.01) plot(res3, ECOFF = TRUE, quantile = 0.01, pi.level = 0.3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.