|
a |
|
b/heatmap_scripts/heatmap_saliency.R |
|
|
1 |
library(gplots) |
|
|
2 |
library(RColorBrewer) |
|
|
3 |
|
|
|
4 |
args <- commandArgs(trailingOnly = TRUE) |
|
|
5 |
# print(args[1]) |
|
|
6 |
# print(args[2]) |
|
|
7 |
|
|
|
8 |
|
|
|
9 |
######################################################### |
|
|
10 |
### reading in data and transform it to matrix format |
|
|
11 |
######################################################### |
|
|
12 |
|
|
|
13 |
data <- read.csv(args[1], comment.char="#") |
|
|
14 |
rnames <- data[,1] # assign labels in column 1 to "rnames" |
|
|
15 |
mat_data <- data.matrix(data[,2:ncol(data)]) # transform column 2-5 into a matrix |
|
|
16 |
rownames(mat_data) <- rnames # assign row names |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
######################################################### |
|
|
21 |
### customizing and plotting heatmap |
|
|
22 |
######################################################### |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
offset <- -13 |
|
|
26 |
offset <- -40 |
|
|
27 |
offset <- -10 |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
colors=NULL |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
color_map <- bluered |
|
|
34 |
color_map <- colorRampPalette(c("white","red"))(n = 39) |
|
|
35 |
|
|
|
36 |
# colors = c(seq(0,0.5,length=20),seq(0.501,1,length=20)) #TODO change for certain graphs |
|
|
37 |
|
|
|
38 |
# color_map <- colorRampPalette(c("white","red"))(n = 39) |
|
|
39 |
# # colors = c(seq(0,0.05,length=20),seq(0.501,1,length=20)) #TODO change for certain graphs |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
png(file = args[2], units="in", width=11, height=8.5, res=300) |
|
|
43 |
|
|
|
44 |
heatmap.2(t(mat_data), |
|
|
45 |
# cellnote = t(mat_data), |
|
|
46 |
Rowv=NULL, |
|
|
47 |
Colv="NA", |
|
|
48 |
srtCol=0, |
|
|
49 |
labRow = "", |
|
|
50 |
col = color_map, |
|
|
51 |
breaks = colors, |
|
|
52 |
scale="none", |
|
|
53 |
margins=c(3,0), # ("margin.Y", "margin.X") |
|
|
54 |
trace='none', |
|
|
55 |
symkey=FALSE, |
|
|
56 |
symbreaks=FALSE, |
|
|
57 |
dendrogram='none', |
|
|
58 |
offsetCol = offset, |
|
|
59 |
cexCol=0.9, |
|
|
60 |
key=FALSE, #change to turn on |
|
|
61 |
density.info=NULL, |
|
|
62 |
denscol="black", |
|
|
63 |
keysize=1, |
|
|
64 |
#( "bottom.margin", "left.margin", "top.margin", "left.margin" ) |
|
|
65 |
key.par=list(mar=c(3.5,0,3,0)), |
|
|
66 |
# lmat -- added 2 lattice sections (5 and 6) for padding |
|
|
67 |
lmat=rbind(c(5, 4, 2), c(6, 1, 3)), lhei=c(2.5, 5), lwid=c(1, 10, 1) |
|
|
68 |
) |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
dev.off() |