-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path03.our.data.heatmap.R
63 lines (42 loc) · 2.22 KB
/
03.our.data.heatmap.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
#--- heatmap for clones from pre- and post-ICB responsive tumors
cd8.clone.post.filt <- ScaleData(cd8.clone.post, do.center = T, do.scale = T)
tibble(cell = colnames(cd8.clone.post.filt), type = cd8.clone.post.filt$type) %>%
dplyr::arrange(type) %>%
dplyr::mutate(cellid = stringr::str_sub(cell, -18, -1)) %>%
dplyr::arrange(desc(type), desc(cellid)) -> tmp.rank
use.genes <- c("CXCL13","CTLA4","PDCD1","ENTPD1","LAG3","LAYN","TIGIT","BATF","HAVCR2","TNFRSF9","GZMB","CCL5","BAG3")
tmp.matr <- cd8.clone.post.filt@[email protected][use.genes,tmp.rank$cell]
colnames(tmp.matr) <- NULL
tmp.matr[tmp.matr < -2] <- -2
tmp.matr[tmp.matr > 3.5] <- 3.5
ha = HeatmapAnnotation(
type = tmp.rank$type,
col = list(
cluster = c("Tex" = "#CD853F","nonTex" = "#009ACD")),
simple_anno_size = unit(0.4, "cm")
)
ComplexHeatmap::Heatmap(tmp.matr, cluster_columns = F, cluster_rows = F,
col = rev(RColorBrewer::brewer.pal(11,"RdBu")),
top_annotation = ha)
#--- heatmap for clones from pre- and post-ICB responsive tumors
cd8.clone.pre.scale <- ScaleData(cd8.clone.pre, do.center = T, do.scale = T)
cd8.clone.pre.scale <- cd8.clone.pre.scale[,cd8.clone.pre.scale$clone.id %in% pre.data$clone]
cd8.clone.pre.scale$type = ifelse(cd8.clone.pre.scale$clone.id %in% pre.data$clone[pre.data$group == "Tex"], "Tex", "nonTex")
Idents(cd8.clone.pre.scale) <- cd8.clone.pre.scale$type
tibble(cell = colnames(cd8.clone.pre.scale), type = cd8.clone.pre.scale$type) %>%
dplyr::arrange(desc(type)) %>%
dplyr::mutate(cellid = stringr::str_sub(cell, -18, -1)) -> tmp.rank
use.genes <- c("CXCL13","CTLA4","PDCD1","ENTPD1","LAG3","LAYN","TIGIT","BATF","HAVCR2","TNFRSF9","GZMB","CCL5","BAG3")
tmp.matr <- cd8.clone.pre.scale@[email protected][use.genes,tmp.rank$cell]
colnames(tmp.matr) <- NULL
tmp.matr[tmp.matr < -2.5] <- -2.5
tmp.matr[tmp.matr > 3.5] <- 3.5
ha = HeatmapAnnotation(
type = tmp.rank$type,
col = list(
cluster = c("Tex" = "#CD853F","nonTex" = "#009ACD")),
simple_anno_size = unit(0.4, "cm")
)
ComplexHeatmap::Heatmap(tmp.matr, cluster_columns = F, cluster_rows = F,
col = rev(RColorBrewer::brewer.pal(11,"RdBu")),
top_annotation = ha)