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
| require(clusterProfiler) require(enrichplot) rres <- readRDS('DEGs_X1.OE.DMSO_X2.OE.DMSO_vs._X1.control.DMSO_X2.control.DMSO_DESeq2.rds') lgene <- rres$log2FoldChange names(lgene) <- rres$symbol WP <- readRDS('WP.hsa.rds') WP$TERM2NAME$name <- gsub('%.*%Homo sapiens', '', WP$TERM2NAME$name) set.seed(0) gse.WP <- GSEA(gene = lgene, pAdjustMethod = "fdr", eps = 0, pvalueCutoff = 0.1, TERM2GENE = WP$TERM2GENE, TERM2NAME = WP$TERM2NAME) require(tidyverse) require(enrichplot) require(DOSE) f_kegg_p <- function(keggr2, n = 15){ keggr <- subset(keggr2@result, p.adjust < 0.05) 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)) } f_title <- function(gp,title){ gp + labs(title = title) + theme(plot.title = element_text(hjust = 0.5)) } gse.WP@result
|