#[0]----------
ifname <- "DataBrandy.csv"
df<-read.delim(ifname,header=T,sep=",",row.names=1,as.is=TRUE,strip.white=FALSE)
mat<-as.matrix(df)
sum1 <- apply(mat,1,mean,na.rm=TRUE) # average of the row vectors
sum2 <- apply(mat,2,mean,na.rm=TRUE) # average of the column vectors
mat<- scale(mat) #normalization for column vectors
#[1]-----------
d_row <- dist(  mat , method="euclidian") # distance matrix for row vectors
d_col <- dist(t(mat), method="euclidian") # distance matrix for column vectors
hc_row <- hclust(d_row,method="ward.D2") # hierarchical clustering for row vectors
hc_col <- hclust(d_col,method="ward.D2") # hierarchical clustering for column vectors
dd_row<- as.dendrogram(hc_row) # dendrogram for row vectors
dd_col<- as.dendrogram(hc_col) # dendrogram for column vectors
dd_row.reorder <- reorder(dd_row,order(sum1)) #reorder of row vectors by sum1 
dd_col.reorder <- reorder(dd_col,order(sum2)) #reorder of column vectors by sum2
#[2]-------------------------------------------------------------------------------
my.col1 <- colorRampPalette(c("red","white","skyblue","blue")) #pallet definition 
heatmap(mat,col=my.col1(100),scale="none",Rowv=dd_row.reorder,Colv=dd_col.reorder)
#[3]:developed by Ono sensei ------------------------------------------------------
r100<-my.col1(100)
source("heatmap_sub.R")
heatmap_tmp(mat, dd_row.reorder, dd_col.reorder, col_mat=r100, colorbar="bottom")