-
Notifications
You must be signed in to change notification settings - Fork 0
/
GO.R
63 lines (51 loc) · 2.02 KB
/
GO.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
library(ggpubr)
library(tidyverse)
library(ggplot2)
library(lemon)
library(scales)
library(RColorBrewer)
library(ggrepel)
library(ggpmisc)
library(ggseqlogo)
library(rstatix)
library(ggdist)
setwd("/fs/ess/PAS1473/ben_past_projects/Function_eggd_smRNA_RNA")
####### GO analysis
data = read_delim("gProfiler_celegans_3-24-2023_10-49-16 AM__intersections.csv", delim = ",")
colnames(data)
data
go_plot = function(gost_result, gosource, color){
data = subset(gost_result, source == paste0(gosource))
print(head(data))
data2 = data %>% add_column(x = runif(nrow(.), min = .40, max = .60))
labels = data2 %>% top_n(3, wt = negative_log10_of_adjusted_p_value)
ymin = 0
ymax = max(data2$negative_log10_of_adjusted_p_value) +5
p = ggplot() +
geom_point(data = data2, aes(x = x, y = negative_log10_of_adjusted_p_value, size = negative_log10_of_adjusted_p_value),color = color) +
theme_classic() +
my_theme() +
#theme(aspect.ratio = 1,
# axis.ticks.length=unit(.25, "cm"),
# text = element_text(size=20),
# axis.text = element_text(size = 20),
# axis.text.x = element_blank()) +
theme(legend.position = "none") +
coord_cartesian() +
coord_capped_cart(bottom = "both", left = "both") +
geom_text_repel(data = labels,aes(x = x, y = negative_log10_of_adjusted_p_value, label = term_name), box.padding = 4) +
scale_x_continuous(limits = c(0,1), breaks = c(.25,.75))+
scale_y_continuous(limits = c(0,ymax), breaks = seq(0,ymax,5)) +
labs(x = paste0(gosource), y = "-log10(p value)")
return(p)
}
mf_plot = go_plot(data, "GO:MF", "darkviolet")
bp_plot = go_plot(data, "GO:BP", "springgreen3")
cc_plot = go_plot(data, "GO:CC", "indianred2")
tf_plot = go_plot(data, "TF", "blue")
go_analysis = ggarrange(mf_plot, bp_plot, cc_plot, tf_plot, ncol = 4, nrow = 1)
ggsave(go_analysis, filename = "figs/go_analysis.pdf", dpi = 300, height = 6, width = 15, device = cairo_pdf)
go_analysis
pdf("go-analysis.pdf", height = 20, width = 20)
go_analysis
dev.off()