Omics Diary
Published in

Omics Diary

How to use GSEApy for pathway enrichment analysis

An Enrichr pathway analysis package within the Python wrapper

GSEApy can execute Enrichr commands within the Python wrapper. Figure taken from Edward Chen et al., BMC Bioinformatics, 2013
pip install gseapy
%matplotlib inline
%config InlineBackend.figure_format='retina'
%load_ext autoreload
%autoreload 2
import csv
import numpy as np
import pandas as pd
import gseapy as gp
import matplotlib.pyplot as plt
import gseapy
names = gseapy.get_library_name()
print(names)
df = pd.read_csv('https://raw.githubusercontent.com/kuanrongchan/vaccine-studies/main/Ad5_seroneg.csv',index_col=0)DEGs_up_1d = (df[(df['fc_1d'] > 1.5) & (df['qval_1d'] < 0.05)]).index.tolist()
DEGs_down_1d = (df[(df['fc_1d'] < -1.5) & (df['qval_1d'] < 0.05)]).index.tolist()
enr_GOBP_up = gp.enrichr(gene_list=DEGs_up_1d ,
gene_sets=['GO_Biological_Process_2021'],
organism='Human',
description='DEGs_up_1d',
outdir='test/enr_DEGs_GOBP_up',
cutoff=0.5
)
enr_GOMF_up = gp.enrichr(gene_list=DEGs_up_1d ,
gene_sets=['GO_Molecular_Function_2021'],
organism='Human',
description='DEGs_up_1d’,
outdir='test/enr_DEGs_GOMF_up',
cutoff=0.5
)
enr_GOCC_up = gp.enrichr(gene_list=DEGs_up_1d ,
gene_sets=['GO_Cellular_Component_2021'],
organism='Human',
description='DEGs_up_1d',
outdir='test/enr_DEGs_GOCC_up',
cutoff=0.5
)
enr_Reactome_up = gp.enrichr(gene_list=DEGs_up_1d ,
gene_sets=['Reactome_2016'],
organism='Human',
description='DEGs_up_1d',
outdir='test/enr_DEGs_Reactome_up',
cutoff=0.5
)
enr_GOBP_up.results.head(5)
from gseapy.plot import barplot, dotplotbarplot(enr_GOBP_up.res2d,title='GO Biological Processes seroneg day 1 (up)',color = 'r')
barplot(enr_GOMF_up.res2d,title='GO Molecular Function seroneg day 1 (up)',color = 'r')barplot(enr_GOCC_up.res2d,title='GO Cellular Component seroneg day 1 (up)',color = 'r')barplot(enr_Reactome_up.res2d,title='Reactome seroneg day 1 (up)',color = 'r')
enr_GOBP_down = gp.enrichr(gene_list=DEGs_down_1d ,
gene_sets=['GO_Biological_Process_2021'],
organism='Human',
description='DEGs_down_1d',
outdir='test/enr_DEGs_GOBP_down',
cutoff=0.5
)
enr_GOMF_down = gp.enrichr(gene_list=DEGs_down_1d ,
gene_sets=['GO_Molecular_Function_2021'],
organism='Human',
description='DEGs_down_1d',
outdir='test/enr_DEGs_GOMF_down',
cutoff=0.5
)
enr_GOCC_down = gp.enrichr(gene_list=DEGs_down_1d ,
gene_sets=['GO_Cellular_Component_2021'],
organism='Human',
description='DEGs_down_1d',
outdir='test/enr_DEGs_GOCC_down',
cutoff=0.5
)
enr_Reactome_down = gp.enrichr(gene_list=DEGs_down_1d ,
gene_sets=['Reactome_2016'],
organism='Human',
description='DEGs_down_1d',
outdir='test/enr_DEGs_Reactome_down',
cutoff=0.5
)
barplot(enr_GOBP_down.res2d,title='GO Biological Processes seroneg day 1 (down)',color = 'b')barplot(enr_GOMF_down.res2d,title='GO Molecular Function seroneg day 1 (down)',color = 'b')barplot(enr_GOCC_down.res2d,title='GO Cellular Component seroneg day 1 (down)',color = 'b')barplot(enr_Reactome_down.res2d,title='Reactome seroneg day 1 (down)',color = 'b')

--

--

A platform to share knowledge and information on how to use Python for systems vaccinology and omics analysis. Also covers interesting scientific literature related to infectious diseases and vaccines. Interested in contributing? Contact me to collaborate!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kuan Rong Chan, Ph.D.

Kuan Rong Chan, PhD, Principal Research Scientist in Duke-NUS Medical School. Virologist | Data Scientist | Loves mahjong | Website: kuanrongchan.com