This method provides a convenient way of sub-setting
objects of class `NMF`

, using a matrix-like syntax.

```
S4 (NMF)
`[`(x, i, j, ..., drop = FALSE)
```

- i
- index used to subset on the
**rows**of the basis matrix (i.e. the features). It can be a`numeric`

,`logical`

, or`character`

vector (whose elements must match the row names of`x`

). In the case of a`logical`

vector the entries are recycled if necessary. - j
- index used to subset on the
**columns**of the mixture coefficient matrix (i.e. the samples). It can be a`numeric`

,`logical`

, or`character`

vector (whose elements must match the column names of`x`

). In the case of a`logical`

vector the entries are recycled if necessary. - ...
- used to specify a third index to subset on the
basis components, i.e. on both the columns and rows of
the basis matrix and mixture coefficient respectively. It
can be a
`numeric`

,`logical`

, or`character`

vector (whose elements must match the basis names of`x`

). In the case of a`logical`

vector the entries are recycled if necessary. Note that only the first extra subset index is used. A warning is thrown if more than one extra argument is passed in`...`

. - drop
- single
`logical`

value used to drop the`NMF-class`

wrapping and only return subsets of one of the factor matrices:- When
`drop=FALSE`

it returns the`NMF`

object`x`

with the basis matrix and/or mixture coefficient matrix subset accordingly to the values in`i`

,`j`

, and`...`

. - When
`drop=TRUE`

it returns the factor that is subset "the more" (see section*Value*).

`i`

and`j`

are provided, argument`drop`

is ignored:`x[i,j, drop=TRUE]`

(resp.`x[i,j,k, drop=TRUE]`

) is identical to`x[i,j, drop=FALSE]`

(resp.`x[i,j,k, drop=FALSE]`

). - When
- x
- object from which to extract element(s) or in which to replace element(s).

It allows to consistently subset one or both matrix factors in the NMF model, as well as retrieving part of the basis components or part of the mixture coefficients with a reduced amount of code.

The returned value depends on the number of subset index
passed and the value of argument `drop`

:

- No index as in
`x[]`

or`x[,]`

: the value is the object`x`

unchanged. - One single index as in
`x[i]`

: the value is the complete NMF model composed of the selected basis components, subset by`i`

. If argument`drop`

is not missing then only the basis matrix is returned and`drop`

is used:`x[i, drop=TRUE.or.FALSE]`

<=>`basis(x)[, i, drop=TRUE.or.FALSE]`

.Note that in version <= 0.8.7, the call

`x[i]`

was equivalent to`basis(x)[, i, drop=TRUE.or.FALSE]`

. - More than one index with
`drop=FALSE`

(default) as in`x[i,j]`

,`x[i,]`

,`x[,j]`

,`x[i,j,k]`

,`x[i,,k]`

, etc...: the value is a`NMF`

object whose basis and/or mixture coefficient matrices have been subset accordingly. The third index`k`

affects simultaneously the columns of the basis matrix AND the rows of the mixture coefficient matrix. - More than one index with
`drop=TRUE`

and`i`

xor`j`

missing: the value returned is the matrix that is the more affected by the subset index. That is that`x[i, , drop=TRUE]`

and`x[i, , k, drop=TRUE]`

return the basis matrix subset by`[i,]`

and`[i,k]`

respectively, while`x[, j, drop=TRUE]`

and`x[, j, k, drop=TRUE]`

return the mixture coefficient matrix subset by`[,j]`

and`[k,j]`

respectively.