Skip to content

Commit

Permalink
make caret and ranger suggested packages
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwbutler committed Jun 26, 2018
1 parent 603caf6 commit 86b6a20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ importFrom(ape,as.phylo)
importFrom(ape,drop.tip)
importFrom(ape,nodelabels)
importFrom(ape,plot.phylo)
importFrom(caret,train)
importFrom(caret,trainControl)
importFrom(cluster,clara)
importFrom(cowplot,get_legend)
importFrom(cowplot,plot_grid)
Expand Down Expand Up @@ -375,7 +373,6 @@ importFrom(pbapply,pbapply)
importFrom(pbapply,pblapply)
importFrom(pbapply,pbsapply)
importFrom(png,readPNG)
importFrom(ranger,ranger)
importFrom(reshape2,melt)
importFrom(reticulate,dict)
importFrom(reticulate,import)
Expand Down
5 changes: 2 additions & 3 deletions R/cluster_determination.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ NumberClusters <- function(object) {
#'
#' @import Matrix
#' @importFrom stats predict
#' @importFrom ranger ranger
#'
#' @export
#'
Expand All @@ -357,6 +356,7 @@ ClassifyCells <- function(
new.data = NULL,
...
) {
PackageCheck('ranger')
# build the classifier
if (missing(classifier)){
classifier <- BuildRFClassifier(
Expand Down Expand Up @@ -398,7 +398,6 @@ ClassifyCells <- function(
#' @return Returns the random forest classifier
#'
#' @import Matrix
#' @importFrom ranger ranger
#'
#' @export
#'
Expand Down Expand Up @@ -431,7 +430,7 @@ BuildRFClassifier <- function(
if (verbose) {
message("Training Classifier ...")
}
classifier <- ranger(
classifier <- ranger::ranger(
data = training.data,
dependent.variable.name = "class",
classification = TRUE,
Expand Down
8 changes: 4 additions & 4 deletions R/cluster_validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ NULL
#' clusters
#' @param acc.cutoff Accuracy cutoff for classifier
#' @param verbose Controls whether to display progress and merging results
#' @importFrom caret trainControl train
#' @return Returns a Seurat object, object@@ident has been updated with new
#' cluster info
#' @export
Expand All @@ -35,6 +34,7 @@ ValidateClusters <- function(
acc.cutoff = 0.9,
verbose = TRUE
) {
PackageCheck('caret')
# probably should refactor to make cleaner
if (length(x = object@snn) > 1) {
SNN.use <- object@snn
Expand Down Expand Up @@ -133,7 +133,6 @@ ValidateClusters <- function(
#' @param pc.use Which PCs to use for model construction
#' @param top.genes Use the top X genes for model construction
#' @param acc.cutoff Accuracy cutoff for classifier
#' @importFrom caret trainControl train
#' @return Returns a Seurat object, object@@ident has been updated with
#' new cluster info
#' @export
Expand All @@ -155,6 +154,7 @@ ValidateSpecificClusters <- function(
top.genes = 30,
acc.cutoff = 0.9
) {
PackageCheck('caret')
acc <- RunClassifier(
object = object,
group1 = cluster1,
Expand Down Expand Up @@ -203,9 +203,9 @@ RunClassifier <- function(object, group1, group2, pcs, num.genes) {
xv <- apply(X = x, MARGIN = 2, FUN = var)
x <- x[, names(x = which(xv > 0))]
# run k-fold cross validation
ctrl <- trainControl(method = "repeatedcv", repeats = 5)
ctrl <- caret::trainControl(method = "repeatedcv", repeats = 5)
set.seed(seed = 1500)
model <- train(
model <- caret::train(
x = x,
y = as.factor(x = y),
formula = as.factor(x = y) ~ .,
Expand Down

0 comments on commit 86b6a20

Please sign in to comment.