Skip to contents

Runs cNMF consensus for a selected number of programs k and a density_threshold (chosen after inspecting the k-selection plot from RunCNMF), then attaches the results to the Seurat object: per-cell program usages become a dimensional reduction (and optionally metadata columns), and gene spectra are stored in seurat_object@misc$cnmf$results.

Usage

GetCNMFPrograms(
  seurat_object,
  k,
  density_threshold = 0.1,
  name = NULL,
  output_dir = NULL,
  reduction_name = "cnmf",
  add_metadata = TRUE,
  top_n_genes = 50L,
  conda_env = NULL,
  python = NULL,
  caffeinate = FALSE,
  show_plot = TRUE
)

Arguments

seurat_object

A Seurat object previously processed by RunCNMF (run metadata is read from @misc$cnmf).

k

Integer. Number of programs to extract (the K you chose from the k-selection plot).

density_threshold

Numeric. Local-density outlier filter for the consensus step. Lower is stricter; 2.0 keeps everything. Default 0.1.

name

Character or NULL. cNMF run name. Defaults to the name stored by RunCNMF.

output_dir

Character or NULL. cNMF output directory. Defaults to the directory stored by RunCNMF.

reduction_name

Character. Name of the DimReduc to create from the usage matrix. Default "cnmf".

add_metadata

Logical. Also add cNMF_1 ... cNMF_k usage columns to meta.data. Default TRUE.

top_n_genes

Integer. Number of top genes per program to retain in the stored top_genes table. Default 50L.

conda_env, python

Character or NULL. Python environment with cnmf installed (as in RunCNMF).

caffeinate

Logical. Prevent the machine from sleeping. Default FALSE.

show_plot

Logical. Display the consensus clustergram in the active graphics device (e.g. the RStudio Plots pane). Default TRUE. Requires the png (preferred) or magick package.

Value

The Seurat object with a new DimReduc (reduction_name), optional usage metadata columns, and seurat_object@misc$cnmf$results holding usage, spectra_scores, spectra_tpm, and top_genes. The consensus clustergram is written with a .legend sidecar, and the analysis_params.json in output_dir is updated with the consensus parameters and a finalized methods paragraph.

See also