Learn R Programming

mixOmics (version 6.3.2)

auroc: Area Under the Curve (AUC) and Receiver Operating Characteristic (ROC) curves for supervised classification

Description

Calculates the AUC and plots ROC for supervised objects from s/plsda, mint.s/plsda and block.plsda, block.splsda or wrapper.sgccda.

Usage

# S3 method for plsda
auroc(object, newdata = object$input.X, outcome.test = as.factor(object$Y),
multilevel = NULL, plot = TRUE, roc.comp = 1, ...)

# S3 method for splsda auroc(object, newdata = object$input.X, outcome.test = as.factor(object$Y), multilevel = NULL, plot = TRUE, roc.comp = 1, ...)

# S3 method for mint.plsda auroc(object, newdata = object$X, outcome.test = as.factor(object$Y), study.test = object$study, multilevel = NULL,plot = TRUE, roc.comp = 1, roc.study = "global", ...)

# S3 method for mint.splsda auroc(object, newdata = object$X, outcome.test = as.factor(object$Y), study.test = object$study, multilevel = NULL,plot = TRUE, roc.comp = 1, roc.study = "global", ...)

# S3 method for sgccda auroc(object, newdata = object$X, outcome.test = as.factor(object$Y), multilevel = NULL,plot = TRUE, roc.block = 1, roc.comp = 1, ...)

Arguments

object

Object from one of the following supervised analysis class: "plsda", "splsda", "mint.plsda", "mint.splsda", "block.splsda" or "wrapper.sgccda"

newdata

numeric matrix of predictors, by default set to the training data set (see details).

outcome.test

Either a factor or a class vector for the discrete outcome, by default set to the outcome vector from the training set (see details).

study.test

For MINT objects, grouping factor indicating which samples of newdata are from the same study. Overlap with object$study are allowed.

multilevel

Sample information when a newdata matrix is input and when multilevel decomposition for repeated measurements is required. A numeric matrix or data frame indicating the repeated measures on each individual, i.e. the individuals ID. See examples in splsda.

plot

Whether the ROC curves should be plotted, by default set to TRUE (see details).

roc.comp

Specify the component (integer) for which the ROC will be plotted from the multivariate model, default to 1.

roc.block

Specify the block number (integer) or the name of the block (set of characters) for which the ROC will be plotted for a block.plsda or block.splsda object, default to 1.

roc.study

Specify the study for which the ROC will be plotted for a mint.plsda or mint.splsda object, default to "global".

...

external optional arguments for plotting

Value

Depending on the type of object used, a list that contains: The AUC and Wilcoxon test pvalue for each 'one vs other' classes comparison performed, either per component (splsda, plsda, mint.plsda, mint.splsda), or per block and per component (wrapper.sgccda, block.plsda, blocksplsda). The ggplot output that can be changed by users by adding ggplot layers.

Details

For more than two classes in the categorical outcome Y, the AUC is calculated as one class vs. the other and the ROC curves one class vs. the others are output.

The ROC and AUC are calculated based on the predicted scores obtained from the predict function applied to the multivariate methods (predict(object)$predict). Our multivariate supervised methods already use a prediction threshold based on distances (see predict) that optimally determine class membership of the samples tested. As such AUC and ROC are not needed to estimate the performance of the model (see perf, tune that report classification error rates). We provide those outputs as complementary performance measures.

The pvalue is from a Wilcoxon test between the predicted scores between one class vs the others.

External independent data set (newdata) and outcome (outcome.test) can be input to calculate AUROC. The external data set must have the same variables as the training data set (object$X).

If newdata is not provided, AUROC is calculated from the training data set, and may result in overfitting (too optimistic results).

Note that for mint.plsda and mint.splsda objects, if roc.study is different from "global", then newdata), outcome.test and sstudy.test are not used.

See Also

tune, perf, and http://www.mixOmics.org for more details.

Examples

Run this code
# NOT RUN {
## example with PLSDA, 2 classes
# ----------------
data(breast.tumors)
X <- breast.tumors$gene.exp
Y <- breast.tumors$sample$treatment

plsda.breast <- plsda(X, Y, ncomp = 2)
auc.plsda.breast = auroc(plsda.breast, ncomp = 1)

# changing plot title
p = auc.plsda.breast$graph.Comp1 #saving the ggplot graph in p
p+ggtitle("Something witty")

## example with sPLSDA
# -----------------
splsda.breast <- splsda(X, Y, ncomp = 2, keepX = c(25, 25))
auroc(plsda.breast, plot = FALSE)

# }
# NOT RUN {
## example with sPLSDA with 4 classes
# -----------------
data(liver.toxicity)
X <- as.matrix(liver.toxicity$gene)
# Y will be transformed as a factor in the function,
# but we set it as a factor to set up the colors.
Y <- as.factor(liver.toxicity$treatment[, 4])

splsda.liver <- splsda(X, Y, ncomp = 2, keepX = c(20, 20))
auc.splsda.liver = auroc(splsda.liver, ncomp = 1)


## example with mint.plsda
# -----------------
data(stemcells)

res = mint.plsda(X = stemcells$gene, Y = stemcells$celltype, ncomp = 3,
study = stemcells$study)
auc.mint.pslda = auroc(res, plot = FALSE)

## example with mint.splsda
# -----------------
res = mint.splsda(X = stemcells$gene, Y = stemcells$celltype, ncomp = 3, keepX = c(10, 5, 15),
study = stemcells$study)
auc.mint.spslda = auroc(res, plot = TRUE, roc.comp = 3)


## example with block.plsda
# ------------------
data(nutrimouse)
data = list(gene = nutrimouse$gene, lipid = nutrimouse$lipid)
# with this design, all blocks are connected
design = matrix(c(0,1,1,0), ncol = 2, nrow = 2,
byrow = TRUE, dimnames = list(names(data), names(data)))

block.plsda.nutri = block.plsda(X = data, Y = nutrimouse$diet)
auc.block.plsda.nutri = auroc(block.plsda.nutri, block = 'lipid')

## example with block.splsda
# ---------------
list.keepX = list(gene = rep(10, 2), lipid = rep(5,2))
block.splsda.nutri = block.splsda(X = data, Y = nutrimouse$diet, keepX = list.keepX)
auc.block.splsda.nutri = auroc(block.splsda.nutri, block = 1)
# }

Run the code above in your browser using DataLab