VAF_plot: Variance accounted for plot

View source: R/user_functions.R

VAF_plotR Documentation

Variance accounted for plot

Description

Plot of VAF from a PCA solution given the first ndim PCs.

Usage

VAF_plot(
  pca,
  pca_data,
  ndim = 1:5,
  resample_ci = NULL,
  style = "line",
  colors = c("steelblue", "orange")
)

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

resample_ci

dataframe. Dataframe containing the columns "original", "mean","ci_low" and "ci_high" containing the center, the lower bound and the upper bound of the confident intervals to plot. Each row contain the values of 1 PC in order (PC1 first row, PC2 second row, etc). This can be obtained by the permut_pc_test "results" element with statistic="VAF" or computed independently.

style

Character. There are two styles of VAF plots "line" by default or "reduced".

colors

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

Value

Returns a ggplot2 object.

Author(s)

Abel Torres Espin

Examples

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

VAF_plot(pca = pca_mtcars, pca_data = mtcars, ndim = 1:7)


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