-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualization.R
31 lines (26 loc) · 1.16 KB
/
visualization.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
source("setup.R")
load("Data/ctrp_cor_short_signif.RData")
# Plotting functions
plot_volcano <- function(data, x, y, color, title) {
ggplot(data, aes(x = {{x}}, y = -log10({{y}}), color = abs({{color}}))) +
geom_point(alpha = 0.6) +
scale_color_gradient(low = "blue", high = "red") +
labs(title = title, x = "Correlation", y = "-log10(p-value)") +
theme_minimal()
}
# Create plots
volcano_pearson <- plot_volcano(ctrp_cor_short_signif,
cor_pearson,
p_value_pearson,
cor_pearson,
"Volcano Plot (Pearson)")
volcano_spearman <- plot_volcano(ctrp_cor_short_signif,
cor_spearman,
p_value_spearman,
cor_spearman,
"Volcano Plot (Spearman)")
# Save plots
ggsave("Plots/volcano_pearson.png", volcano_pearson, width = 10, height = 8)
ggsave("Plots/volcano_spearman.png", volcano_spearman, width = 10, height = 8)
# Clean up
rm(list = setdiff(ls(), c("plot_volcano", "volcano_pearson", "volcano_spearman")))