-
Notifications
You must be signed in to change notification settings - Fork 0
/
Oscar_scenic_v2_plotting.R
117 lines (70 loc) · 3.06 KB
/
Oscar_scenic_v2_plotting.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
library(tidyverse)
scenicz = read.csv("./data/albeck_pyscenic_analysis_v2_condition_specific_regulons_zscores.csv")
table(scenicz$Conditions)
# removing oscar's typo in the name of the condition
scenicz =
scenicz %>%
mutate(Conditions = case_when(Conditions == "base_i_maging_medium_im" ~ "base_imaging_medium",
TRUE ~ Conditions))
scenicz$Conditions = factor(scenicz$Conditions)
scenicz %>%
ggplot(aes(x = regulon,
fill = Zscores,
y = Conditions))+
theme_bw()+
geom_raster()+
scale_fill_gradient2(low = "blue",
mid = "white",
high = "red",)+
theme(axis.text.x = element_text(angle = 80, hjust=1, size = 8))+
scale_y_discrete(limits = rev(levels(scenicz$Conditions))) + # to get alphabetical order
labs(title = "All significantly enriched regulons across conditions",
subtitle = "scRNAseq data, Oscar Davalos pySCENIC v2")
ggsave(plot = last_plot(), "./figures/TF_all_regulons_zscore.svg", width = 35, height = 14,
units = "cm",dpi = 300, scale = 1.3)
# let's try to plot it as a heatmap so I can cluster it
# Do the scaling to get z-scores
# z-score don't require the log tranformation to scale your conditions
# in a way where you can compare them
library(pheatmap)
library(RColorBrewer)
mats =
scenicz %>%
select(-X) %>%
pivot_wider(names_from = regulon,
values_from = Zscores) %>%
select(-Conditions)
rownames(mats) = unique(scenicz$Conditions)
# annot = as.data.frame(annot$ResponseType)
# rownames(annot) = rownames(mats)
# colnames(annot) = "ResponseType"
svg(file="./figures/heatmap_TF_all_regulons.svg", width = 18, height = 8, pointsize = 7)
pheatmap(mats, main="All significantly enriched regulons across conditions",
subtitle = "scRNAseq data, Oscar Davalos pySCENIC v2",
color = rev(brewer.pal(9,"RdBu")),
cluster_cols=T,
fontsize_row=10, border_color=NA,
legend = T)
dev.off()
# Remove the uninteresting regulons
roi = mats[,abs(colMeans(mats))>.001]
rownames(roi) = rownames(mats)
svg(file="./figures/heatmap_TF_regulons_top107.svg", width = 16, height = 8, pointsize = 7)
pheatmap(roi, main="Top 107 significantly enriched regulons across conditions",
subtitle = "scRNAseq data, Oscar Davalos pySCENIC v2",
color = rev(brewer.pal(9,"RdBu")),
cluster_cols=T,
fontsize_row=10, border_color=NA,
legend = T)
dev.off()
# more stringent clustering
roi = mats[,abs(colMeans(mats))>.005]
rownames(roi) = rownames(mats)
svg(file="./figures/heatmap_TF_regulons_top64.svg", width = 14, height = 8, pointsize = 7)
pheatmap(roi, main="Top 64 significantly enriched regulons across conditions",
subtitle = "scRNAseq data, Oscar Davalos pySCENIC v2",
color = rev(brewer.pal(9,"RdBu")),
cluster_cols=T,
fontsize_row=10, border_color=NA,
legend = T)
dev.off()