predict: Prediction Method of Random Forest for 'pDMP' Objects

predictR Documentation

Prediction Method of Random Forest for 'pDMP' Objects

Description

This function applies predict.randomForest to a 'pDMP' object provided in the argument newdata.

Usage

predict(object, newdata = NULL, ...)

## S4 method for signature 'RandomForest,GRanges'
predict(
  object,
  newdata,
  type = c("class", "response", "prob", "votes"),
  predict.all = FALSE,
  keep.data = FALSE,
  ...
)

## S4 method for signature 'RandomForest,pDMP'
predict(
  object,
  newdata,
  type = c("class", "response", "prob", "votes"),
  predict.all = FALSE,
  keep.data = FALSE,
  num.cores = 1L,
  tasks = 0L,
  ...
)

## S4 method for signature 'randomForestformula,GRanges'
predict(
  object,
  newdata,
  type = c("class", "response", "prob", "votes"),
  predict.all = FALSE,
  keep.data = FALSE,
  ...
)

## S4 method for signature 'randomForestformulaList,GRangesList'
predict(
  object,
  newdata,
  type = c("class", "response", "prob", "votes"),
  predict.all = FALSE,
  keep.data = FALSE,
  num.cores = 1L,
  tasks = 0L,
  ...
)

Arguments

object

an object of 'RandomForest-class', as that created by the function evaluateDIMPclass. If newdata is a GRanges-class, then 'newdata' must be an element of a pDMP-class object, i.e., it must have the same structure as the GRanges-class elements in a pDMP-class object.

newdata

A 'pDMP' object generated with function selectDIMP.

predict.all, type, ...

The same as in predict.randomForest.

keep.data

Logical. Whether to preserve the original class from object 'newdata'. If TRUE, then the predicted class and the posterior probability of the treatment class are added as a metacolumns of 'newdata'.

num.cores, tasks

Parameters for parallel computation using package BiocParallel-package: the number of cores to use, i.e. at most how many child processes will be run simultaneously (see bplapply and the number of tasks per job (only for Linux OS).

Details

The generic function just call function predict from 'stats' R package.

If newdata is a GRanges-class, then 'newdata' must be an element of a pDMP-class object, i.e., it must have the same structure as the GRanges-class elements in a pDMP-class object.

Value

The same results as given by function predict.randomForest.

Author(s)

Robersy Sanchez https://genomaths.com

Examples

## Load a DMP data set
data(dmps, package = 'MethylIT')

## Let's accomplish the classification by using Random Forest
## algorithm
perf <- evaluateDIMPclass(LR = dmps,
                          column = c(hdiv = TRUE, TV = TRUE,
                                     wprob = TRUE, pos = TRUE),
                          classifier = 'random_forest',
                          n.pc = 4L,
                          control.names =  c('C1', 'C2', 'C3'),
                          treatment.names = c('T1', 'T2', 'T3'),
                          center = FALSE,
                          scale = FALSE,
                          prop = 0.6)

predict(object = perf$model, newdata = dmps, keep.data = TRUE)

genomaths/MethylIT documentation built on Feb. 3, 2024, 1:24 a.m.