-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathplotHeat.R
117 lines (97 loc) · 4.67 KB
/
plotHeat.R
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# large parts part copied from http://sebastianraschka.com/Articles/heatmaps_in_r.html
require("gplots")
require("RColorBrewer")
system("python heatFilter.py")
data <- read.delim("out/heatData.tsv", comment.char="#", check.names=FALSE)
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
# creates a 5 x 5 inch image
pdf("out/heatMap.pdf", # create PNG for the heat map
width = 5, # 5 x 300 pixels
height = 5,
pointsize = 7) # smaller font size
heatmap.2(mat_data,
#distfun=function(c) dist(c, method="euclidian"),
cellnote = mat_data, # same data set for cell labels
#hclustfun = function(x) hclust(x),
#hclustfun = function(x) hclust(x,method = 'ward.D'),
#hclustfun = function(x) hclust(x,method = 'ward.D2'),
#hclustfun = function(x) hclust(x,method = 'centroid'),
#hclustfun = function(x) hclust(x,method = 'median'),
#hclustfun = function(x) hclust(x,method = 'average'),
#hclustfun = function(x) hclust(x,method = 'mcquitty'),
#hclustfun = function(x) hclust(x,method = 'complete'),
#hclustfun = function(x) hclust(x,method = 'single'),
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
margins =c(14,16), # widens margins around plot
keysize = 0.8,
cexRow=1.1,
cexCol=1.1,
#lmat = lmat,
#lwid = lwid, lhei = lhei,
#dendrogram="row", # only draw a row dendrogram
dendrogram='none', Rowv=FALSE, # remove the row reordering and dendrogram
Colv="NA") # turn off column clustering
dev.off() # close the PNG device
system("convert -density 300 -quality 100 out/heatMap.pdf out/heatMap.png")
print("output written to out/heatMap.png and .pdf")
# ----- 2ND HEAT MAP -----
system("python heatFilter.py part2")
data <- read.delim("out/heatData.tsv", comment.char="#", check.names=FALSE)
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
# creates a 5 x 5 inch image
pdf("out/heatMap-part2.pdf", # create PNG for the heat map
width = 5, # 5 x 300 pixels
height = 3,
pointsize = 7) # smaller font size
heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
dendrogram='none', Rowv=FALSE, # remove the row reordering and dendrogram
hclustfun = function(x) hclust(x,method = 'single'),
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
margins =c(14,14), # widens margins around plot
#keysize = 0.8,
cexRow=0.8,
cexCol=0.8,
#lmat = lmat,
#lwid = lwid, lhei = lhei,
Colv="NA") # turn off column clustering
dev.off() # close the PNG device
system("convert -density 300 -quality 100 out/heatMap-part2.pdf out/heatMap-part2.png")
print("output written to out/heatMap-part2.png and .pdf")
# ----- PART 3 ---- for suppl fig
system("python heatFilter.py part3")
data <- read.delim("out/heatData.tsv", comment.char="#", check.names=FALSE)
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
# creates a 5 x 5 inch image
pdf("out/heatMap-part3.pdf", # create PNG for the heat map
width = 7, # 5 x 300 pixels
height = 6,
pointsize = 7) # smaller font size
heatmap.2(mat_data,
cellnote = mat_data, # same data set for cell labels
dendrogram='none', Rowv=FALSE, # remove the row reordering and dendrogram
hclustfun = function(x) hclust(x,method = 'single'),
notecol="black", # change font color of cell labels to black
density.info="none", # turns off density plot inside color legend
trace="none", # turns off trace lines inside the heat map
margins =c(14,14), # widens margins around plot
#keysize = 0.8,
cexRow=0.8,
cexCol=0.8,
key = FALSE,
#lmat = lmat,
#lwid = lwid, lhei = lhei,
Colv="NA") # turn off column clustering
dev.off() # close the PNG device
system("convert -density 300 -quality 100 out/heatMap-part3.pdf out/heatMap-part3.png")
print("output written to out/heatMap-part3.png and .pdf")