
Extract cNMF consensus programs for a chosen K
GetCNMFPrograms.RdRuns 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.0keeps everything. Default0.1.- name
Character or
NULL. cNMF run name. Defaults to the name stored byRunCNMF.- output_dir
Character or
NULL. cNMF output directory. Defaults to the directory stored byRunCNMF.- reduction_name
Character. Name of the
DimReducto create from the usage matrix. Default"cnmf".- add_metadata
Logical. Also add
cNMF_1 ... cNMF_kusage columns tometa.data. DefaultTRUE.- top_n_genes
Integer. Number of top genes per program to retain in the stored
top_genestable. Default50L.- conda_env, python
Character or
NULL. Python environment withcnmfinstalled (as inRunCNMF).- 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 thepng(preferred) ormagickpackage.
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.