Fits V \approx W H with W, H \ge 0 using Lee-Seung multiplicative updates under the Frobenius loss.

run_nmf(V, rank, max_iter = 200L, tol = 1e-04, seed = NULL, eps = 1e-09)

Arguments

V

Numeric matrix, genes as rows and samples as columns; non-negative.

rank

Integer factorization rank (number of latent programs).

max_iter

Maximum number of multiplicative update iterations.

tol

Stop when relative change in Frobenius error falls below this value.

seed

Optional random seed passed to initialize_nmf().

eps

Small constant for numerical stability in updates.

Value

A list with W, H, error_history, and iterations.

Examples

path <- expression_matrix_path()
if (nzchar(path)) {
  V <- load_expression_matrix(path)
  fit <- run_nmf(V, rank = 3L, max_iter = 50L, seed = 42L)
  fit$iterations
}
#> [1] 50