我们经常使用Y叔的clusterprofiler包进行GSEA分析,之后使用gseaplot或enrichplot::gseaplot2来可视化结果。这两个函数中可以调整的参数较少,因此我们希望把图导出为ggplot对象,然后用ggplot2包重新对其进行调整。
enrichplot::gseaplot2最后产生的对象是使用plot_grid按列组合形成的图,我们需要组合前的图形对象,因此需要对该函数小做调整。
my_gseaplot2<-function (x, geneSetID, title = \"\", color = \"green\", base_size = 11,
rel_heights = c(1.5, 0.5, 1), subplots = 1:3, pvalue_table = FALSE,
ES_geom = \"line\")
{
-----------------------------------------------------------------------------------------
中间代码
-----------------------------------------------------------------------------------------
#plot_grid(plotlist = plotlist, ncol = 1, align = \"v\", rel_heights = rel_heights)
#修改为
return(plotlist)
}
#在这最后,需要将自定义函数的环境修改为原函数的环境,不然会报错
environment(my_gseaplot2)=environment(gseaplot2)
当然,除了自定义函数,我们也可以通过调整subplots参数,逐一输出ggplot对象来达到目的。
expr_DEG_limma_GSEA_go%>%gseaplot2(.,expr_DEG_limma_GSEA_go@result$ID,subplots = 1) ->up_plot
expr_DEG_limma_GSEA_go%>%gseaplot2(.,expr_DEG_limma_GSEA_go@result$ID,subplots = 2) ->mid_plot
expr_DEG_limma_GSEA_go%>%gseaplot2(.,expr_DEG_limma_GSEA_go@result$ID,subplots = 3) ->bottom_plot
![图片[1]-个性化调整GSEAplot—科研工具箱-叨客学习资料网](https://cdn.leobba.cn/wp-content/uploads/7983008-43247228ec5c9763.webp_.jpg~tplv-vsxgrxnt6c-1.image)
![图片[2]-个性化调整GSEAplot—科研工具箱-叨客学习资料网](https://cdn.leobba.cn/wp-content/uploads/7983008-8cd5f1fba0ebe854.webp_.jpg~tplv-vsxgrxnt6c-1.image)
![图片[3]-个性化调整GSEAplot—科研工具箱-叨客学习资料网](https://cdn.leobba.cn/wp-content/uploads/7983008-8e16c514cb1833fc.webp_.jpg~tplv-vsxgrxnt6c-1.image)
都是ggplot图形,分别修改后再拼图即可
© 版权声明
THE END
暂无评论内容