This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Python scripts to find enrichment of GO terms

Project Description
Tools for Gene Ontology

.. image::
:alt: DOI

.. image::
:alt: Latest PyPI version

.. image::
:alt: Number of PyPI downloads

.. image::
:alt: bioconda

.. image::
:alt: Travis-CI

:Author: Haibao Tang (`tanghaibao <>`_),
Brent Pedersen (`brentp <>`_),
Fidel Ramirez (`fidelram <>`_),
Aurelien Naldi (`aurelien-naldi <>`_),
Patrick Flick (`patflick <>`_),
Jeff Yunes (`yunesj <>`_),
Kenta Sato (`bicycle1885 <>`_),
Chris Mungall (`cmungall <>`_),
Greg Stupp (`stuppie <>`_),
DV Klopfenstein (`dvklopfenstein <>`_),
David DeTomaso (`deto <>`_),
Olga Botvinnik (`olgabot <>`_)
:License: BSD

.. contents ::

This package contains a Python library to

- process over- and under-representation of certain GO terms, based on Fisher's
exact test. With numerous multiple correction routines including locally
implemented routines for Bonferroni, Sidak, Holm, and false discovery rate. Also included are
multiple test corrections from `statsmodels <>`_:
FDR Benjamini/Hochberg, FDR Benjamini/Yekutieli, Holm-Sidak, Simes-Hochberg,
Hommel, FDR 2-stage Benjamini-Hochberg, FDR 2-stage Benjamini-Krieger-Yekutieli,
FDR adaptive Gavrilov-Benjamini-Sarkar, Bonferroni, Sidak, and Holm.
- process the obo-formatted file from `Gene Ontology website <>`_.
The data structure is a directed acyclic graph (DAG) that allows easy traversal
from leaf to root.
- Read GO Association files:
- Read GAF (GO Association File) files.
- Read NCBI's gene2go GO association file.
- map GO terms (or protein products with multiple associations to GO terms) to
GOslim terms (analog to the script supplied by

Make sure your Python version >= 2.7, install the latest stable version via PyPI::

easy_install goatools

To install the development version::

pip install git+git://

``.obo`` file for the most current `GO <>`_::


``.obo`` file for the most current `GO Slim <>`_
terms (e.g. generic GOslim) ::


- To calculate the uncorrected p-values, there are currently two options:

1. `fisher <>`_ for calculating
Fisher's exact test::

easy_install fisher

2. `fisher <>`_
from `SciPy's <>`_
`stats <>`_

- `statsmodels` (optional) for access to a variety of statistical tests for GOEA::

easy_install statsmodels

- To plot the ontology lineage, install one of these two options:

1. Graphviz

- `Graphviz <>`_, for graph visualization.
- `pygraphviz <>`_, Python binding for
communicating with Graphviz::

easy_install pygraphviz

2. `pydot <>`_, a Python interface to Graphviz's Dot language.

* `pyparsing <>`_ is a prerequisite for pydot
* Images can be viewed using either:

* `ImageMagick <>`_'s *display*
* `Graphviz <>`_

- Alternatively, it is possible to install via bioconda. See details
`here <>`_.

```` contains example cases, which calls the utility scripts in the
``scripts`` folder.

Find GO enrichment of genes under study
See ```` for usage. It takes as arguments files containing:

* gene names in a study
* gene names in population (or other study if --compare is specified)
* an association file that maps a gene name to a GO category.

Please look at ``tests/data/`` folder to see examples on how to make these
files. when ready, the command looks like::

python scripts/ --pval=0.05 --indent data/study data/population data/association

and can filter on the significance of (e)nrichment or (p)urification.
it can report various multiple testing corrected p-values as well as
the false discovery rate.

The "e" in the "Enrichment" column means "enriched" - the concentration of GO
term in the study group is significantly *higher* than those in the population.
The "p" stands for "purified" - significantly *lower* concentration of the GO
term in the study group than in the population.

**Important note**: by default, ```` propagates counts to all
the parents of a GO term. As a result, users may find terms in the output that
are not present in their ``association`` file. Use ``--no_propagate_counts`` to
disable this behavior.

Read and plot GO lineage
See ```` for usage. ```` can plot the lineage of
a certain GO term, by::

python scripts/ --term=GO:0008135

This command will plot the following image.

.. image::
:alt: GO term lineage

Sometimes people like to stylize the graph themselves, use option ``--gml`` to
generate a GML output which can then be used in an external graph editing
software like `Cytoscape <>`_. The following image is
produced by importing the GML file into Cytoscape using yFile orthogonal
layout and solid VizMapping. Note that the `GML reader plugin
<>`_ may need to be
downloaded and installed in the ``plugins`` folder of Cytoscape::

python scripts/ --term=GO:0008135 --gml

.. image::
:alt: GO term lineage (Cytoscape)

Map GO terms to GOslim terms
See ```` for usage. As arguments it takes the gene ontology files:

* the current gene ontology file ``go-basic.obo``
* the GOslim file to be used (e.g. ``goslim_generic.obo`` or any other GOslim

The script either maps one GO term to its GOslim terms, or protein products
with multiple associations to all its GOslim terms.

To determine the GOslim terms for a single GO term, you can use the following

python scripts/ --term=GO:0008135 go-basic.obo goslim_generic.obo

To determine the GOslim terms for protein products with multiple associations::

python scripts/ --association_file=data/association go-basic.obo goslim_generic.obo

Where the ``association`` file has the same format as used for

The implemented algorithm is described in more detail at the go-perl
documentation of `map2slim <>`_.

Available statistical tests for calculating uncorrected p-values
There are currently two fisher tests available for calculating uncorrected p-values.
Both fisher options from the fisher package and SciPy's stats package
calculate the same pvalues, but provide the user an option in installing packages.

* ``fisher``, `fisher <>`_ package's fisher.pvalue_population
* ``fisher_scipy_stats``: `SciPy's <>`_
`stats <>`_ package's
`fisher_exact <>`_

Available multiple test corrections
We have implemented several significance tests:

* ``bonferroni``, bonferroni correction
* ``sidak``, sidak correction
* ``holm``, hold correction
* ``fdr``, false discovery rate (fdr) implementation using resampling

Additional methods are available if ``statsmodels`` is installed:

* ``sm_bonferroni``, bonferroni one-step correction
* ``sm_sidak``, sidak one-step correction
* ``sm_holm-sidak``, holm-sidak step-down method using Sidak adjustments
* ``sm_holm``, holm step-down method using Bonferroni adjustments
* ``simes-hochberg``, simes-hochberg step-up method (independent)
* ``hommel``, hommel closed method based on Simes tests (non-negative)
* ``fdr_bh``, fdr correction with Benjamini/Hochberg (non-negative)
* ``fdr_by``, fdr correction with Benjamini/Yekutieli (negative)
* ``fdr_tsbh``, two stage fdr correction (non-negative)
* ``fdr_tsbky``, two stage fdr correction (non-negative)
* ``fdr_gbs``, fdr adaptive Gavrilov-Benjamini-Sarkar

In total 15 tests are available, which can be selected using option ``--method``.
Please note that the default FDR (``fdr``) uses a resampling strategy which may
lead to slightly different q-values between runs.

iPython Notebooks

Run a Gene Ontology Enrichment Analysis (GOEA)

Show many study genes are associated with RNA, translation, mitochondria, and ribosomal

Report level and depth counts of a set of GO terms

Find all human protein-coding genes associated with cell cycle

Calculate annotation coverage of GO terms on various species

Determine the semantic similarities between GO terms

Want to Help?
Items that we know we need include:

* Edit tests in the **makefile** under the comment, **# TBD**, such they run using **nosetests**
* Help setting up documentation,

We are using Sphinx and Python docstrings to create documentation.

For documentation practice, use make targets:
% make mkdocs_practice

To remove practice documentation:
% make rmdocs_practice

Once you are happy with the documentation do:
% make gh-pages

Haibao Tang et al. (2015). GOATOOLS: Tools for Gene Ontology. Zenodo.
`10.5281/zenodo.31628 <>`_.
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


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
goatools-0.6.10.tar.gz (56.5 kB) Copy SHA256 Checksum SHA256 Source Oct 6, 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