library(ggplot2)
library(ggthemes)
tab<-read.table("leaf.ori.IDs.keggEnrich.tab.final.xls",header=T,sep="\t")
colnames(tab)
tab<-tab[,c("Term.Name","MainClass",
"GeneHitsInSelectedSet",
"GeneHitsInBackground"
)]
head(tab)
tab$richFactor<-tab$GeneHitsInSelectedSet/tab$GeneHitsInBackground
tab<-tab[order(tab$richFactor,decreasing = T),]
tab<-tab[order(tab$MainClass,decreasing = F),]
tab$Term.Name<-factor(tab$Term.Name,levels=unique(as.character(tab$Term.Name)))
p<-ggplot(tab,aes(x=Term.Name,y=richFactor))
p+geom_bar(stat="identity",width=0.1)+geom_point(aes(color=MainClass),size=10)+
geom_text(aes(label=GeneHitsInSelectedSet),alpha=I(0.8))+
theme_bw() +
theme(
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), # element_line(size = 0.8,color="darkgray"), # element_blank(),
axis.line.x = element_line(colour = "black", size = 0.8),
axis.line.y = element_line(colour = "black", size = 0.8),
axis.ticks.x = element_line(size = 0.8),
axis.ticks.y = element_line(size = 0.8),
axis.text.x = element_text(
angle = 90, hjust = 0, vjust = 0
),
# legend.position="NA",
legend.key = element_blank(),
legend.title = element_blank(),
legend.text = element_text(size = 12, face = "bold"),
legend.background = element_rect(fill = "transparent"),
strip.background = element_rect(
colour = "white", fill = "white",
size = 0.2
),
strip.text.x = element_text(size = 14),
strip.text.y = element_text(size = 14),
text = element_text(
size = 14,
#family = "arial",
face = "bold"
),
plot.title = element_text(
size = 16,
#family = "arial",
face = "bold"
)
)+scale_color_pander()+xlab("KEGG Pathway")+ylab("Rich Factor")
网友评论