Diff of /R/RpartDT.R [000000] .. [28e211]

Switch to unified view

a b/R/RpartDT.R
1
#' @title RPART Decision Tree
2
#' @description The decision tree analysis is implemented over a training
3
#'   dataset, which consisted of the DEGs obtained by either SAMseq or the
4
#'   binomial differential expression.
5
#' @param data The exact output of the exprmclust function.
6
#' @param quiet If `TRUE`, suppresses intermediary output
7
#' @param plot If `FALSE`, suppresses plot output
8
#' @export
9
#' @importFrom rpart rpart
10
#' @importFrom rpart.plot rpart.plot
11
#' @return Information about the model and, by default, a plot of the decision
12
#'   tree.
13
RpartDT <- function(data, quiet = FALSE, plot = TRUE) {
14
  exp.df <- as.data.frame(t(data))
15
  exp.df$classVector <- factor(colnames(data))
16
  model <- rpart(
17
    classVector ~ .,
18
    exp.df,
19
    method = "class",
20
    minsplit = 1,
21
    cp = -1
22
  )
23
  if (!quiet) print(model)
24
  if (plot) rpart.plot(model, type = 4, extra = 101)
25
  return(model)
26
}