#!/bin/tcsh

set data_table=${1}
set out_prefix=${2}
cat > makeplot.R <<EOF
 library(marray)
 SPDB_mutent <- read.table("${data_table}")
 pdf("${out_prefix}_unclustered.pdf",width=48,height=48)
 heatmap(as.matrix(SPDB_mutent), col=maPalette(low="white",mid="blue",high="red"), add = FALSE, xaxs = "i", yaxs = "i", xaxt = "n", yaxt = "n", Rowv = NA, Colv = NA, cexRow=1.05, cexCol=1.05, oldstyle=FALSE,symm = TRUE)
 dev.off()

pdf("${out_prefix}_clustered.pdf",width=48,height=48)
heatmap(x=as.matrix((SPDB_mutent)),zlim=c(0,max(SPDB_mutent)*1.0), col = maPalette(low = "white", mid = "blue", high = "red", k =50),     add = FALSE, xaxs = "i", yaxs = "i",xaxt= "n", yaxt = "n", reorderfun = function(d,w) rev(reorder(d,w)),revC=TRUE, cexRow=0.8,  cexCol=0.8,      oldstyle = FALSE,symm=TRUE )
dev.off()

EOF


cat makeplot.R | R --no-save

#END



