
Run single-run NMF on single cell or meta cell data
nmf_sc.RdRuns a single HALS NMF on a chosen subset of cells and genes. For
SingleCells, the counts are streamed from disk via the Rust binary
files; for MetaCells, the in-memory sparse counts are used.
Usage
nmf_sc(
object,
k,
cell_ids = NULL,
gene_ids = NULL,
preprocessing = "none",
use_second_layer = TRUE,
nmf_hals_params = params_nmf_hals(),
seed = 42L,
.verbose = TRUE
)Arguments
- object
SingleCellsorMetaCellsclass.- k
Integer. Number of latent factors to return.
- cell_ids
Optional character. Cell ids (or meta cell ids) to restrict the NMF to. If
NULL, usesget_cells_to_keep()forSingleCellsand all meta cells forMetaCells.- gene_ids
Optional character. Gene ids to restrict the NMF to. If
NULL, usesget_hvg()on the object.- preprocessing
String. One of
c("none", "sd", "sqrt_sd").- use_second_layer
Boolean. If
TRUE, runs NMF on the normalised counts (recommended); ifFALSE, on the raw counts.- nmf_hals_params
List, see
params_nmf_hals().- seed
Integer. Random seed for initialisation.
- .verbose
Boolean or integer. Verbosity.
Examples
# three factors on the highly variable genes
sc <- demo_single_cells()
res <- nmf_sc(sc, k = 3L, .verbose = FALSE)
res
#> NmfResult (single-run HALS NMF)
#> Source class: SingleCells
#> No genes: 30
#> No cells: 500
#> No components: 3
#> Final loss: 5.941e+04
#> Iterations: 40
#> Converged: TRUE
#> Preprocessing: none
unlink(sc@dir_data, recursive = TRUE, force = TRUE)