Skip to contents

Align two NMF models

Usage

align(object, ...)

# S4 method for class 'nmf'
align(object, ref, method = "cosine", ...)

Arguments

object

nmf model to be aligned to ref

...

arguments passed to or from other methods

ref

reference nmf model to which object will be aligned

method

either cosine or cor

Value

An nmf object with factors reordered to best match ref.

Details

For nmf models, factors in object are reordered to minimize the cost of bipartite matching (see bipartiteMatch) on a cosine or correlation distance matrix. The \(w\) matrix is used for matching, and must be equidimensional in object and ref.

Examples

# \donttest{
data <- simulateNMF(50, 30, k = 3, seed = 1)
m1 <- nmf(data$A, 3, seed = 1, maxit = 50)
m2 <- nmf(data$A, 3, seed = 2, maxit = 50)
aligned <- align(m2, m1)  # reorder m2 factors to match m1
# }