addNMF | R Documentation |
These functions perform Non-negative Matrix Factorization on data stored in a
TreeSummarizedExperiment
object.
getNMF(x, ...)
addNMF(x, ...)
## S4 method for signature 'SummarizedExperiment'
getNMF(x, k = 2, assay.type = "counts", eval.metric = "evar", ...)
## S4 method for signature 'SummarizedExperiment'
addNMF(
x,
k = 2,
assay.type = "counts",
eval.metric = "evar",
name = "NMF",
...
)
x |
a
|
... |
optional arguments passed to |
k |
|
assay.type |
|
eval.metric |
|
name |
|
The functions getNMF
and addNMF
internally use nmf::NMF
compute the ordination matrix and
feature loadings.
If k is a vector of integers, NMF output is calculated for all the rank
values contained in k, and the best fit is selected based on
eval.metric
value.
For getNMF
, the ordination matrix with feature loadings matrix
as attribute "loadings"
.
For addNMF
, a
TreeSummarizedExperiment
object is returned containing the ordination matrix in
reducedDims(x, name)
with the following attributes:
"loadings" which is a matrix containing the feature loadings
"NMF_output" which is the output of function nmf::NMF
"best_fit" which is the result of the best fit if k is a vector of integers
data(GlobalPatterns)
tse <- GlobalPatterns
# Reduce the number of features
tse <- agglomerateByPrevalence(tse, rank = "Phylum")
# Run NMF and add the result to reducedDim(tse, "NMF").
tse <- addNMF(tse, k = 2, name = "NMF")
# Extract feature loadings
loadings_NMF <- attr(reducedDim(tse, "NMF"), "loadings")
head(loadings_NMF)
# Estimate models with number of topics from 2 to 4. Perform 2 runs.
tse <- addNMF(tse, k = c(2, 3, 4), name = "NMF_4", nrun = 2)
# Extract feature loadings
loadings_NMF_4 <- attr(reducedDim(tse, "NMF_4"), "loadings")
head(loadings_NMF_4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.