Creates a scree plot from a "beta_pcoa" object (output of
compute_pcoa()), showing the percentage of variance explained
for the first n_axes axes.
Usage
plot_scree(pcoa_res, n_axes = NULL, type = c("bar", "line"))Arguments
- pcoa_res
A
"beta_pcoa"object as returned bycompute_pcoa(). Must contain aneigenvaluescomponent (numeric vector of eigenvalues).- n_axes
Integer giving the number of axes to display. If
NULL(default), the function usesmin(10, length(eigenvalues)).- type
Type of scree plot to draw:
"bar"(default) for a bar plot of variance explained, or"line"for a line/point plot.
Value
A ggplot2::ggplot object representing the scree plot.
Details
Percentages are computed from the positive part of the eigenvalues,
i.e. pmax(eigenvalues, 0), to handle possible small negative
eigenvalues from non-perfectly Euclidean distance matrices.
Styled with theme_phip().