addLDA | R Documentation |
These functions perform Latent Dirichlet Allocation on data stored in a
TreeSummarizedExperiment
object.
getLDA(x, ...)
addLDA(x, ...)
## S4 method for signature 'SummarizedExperiment'
getLDA(x, k = 2, assay.type = "counts", eval.metric = "perplexity", ...)
## S4 method for signature 'SummarizedExperiment'
addLDA(x, k = 2, assay.type = "counts", name = "LDA", ...)
x |
a
|
... |
optional arguments passed to |
k |
|
assay.type |
|
eval.metric |
|
name |
|
The functions getLDA
and addLDA
internally use
LDA
to compute the ordination matrix and
feature loadings.
For getLDA
, the ordination matrix with feature loadings matrix
as attribute "loadings"
.
For addLDA
, a
TreeSummarizedExperiment
object is returned containing the ordination matrix in
reducedDim(..., name)
with feature loadings matrix as attribute
"loadings"
.
data(GlobalPatterns)
tse <- GlobalPatterns
# Reduce the number of features
tse <- agglomerateByPrevalence(tse, rank="Phylum")
# Run LDA and add the result to reducedDim(tse, "LDA")
tse <- addLDA(tse)
# Extract feature loadings
loadings <- attr(reducedDim(tse, "LDA"), "loadings")
head(loadings)
# Estimate models with number of topics from 2 to 10
tse <- addLDA(tse, k = c(2, 3, 4, 5, 6, 7, 8, 9, 10), name = "LDA_10")
# Get the evaluation metrics
tab <- attr(reducedDim(tse, "LDA_10"),"eval_metrics")
# Plot
plot(tab[["k"]], tab[["perplexity"]], xlab = "k", ylab = "perplexity")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.