-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulk_05_clusters_funcomics_visualisation.R
More file actions
95 lines (83 loc) · 3.17 KB
/
bulk_05_clusters_funcomics_visualisation.R
File metadata and controls
95 lines (83 loc) · 3.17 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
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
# Copyright (c) [2025] [Ines Rivero Garcia]
# ines.rivero@uni-heidelberg.de
# Visualise mRNA-seq funcomics results
library(dplyr)
library(ggplot2)
library(ComplexHeatmap)
setwd("/mnt/sds-hd/sd22b002/projects/ines/heart_revremod/")
# Visualise hallmarks
hallmarks <- read.csv("results/bulk/mrna_time_clusters_funcomics_hallmarks.csv", header = TRUE, row.names = 1)
top_hallmarks <- hallmarks %>%
filter(fdr < 0.05) %>%
filter(activity > 0) %>%
arrange(fdr, activity) %>%
pull(gene) %>%
unique()
hallmarks_mat <- hallmarks %>%
filter(gene %in% top_hallmarks) %>%
mutate(gene_cluster = paste0("cluster_", gene_cluster)) %>%
select(gene_cluster, gene, activity) %>%
tidyr::pivot_wider(names_from = gene_cluster, values_from = activity) %>%
tibble::column_to_rownames("gene") %>%
as.matrix()
hallmarks_fdr <- hallmarks %>%
filter(gene %in% top_hallmarks) %>%
mutate(gene_cluster = paste0("cluster_", gene_cluster)) %>%
select(gene_cluster, gene, fdr) %>%
tidyr::pivot_wider(names_from = gene_cluster, values_from = fdr) %>%
tibble::column_to_rownames("gene") %>%
as.matrix()
hallmarks_fdr <- ifelse(hallmarks_fdr < 0.05, "*", "")
pdf("results/bulk/mrna_time_clusters_hallmarks_heatmap.pdf", height = 6, width = 4)
Heatmap(hallmarks_mat,
name = "pathway\nactivity",
#col = col_fun,
cell_fun = function(j, i, x, y, width, height, fill) {
if (hallmarks_fdr[i, j] == "*") {
grid.text("*", x, y, gp = gpar(fontsize = 14, fontface = "bold"))
}
},
cluster_rows = TRUE,
cluster_columns = TRUE
)
dev.off()
# Visualise TF activities
collectri <- read.csv("results/bulk/mrna_time_clusters_funcomics_collectri.csv", header = TRUE, row.names = 1)
top_collectri <- collectri %>%
filter(fdr < 0.05) %>%
filter(activity > 0) %>%
arrange(fdr, activity) %>%
pull(gene) %>%
unique() %>%
head(n=30)
collectri_mat <- collectri %>%
filter(gene %in% top_collectri) %>%
mutate(gene_cluster = paste0("cluster_", gene_cluster)) %>%
select(gene_cluster, gene, activity) %>%
tidyr::pivot_wider(names_from = gene_cluster, values_from = activity) %>%
tibble::column_to_rownames("gene") %>%
as.matrix()
collectri_fdr <- collectri %>%
filter(gene %in% top_collectri) %>%
mutate(gene_cluster = paste0("cluster_", gene_cluster)) %>%
select(gene_cluster, gene, fdr) %>%
tidyr::pivot_wider(names_from = gene_cluster, values_from = fdr) %>%
tibble::column_to_rownames("gene") %>%
as.matrix()
collectri_fdr <- ifelse(collectri_fdr < 0.05, "*", "")
# color palette to nicely show activities
col_fun = circlize::colorRamp2(breaks = seq(min(collectri_mat), max(collectri_mat), length.out = 9),
colors = c("#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"))
pdf("results/bulk/mrna_time_clusters_collectri_heatmap.pdf", height = 6, width = 4)
Heatmap(collectri_mat,
name = "pathway\nactivity",
col = col_fun,
cell_fun = function(j, i, x, y, width, height, fill) {
if (collectri_fdr[i, j] == "*") {
grid.text("*", x, y, gp = gpar(fontsize = 14, fontface = "bold"))
}
},
cluster_rows = TRUE,
cluster_columns = TRUE
)
dev.off()