DependsR(>=2.0)DescriptionApackagefordrawingprettyheatmapsinR.Theordinary
heatmapfunctioninRhasseveraldrawbackswhenitcomestoproducingpublicationqualityheatmaps.Itishardtoproducepictureswithconsistenttext,cellandoverallsizesand
shapes.Thefunctionpheatmaptriestoalleviatetheproblems
byofferingmorefinegrainedcontroloverheatmapdimensionsandappearance.ImportsgridLicenseGPL-2LazyLoadyes
Collate’pheatmap-package.r’’pheatmap.r’RepositoryCRAN
Date/Publication2012-09-1412:07:21
Rtopicsdocumented:
pheatmap-package.....................................pheatmap..........................................
Index
1
226
2pheatmap
pheatmap-packagePrettyheatmaps
Description
ThepackagefordrawingprettyheatmapsinR.TheordinaryheatmapfunctioninRhasseveraldrawbackswhenitcomestoproducingpublicationqualityheatmaps.Itishardtoproducepictureswithconsistenttext,cellandoverallsizes.Thefunctionpheatmaptriestoalleviatetheproblemsbyofferingmorefinegrainedcontroloverheatmapdimensionsandappearance.
pheatmapAfunctiontodrawclusteredheatmaps.
Description
Afunctiontodrawclusteredheatmapswhereonehasbettercontroloversomegraphicalparameterssuchascellsize,etc.Usage
pheatmap(mat,
color=colorRampPalette(rev(c(\"#D7327\\"#FC8D59\\"#FEE9\\"#FFFFBF\\"#EF3F8\\"#91BFDB\kmeans_k=NA,breaks=NA,border_color=\"grey6\cellwidth=NA,cellheight=NA,scale=\"none\cluster_rows=TRUE,cluster_cols=TRUE,clustering_distance_rows=\"euclidean\clustering_distance_cols=\"euclidean\clustering_method=\"complete\
treeheight_row=ifelse(cluster_rows,5,),treeheight_col=ifelse(cluster_cols,5,),
legend=TRUE,legend_breaks=NA,legend_labels=NA,annotation=NA,annotation_colors=NA,
annotation_legend=TRUE,drop_levels=TRUE,show_rownames=T,show_colnames=T,main=NA,fontsize=1,fontsize_row=fontsize,
fontsize_col=fontsize,display_numbers=F,number_format=\"%.2f\
fontsize_number=.8*fontsize,filename=NA,width=NA,height=NA,...)Arguments
matcolor
numericmatrixofthevaluestobeplotted.vectorofcolorsusedinheatmap.
pheatmap
kmeans_kbreaks
3
thenumberofkmeansclusterstomake,ifwewanttoagggregatetherowsbeforedrawingheatmap.IfNAthentherowsarenotaggregated.
asequenceofnumbersthatcoverstherangeofvaluesinmatandisoneelementlongerthancolorvector.Usedformappingvaluestocolors.Useful,ifneededtomapcertainvaluestocertaincolors,tocertainvalues.IfvalueisNAthenthebreaksarecalculatedautomatically.
colorofcellbordersonheatmap,useNAifnobordershouldbedrawn.individualcellwidthinpoints.IfleftasNA,thenthevaluesdependonthesizeofplottingwindow.
individualcellheightinpoints.IfleftasNA,thenthevaluesdependonthesizeofplottingwindow.
characterindicatingifthevaluesshouldbecenteredandscaledineithertherowdirectionorthecolumndirection,ornone.Correspondingvaluesare\"row\",\"column\"and\"none\"
booleanvaluesdeterminingifrowsshouldbeclustered,
border_colorcellwidthcellheightscale
cluster_rows
cluster_colsbooleanvaluesdeterminingifcolumnsshouldbeclustered.clustering_distance_rows
distancemeasureusedinclusteringrows.Possiblevaluesare\"correlation\"
forPearsoncorrelationandallthedistancessupportedbydist,suchas\"euclidean\",etc.Ifthevalueisnoneoftheaboveitisassumedthatadistancematrixispro-vided.
clustering_distance_cols
distancemeasureusedinclusteringcolumns.Possiblevaluesthesameasforclustering_distance_rows.
clustering_method
clusteringmethodused.Acceptsthesamevaluesashclust.treeheight_rowtheheightofatreeforrows,iftheseareclustered.Defaultvalue50points.treeheight_coltheheightofatreeforcolumns,iftheseareclustered.Defaultvalue50points.legendlegend_breakslegend_labelsannotation
logicaltodetermineiflegendshouldbedrawnornot.vectorofbreakpointsforthelegend.vectoroflabelsforthelegend_breaks.
dataframethatspecifiestheannotationsshownontopofthecolumns.Eachrowdefinesthefeaturesforaspecificcolumn.Thecolumnsinthedataandrowsintheannotationarematchedusingcorrespondingrowandcolumnnames.Notethatcolorschemestakesintoaccountifvariableiscontinuousordiscrete.
annotation_colors
listforspecifyingannotationtrackcolorsmanually.Itispossibletodefinethecolorsforonlysomeofthefeatures.Checkexamplesfordetails.
annotation_legend
booleanvalueshowingifthelegendforannotationtracksshouldbedrawn.drop_levelsshow_rownamesshow_colnames
logicaltodetermineifunusedlevelsarealsoshowninthelegendbooleanspecifyingifcolumnnamesarebeshown.booleanspecifyingifcolumnnamesarebeshown.
4
mainfontsizefontsize_row
thetitleoftheplotbasefontsizefortheplot
fontsizeforrownames(Default:fontsize)
pheatmap
fontsize_colfontsizeforcolnames(Default:fontsize)display_numbers
logicaldeterminingifthenumericvaluesarealsoprintedtothecells.number_format
formatstrings(Cprintfstyle)ofthenumbersshownincells.Forexample\"%.2f\"shows2decimalplacesand\"%.1e\"showsexponentialnotation(seemoreinsprintf).
fontsizeofthenumbersdisplayedincells
filename
filepathwheretosavethepicture.Filetypeisdecidedbytheextensioninthepath.Currentlyfollowingformatsaresupported:png,pdf,tiff,bmp,jpeg.Eveniftheplotdoesnotfitintotheplottingwindow,thefilesizeiscalculatedsothattheplotwouldfitthere,unlessspecifiedotherwise.manualoptionfordeterminingtheoutputfilewidthinmanualoptionfordeterminingtheoutputfileheightininches.
graphicalparametersforthetextusedinplot.Parameterspassedtogrid.text,seegpar.
fontsize_number
widthheight...
Details
Thefunctionalsoallowstoaggregatetherowsusingkmeansclustering.ThisisadvisableifnumberofrowsissobigthatRcannothandletheirhierarchicalclusteringanymore,roughlymorethan1000.Insteadofshowingalltherowsseparatelyonecanclustertherowsinadvanceandshowonlytheclustercenters.Thenumberofclusterscanbetunedwithparameterkmeans_k.Value
Invisiblyalistofcomponents
•tree_rowtheclusteringofrowsashclustobject•tree_coltheclusteringofcolumnsashclustobject
•kmeansthekmeansclusteringofrowsifparameterkmeans_kwasspecified
Author(s)
RaivoKoldeExamples#Generatesomedata
test=matrix(rnorm(2),2,1)
test[1:1,seq(1,1,2)]=test[1:1,seq(1,1,2)]+3test[11:2,seq(2,1,2)]=test[11:2,seq(2,1,2)]+2test[15:2,seq(2,1,2)]=test[15:2,seq(2,1,2)]+4colnames(test)=paste(\"Test\1:1,sep=\"\")
pheatmap
rownames(test)=paste(\"Gene\1:2,sep=\"\")
#Drawheatmapspheatmap(test)
pheatmap(test,kmeans_k=2)
pheatmap(test,scale=\"row\clustering_distance_rows=\"correlation\")
pheatmap(test,color=colorRampPalette(c(\"navy\\"white\\"firebrick3\"))(5))pheatmap(test,cluster_row=FALSE)pheatmap(test,legend=FALSE)
pheatmap(test,display_numbers=TRUE)
pheatmap(test,display_numbers=TRUE,number_format=\"%.1e\")
pheatmap(test,cluster_row=FALSE,legend_breaks=-1:4,legend_labels=c(\"\\"1e-4\\"1e-3\\"1e-2\\"1e-1\\"1\"))
pheatmap(test,cellwidth=15,cellheight=12,main=\"Exampleheatmap\")
pheatmap(test,cellwidth=15,cellheight=12,fontsize=8,filename=\"test.pdf\")
5
#Generatecolumnannotations
annotation=data.frame(Var1=factor(1:1\\%\\%2==,labels=c(\"Class1\\"Class2\")),Var2=1:1)annotation$Var1=factor(annotation$Var1,levels=c(\"Class1\\"Class2\\"Class3\"))rownames(annotation)=paste(\"Test\1:1,sep=\"\")
pheatmap(test,annotation=annotation)
pheatmap(test,annotation=annotation,annotation_legend=FALSE)
pheatmap(test,annotation=annotation,annotation_legend=FALSE,drop_levels=FALSE)#Specifycolors
Var1=c(\"navy\\"darkgreen\")
names(Var1)=c(\"Class1\\"Class2\")Var2=c(\"lightgreen\\"navy\")
ann_colors=list(Var1=Var1,Var2=Var2)
pheatmap(test,annotation=annotation,annotation_colors=ann_colors,main=\"Examplewithallthefeatures\")#Specifyingclusteringfromdistancematrixdrows=dist(test,method=\"minkowski\")dcols=dist(t(test),method=\"minkowski\")
pheatmap(test,clustering_distance_rows=drows,clustering_distance_cols=dcols)
Index
dist,3gpar,4
grid.text,4hclust,3,4
pheatmap,2
pheatmap-package,2sprintf,4
6