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
| require(tidyverse) require(enrichplot) require(DOSE) require(stringr) require(clusterProfiler) f_kegg_p <- function(keggr2, n = 15){ keggr <- subset(keggr2@result, p.adjust < 0.1) keggr[['-log(Padj)']] <- -log10(keggr[['p.adjust']]) keggr[['geneRatio']] <- parse_ratio(keggr[['GeneRatio']]) keggr$Description <- factor(keggr$Description, levels=keggr[order(keggr$geneRatio),]$Description) ggplot(head(keggr,n),aes(x=geneRatio,y=Description))+ geom_point(aes(color=`-log(Padj)`, size=`Count`))+ theme_bw()+ scale_color_gradient(low="blue1",high="brown1")+ labs(y=NULL) + theme(axis.text.x=element_text(angle=90,hjust = 1,vjust=0.5, size = 12), axis.text.y=element_text(size = 15))+ scale_size(range = c(5,10)) + theme(axis.text=element_text(size=20),axis.title=element_text(size=20)) + scale_y_discrete(labels=function(y){str_wrap(gsub('_', ' ', y),width = 20)}) } f_title <- function(gp,title){ gp + labs(title = title) + theme(plot.title = element_text(hjust = 0.5)) }
|