Skip to contents

Optimize clustering directly on a Seurat object

Usage

RunOptimization(
  object,
  cluster_col,
  result_col = "scClustEval_clusters",
  prefix = "scClustEval",
  store_rounds = TRUE,
  assay = NULL,
  use = "pca",
  dims = 1:50,
  features = NULL,
  min_accuracy = 0.9,
  max_rounds = 10,
  classifier = "LR",
  penalty = "l1",
  test_size = 0.5,
  n_per_class = 100,
  cv = 5,
  n_iter = 3,
  r1_cutoff = 0.5,
  r2_cutoff = 0.05,
  under_cluster_col = NULL,
  seed = 1,
  n_cores = NULL,
  verbose = TRUE,
  ...
)

Arguments

object

Seurat object

cluster_col

Column name containing initial over-clustering

result_col

Column name to store final optimized clustering

prefix

Prefix for intermediate round columns (default: "scClustEval")

store_rounds

Whether to store intermediate round results

assay

Assay to use

use

Feature space: "raw", "pca", etc.

dims

Dimensions for PCA/reduction

features

Specific features to use

min_accuracy

Target accuracy

max_rounds

Maximum rounds

classifier

Classifier type

penalty

For LR: regularization type

test_size

Test fraction

n_per_class

Max samples per class

cv

CV folds

n_iter

Confusion matrix iterations

r1_cutoff

Initial R1 cutoff

r2_cutoff

Initial R2 cutoff

under_cluster_col

Optional: column with under-clustering constraint

seed

Random seed

n_cores

Number of cores

verbose

Print progress

...

Additional arguments

Value

Modified Seurat object with optimized clustering added to meta.data

Details

The function modifies the Seurat object by adding:

  • Final optimized clustering in result_col (default: "scClustEval_clusters")

  • Intermediate round results (if store_rounds = TRUE)

  • Cluster reliability scores (optional)

Examples

if (FALSE) { # \dontrun{
# Basic optimization
seurat_obj <- RunOptimization(
  seurat_obj,
  cluster_col = "seurat_clusters",
  min_accuracy = 0.9
)

# With under-clustering constraint
seurat_obj <- RunOptimization(
  seurat_obj,
  cluster_col = "high_res_clusters",
  under_cluster_col = "low_res_clusters",
  min_accuracy = 0.95
)
} # }