[6d0c6b]: / heatmap_scripts / heatmap_saliency.R

Download this file

73 lines (51 with data), 1.8 kB

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