vb_factorize {ccfindR} | R Documentation

## Bayesian NMF inference of count matrix

### Description

Perform variational Bayes NMF and store factor matrices in object

### Usage

    vb_factorize(object, ranks = 2, nrun = 1, verbose = 2,
      progress.bar = TRUE, initializer = "random", Itmax = 10000,
      hyper.update = rep(TRUE, 4), gamma.a = 1, gamma.b = 1,
      Tol = 1e-05, hyper.update.n0 = 10, hyper.update.dn = 1,
      connectivity = TRUE, fudge = NULL, ncores = 1, useC = TRUE,
      unif.stop = TRUE)

### Arguments

`object` | `scNMFSet` object containing count matrix.
`ranks` | Rank for factorization; can be a vector of multiple values.
`nrun` | No. of runs with different initial guesses.
`verbose` | The verbosity level: 3, each iteration output printed; 2, each run output printed; 1, each randomized sample output printed; 0, silent.
`progress.bar` | Display progress bar with `verbose = 1` for multiple runs.
`initializer` | If `'random'`, randomized initial conditions; `'svd2'` for singular value decomposed initial condition.
`Itmax` | Maximum no. of iteration.
`hyper.update` | Vector of four logicals, each indcating whether hyperparameters `c(aw, bw, ah, bh)` should be optimized.
`gamma.a` | Gamma distribution shape parameter.
`gamma.b` | Gamma distribution mean. These two parameters are used for fixed hyperparameters with `hyper.update` elements `FALSE`.
`Tol` | Tolerance for terminating iteration.
`hyper.update.n0` | Initial number of steps in which hyperparameters are fixed.
`hyper.update.dn` | Step intervals for hyperparameter updates.
`connectivity` | If `TRUE`, connectivity and dispersion will be calculated after each run. Can be turned off to save memory.
`fudge` | Small positive number used as lower bound for factor matrix elements to avoid singularity. If `fudge = NULL` (default), it will be replaced by `.Machine$double.eps`. Can be set to 0 to skip regularization.
`ncores` | Number of processors (cores) to run. If `ncores > 1`, parallelization is attempted.
`useC` | Use C++ version of updates for speed.
`unif.stop` | Terminate if any of columns in basis matrix is uniform.

### Details

The main input is the `scNMFSet` object with count matrix. This function performs non-negative factorization using Bayesian algorithm and gamma priors. Slots `basis`, `coeff`, and `ranks` are filled.

When run with multiple values of `ranks`, factorization is repeated for each rank and the slot `measure` contains log evidence and optimal hyperparameters for each rank. With `nrun > 1`, the solution with the maximum log evidence is stored for a given rank.

### Value

Object of class `scNMFSet` with factorization slots filled.

### Examples

    set.seed(1)
    x <- simulate_whx(nrow=50,ncol=100,rank=5)
    s <- scNMFSet(x$x)
    s <- vb_factorize(s,ranks=seq(2,8),nrun=5)
    plot(s)

[Package ccfindR version 1.12.0 Index]