plot_loadings {RNAseqQC}R Documentation

Plot loadings of a principal component

Description

Plot loadings of a principal component

Usage

plot_loadings(
  pca_res,
  PC = 1,
  square = FALSE,
  color_by = NULL,
  annotate_top_n = 0,
  highlight_genes = NULL,
  show_plot = TRUE
)

Arguments

pca_res

A result returned from plot_pca()

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 pca_res$loadings) to color points by. Can also be 'pc_sign' to color by the sign of the loading (useful in combination with the square = TRUE parameter).

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

Value

The function displays the loadings plot and returns invisible a list of the plot, the data.frame of the PCA loadings.

Examples

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)

[Package RNAseqQC version 0.2.1 Index]