-
Notifications
You must be signed in to change notification settings - Fork 1
/
SNPs_3_enrichment_clusterProfiler.R
72 lines (54 loc) · 2.17 KB
/
SNPs_3_enrichment_clusterProfiler.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
setwd("data/")
lal_snps <- unlist(read.csv("lookalike_genes.txt", stringsAsFactors = F, header = F))
bck_snps <- unlist(read.csv("all_infinium_genes.txt", stringsAsFactors = F, header = F))
library(clusterProfiler)
library(org.Hs.eg.db)
egobp <- enrichGO(gene = lal_snps, universe = bck_snps, keyType = "ENSEMBL", OrgDb = org.Hs.eg.db,
minGSSize = 1, maxGSSize = 22000,
ont = "BP",
pAdjustMethod = "BH", pvalueCutoff = 0.05, qvalueCutoff = 0.5, readable = T)
egomf <- enrichGO(gene = lal_snps, universe = bck_snps, keyType = "ENSEMBL", OrgDb = org.Hs.eg.db,
minGSSize = 1, maxGSSize = 22000,
ont = "MF",
pAdjustMethod = "BH", pvalueCutoff = 0.05, qvalueCutoff = 0.5, readable = T)
egocc <- enrichGO(gene = lal_snps, universe = bck_snps, keyType = "ENSEMBL", OrgDb = org.Hs.eg.db,
minGSSize = 1, maxGSSize = 22000,
ont = "CC",
pAdjustMethod = "BH", pvalueCutoff = 0.05, qvalueCutoff = 0.5, readable = T)
for(go in c("bp", "mf", "cc")) {
ego <- get(paste0("ego", go))
write.table(ego, file = paste0("clusterProfiler_results/", toupper(go), "cluster_profiler_enrichGO_table.tsv"),
row.names = F,
quote = F, sep = "\t")
}
#### PLOTS ####
# Biological Process
pdf("clusterProfiler_results/emapplot_all_BP_no_names.pdf")
emapplot(egobp)
dev.off()
# TOP 10
pdf("clusterProfiler_results/emapplot_top10_BP_no_names.pdf")
ep <- emapplot(egobp, showCategory = 10)
ep$data[, "name"] <- ""
plot(ep)
dev.off()
# Molecular function
pdf("clusterProfiler_results/emapplot_all_MF_no_names.pdf")
emapplot(egomf)
dev.off()
# TOP 10
pdf("clusterProfiler_results/emapplot_top10_MF_no_names.pdf")
ep <- emapplot(egomf, showCategory = 10)
ep$data[, "name"] <- ""
plot(ep)
dev.off()
# Cellular compartment
pdf(paste0("clusterProfiler_results/emapplot_all_CC_no_names.pdf"))
emapplot(egocc)
dev.off()
# TOP 10
pdf(paste0("clusterProfiler_results/emapplot_top10_CC_no_names.pdf"))
ep <- emapplot(egocc, showCategory = 10 )
ep$data[, "name"] <- ""
plot(ep)
dev.off()