-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_Marker_expression_heatmap.R
More file actions
56 lines (44 loc) · 1.74 KB
/
4_Marker_expression_heatmap.R
File metadata and controls
56 lines (44 loc) · 1.74 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
################
# dependencies #
################
#library(stringr)
library(ComplexHeatmap)
library(circlize)
library(viridis)
library(dplyr)
load(paste0(results_folder,"/Cell_matrix_pre_post.RData"))
##########
# Script #
##########
cluster_expression <- all_cells_combined %>% group_by(pheno_merge) %>% summarise(across(everything(), mean), .groups = 'drop') %>%
as.data.frame()
cluster_expression <- cluster_expression %>% filter(!grepl(phenotypes_to_exclude, pheno_merge))
rownames(cluster_expression) <- cluster_expression$pheno_merge
cluster_expression = subset(cluster_expression, select = c(markers+1))
cluster_expression_matrix <- as.matrix(cluster_expression)
#cluster_expression_matrix <- scale(cluster_expression_matrix)
col_fun = colorRamp2(c(0.05, 0.25, 0.5), c("darkblue", "yellow", "red"))
col_fun(seq(-6, 6))
pdf(file = paste0(results_folder, "/category_expression_heatmap.pdf"), width = 12, height = 8)
if (exists("pheno_order")) {
Heatmap(cluster_expression_matrix,
col = col_fun,
name = "relative\nintensity",
column_title = "Marker expression per phenotype cluster",
width = ncol(cluster_expression_matrix) * unit(4, "mm"),
column_names_gp = gpar(fontsize = 10),
row_names_gp = gpar(fontsize = 10),
row_order = pheno_order
)
} else {
Heatmap(cluster_expression_matrix,
col = col_fun,
name = "relative\nintensity",
column_title = "Marker expression per phenotype cluster",
width = ncol(cluster_expression_matrix) * unit(3, "mm"),
column_names_gp = gpar(fontsize = 10),
row_names_gp = gpar(fontsize = 10),
cluster_rows = TRUE
)
}
dev.off()