Learn R Programming

NMF (version 0.2.2)

NMFstd-class: Implement of the standard NMF model

Description

Class that implements the standard model of Nonnegative Matrix Factorisation.

It provides a general structure and generic functions to manage factorizations that follow NMF standard model.

Arguments

Validity checks

The validity method for class NMF checks for compatibility of slots W and H, as those matrices must be compatible with respect to the matrix product. It also checks the relevance of the factorisation, and throws a warning when the factorisation rank is greater than the number of columns in H.

Objects from the Class

Factory method

The more convenient way of creating NMF objects is to use factory method newNMF:

newNMF(rank, target=0, model='NMFstd', ...)

It provides a unique interface to create NMF objects that can follow different NMF models. Using this interface allows to automatically resolve some inconsistencies in the matrices dimensions. The standard model is the default model, so the following calls will create objects of class NMFstd:

newNMF()

This creates a completely empty NMFstd object, where both slots W and H are of dimension 0x0. newNMF(3)

This creates an empty NMFstd object with factorization rank of 3. Slots W and H are of dimension 0x3 and 3x0 respectively.

newNMF(3, c(50,10))

This creates a NMFstd object to fit a target matrix of dimension 50x10, with factorization rank of 3. Slots W and H are set to dimension 50x3 and 3x10 respectively, and filled with NAs.

newNMF(W=w)

newNMF(H=h)

newNMF(W=w, H=h) This creates a NMFstd object, where slots W and/or H are provided as matrices. When only one of the matrices is provided, a compatible NA-filled matrix is created for the missing slot.

When W and H are both provided, the NMFstd object created is suitable to seed a NMF algorithm. Note that it implicitly sets the factorisation rank to the number of columns in W.

Note that when not created as results of algorithm methods, only slots W and H are usually set. The remaining slots would be automatically set by method nmf with data about the way the factorisation was computed.

Standard way

Objects can still be created by calls of the usual form:

new("NMF")

new("NMF", W=w, H=h)

Details

Let $V$ be a $n \times m$ non-negative matrix and $r$ a positive integer. In its standard form (see references below), a NMF of $V$ is commonly defined as a pair of matrices $(W, H)$ such that: $$V \equiv W H,$$ where:
  • $W$and$H$are$n \times r$and$r \times m$matrices respectively with non-negative entries;
  • $\equiv$is to be understood with respect to some loss function. Common choices of loss functions are based on Frobenius norm or Kullbach-Leibler divergence.

Integer $r$ is called the factorization rank. Depending on the context of application of NMF, the columns of $W$ and $H$ take different names: [object Object],[object Object] NMF approach has been successfully applied to several fields. Package NMF was implemented trying to use names as generic as possible for objects and methods. The following terminology is used: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object] However, because package NMF was primilary implemented to work with gene expression microarray data, it also provides a layer to easily and intuitively work with objects from the Bioconductor base framework. See NMF-bioc for more details.

References

Definition of Nonnegative Matrix Factorization in its modern formulation: Lee D.D. and Seung H.S. (1999). Learning the parts of objects by non-negative matrix factorization. Nature, 401, 788--791.

Historical first definition and algorithms: Paatero, P., Tapper, U. (1994). Positive matrix factorization: A non-negative factor model with optimal utilization of error estimates of data values. Environmetrics, 2, 111--126 , doi:10.1002/env.3170050203. Reference for some utility functions: Kim, H. and Park, H. (2007). Sparse non-negative matrix factorizations via alternating non-negativity-constrained least squares for microarray data analysis. Bioinformatics. Hoyer (2004). Non-negative matrix factorization with sparseness constraints. Journal of Machine Learning Research, 5, 1457-1469.

See Also

Main interface to perform NMF in nmf-methods. Method seed to set NMF objects with values suitable to start algorithms with.

Examples

Run this code
# create a completely empty NMF object (i.e. 0 features, 0 basis components, 0 samples)
new('NMFstd')

# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF 
n <- 50; r <- 3; 
w <- matrix(runif(n*r), n, r) 
newNMF(W=w)

# create a NMF object based on random (compatible) matrices
p <- 20
h <- matrix(runif(r*p), r, p)
newNMF(W=w, H=h)

# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)

# same thing using the factory method: dimensions are corrected and a warning 
# is thrown saying that the dimensions used are reduced 
newNMF(W=w, H=h)

# apply default NMF algorithm to a random target matrix
V <- matrix(runif(n*p), n, p)
nmf(V, r)

Run the code above in your browser using DataLab