Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

GO enrichment with python -- pandas meets networkx

Project Description

goenrich README

Convenient GO enrichments from python. For use in python projects.

  1. Builds the GO-ontology graph
  2. Propagates GO-annotations up the graph
  3. Performs enrichment test for all categories
  4. Performs multiple testing correction
  5. Allows for export to pandas for processing and graphviz for visualization


Install package from pypi and download ontology
and needed annotations.
pip install goenrich
mkdir db
# Ontology
wget -O db/go-basic.obo
# UniprotACC
wget -O db/gene_association.goa_ref_human.gz
# Yeast SGD
wget -O db/gene_association.sgd.gz
# Entrez GeneID
wget -O db/gene2go.gz

Run GO enrichment

import goenrich

# build the ontology
O = goenrich.obo.ontology('db/go-basic.obo')

# use all entrez geneid associations form gene2go as background
# use annot ='db/gene_association.goa_ref_human.gz') for uniprot
# use annot ='db/gene_association.sgd.gz') for yeast
gene2go ='db/gene2go.gz')
# use values = {k: set(v) for k,v in annot.groupby('go_id')['db_object_symbol']} for uniprot/yeast
values = {k: set(v) for k,v in gene2go.groupby('GO_ID')['GeneID']}

# propagate the background through the ontology
background_attribute = 'gene2go'
goenrich.enrich.propagate(O, values, background_attribute)

# extract some list of entries as example query
# use query = annot['db_object_symbol'].unique()[:20]
query = gene2go['GeneID'].unique()[:20]

# for additional export to graphviz just specify the gvfile argument
# the show argument keeps the graph reasonably small
df = goenrich.enrich.analyze(O, query, background_attribute, gvfile='')

# generate html

# call to graphviz
import subprocess
subprocess.check_call(['dot', '-Tpng', '', '-o', 'test.png'])

Generate png image using graphviz:

dot -Tpng > example.png

or directly from python:

import subprocess
subprocess.check_call(['dot', '-Tpng', '', '-o', 'example.png'])

Check the documentation for all available parameters


This work is licenced under the MIT licence

Contributions are welcome!

Building the documentation

sphinx-apidoc -f -o docs goenrich goenrich/tests
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
goenrich-1.5.7.tar.gz (26.8 kB) Copy SHA256 Checksum SHA256 Source Sep 27, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting