Learn R Programming

scStability (version 1.0.2)

clustStable: Create and compare multiple clustering runs on scRNA-seq data

Description

Generate multiple clustering iterations on a Seurat object containing scRNA-seq data using the provided dimensionality reduction. The function creates a shared nearest neighbor (SNN) graph and assigns clusters using the specified algorithm, then calculates stability metrics across iterations.

Usage

clustStable(
  n_runs,
  seurat_obj,
  method = c("louvain", "leiden"),
  resolution = 0.8,
  dims = 1:10,
  n_cores = 1,
  verbose = TRUE,
  print_plot = TRUE,
  seeds = NULL
)

Value

A list containing the following components:

per_index_means

Numeric vector of NMI values for each clustering iteration

ci

Numeric vector containing the lower and upper bounds of the 95% confidence interval

cluster_labels

List of cluster assignments for each iteration

Arguments

n_runs

Integer specifying the number of cluster assignments to generate (default: 100)

seurat_obj

A Seurat object containing scRNA-seq data with a PCA reduction

method

Character string specifying the clustering algorithm to use: either "louvain" or "leiden"

resolution

Numeric value specifying the clustering resolution parameter (default: 0.8)

dims

Integer vector specifying which PCA dimensions to use (default: 1:10)

n_cores

Integer specifying the number of CPU cores to use for parallelization (default: 1)

verbose

Whether the function should print summary statistics as it calculates them

print_plot

Whether the final violin plot should be automatically printed

seeds

A set of seeds of length n_runs for creating clusters