R Script: heatmap plot demo

Approx. CPU requirement: seconds
Description:

This demo script performs hiwerarchical clustering by genes or samples, then plots a heatmap. In either case, each data column is transformed to Z-scores (ie normalized by the column mean and standard deviation) before clustering. The input file is a comma-separated values (CSV) file (eg from Excel) with row and column labels: one sample per row, one gene per colum.


Source code:


   1  myData	<- as.matrix(read.table(inFile,header=TRUE,sep=",",row.names=1))
   2  if (clusterBy=="genes") myData	<- t(myData)
   3  myData	<- sweep(myData,1,apply(myData,1,mean),"-")
   4  myData	<- sweep(myData,1,apply(myData,1,sd),"/")
   5  library(hopach)
   6  hopachOutput <- hopach(data=myData,d="cor")
   7  orderedList=(as.integer(hopachOutput$final$labels[hopachOutput$final$order]))
   8  names(orderedList)=row.names(myData)[hopachOutput$final$order]
   9  library(RColorBrewer)
  10  library(gplots)
  11  #<crdata_image>
  12  print(heatmap.2(myData[,dim(myData)[2]:1],col=brewer.pal(11,"RdYlGn"), trace="none", dendrogram="row",	
  13  			scale="column",Colv=FALSE,Rowv=TRUE,key=TRUE, margins=c(10,10)))
  14  #</crdata_image>



Ratings by Hamid Bolouri:

Speed of Execution:
  • Your rating: 5 out of 5
  • 5
  • 5
  • 5
  • 5
  • 5
Ease of Use:
  • Your rating: 4 out of 5
  • 4
  • 4
  • 4
  • 4
  • 4
Reliability of Results:
  • Your rating: 5 out of 5
  • 5
  • 5
  • 5
  • 5
  • 5
Quality of Docs:
  • Your rating: 3 out of 5
  • 3
  • 3
  • 3
  • 3
  • 3

Comment:
my example ratings

example



Back