forked from CahanLab/CellNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewHm.R
45 lines (39 loc) · 1.11 KB
/
newHm.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
newHm <- function
### heatmap of the classification result
(cnRes,
### cellnet result
isBig=FALSE
### is this a big heatmap
){
classMat<-cnRes$classRes
## SORT BY TISSUE TYPE
classMat = classMat[,order(colnames(classMat))]
## MAP COLOR TO TISSUE TYPE
columns = unique(colnames(classMat))
counts = list()
for(i in 1:length(columns)) {
counts[[i]] = length(which(colnames(classMat) == columns[[i]]))
}
annotation_col = data.frame(TissueType = factor(rep(columns, counts)))
ann_colors = list(c(columns = rainbow(length(columns))))
##
colnames(classMat) = rownames(annotation_col)
cools<-colorRampPalette(c("black", "limegreen", "yellow"))( 100 )
bcol<-'white';
if(isBig){
bcol<-NA;
}
# GENERATE HEATMAP
pheatmap(classMat,
col=cools,
border_color=bcol,
cluster_rows = FALSE,
cluster_cols = FALSE,
show_colnames = FALSE,
annotation_col = annotation_col,
annotation_colors = ann_colors,
)
##library(grid)
##grid.ls(grid.force())
##grid.gedit("col_annotation", gp = gpar(col="grey70"))
}