An improved heatmap package. Completely compatible with the original R function 'heatmap', and provides more powerful and convenient features.
install.packages("heatmap3")
# Example #
After you have installed heatmap3 package. You can enter R and use following R codes to see the examples for it.
#Load heatmap3 package
library(heatmap3)
#View help files
?heatmap3
#The examples of heatmap3 and other functions
example(heatmap3)
example(showLegend)
example(showAnn)
example(colByValue)
# Reproduce the figures #
We used the TCGA BRCA data to generate two example figures, which were used in our paper.
First you will need to download the count data. We generate the count data based on the TCGA BRCA samples. You can use the following codes in Linux system to download the count data. Or you can download it in github release page.
wget https://github.com/slzhao/heatmap3/releases/download/example/allSample_edgeR_result.csv
wget https://github.com/slzhao/heatmap3/releases/download/example/BRCA_30Samples.csv
wget https://github.com/slzhao/heatmap3/releases/download/example/BRCA_30Samples_clinic.csv
Here are the R codes to generate the figures.
#Assume you have already installed heatmap3 package. And the 3 example file were download in current working directory. You can use the following codes in R to generate the figures.
#Prepare expression data
counts<-read.csv("BRCA_30Samples.csv",header=T,row.names=1)
#Prepare column side annotation
clinic<-read.csv("BRCA_30Samples_clinic.csv",header=T,row.names=1)
#Prepare row side color bar annotation
edgeR_result<-read.csv("allSample_edgeR_result.csv",header=T,row.names=1)
temp1<-(edgeR_result$logFC)
temp2<--log10(edgeR_result$FDR)
temp1<-colByValue(as.matrix(temp1),range=c(-4,4),col=colorRampPalette(c('chartreuse4','white','firebrick'))(1024))
temp2<-colByValue(as.matrix(temp2),range=c(0,5),col=heat.colors(1024))
colGene<-cbind(temp1,temp2)
row.names(colGene)<-row.names(edgeR_result)
colnames(colGene)<-c("log2FC","-Log10P")
#Generate Figure1
#counts, colGene and clinic were read throught the csv file
##Assume counts has counts information for each gene, colGene has the colors for each gene, clinic has the clinic information for each sample
temp<-apply(counts,1,sd)
selectedGenes<-rev(order(temp))[1:500]
heatmap3(counts[selectedGenes,],labRow="",margin=c(7,0),RowSideColors=colGene[selectedGenes,],ColSideCut=0.85,ColSideAnn=clinic,ColSideFun=function(x) showAnn(x),ColSideWidth=1.2,balanceColor=T)
#Generate Figure2
heatmap3(counts,topN=c(500,3000,nrow(counts)),Rowv=NA,labRow="",margin=c(7,0),RowSideColors=colGene,ColSideCut=0.85,ColSideAnn=clinic,ColSideFun=function(x) showAnn(x),ColSideWidth=1.2,balanceColor=T)
Here is the environment (including the version of packages).
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] heatmap3_1.0.3
loaded via a namespace (and not attached):
[1] fastcluster_1.1.13 tools_3.0.2
2015-04-06 heatmap3 1.1.1: Fixed a bug (method parameter now works in both row and column cluster); Documents and examples were improved.
2014-12-15 heatmap3 1.1.0: Fixed a bug.
2014-10-14 heatmap3 1.0.9: lasRow and lasCol parameters were used to specific style of axis labels.
2014-08-29 heatmap3 1.0.8: highlightCell parameter was used to highlight specific cells by rectangles with specific colors. Fixed a bug.
2014-08-28 heatmap3 1.0.7: colorCell parameter was used to color specific cells by specific colors.
2014-08-08 heatmap3 1.0.6: Fixed a bug.
2014-07-17 heatmap3 1.0.5: Fixed a bug.
2014-06-10 heatmap3 1.0.4: Fixed some Notes in check.
2014-06-07 heatmap3 1.0.3: Examples were improved and tested. Documents were improved.
2014-05-23 heatmap3 1.0.2: Documents were improved and fixed a bug.
2014-05-20 heatmap3 1.0.1: New features and parameters: ColSideAnn, ColSideFun, ColSideCut, ColSideWidth.
2014-03-06 heatmap3 1.0.0: Documents were improved.
2013-10-30 heatmap3 0.1.6: Some parameters were modified. Released for test.
2013-10-08 heatmap3 0.1.5: Updated new features and fixed a bug. New parameters balanceColor, ColSideLabs and RowSideLabs were supported.
2013-09-30 heatmap3 0.1.0: First version for test.