View source: R/heatmap.ggplot.R
heatmap.ggplot2 | R Documentation |
heatmap.ggplot2
is the main function to draw and/or save the heatmap from an
expression set object
heatmap.ggplot2(
eSet,
brewer.pal.name = "RdBu",
brewer.pal.rev = TRUE,
brewer.numColors = 11,
col.legend.brewer = "",
row.legend.brewer = "",
col.clust = TRUE,
row.clust = TRUE,
col.clust.hc = NA,
row.clust.hc = NA,
col.lab = "",
row.lab = "",
heatmap.y.text = FALSE,
heatmap.x.text = FALSE,
heatmap.y.text.size = 7,
heatmap.x.text.size = 6,
heatmap.colorlegend.name = "val",
title.text = "",
col.legend.name = "",
row.legend.name = "",
legend.lab.max.char = 15,
row.scaling = "none",
z.norm = FALSE,
cuttree.col = 0,
cuttree.row = 0,
verbose = FALSE,
grid.heights = NA,
grid.widths = NA,
show = FALSE
)
eSet |
expression set object to plot |
brewer.pal.name |
name of colorbrewer, see options at RColorBrewer::display.brewer.all() |
brewer.pal.rev |
reverse colorbrewer (TRUE or FALSE) |
brewer.numColors |
number of colors for heatmap palette default 11 |
col.legend.brewer |
string vector of hexdecimal values for column labels, see example p3 and p4 for how to determine annotation labels and assigning colors |
row.legend.brewer |
string vector of hexdecimal values for row labels |
col.clust |
perform column-wise hierarchical clustering (TRUE or FALSE) |
row.clust |
perform row-wise hierarchical clustering (TRUE or FALSE) |
col.clust.hc |
hc object to be passed to as.dendrogram, available when col.clust = TRUE, default NA: hc.col = hcopt(stats::dist(t(x)), method="ward.D") |
row.clust.hc |
hc object to be passed to as.dendrogram, available when row.clust = TRUE, default NA: hc.row = hcopt(stats::as.dist(1-cor(t(x))),method="ward.D") |
col.lab |
column labels to include: subset of pData colnames character vector |
row.lab |
row labels to include: subset of fData colnames character vector |
heatmap.y.text |
include y axis labels for heatmap, uses rownames(eSet) (TRUE or FALSE) |
heatmap.x.text |
include x axis labels for heatmap, uses colnames(eSet)) (TRUE or FALSE) |
heatmap.y.text.size |
text size for y axis labels |
heatmap.x.text.size |
text size for x axis labels |
heatmap.colorlegend.name |
name for heatmap color legend |
title.text |
main title for the plot |
col.legend.name |
character vector for subset of col.lab to include in color legend |
row.legend.name |
character vector for subset of row.lab to include in color legend |
legend.lab.max.char |
number of characters limit for legend labels, default = 15 |
row.scaling |
how should rows be scaled ("none", "quantile", "z-score.all", or "z-score.capped") |
z.norm |
heatmap colors reflect z-scores rather than original values, can be TRUE if row.scaling is "none" |
cuttree.col |
number of clusters for columns, default 0: do not show cluster assignment |
cuttree.row |
number of clusters for rows, default 0: do not show cluster assignment |
verbose |
return additional clustred annotation information as well as heatmap |
grid.heights |
numeric vector of length 7 representing heights of subpanels, leave NA for default |
grid.widths |
numeric vector of length 4 represeting weights of subpanels, leave NA for default |
show |
prints the heatmap within execution of the function (TRUE or FALSE) |
#Use example data #1, for data set information: ?eSet1
data(eSet.brca.100)
eSet1<-eSet.brca.100
eSet1<-eSet1[1:10,1:25]
p1<-heatmap.ggplot2(eSet=eSet1, col.clust = TRUE, row.clust = TRUE,
col.clust.hc = NA, row.clust.hc = NA,
col.lab = c("HER2_status", "ER_status", "PR_status", "TN_status"), row.lab = "",
heatmap.y.text = TRUE, heatmap.x.text = TRUE,
heatmap.colorlegend.name = "RNASeq_expression",
title.text = "TCGA BRCA log2 RNA-seq expression, z-score row normalized",
col.legend.name = c("HER2_status", "ER_status", "PR_status", "TN_status"),
row.legend.name = "",
row.scaling = "z-score.capped",
z.norm = FALSE,
cuttree.col = 4, cuttree.row = 3,
verbose = FALSE, show = FALSE)
grid.arrange(p1)
x<-exprs(eSet1)
hc.row<-hcopt(stats::as.dist(1-cor(t(x))),method="ward.D")
hc.col <- hcopt(stats::dist(t(x), method = "euclidean"), method="ward.D")
#Adding custom hclust object in col.clust.hc and row.clust.hc
p2 <- heatmap.ggplot2(eSet=eSet1, col.clust = TRUE, row.clust = TRUE,
col.clust.hc = hc.col, row.clust.hc = hc.row,
col.lab = c("HER2_status", "ER_status", "PR_status", "TN_status"), row.lab = "",
heatmap.y.text = TRUE, heatmap.x.text = TRUE,
heatmap.colorlegend.name = "RNASeq_expression",
title.text = "TCGA BRCA log2 RNA-seq expression, z-score row normalized",
col.legend.name = c("HER2_status", "ER_status", "PR_status", "TN_status"),
row.legend.name = "",
row.scaling = "z-score.capped",
z.norm = FALSE,
cuttree.col = 4, cuttree.row = 3,
verbose = FALSE, show = FALSE)
grid.newpage()
grid.arrange(p2)
#Saving plot in verbose format
p3 <- heatmap.ggplot2(eSet=eSet1, col.clust = TRUE, row.clust = TRUE,
col.clust.hc = hc.col, row.clust.hc = hc.row,
col.lab = c("HER2_status", "ER_status", "PR_status", "TN_status"), row.lab = "",
heatmap.y.text = TRUE, heatmap.x.text = TRUE,
heatmap.colorlegend.name = "RNASeq_expression",
title.text = "TCGA BRCA log2 RNA-seq expression, z-score row normalized",
col.legend.name = c("HER2_status", "ER_status", "PR_status", "TN_status"),
row.legend.name = "",
row.scaling = "z-score.capped",
z.norm = FALSE,
cuttree.col = 4, cuttree.row = 3,
verbose = TRUE, show = FALSE)
grid.newpage()
grid.arrange(p3$heatmap)
#Adding custom colors to column and row annotation labels
print(p3$meta.c$id)
meta.c.color.string<-c("yellow", "khaki3", "gold", "chocolate", "darkred", "cyan")
meta.c.color<-as.character(sapply(meta.c.color.string, to.hex))
names(meta.c.color)<-c("Negative", "Positive", "1", "2", "3", "4")
print(p3$meta.r$id)
meta.r.color.string<-c("pink", "azure", "green")
meta.r.color<-as.character(sapply(meta.r.color.string, to.hex))
names(meta.r.color)<-c("1", "2", "3")
p4<-heatmap.ggplot2(eSet=eSet1,
col.legend.brewer = meta.c.color,
row.legend.brewer = meta.r.color,
col.clust = TRUE, row.clust = TRUE,
col.clust.hc = hc.col, row.clust.hc = hc.row,
col.lab = c("HER2_status", "ER_status", "PR_status", "TN_status"), row.lab = "cluster.row",
heatmap.y.text = TRUE, heatmap.x.text = TRUE,
heatmap.colorlegend.name = "RNASeq_expression",
title.text = "TCGA BRCA log2 RNA-seq expression, z-score row normalized",
col.legend.name = c("HER2_status", "ER_status", "PR_status", "TN_status", "cluster.col"),
row.legend.name = "cluster.row",
row.scaling = "z-score.capped",
z.norm = FALSE,
cuttree.col = 4, cuttree.row = 3,
verbose = FALSE, show = FALSE)
grid.newpage()
grid.arrange(p4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.