Learn R Programming

BioMark (version 0.4.5)

ROC: ROC curves

Description

Functions for making, plotting and analysing ROC curves.

Usage

ROC(TestResult, ...) "ROC"(TestResult, D, take.abs = TRUE, ...) "plot"(x, type = "b", null.line = TRUE, xlab = "False Pos. Rate", ylab = "True Pos. Rate", xlim = c(0, 1), ylim = c(0, 1), main = "ROC", ...) "points"(x, ...) "lines"(x, ...) "identify"(x, labels = NULL, ..., digits = 1) "print"(x, ...) roc.value(found, true, totalN) AUC(x, max.mspec)

Arguments

TestResult
Typically regression coefficients or t statistics. Note that when p values are used directly, the least significant values would be selected first. In this case one should use 1/p.
D
True, known, differences, either expressed as a vector of 0 and 1 of the same length as TestResult or as a vector of indices.
take.abs
Logical, indicating whether to take absolute values of the test statistic.
x
An object of class ROC.
type, xlab, ylab, xlim, ylim, main, labels, digits
Standard arguments to functions like plot and identify.
null.line
Logical, whether to draw the line y = x, corresponding to random guessing.
max.mspec
Maximal value of the True Positive Rate to consider in AUC calculations. Setting this to a value smaller than one (which is the default) leads to a partial AUC value, which may in many cases be more useful.
found
The indices of the coefficients identified with a biomarker identification method.
true
The indices of the true biomarkers.
totalN
The total number of variables to choose from.
...
Further arguments, especially useful in the plotting functions.

Value

Function ROC returns a list with elements:
  1. sensSensitivity, or True Positive Rate (TPR).
  2. mspec1 - Specificity, or False Positive Rate (FPR).
  3. testlevels of the test statistic.
  4. callFunction call.
Function roc.value returns a list with elements sens and mspec, i.e., one point on a ROC curve.Function AUC returns the area under the curve, measured up to the value of max.mspec - if the latter is smaller than 1, it is a partial AUC curve.

References

T. Lumley: ROC curves - in Programme's Niche, R News 4/1, June 2004.

Examples

Run this code
data(spikedApples)
apple.coef <- get.biom(X = spikedApples$dataMatrix,
                       Y = rep(1:2, each = 10),
                       fmethod = "vip",
                       ncomp = 3, type = "coef")

## ROC curve for all VIP values, ordered according to size
true.biom <- (1:ncol(spikedApples$dataMatrix) %in% spikedApples$biom)
vip.roc <- ROC(apple.coef$vip, true.biom)
plot(vip.roc)

## Add stability-based selection point
apple.stab <- get.biom(X = spikedApples$dataMatrix,
                       Y = rep(1:2, each = 10),
                       fmethod = "vip",
                       ncomp = 3, type = "stab")
stab.roc <- roc.value(apple.stab$vip[[1]]$biom.indices,
                      spikedApples$biom,
                      totalN = ncol(spikedApples$dataMatrix))
points(stab.roc, col = "red", pch = 19, cex = 1.5)

## Not run: 
# ## Add HC-based selection point
# ## Attention: takes approx. 2 minutes on my PC
# apple.HC <- get.biom(X = spikedApples$dataMatrix,
#                      Y = rep(1:2, each = 10),
#                      fmethod = "vip",
#                      ncomp = 3, type = "HC")
# HC.roc <- roc.value(apple.HC$vip$biom.indices,
#                     spikedApples$biom,
#                     totalN = ncol(spikedApples$dataMatrix))
# points(HC.roc, col = "blue", pch = 19, cex = 1.5)
# ## End(Not run)

Run the code above in your browser using DataLab