-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.R
89 lines (70 loc) · 2.51 KB
/
cluster.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
gene <- as.matrix(read.csv("union_gene.csv",header = T))
colnames(gene) <- c('gene')
library(org.Hs.eg.db)
library(clusterProfiler)
# genes symbol ----------------------------------------------------------
genelist <- as.character(gene)
eg <- bitr(genelist, fromType="SYMBOL", toType=c("ENTREZID","GENENAME"), OrgDb="org.Hs.eg.db");
head(eg)
# go ----------------------------------------------------------------------
geneList <- eg$ENTREZID
go_BP <- enrichGO(gene = geneList,
OrgDb = org.Hs.eg.db,
ont = "BP",
pvalueCutoff = 0.05,
qvalueCutoff = 0.05,
readable = TRUE)
head(go_BP)[,1:6]
class(go_BP)
write.csv(go_BP@result, file = "cluster_GO_NEW.csv", row.names = F)
# Perform simple visualization ----------------------------------------------------------------
barplot(go_BP, showCategory=10,drop=T) # showCategory=10,title="Enrichment GO"
dotplot(go_BP, showCategory=10,title="Enrichment GO Top10") #ÅÝÅÝͼ
# plotGOgraph(go_BP)
library(ggnewscale)
cnetplot(go_BP)
aa <- go_BP@result[1:30,]
bb <- aa[-c(9,17,20),]
cnetplot(go_BP,
showCategory = 5,
foldChange = NULL,
layout = "kk",
colorEdge = T,
circular = T,
node_label = "all"
)
enrichGO = DOSE::setReadable(go_BP, OrgDb='org.Hs.eg.db',keyType='ENTREZID')
enrichGO
library(ggnewscale)
cnetplot(enrichGO)
library(enrichplot)
library(DOSE)
# data(geneList)
# de <- names(geneList)[1:100]
# x <- enrichDO(de)
# x2 <- pairwise_termsim(x)
x2 <- go_BP
cnetplot(x2)
# use `layout` to change the layout of map
cnetplot(x2, layout = "star")
# use `showCategory` to select the displayed terms. It can be a number of a vector of terms.
cnetplot(x2, showCategory = 10)
categorys <- c("cell fate commitment", "canonical Wnt signaling pathway",
"cardiac chamber development", "mitral valve morphogenesis",
"Notch signaling pathway", "regulation of Wnt signaling pathway")
plot <- cnetplot(go_BP,
showCategory = categorys,
foldChange = NULL,
layout = "kk", # kk, gem
colorEdge = T,
circular = F,
node_label = "gene",
cex_category = 1.0,
cex_gene = 1.0,
cex_label_category = 1.0,
cex_label_gene = 0.6,
shadowtext = "none")
pdf(file = "cnetplot_cluster_NEW.pdf", width = 6.5, height = 4.5)
plot
dev.off()
## ¡¯star¡¯, ¡¯circle¡¯, ¡¯gem¡¯, ¡¯dh¡¯, ¡¯graphopt¡¯, ¡¯grid¡¯, ¡¯mds¡¯, ¡¯randomly¡¯, ¡¯fr¡¯, ¡¯kk¡¯, ¡¯drl¡¯, ¡¯lgl¡¯