predict: Extract predictions from 'classify()' object

Description Usage Arguments Value Note Author(s) See Also Examples

Description

This function predicts the class labels of test data for a given model.

predictClassify and predict functions return the predicted class information along with trained model. Predicted values are given either as class labels or estimated probabilities of each class for each sample. If type = "raw", as can be seen in the example below, the predictions are extracted as raw class labels.In order to extract estimated class probabilities, one should follow the steps below:

Usage

1
2
3
4
5
6
7
## S3 method for class 'MLSeq'
predict(object, test.data, ...)

predictClassify(object, test.data, ...)

## S4 method for signature 'MLSeq'
predict(object, test.data, ...)

Arguments

object

a model of MLSeq class returned by classify

test.data

a DESeqDataSet instance of new observations.

...

further arguments to be passed to or from methods. These arguements are used in predict.train from caret package.

Value

MLSeqObject an MLSeq object returned from classify. See details.

Predictions a data frame or vector including either the predicted class probabilities or class labels of given test data.

Note

predictClassify(...) function was used in MLSeq up to package version 1.14.x. This function is alliased with generic function predict. In the upcoming versions of MLSeq package, predictClassify function will be ommitted. Default function for predicting new observations will be predict from version 1.16.x and later.

Author(s)

Dincer Goksuluk, Gokmen Zararsiz, Selcuk Korkmaz, Vahap Eldem, Ahmet Ozturk and Ahmet Ergun Karaagaoglu

See Also

classify, train, trainControl

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Not run: 
library(DESeq2)
data(cervical)

# a subset of cervical data with first 150 features.
data <- cervical[c(1:150), ]

# defining sample classes.
class <- data.frame(condition = factor(rep(c("N","T"), c(29, 29))))

n <- ncol(data)  # number of samples
p <- nrow(data)  # number of features

# number of samples for test set (30% test, 70% train).
nTest <- ceiling(n*0.3)
ind <- sample(n, nTest, FALSE)

# train set
data.train <- data[ ,-ind]
data.train <- as.matrix(data.train + 1)
classtr <- data.frame(condition = class[-ind, ])

# train set in S4 class
data.trainS4 <- DESeqDataSetFromMatrix(countData = data.train,
                   colData = classtr, formula(~ 1))

# test set
data.test <- data[ ,ind]
data.test <- as.matrix(data.test + 1)
classts <- data.frame(condition=class[ind, ])

data.testS4 <- DESeqDataSetFromMatrix(countData = data.test,
                                      colData = classts, formula(~ 1))

## Number of repeats (repeats) might change model accuracies ##
# Classification and Regression Tree (CART) Classification
cart <- classify(data = data.trainS4, method = "rpart",
          ref = "T", preProcessing = "deseq-vst",
          control = trainControl(method = "repeatedcv", number = 5,
                                 repeats = 3, classProbs = TRUE))
cart

# predicted classes of test samples for CART method (class probabilities)
pred.cart = predictClassify(cart, data.testS4, type = "prob")
pred.cart

# predicted classes of test samples for RF method (class labels)
pred.cart = predictClassify(cart, data.testS4, type = "raw")
pred.cart

## End(Not run)

dncR/MLSeq documentation built on May 17, 2020, 6:45 p.m.