plot_correlation_heatmap.Rd
Generates a heatmap of the upper triangle of a correlation matrix.
plot_correlation_heatmap(
x,
ttl = "Correlation matrix",
labels = NULL,
lyt = NULL,
gradient = c("#E69F00", "#56B4E9"),
txtSz = 1.25,
mc_adjust = "BH",
cut_off = 0.05,
new = T,
H = 20/3,
W = 25/3,
abbr_labels = TRUE,
status = FALSE
)
A data frame (all variables will be used when generating the correlation matrix).
An optional title for the figure.
The labels for the rows/columns. Users can pass a list with two character vectors of matching length to provide separate labels for rows and columns.
An optional matrix specifying the layout of the main panel (1) versus the side panel (2) with the color gradient.
The final end colors for the negative and positive correlations, respectively.
The size of the text in the figure (a second value can be provided to adjust variable labels separately).
The method to use when correcting for
multiple comparisons (see p.adjust
).
Cut-off for statistical significance.
Logical; if TRUE
generates a new
plotting window via x11
.
The height in inches of the figure if a new plotting window is generated.
The width in inches of the figure if a new plotting window is generated.
Logical; if TRUE
abbreviates
labels to 4 characters. A second value can be provided
to abbreviate labels on the top separately.
Logical; if TRUE
displays the
progress of the function for debugging purposes.
A heatmap for the upper-triangle portion of the correlation matrix.
# Load data
data("mtcars")
x <- mtcars[, c(1,3,4,5,6,7)]
plot_correlation_heatmap( x, new = FALSE )
# Simulate a correlation matrix
# 5 x 5 matrix of random values
rand_mat <- matrix( rnorm(25), 5, 5 )
# Create covariance matrix by
# multiplying matrix by its transpose
cov_mat <- rand_mat %*% t( rand_mat )
corr_mat <- cov_mat/sqrt(diag(cov_mat)%*%t(diag(cov_mat)))
# Simulate data
x <- MASS::mvrnorm( 100, rep( 0, nrow( corr_mat ) ), corr_mat )
colnames( x ) <- paste0( 'V', 1:ncol( x ) )
x <- data.frame(x)
plot_correlation_heatmap( x, new = FALSE )