NMFstd-class: NMF Model - Standard model

Description Usage Arguments Details Slots Methods (by generic) References See Also Examples

Description

This class implements the standard model of Nonnegative Matrix Factorization. It provides a general structure and generic functions to manage factorizations that follow the standard NMF model, as defined by Lee and Seung (2001).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## S4 method for signature 'NMFstd'
show(object)

## S4 method for signature 'NMFstd'
.basis(object, slice = NULL)

## S4 replacement method for signature 'NMFstd,array'
.basis(object) <- value

## S4 replacement method for signature 'NMFstd,mMatrix'
.basis(object, slice = 1L) <- value

## S4 method for signature 'NMFstd'
.coef(object, slice = NULL)

## S4 replacement method for signature 'NMFstd,array'
.coef(object) <- value

## S4 replacement method for signature 'NMFstd,mMatrix'
.coef(object, slice = 1L) <- value

## S4 method for signature 'NMFstd'
fitted(object, W, H)

## S4 method for signature 'NMFstd'
ibterms(object)

## S4 method for signature 'NMFstd'
icterms(object)

Arguments

object

an object of class NMFstd.

slice

optional slice (3rd margin) to extract in 3D-array NMF models.

value

an object whose value is used to modify properties of the given object.

W

a optional matrix to use in the computation as the basis matrix in place of basis(object). It must be compatible with the coefficient matrix used in the computation. That is, number of columns in W = number of rows in the mixture coefficient matrix coef(object) or H (if provided).

H

a optional matrix to use in the computation as the coefficient matrix in place of coef(object). It must be compatible with the basis matrix used in the computation. That is, number of rows in H = number of columns in the basis matrix basis(object) or W (if provided).

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 are given different names:

columns of W

basis vector, metagenes, factors, source, image basis

columns of H

mixture coefficients, metagene sample expression profiles, weights

rows of H

basis profiles, metagene expression profiles

NMF approaches have been successfully applied to several fields. The 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 the package NMF was primarily 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 bioc-NMF for more details.

Slots

W

A matrix that contains the basis matrix, i.e. the first matrix factor of the factorisation

H

A matrix that contains the coefficient matrix, i.e. the second matrix factor of the factorisation

bterms

a data.frame that contains the primary data that define fixed basis terms. See bterms.

ibterms

integer vector that contains the indexes of the basis components that are fixed, i.e. for which only the coefficient are estimated.

IMPORTANT: This slot is set on construction of an NMF model via nmfModel and is not recommended to not be subsequently changed by the end-user.

cterms

a data.frame that contains the primary data that define fixed coefficient terms. See cterms.

icterms

integer vector that contains the indexes of the basis components that have fixed coefficients, i.e. for which only the basis vectors are estimated.

IMPORTANT: This slot is set on construction of an NMF model via nmfModel and is not recommended to not be subsequently changed by the end-user.

Methods (by generic)

.basis:

.basis<-:

.coef:

.coef<-:

bterms<-:

cterms<-:

fitted:

ibterms:

icterms:

t:

References

Lee DD, Seung H (2001). “Algorithms for non-negative matrix factorization.” _Advances in neural information processing systems_. <URL: http://scholar.google.com/scholar?q=intitle:Algorithms+for+non-negative+matrix+factorization\#0>.

See Also

Other NMF-model: NMFOffset-class, NMFns-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# create a completely empty NMFstd object
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 <- rmatrix(n, r) 
nmfModel(W=w)

# create a NMF object based on random (compatible) matrices
p <- 20
h <- rmatrix(r, p)
nmfModel(W=w, H=h)

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

# Giving target dimensions to the factory method allow for coping with dimension
# incompatibilty (a warning is thrown in such case) 
nmfModel(r, W=w, H=h)
 
# create a NMF array object based on random (compatible) arrays
# extra dimension (levels)
q <- 2 
w <- array(seq(n*r*q), dim = c(n, r, q))
h <- rmatrix(r, p)
nmfModel(W = w, H = h)

# random standard NMF model
x <- rnmf(3, 10, 5)
basis(x)
coef(x)

# set matrix factors
basis(x) <- matrix(1, nrow(x), nbasis(x))
coef(x) <- matrix(1, nbasis(x), ncol(x))
# set random factors
basis(x) <- rmatrix(basis(x))
coef(x) <- rmatrix(coef(x))

# incompatible matrices generate an error:
try( coef(x) <- matrix(1, nbasis(x)-1, nrow(x)) )
# but the low-level method allow it
.coef(x) <- matrix(1, nbasis(x)-1, nrow(x))
try( validObject(x) )

# random standard NMF model
x <- rnmf(3, 10, 5)
all.equal(fitted(x), basis(x) %*% coef(x))

renozao/NMF documentation built on June 14, 2020, 9:35 p.m.