plot_corr: Correlation Plot

View source: R/plot_corr.R

plot_corrR Documentation

Correlation Plot

Description

This function plots pairwise correlations between variables.

Usage

plot_corr(
  dat,
  method = "pearson",
  use = "everything",
  alpha = NULL,
  p_adj = NULL,
  lim = NULL,
  geom = "tile",
  label = FALSE,
  diag = FALSE,
  title = "Correlation Plot",
  legend = "right",
  hover = FALSE,
  export = FALSE
)

Arguments

dat

A sample by feature data frame or matrix, e.g. of clinical variables. Non-numeric features are dropped with a warning.

method

String specifying which correlation coefficient to compute. Must be one of "pearson", "kendall", or "spearman". See cor.

use

Optional character string giving a method for computing covariances in the presence of missing values. Must be one of "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs".

alpha

Optional significance threshold to impose on correlations. Those with p-values (optionally adjusted) less than or equal to alpha are outlined in black.

p_adj

Optional p-value adjustment for multiple testing. Options include "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", and "fdr". See p.adjust.

lim

Optional vector of length two defining lower and upper bounds for the scale range. Default is observed extrema.

geom

String specifying whether to visualize correlation coefficients as "tile" or "circle".

label

Print correlation coefficient over geom?

diag

Include principal diagonal of the correlation matrix?

title

Optional plot title.

legend

Legend position. Must be one of "bottom", "left", "top", "right", "bottomright", "bottomleft", "topleft", or "topright".

hover

Show correlation coefficient by hovering mouse over the corresponding tile or circle? If TRUE, the plot is rendered in HTML and will either open in your browser's graphic display or appear in the RStudio viewer.

export

Export correlation matrix? If TRUE and alpha is non-NULL, then the p-value matrix will also be returned.

Details

Correlation plots visualize the associations between numeric features. They are a valuable tool in exploratory data analysis for biological experiments, where they may help identify dependencies among clinical covariates, leading to better omic models.

Value

If export = TRUE, a list with up to two elements:

  • The correlation matrix, computed via the chosen method.

  • The matrix of p-values (optionally adjusted), if alpha is non-NULL.

Examples

mat <- matrix(rnorm(100), 10, 10)
plot_corr(mat)


dswatson/bioplotr documentation built on March 3, 2023, 9:43 p.m.