HEATMAP.R and this AUTOMATED code should be in same directory.
Change ROWS and COLUMNS according to your xls or csv file in this automated heatmap code.
setwd("/home/student/test/testing")
heat<-function() source("HEATMAP.R")
a<-list.files(pattern="txt$")
file=array(c(a))
filename=array(c("genus1.0.6.txt","genus1.0.7.txt","genus1.0.8.txt","genus1.0.9.txt","genus.0.6.txt","genus.0.7.txt","genus.0.8.txt","genus.0.9.txt"))
heatmapname=array(c("Set1_0.6.png","Set1_0.7.png","Set1_0.8.png","Set1_0.9.png","Set0.6.png","Set0.7.png","Set0.8.png","Set0.9.png"))
for(x in 1:dim(file))
{
genus<-as.matrix(read.table(file[x]))
ratio.genus=genus
for(row in 11:dim(genus)[1])
{
for(col in 2:dim(genus)[2])
{
if(as.numeric(genus[row,col])==0)
{
next;
}
if(as.numeric(genus[row,col])!=0)
{
a=(as.numeric(genus[row,col]))/(as.numeric(genus[10,col]))
ratio.genus[row,col]=a
}
}
}
write.table(ratio.genus,file=filename[x],append=TRUE,row.names=FALSE,col.names=FALSE,quote=FALSE,eol="\n",sep="\t")
ratio.genus=0
heat()
}
No comments:
Post a Comment