Function that takes a data frame with a Geneid column and several columns for expression data of different samples (e.g. TPMs, Log2FC...) and draws a correlation plot
expressionCor(
df,
genes = NULL,
samples = NULL,
samples_order = samples,
corr_method = "pearson",
plot_type = "lower",
plot_diagonal = TRUE,
plot_size = 85,
plot_border = TRUE,
plot_colors = c("Gold3", "White", "Cornflowerblue"),
plot_title = NULL,
plot_subtitle = NULL,
plot_caption = NULL,
cell_border = "Black",
legend_pos = "right",
legend_size = c(8, plot_size),
legend_limits = c(-1, 1),
legend_breaks_by = 0.5,
legend_title = paste(stringr::str_to_sentence(corr_method), "correlation", sep = " "),
legend_title_size = 10,
coeffs_color = "Black",
coeffs_size = 4,
title_hjust = 0.5,
title_face = "plain",
title_size = 12,
subtitle_face = "italic",
subtitle_size = 11,
caption_size = 6,
axis_text_size = 8,
axis_text_color = "black",
by_groups = F
)
Dataframe with a 'Geneid' column and several columns with numerical expression data for different samples, such as TPMs or Log2FC.
Character or NULL. Names of the genes to be used for the correlation analysis. They must present in the column 'Geneid' of 'df'. If NULL, all genes in the data frame are used. Default: NULL
Character or NULL. Names of the samples to be used for the correlation analysis. They must be column names of 'df'. If NULL, all samples are used. Default: NULL.
Character of length 1. Correlation method to be passed through cor()
. One of "pearson"
, "spearman"
or "kendall"
. Default: "pearson".
Character of length 1. Type of the correlation plot. One of "full"
, "upper"
or "lower"
. Default: "lower".
Logical of length 1. Whether to plot the diagonal or not if the plot type is upper or lower. Default: TRUE.
Numerical of length 1. Size in milimeters of the plot. The same number is used for plot height and plot width Default: 85.
Logical of length 1. Whether to draw a border in the panel or not. Default: TRUE.
Character of length 3. Colors of the lower, midpoint and higher limits of the scale. Default: c("Gold3", "White", "Cornflowerblue").
Character of length 1 or NULL. Title of the plot. Defalut: NULL.
Character of length 1 or NULL. Subtitle of the plot. Defalut: NULL.
Character of length 1 or NULL. Caption of the plot. Defalut: NULL.
Charachter of length 1, NULL or NA. Color of the cell border. Default: "Black".
Charachter of length 1. Position of the legend, to be passed through ggpubr::theme_pubr()
. Default: "right".
Numerical of length 2. Size of the legend. The first element is the width and the second is the height of the legend bar. Default: c(8,plot_size)
Numerical of length 2. Lower and upper limits of the correlation scale. Default: c(-1,1).
Numerical of length 1. Size of the breaks in the legend. Default: 0.5.
Character of length 1 or NULL. Title of the legend. Default: paste(stringr::str_to_sentence(corr_method), "correlation", sep = " ")
.
Numerical of length 1. Size of the legend title. Default: 10.
Character of length 1 or NULL. Color of the correlation coeficients to be plotted. If NULL, no correlation coefficients are plotted. Default: "Black".
Numerical of length 1. Size of the correlation coefficients. Default: 4.
Numerical of length 1. Horizontal justification of the title and the subtitle. Default: 0.5.
Character of length 1. Face of the title text. One of "plain", "italic", "bold". Default: "plain".
Numerical of length 1. Size of the title text. Default: 12.
Character of length 1. Face of the subtitle text. One of "plain", "italic", "bold". Default: "italic".
Numerical of length 1. Size of the subtitle text. Default: 11.
Numerical of length 1. Size of the plot caption. Default: 6.
Numerical of length 1. Size of the text in the axes. Default: 7.
Character of length 1. Color of the text in the axes. Default: "Black".
Logical of length 1. If TRUE, the function searches an extra column named 'group', whose values will be used to separate the plot into facets using facet_wrap(). Default: FALSE.