Function that takes a list of dataframes with expression data and the columns 'Geneid' and 'log2FoldChange'. and draws a heatmap using ggplot.

expressionHeatmap2(expr_list, expr_names = names(expr_list), genes, clust_rows = T, clust_cols = F, show_dend_rows = F, show_dend_cols = F, dist_method = "euclidean", hclust_method = "ward.D", write_label = T, label_size = 3, label_color = "black", label_digits = 2, hm_height = length(genes)*10, hm_width = length(expr_list)*10, hm_colors = c("cornflowerblue", "white", "gold3"), legend_scale = c(-1.5, 1.5), legend_breaks_num = 5, legend_breaks_by = .5, legend_midpoint = 0, legend_height = hm_height, legend_title = NULL, dend_cols_prop = .1, dend_rows_prop = .2, title = "", subtitle = "", caption = NULL, xlab = "", ylab = NULL, axis_text_size = 10, x_axis_angle = 90)

Arguments

expr_list

List of dataframes with, at least, the columns 'Geneid' and 'log2FoldChange'. Better if it's a named list.

expr_names

Character of namesof equal length to 'expr_list'. Names of the elements in 'expr_list'. Default: names(expr_list)

genes

Character. Names of the genes to be plotted. They must present in the column 'Geneid' of 'df'.

clust_rows

Logical of length 1. Whether to cluster the rows (TRUE) or not (FALSE) using hclust. Default: T.

clust_cols

Logical of length 1. Whether to cluster the columns (TRUE) or not (FALSE) using hclust. Default: T.

show_dend_rows

Logical of length 1. Whether to draw the dendogram of the rows clustering (TRUE) or not (FALSE). It works only with 'clust_rows = T'. Default: T.

show_dend_cols

Logical of length 1. Whether to draw the dendogram of the columns clustering (TRUE) or not (FALSE). It works only with 'clust_cols = T'. Default: T.

dist_method

Character of length 1. Distance calculation. One of "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski". Default: "euclidean".

hclust_method

Character of length 1. Method for hierarchical clustering. One of "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC). Default: "ward.D"

write_label

Logical of length 1. Whether to write the expression values in the heatmap (TRUE) or not (FALSE). Default: T.

label_size

Numerical of length 1. Size of the expression values written in each cell of the heatmap. Default: 3.

label_color

Character of length 1. Color of the expression values written in each cell of the heatmap. Default: "black".

label_digits

Numerical of length 1. Number of digits the expression values are rounded to. Defalut: 2.

hm_height

Numerical of length 1. Height of the heatmap in mm. Default: length(genes)*10.

hm_width

Numerical of length 1. Width of the heatmap in mm. Default: (ncol(df)-1)*10.

hm_colors

Character of length 3. Colors in the lower limit, midpoint (defined by 'legend_midpoint') and higher limit, respectively. Default: c("cornflowerblue", "white", "gold3").

na_color

Charachter of length 1. Color for the NA values. Default: "Gray".

border_color

Character of length 1 or NA. Color of the border of each cell in the heatmap. Default: NA.

legend_scale

Numerical of length 2 or NULL. If NULL, the color scale of the heatmap will take the minimum and the maximum values as limits. If numerical, the color scale will take the first as the lower limit and the second element as the higher limit. Default: c(-1.5, 1.5).

legend_breaks_num

Numerical of length 1. Only if 'legend_scale = NULL'. The number of breaks you want in the legend. Default: 5.

legend_breaks_by

Numerical of length 1. Only 'legend_scale' is numerical (e.g. c(-1,1)). The distance between the breaks of the legend. Default: .5.

legend_midpoint

Numerical of length 1. Only if scale is not NULL. Point where the central color of the legend will placed. Default: 0

legend_height

Numerical of length 1. Height of the legend which, by default, is the height of the heatmap. Default: hm_height.

legend_title

Character of length 1 or NULL. Title of the legend, placed in the right part of it. Default: NULL.

legend_title_size

Numerical of length 1. Size of the legend title. Default: 8

dend_cols_prop

Numerical of length 1. Proportion (from 0 to 1) of the columns dendogram compared to the heatmap height. Default: 0.1.

dend_rows_prop

Numerical of length 1. Proportion (from 0 to 1) of the rows dendogram compared to the heatmap width Default: 0.2.

title

Character of length 1 or NULL. Title of the plot. Default: "".

title_size

Numerical of length 1. Size of the plot title. Default: 13.

title_hjust

Numerical of length 1. Justification of the plot title and subtitle. Default: 0.

subtitle

Character of length 1 or NULL. Subtitle of the plot. Default: "".

subtitle_size

Numerical of length 1. Size of the plot subtitle. Default: 13.

caption

Character of length 1 or NULL. Caption of the plot; placed at the bottom. Default: NULL.

caption_size

Numerical of length 1. Size of the plot caption. Default: 7.

xlab

Character of length 1 or NULL. Title of the X axis. Default: "

ylab

Character of length 1 or NULL. Title of the Y axis. If row dendogram is plotted, the Y axis is placed to the right. Default: NULL.

axis_title_size

Numerical of length 1. Size of the axis titles. Default: 10

axis_text_size

Numerical of length 1. Size of the text in the axes. Default: 10

scale

Character of length 1 or NULL. One of c("rows", "cols"). If "rows", it scales data by row; if "cols", it scales data by columns; if NULL (the default), it does not scale the data. Default: NULL.

See also

Author

amitjavilaventura