python基因集富集分析

gseap的Python项目详细描述


gseapy:python中的基因集富集分析。

https://badge.fury.io/py/gseapy.svghttps://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat-squarehttps://travis-ci.org/zqfang/GSEApy.svg?branch=masterDocumentation Statushttps://img.shields.io/badge/license-MIT-blue.svgPyPI - Python Version

有关使用gseapy的示例,请单击此处:Example

发行说明https://github.com/zqfang/GSEApy/releases

faqwiki

gseapy是gseaenrichr的python包装器。

gseapy可用于rna序列、芯片序列、微阵列数据。它可以用于方便的go扩展,并在python中生成发布质量图

gseapy有六个子命令可用:gseaprerankssgseareplotenrichrbiomart

gsea:The ^{tt1}$ module produces GSEA results. The input requries a txt file(FPKM, Expected Counts, TPM, et.al), a cls file, and gene_sets file in gmt format.
prerank:The ^{tt2}$ module produces Prerank tool results. The input expects a pre-ranked gene list dataset with correlation values, provided in .rnk format, and gene_sets file in gmt format. ^{tt2}$ module is an API to GSEA pre-rank tools.
ssgsea:The ^{tt3}$ module performs single sample GSEA(ssGSEA) analysis. The input expects a pd.Series (indexed by gene name), or a pd.DataFrame (include ^{tt11}$ file) with expression values and a ^{tt12}$ file. For multiple sample input, ssGSEA reconigzes gct format, too. ssGSEA enrichment score for the gene set is described by D. Barbie et al 2009.
replot:The ^{tt4}$ module reproduce GSEA desktop version results. The only input for GSEApy is the location to ^{tt14}$ Desktop output results.
enrichr:The ^{tt5}$ module enable you perform gene set enrichment analysis using ^{tt16}$ API. Enrichr is open source and freely available online at: http://amp.pharm.mssm.edu/Enrichr . It runs very fast.
biomart:The ^{tt6}$ module helps you convert gene ids using BioMart API.

请使用“gseapy command-h”查看每个模块的每个选项的详细说明。

完整的GSEA太多,无法在此描述;请参见 GSEA文档了解更多信息。gseapy的所有文件格式都与GSEA桌面版本相同。

如果你在研究中使用gseapy,你应该引用原始的``gsea``和``enrichr``论文。

为什么选择GSeapy

我想用熊猫来探索我的数据,但是我没有找到一个方便的工具来 在python中进行基因集富集分析。所以,我的理由如下:

  • 能够在python交互控制台内运行,而不必切换到r!!!
  • 方便干湿实验室用户使用。
  • 制作或复制可出版的图形。
  • 轻松执行批处理作业。
  • 在bash shell或您的数据分析工作流中易于使用,例如snakemake。

gseapyPrerank模块输出

使用来自GSEA的相同数据,gseapy复制上面的示例。

使用Prerankreplot模块将为gsea java桌面输出复制相同的图形

docs/gseapy_OCT4_KD.png

由GSEAPY生成

gseapy图形受所有matplotlib图形格式支持。

可以在.pdf文件中轻松修改GSEA绘图。请欣赏。

安装

从bioconda或pypi安装gseapy包。
# if you have conda
$ conda install -c conda-forge -c bioconda gseapy

# or use pip to install the latest release
$ pip install gseapy
您可能希望通过运行
$ pip install git+git://github.com/zqfang/gseapy.git#egg=gseapy

依赖性

  • Python3.5+

强制性

  • numpy=1.13.0
  • scipy
  • 熊猫
  • matplotlib
  • 美化组4
  • 请求(Enrichr API)
  • 生物服务(用于Biomart API)

如果无法分析XML文件,则可能还需要安装lxml,html5lib

运行gseapy

开始之前:

除非您确切知道gsea是如何工作的,否则应该首先将所有基因符号名转换为大写。

对于命令行用法:

# An example to reproduce figures using replot module.
$ gseapy replot -i ./Gsea.reports -o test# An example to run GSEA using gseapy gsea module
$ gseapy gsea -d exptable.txt -c test.cls -g gene_sets.gmt -o test# An example to run Prerank using gseapy prerank module
$ gseapy prerank -r gsea_data.rnk -g gene_sets.gmt -o test# An example to run ssGSEA using gseapy ssgsea module
$ gseapy ssgsea -d expression.txt -g gene_sets.gmt -o test# An example to use enrichr api
# see details of -g below, -d  is optional
$ gseapy enrichr -i gene_list.txt -g KEGG_2016 -d pathway_enrichment -o test

