-
Notifications
You must be signed in to change notification settings - Fork 1
/
Enrichr pathway analysis PRS-HOMAIR.R
51 lines (40 loc) · 2.01 KB
/
Enrichr pathway analysis PRS-HOMAIR.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
#####Pathway Enrichr analysis####
#####set directory####
setwd("/Users/slaber/Desktop/github/")
#####load gene list for pathway enrichemnet####
LP<-read.csv(file="RNA-seq PRS-HOMAIR D14.csv")
LP<-LP[,-1]
##eg. significant features
LP_significant<-subset(LP, LP$score.anova.pvalue < 0.05 & LP$q.a < 0.10)
library(enrichR)
#####define pathway enrichment gene list you want to use###
enrich<-enrichR::enrichr(as.character(as.character(LP_significant$RNA_big.symbol)), c("KEGG_2019_Human",
"BioPlanet_2019",
"WikiPathways_2019_Human",
"GO_Biological_Process_2018"))
#####check top rows of enriched pathways###
head(enrich[["KEGG_2019_Human"]])
head(enrich[["BioPlanet_2019"]])
head(enrich[["WikiPathways_2019_Human"]])
head(enrich[["GO_Biological_Process_2018"]])
######select on list of pathway###
enrichr_data<-enrich[["KEGG_2019_Human"]]
#####save analysis###
write.table(enrichr_data, file="PRS-HOMA KEGG pathway.csv", sep=",", col.names = NA, qmethod = "double")
######plot enrichr analysis####
#####define significance level####
library(dplyr)
plot_input <- enrichr_data %>% dplyr::mutate(label = ifelse(enrichr_data$Adjusted.P.value <= 0.05, "<5%FDR", ">5%FDR"))
####plot####
library(ggplot2)
plot<-ggplot(plot_input,aes(x=Odds.Ratio, y=-log10(Adjusted.P.value), size=-log10(Adjusted.P.value), fill=label)) +
geom_point(alpha=0.6, color="black", pch=21) +
geom_text(aes(label = ifelse(Adjusted.P.value <= 0.05, as.character(Term), "") ,size = -log10(Adjusted.P.value)),
hjust=0, vjust=0,color = "black", check_overlap = F)+
scale_size(range = c(.01, 4), name="-log(Adjusted.P.value)")+
scale_fill_manual(name = "Adjusted.P.value", values= c("<5%FDR"= "#4DAC26",
">5%FDR"= "#B9C1C7" ))+
theme_bw()
pdf("enrichr plot KEGGPathway PRS-HOMAIR visceral D14.pdf")
plot_input
dev.off()