syndromic_plot: Syndromic plot

View source: R/user_functions.R

syndromic_plotR Documentation

Syndromic plot

Description

Extract the syndromic plots from a pca solution or from a table of loadings for all the specified PCs.

Usage

syndromic_plot(
  pca,
  pca_data = NULL,
  ndim = 3,
  cutoff,
  VAF,
  arrow_size_multi = 10,
  repel = TRUE,
  plot_legend = TRUE,
  plot_cutoff = TRUE,
  text_size = 9,
  var_order = "abs decreasing",
  colors = c("steelblue1", "white", "firebrick1"),
  ...
)

Arguments

pca

Object of class prcomp, princals, or data.frame. If object is a prcomp or princals object, pca_data argument 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 to plot. If only one value is passed, the same cutoff will be used for all the PCs. If a vector is passed, each value will be used for the corresponding PC.

VAF

If pca is from prcomp or princals, VAF argument is not needed. Otherwise, VAF is a String vector with text for the centers of the syndromic plots. The text generally corresponds to the variance accounted for (VAF) for the respective PCs.

arrow_size_multi

Numeric. Controls the size of the arrows proportional to the loading. Default=10

repel

Logical. Whether to repel the text for preventing text overlap. Default= TRUE

plot_legend

Logical. Whether to plot the legend or not. Default= TRUE

plot_cutoff

Logical. Whether to report the cutoff on the legend or not. Default = TRUE

text_size

Numeric. Controls for the size of the text. Default=9

var_order

Character. Specify the order of the variables in the plot by the loading values, starting at 12 o’clock and moving counterclockwise. Possible values: 'abs decreasing': plot by decreasing absolute value; 'abs increasing': plot by increasing absolute value; 'decreasing'; or 'increasing’.

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.

...

Other arguments passed to extract_syndromic_plot()

Value

Returns a list of ggplot2 objects with one element for each PC plot. Plots can be saved usign ggsave().

Examples

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

syndromic_plot(pca = pca_mtcars, pca_data = mtcars, ndim = 2, cutoff = 0.5)


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