plot_gene_heatmap: Plot a heatmap of gene expression counts

Description Usage Arguments

View source: R/plot_gene_heatmap.R

Description

This is a wrapper for heatmap3, designed to make plotting of gene expression heatmaps more automated. Samples can be order and/or colored based on variables in an optional design object. It also provides a nicer default color palette than the heatmap3 default.

Usage

1
2
3
4
5
6
7
8
9
plot_gene_heatmap(
     counts, design=NULL, libID_col="lib.id",
     order_by_var=NULL, order_by_var_levels=NULL,
     color_by_var=order_by_var, my_var_colors=NULL, color_by_var_levels=NULL,
     norm.method="range01", scale="none", row_dendro=NULL, col_dendro=NULL,
     filename=NULL, plotdims=c(9,9),
     my_heatmap_cols=NULL,
     add_legend=FALSE, leg_x=0.7, leg_y=1.1, xl=0.6, xr=0.7, yb=0.9, yt=1.1,
     ...)

Arguments

counts

a numeric matrix (or object that can be coerced to matrix) of gene expression values, with genes in rows and samples in columns, or an object from which counts can be extracted (such as an EList or DGEList).

design

(optional) design object, used for ordering or coloring samples. If provided, must include a column (named in libID_col) with identifiers matching column names in counts, and columns matching color_by_var and/or order_by_var. Only samples found in both counts and design will be plotted.

libID_col

(optional) string, the name of the column in design containing sample identifiers matching the column names of counts.

order_by_var

(optional) character vector, the names of the columns in design by which to order the samples. If multiple columns are provided, ordering is done by the first variable, then the second, etc. by passing the columns as argument to dplyr::arrange

order_by_var_levels

(optional) character vector, or list of character vectors, one for each element in order_by_var, with the levels of order_by_var in the order to use for plotting. If not provided, elements are ordered by factor levels (if a factor) or based on first appearance in the design object. Ignored if order_by_var is numeric.

color_by_var

(optional) character vector, the names of the columns in design by which to color the sample labels. If order_by_var is specified and color_by_var is not, sample labels will be colored by order_by_var.

my_var_colors

(optional) vector, or list of vectors, containing colors for use in coloring column identifiers, one for each element in color_by_var. Use varies depending on class of color_by_var. For each variable specified by color_by_var: if the variable is numeric, values of are broken up into even intervals with number specified by color_byvars_levels, and assigned colors from the corresponding vector of colors in my_var_colors; if needed, additional colors are imputed using colorRampPalette. If not provided, the "viridis" palette from viridis is used. If the variable is not numeric, my_var_colors should include at least as many colors as there are unique values for the variable; these colors are assigned to the values for plotting. If not provided, "Set1" from RColorBrewer is used.

color_by_var_levels

(optional) vector, or list of vectors, one for each element in color_by_var, providing control over coloring of sample labels. Use varies depending on the class of the variable. If the variable is NOT numeric, should include the unique values of color_by_var; this vector is matched to my_var_colors to allow control of color labels. If an empty list is provided, elements are matched to colors in order by factor levels (if a factor) or based on first appearance in the design object. If the variable is numeric, should be an integer providing the number of intervals to split the variable into (defaults to 10).

norm.method

name of the function to be used in normalizing the gene expression values in each row. Defaults to "range01", which normalizes each row to extend from 0 to 1. Can be any function that returns a numeric vector of the same length as its argument. Passed to match.fun. To use counts without normalization, use NULL or "identity".

scale

alternative method for normalizing counts. Passed to heatmap3. Defaults to "none", to allow control via norm.method. Can be "row" or "column", specifying centering and scaling over rows or columns. Use in combination with norm.method may yield unexpected results.

row_dendro, col_dendro

variables that specify the row and/or columns dendrogram(s). Set to NA to suppress dendrograms. if order_by_var is specified, col_dendro is ignored.

filename

a character string. If provided, the function outputs a pdf of the plot, named "filename.pdf". If not provided, the function prints to a plotting window.

plotdims

a numeric vector, the width and height (in inches) of the plotting object. Either the size of the pdf, or the size of the plotting window.

my_heatmap_cols

a vector of color names, typically the result of a call to colorRampPalette. If not provided, the "RdBu" palette from RColorBrewer is used.

add_legend

logical, whether to add a legend for the coloring of sample labels. If samples are colored by more than one variable, legends are output as separate plots. Defaults to FALSE.

leg_x, leg_y

x- and y-coordinates for the plot location of the legend for non-numeric variables. As the coordinates of heatmap3 vary with the data set, the defaults may not provide a good location. Used only if color_by_var has length 1.

xl, xr, yb, yt

x- and y-coordinates for the left, right, bottom, and top boundaries of the legend for numeric variables. As the coordinates of heatmap3 vary with the data set, the defaults may not provide a good location. Used only if color_by_var has length 1.

...

(optional) additional arguments passed to heatmap3.


BenaroyaResearch/limmaTools documentation built on Dec. 17, 2021, 10:49 a.m.