plotLoadings | R Documentation |
This function is used after performing a reduction method. If TreeSE
is given it retrieves the feature loadings matrix to plot values.
A tree from rowTree
can be added to heatmap layout.
plotLoadings(x, ...)
## S4 method for signature 'TreeSummarizedExperiment'
plotLoadings(
x,
dimred,
layout = "barplot",
ncomponents = 5,
tree.name = "phylo",
row.var = NULL,
add.tree = FALSE,
...
)
## S4 method for signature 'SingleCellExperiment'
plotLoadings(x, dimred, layout = "barplot", ncomponents = 5, ...)
## S4 method for signature 'matrix'
plotLoadings(x, layout = "barplot", ncomponents = 5, ...)
x |
a
|
... |
additional parameters for plotting.
|
dimred |
|
layout |
|
ncomponents |
|
tree.name |
|
row.var |
|
add.tree |
|
These method visualize feature loadings of dimension reduction results.
Inspired by the plotASVcircular
method using phyloseq
.
TreeSummarizedExperiment
object is expected to have
content in reducedDim
slot calculated with standardized methods from
mia
or scater
package.
A ggplot2
object.
library(mia)
library(scater)
data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns
# Calculate PCA
tse <- agglomerateByPrevalence(tse, rank="Phylum", update.tree = TRUE)
tse <- transformAssay(tse, method = "clr", pseudocount = 1)
tse <- runPCA(tse, ncomponents = 5, assay.type = "clr")
#' # Plotting feature loadings with tree
plotLoadings(tse, dimred = "PCA", layout = "heatmap", add.tree = TRUE)
# Plotting matrix as a barplot
loadings_matrix <- attr(reducedDim(tse, "PCA"), "rotation")
plotLoadings(loadings_matrix)
# Plotting more features but less components
plotLoadings(tse, dimred = "PCA", ncomponents = 2, n = 12)
# Plotting matrix as heatmap without tree
plotLoadings(loadings_matrix, layout = "heatmap")
# Plot with less components
plotLoadings(tse, "PCA", layout = "heatmap", ncomponents = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.