plotScree creates a scree plot or eigenvalues plot starting from a TreeSummarizedExperiment object or a vector of eigenvalues. This visualization shows how the eigenvalues decrease across components.

plotScree(x, ...)

# S4 method for class 'SingleCellExperiment'
plotScree(x, dimred, cumulative = FALSE, ...)

# S4 method for class 'vector'
plotScree(x, cumulative = FALSE, ...)

Arguments

x

a TreeSummarizedExperiment or a vector of eigenvalues.

...

additional parameters for plotting

show.barplot

Logical scalar. Whether to show a barplot. (Default: TRUE).

show.points

Logical scalar. Whether to show points. (Default: TRUE).

show.line

Logical scalar. Whether to show a line connecting points. (Default: TRUE).

show.labels

Logical scalar. Whether to show labels for each point. (Default: FALSE).

dimred

Character scalar or integer scalar. Determines the reduced dimension to plot. This is used when x is a TreeSummarizedExperiment to extract the eigenvalues from reducedDim(x, dimred).

cumulative

Logical scalar. Whether to show cumulative explained variance. (Default: FALSE).

Value

A ggplot2 object

Details

plotScree creates a scree plot or eigenvalues plot, which is useful for visualizing the relative importance of components in dimensionality reduction techniques like PCA, RDA, or CCA. When the input is a TreeSummarizedExperiment, the function extracts eigenvalues from the specified reduced dimension slot. When the input is a vector, it directly uses these values as eigenvalues.

The plot can include a combination of barplot, points, connecting lines, and labels, which can be controlled using the show.* parameters.

An option to show cumulative explained variance is also available by setting cumulative = TRUE.

Examples

# Load necessary libraries
library(ggplot2)

# Load dataset
library(miaViz)
data("enterotype", package = "mia")
tse <- enterotype
 
# Run RDA and store results into TreeSE
tse <- addRDA(
    tse,
    formula = assay ~ ClinicalStatus + Gender + Age,
    FUN = getDissimilarity,
    distance = "bray",
    na.action = na.exclude
    )

# Plot scree plot
plotScree(tse, "RDA")