barmap_loading: Barmap of standardized loadings

View source: R/user_functions.R

barmap_loadingR Documentation

Barmap of standardized loadings

Description

Plot a Barmap of the standardized loadings from a PCA solution.

Usage

barmap_loading(
  pca,
  pca_data,
  ndim = 1:5,
  cutoff = 0,
  resample_ci = NULL,
  conf = 0.95,
  plot_list_center = F,
  plot_legend = TRUE,
  text_values = F,
  star_values = F,
  text_size = 2,
  plot_cutoff = TRUE,
  vars = NULL,
  colors = c("steelblue1", "white", "firebrick1"),
  gradient_color = TRUE
)

Arguments

pca

Object of class prcomp, princals, or data.frame. If object is a prcomp or princals object, pca_data is required, and the loadings will be extracted. If object is a data.frame object, the dataframe needs to be formatted as: first column named Variables and all other columns corresponding to a PC. One row per variable. The values are the loadings.

pca_data

Data passed to the prcomp or princals function.

ndim

Numeric. Number of PCs to plot

cutoff

Numeric or numeric vector of length ndim. Value of the loadings threshold (i.e. |loadings| >= cutoff) to plot with stars. Default = 0.5

resample_ci

dataframe. Dataframe containing the columns "Variables", "component","original", "mean","ci_low" and "ci_high" containing the center, the lower bound and the upper bound of the confident intervals to plot. These can be obtained by the pc_stability or permut_pc_test "results" element or computed independently.

conf

Numeric. Confidence level used when load_list is provided.

plot_list_center

Logical. Whether to plot the average loadings obtained from load_list.

plot_legend

Logical. Whether legend should be plotted.

text_values

Logical. Whether to plot the values of the loadings or not. Default= TRUE

star_values

Logical. Whether to plot a star in |loadings|>=cutoff. Only relevant if text_values=FALSE. Default=FALSE

text_size

Numeric. Size of the text_values.

plot_cutoff

Logical. Whether to plot the cutoff lines or not.

vars

Character vector. Variables will be ordered as the provided variable names. Non-specified variables will be excluded from the plot. By default variables are ordered in alphabetically by ggplot.

colors

Character vector of length 3. Vector with the character name or hexadecimal number (e.g. "#FF0000") of three colors, the lower color, the middle color and the higher color for the gradient used in the plot. Hexadecimal number can be obtained using rgb for example.

gradient_color

Logical. Whether colors should be plotted as a gradient proportional to the loadings.

Value

Returns a ggplot2 object.

Author(s)

Abel Torres Espin

Examples

data(mtcars)
pca_mtcars<-prcomp(mtcars, center = TRUE, scale. = TRUE)

barmap_loading(pca = pca_mtcars, pca_data = mtcars, ndim = 1:4)


ucsf-ferguson-lab/syndRomics documentation built on June 26, 2022, 5:36 p.m.