在python控制台中运行gseapy:

  1. 准备GSEA所需的expression.txt、gene_sets.gmt和test.cls,您可以这样做
importgseapy# run GSEA.gseapy.gsea(data='expression.txt',gene_sets='gene_sets.gmt',cls='test.cls',outdir='test')# run prerankgseapy.prerank(rnk='gsea_data.rnk',gene_sets='gene_sets.gmt',outdir='test')# run ssGSEAgseapy.ssgsea(data="expression.txt",gene_sets="gene_sets.gmt",outdir='test')# An example to reproduce figures using replot module.gseapy.replot(indir='./Gsea.reports',outdir='test')
  1. 如果您喜欢在交互式python控制台中使用dataframe、dict、list,那么可以这样做。

请参见此处的详细信息:Example

# assign dataframe, and use enrichr library data set 'KEGG_2016'expression_dataframe=pd.DataFrame()sample_name=['A','A','A','B','B','B']# always only two group,any names you like# assign gene_sets parameter with enrichr library name or gmt file on your local computer.gseapy.gsea(data=expression_dataframe,gene_sets='KEGG_2016',cls=sample_names,outdir='test')# using prerank toolgene_ranked_dataframe=pd.DataFrame()gseapy.prerank(rnk=gene_ranked_dataframe,gene_sets='KEGG_2016',outdir='test')# using ssGSEAgseapy.ssgsea(data=ssGSEA_dataframe,gene_sets='KEGG_2016',outdir='test')
  1. 对于enrichr,您可以指定一个list、pd.series、pd.dataframe对象或一个txt文件(每行应该有一个基因名)
# assign a list object to enrichrgl=['SCARA3','LOC100044683','CMBL','CLIC6','IL13RA1','TACSTD2','DKKL1','CSF1','SYNPO2L','TINAGL1','PTX3','BGN','HERC1','EFNA1','CIB2','PMP22','TMEM173']gseapy.enrichr(gene_list=gl,description='pathway',gene_sets='KEGG_2016',outdir='test')# or a txt file path.gseapy.enrichr(gene_list='gene_list.txt',description='pathway',gene_sets='KEGG_2016',outdir='test',cutoff=0.05,format='png')

gseapy支持的基因集库:

要查看gseapy支持的基因集库的完整列表,请单击此处:Library

或者在python控制台中使用get_library_name函数。

#see full list of latest enrichr library names, which will pass to -g parameter:names=gseapy.get_library_name()# show top 20 entries.print(names[:20])['Genome_Browser_PWMs','TRANSFAC_and_JASPAR_PWMs','ChEA_2013','Drug_Perturbations_from_GEO_2014','ENCODE_TF_ChIP-seq_2014','BioCarta_2013','Reactome_2013','WikiPathways_2013','Disease_Signatures_from_GEO_up_2014','KEGG_2016','TF-LOF_Expression_from_GEO','TargetScan_microRNA','PPI_Hub_Proteins','GO_Molecular_Function_2015','GeneSigDB','Chromosome_Location','Human_Gene_Atlas','Mouse_Gene_Atlas','GO_Cellular_Component_2015','GO_Biological_Process_2015','Human_Phenotype_Ontology',]

错误报告

如果您想在使用gseapy时报告任何bug,请不要犹豫在这里的github上创建一个问题。

要获得gseapy的帮助

  1. 查看wiki页面:https://github.com/zqfang/GSEApy/wiki/FAQ
  2. 访问文档站点http://gseapy.rtfd.io/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在导航抽屉中显示图像   DDD中的java聚合对象   java如何在登录后隐藏主活动上的项目?   java如何知道MouseWheelListener是否可以接收事件?   java地图中未显示新标记   Z3Java绑定是否具有与python相同的get_vars()API?   java重置或清除Lucene索引   Java骑士之旅代码   集合Java类树集合中的Java方法headSet和tailSet在日志(N)时间内工作吗?   java从SpringWeb服务获取Jetty实例   java需要在jira中将jsp文件更改为vm文件   创建对象时发生java IllegalMonitorStateException   java SnakeYaml从字符串第一行转储   使用java在文件中逐个使用for循环写入行