a b/heatmap_scripts/heatmap_mutation.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 <- colorRampPalette(c("blue","red"))(n = 500)
34
# colors = c(seq(-1,0,length=100),seq(0.001,1,length=100)) # for yellow\
35
36
color_map <- bluered
37
# color_map <- colorRampPalette(c("white","red"))(n = 39)
38
39
40
41
png(file = args[2], units="in", width=11, height=8.5, res=300)
42
43
heatmap.2(t(mat_data),
44
    # cellnote = t(mat_data),
45
    Rowv=NULL,
46
    Colv="NA",
47
    srtCol=0,
48
    labRow = "",
49
    col = color_map,
50
  breaks = colors,
51
    scale="none",
52
    margins=c(3,0), # ("margin.Y", "margin.X")
53
    trace='none',
54
    symkey=FALSE,
55
    symbreaks=FALSE,
56
    dendrogram='none',
57
    offsetCol = offset,
58
    cexCol=0.9,
59
  key=FALSE, #change to turn on
60
  density.info=NULL,
61
  denscol="black",
62
    keysize=1,
63
  #( "bottom.margin", "left.margin", "top.margin", "left.margin" )
64
  key.par=list(mar=c(3.5,0,3,0)),
65
  # lmat -- added 2 lattice sections (5 and 6) for padding
66
  lmat=rbind(c(5, 4, 2), c(6, 1, 3)), lhei=c(2.5, 5), lwid=c(1, 10, 1)
67
  )
68
69
70
71
dev.off()