Heatmap plot
Jump to navigation
Jump to search
setwd("/media/NAS3_volume2/shg047/Alice") heatMap<-function(data){ # note: this function include correlation based heatmap (pearson or spearman) # data: row is gene and column is sample # colname and rowname cannot be NULL # Usage example: # test<- matrix(runif(100),nrow=20) # colnames(test)=c("A","A","A","B","B") # rownames(test)=paste("Gene",1:20,sep="") # HeatMap(test) library("gplots") colors <- colorpanel(75,"midnightblue","mediumseagreen","yellow") colors <-bluered(75) sidecol<-function(x){ x<-as.numeric(as.factor(x)) col<-rainbow(length(table(x))) sapply(x,function(x) col[x]) } Hclust=function(x){hclust(x,method="complete")} #Distfun=function(x){as.dist((1-cor(t(x),method = "pearson")^2))} ColSideColors=sidecol(colnames(data)) Heatmap<-heatmap.2(data,trace="none", hclust=Hclust, cexRow = 1, cexCol = 1, ColSideColors=ColSideColors, density.info="none",col=colors, Colv=T,Rowv = TRUE, keysize=0.9, margins = c(10, 10) ) return(Heatmap) } data1<-read.table("PluDiff_allsample.txt",head=T,sep = "\t",row.names=1) colnames(data1)[grep("ips",colnames(data1))]="iPS" colnames(data1)[grep("NT",colnames(data1))]="SCNT" Heatmap<-heatMap(data.matrix(data1)) save.image(file = "heatmap.scRNA.alice.RData")