heatmapArrange: heatmapArrange

Description Usage Arguments Value Examples

View source: R/heatmapArrange.R

Description

A function to take a matrix/dataframe of gene expression data and return a dataframe suitable for plotting as a heatmap with ggplot2

Usage

1
2
heatmapArrange(data_in, cluster_row = FALSE, cluster_column = FALSE,
  scale = TRUE, by_row = TRUE)

Arguments

data_in

is a dataframe of gene expression data

cluster_row

A logical value for whether row clustering is performed

cluster_column

A logical value for whether column clustering is performed

scale

A logical value for whether scaling is performed

by_row

A logical value for whether scaling is performed by row (TRUE) of column (FALSE)

Value

A dataframe compatible with ggplot2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
mtx <- matrix(rnorm(mean = 7, n = 90), ncol = 10) 
row.names(mtx) <- LETTERS[1:9]
colnames(mtx) <- c(paste0("X", 1:5), paste0("Y", 1:5))
#add in some differential expression 
mtx[,6:10] <- mtx[,6:10] + 3

#Arrange and cluster data for heatmap plotting via ggplot2
hm_dfr <- heatmapArrange(mtx, 
                         cluster_row = TRUE,
                         cluster_column = FALSE,
                         scale = TRUE,
                         by_row = TRUE
) 

library(ggplot2)
ggplot(hm_dfr, aes(x = col_var, y  = row_var, fill = value)) +
    geom_tile() +
    scale_fill_gradient2(high = '#d73027', mid = 'black', low = '#1a9850')

abc-igmm/transcripTools documentation built on May 20, 2019, 3:05 p.m.