plot_loadings | R Documentation |
Plot loadings of a principal component
plot_loadings(
pca_res,
PC = 1,
square = FALSE,
color_by = NULL,
annotate_top_n = 0,
highlight_genes = NULL,
show_plot = TRUE
)
pca_res |
A result returned from |
PC |
Number of the principal component to plot |
square |
Whether to plot squared loadings. The squared loading is equal to the fraction of variance explained by the respective feature in the given principal component. |
color_by |
Variable (column in |
annotate_top_n |
Annotate the top n features with positive or negative loading |
highlight_genes |
Vector of gene names or gene IDs to highlight on the plot (overwrites top_n annotation) |
show_plot |
Whether to show the plot |
The function displays the loadings plot and returns invisible a list of the plot, the data.frame of the PCA loadings.
set.seed(1)
data <- matrix(rnorm(100*6), ncol=6)
data <- t(t(data)+c(-1, -1.1, -1.2, 1, 1.1, 1.2))
pca_res <- plot_pca(data)
plot_loadings(pca_res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.