Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:satijalab/seurat-private into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
Paul Hoffman committed Jun 27, 2018
2 parents 59a3f64 + 3ae71c3 commit d89df89
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 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
6 changes: 3 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 All @@ -415,6 +414,7 @@ BuildRFClassifier <- function(
verbose = TRUE,
...
) {
PackageCheck('ranger')
training.classes <- as.vector(x = training.classes)
training.genes <- SetIfNull(
x = training.genes,
Expand All @@ -431,7 +431,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
4 changes: 2 additions & 2 deletions R/conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ Convert.seurat <- function(
from@data <- as.matrix(from@data)
}
sce <- if (class(from@raw.data) %in% c("matrix", "dgTMatrix")) {
SingleCellExperiment::SingleCellExperiment(assays = list(counts = as(from@raw.data[, from@cell.names], "dgCMatrix")))
SingleCellExperiment::SingleCellExperiment(assays = list(counts = as(from@raw.data[rownames(from@data), from@cell.names], "dgCMatrix")))
} else if (inherits(x = from@raw.data, what = "dgCMatrix")) {
SingleCellExperiment::SingleCellExperiment(assays = list(counts = from@raw.data[, from@cell.names]))
SingleCellExperiment::SingleCellExperiment(assays = list(counts = from@raw.data[rownames(from@data), from@cell.names]))
} else {
stop("Invalid class stored in seurat object's raw.data slot")
}
Expand Down

0 comments on commit d89df89

Please sign in to comment.