Skip to content

Commit

Permalink
Add warning message if only a single iteration occurred.
Browse files Browse the repository at this point in the history
  • Loading branch information
agdenadel committed Feb 27, 2024
1 parent bfaef0c commit e187092
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ FindClustersCallback <- function(seurat_obj,


# Pre-process data

#library(future)
options(future.globals.maxSize = 8000 * 1024^2)
# todo log number of cores being used
future::plan("multicore", workers = as.numeric(cores))
#options(future.globals.maxSize = 8000 * 1024^2)
# todo log number of cores being used

if (verbose) {
message(paste("Number of cores:", cores))
}

#plan("multicore", workers = as.numeric(cores))

knockoff_seurat_obj <- Seurat::NormalizeData(knockoff_seurat_obj,
Expand All @@ -136,6 +138,9 @@ FindClustersCallback <- function(seurat_obj,

resolution_param <- resolution_start


first_iteration <- TRUE

while (TRUE) {
if (verbose) {
message("####################################################################")
Expand Down Expand Up @@ -220,6 +225,7 @@ FindClustersCallback <- function(seurat_obj,
cli::cli_progress_done()
message("Found clusters with no significant differences.")
message("Progressing to next clustering iteration.")
first_iteration <- FALSE
}
break
}
Expand All @@ -231,6 +237,10 @@ FindClustersCallback <- function(seurat_obj,
break
}

if (first_iteration) {
warning("Only a single iteration occurred. The inferred cluster labels may be underclustered. To prevent this, you may want to re-run callback with a larger starting parameter.")
}

seurat_obj@meta.data$callback_clusters <- Seurat::Idents(knockoff_seurat_obj)
Seurat::Idents(seurat_obj) <- seurat_obj@meta.data$callback_clusters

Expand Down

0 comments on commit e187092

Please sign in to comment.