NMFstd-class {NMF}R Documentation

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.

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:

Integer r is called the factorization rank. Depending on the context of application of NMF, the columns of W and H take different names:

columns of W
basis vector, metagenes, factors, source, image basis
columns of H
mixture coefficients, metagenes expression profiles, weights

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:

samples
the columns of the target matrix V
features
the rows of the target matrix V
basis matrix
the first matrix factor W
basis vectors
the columns of first matrix factor W
mixture matrix
the second matrix factor H
mixtures coefficients
the columns of second matrix factor H

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.

Slots

W:
A "matrix" that contains the first matrix factor of the factorisation
H:
A "matrix" that contains the second matrix factor of the factorisation

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)

Methods

distance
signature(target = "matrix", x = "NMF"): return the value of the loss function given a target matrix and a NMF fit.
fitted
signature(object = "NMF"): compute the estimated target matrix according to the standard NMF model object, i.e. as the matrix product of slots W and H.

Note that this method is part of the minimum interface for NMF model, as defined by class NMF.

basis
signature(object = "NMF"): Returns slot W, the matrix of basis vectors in NMF model object.

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

basis<-
signature(object = "NMF", value = "matrix"): Sets the value of slot W, the matrix of basis vectors in NMF model object.

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

coef
signature(object = "NMF"): Returns slot H, the matrix of mixture coefficients in the NMF model object.

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

coef<-
signature(object = "NMF", value = "matrix"): Set the value of slot H, the matrix of mixture coefficients in the NMF model object.

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

random
signature(x = "NMF", target): seed NMF model x with random values drawn from a random distribution. If a target is specified as a matrix, then the values are drawn within the interval [0, max(target)].

show
signature(object = "NMF"): standard generic show method for objects of class NMF.
summary
signature(x = "NMF"): standard generic summary method for objects of class NMF.

Class NMFstd inherits from all the methods defined on class NMF to manipulate and interpret NMF models. Some useful are: dim, nbasis, predict, sparseness. See NMF for more details.

Author(s)

Renaud Gaujoux renaud@cbio.uct.ac.za

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


# 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)
## Not run: 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)
## Not run: nmf(V, r)


[Package NMF version 0.2.4 Index]