美文网首页科研信息学
R语言Pathway可视化

R语言Pathway可视化

作者: 落寞的橙子 | 来源:发表于2019-06-06 01:46 被阅读9次

    使用的是Y叔的包
    主要是构建geneList数据结构

    library(clusterProfiler)
    library(enrichplot)
    #需要将差异倍数logFC按从高到底排序,同时将gene name转化为NCBI的ID
    data<-read.csv("~/Desktop/DEGs.csv",header = T)
    geneList<-data$logFC
    names(geneList)<-data$geneID
    de<-as.character(data$geneID)
    ego <- enrichGO(de, OrgDb = "org.Hs.eg.db", ont="BP", readable=TRUE)
    goplot(ego)
    barplot(ego, showCategory=20)
    dotplot(ego, showCategory=30)
    ego2 <- simplify(ego)
    cnetplot(ego2, foldChange=geneList)
    cnetplot(ego2, foldChange=geneList, circular = TRUE, colorEdge = TRUE)
    heatplot(ego2, foldChange=geneList)
    upsetplot(ego)
    emapplot(ego2)
    kk <- gseKEGG(geneList, nPerm=1000)
    ridgeplot(kk)
    

    我的一个例子

    rt<-human_dif
    filename<-"human_dif"
    
    human_fasting_fed_dif<-human_dif[order(human_dif$log2FoldChange,decreasing = T),]
    new_names<-unlist(lapply(row.names(rt), FUN = function(x) {return(strsplit(x, split = ".", fixed=T)[[1]][1])}))
    row.names(rt)<-new_names
    gene_list<-select(org.Hs.eg.db, keys=as.character(new_names), columns=c("SYMBOL","ENTREZID"), keytype="ENSEMBL") 
    gene_list<-gene_list[!duplicated(gene_list$ENSEMBL),]
    row.names(gene_list)<-as.character(gene_list$ENSEMBL)
    a<-intersect(row.names(rt),row.names(gene_list))
    data<-cbind(rt[a,],gene_list[a,])
    data<-na.omit(data)
    geneList<-data[,8]
    names(geneList)<-as.character(data$ENTREZID)
    de<-as.character(data$ENTREZID)
    ego <- enrichGO(de, OrgDb = "org.Hs.eg.db", ont="BP", readable=TRUE)
    
    goplot<-goplot(ego)
    barplot<-barplot(ego, showCategory=20)
    dotplot<-dotplot(ego, showCategory=30)
    ego2 <- simplify(ego)
    cnetplot<-cnetplot(ego2, foldChange=geneList)
    cnetplot2<-cnetplot(ego2, foldChange=geneList, circular = TRUE, colorEdge = TRUE)
    heatplot<-heatplot(ego2, foldChange=geneList)
    upsetplot<-upsetplot(ego)
    emapplot<-emapplot(ego2)
    ggsave(plot=goplot,paste0(filename,"_goplot"),device = "pdf")
    ggsave(plot=barplot,paste0(filename,"_barplot"),device = "pdf")
    ggsave(plot=dotplot,paste0(filename,"_dotplot"),device = "pdf")
    ggsave(plot=cnetplot,paste0(filename,"_cnetplot"),device = "pdf")
    ggsave(plot=cnetplot2,paste0(filename,"_cnetplot2"),device = "pdf")
    ggsave(plot=heatplot,paste0(filename,"_heatplot"),device = "pdf")
    ggsave(plot=upsetplot,paste0(filename,"_upsetplot"),device = "pdf")
    ggsave(plot=upsetplot,paste0(filename,"_emapplot"),device = "pdf")
    kk <- gseKEGG(geneList, nPerm=1000)
    ridgeplot<-ridgeplot(kk)
    ggsave(plot=ridgeplot,paste0(filename,"_ridgeplot"),device = "pdf")
    

    相关文章

      网友评论

        本文标题:R语言Pathway可视化

        本文链接:https://www.haomeiwen.com/subject/nmwexctx.html