Skip to main content

obogo: Yet another ontology crawler to perform ORA!!!

installation

pip install obogo

prerequistes

You will need to grab the latest Gene Ontology description in .obo format. Download it from the official GO site. This is a reasonable format, where each GO term is encoded as a paragraph of key:value lines:

[Term]
id: GO:0000001
name: mitochondrion inheritance
namespace: biological_process
def: "The distribution of mitochondria, including the mitochondrial genome, into daughter cells after mitosis or meiosis, mediated by interactions between mitochondria and the cytoskeleton." [GOC:mcc, PMID:10873824, PMID:11389764]
synonym: "mitochondrial inheritance" EXACT []
is_a: GO:0048308 ! organelle inheritance
is_a: GO:0048311 ! mitochondrion distribution

Obvisously, is_a is the main relationship of interest to build the DAG of GO terms. But consider, replaced_by and alias_to properties are also handled by this package.

Build the GO DAG structure

Simply read from a flat .obo file

from obogo import create_tree_from_obo
obogo_tree = create_tree_from_obo('../data/go-basic.obo')

You can query a go term by a name or its GO identifier

obogo_tree.view_go_node('GO:1903507')
obogo_tree.view_go_node('biological process')

Build a protein collection

In order to set the background population of proteins for each GO term, you will need to build a collection of uniprot data containers. In obogo, these are called UniprotDatum and can be directly created from a uniprot proteome xml reference file (eg: E.coli K12). Supposed we downloaded the above mentioned E.Coli K12 proteome xml file named uniprotkb_proteome_UP000000625.xml, the collection of uniprot containers can be buildt this way:

from uniprot_redis.store.mockup import UniprotStoreDummy
from uniprot_redis.wrapper import Collector
#populate store
store = UniprotStoreDummy()
load_data = store.load_uniprot_xml(file="path/to/uniprotkb_proteome_UP000000625.xml")
store.save_collection('ecoli_K12', load_data)
#retrieve collection
my_collection = Collector(store, 'ecoli_K12')

This collection is iterable, slice-able or get-able via uniprot Accession numbers.

print(my_collection['P19636'])
for uniprot_datum in my_collection:
    print(uniprot_datum.id, uniprot_datum.go)

Assign whole proteome to the GO structure

Each protein of the collection now has to be attached to the GO terms that are described in its UniprotDatum go field (see above).

obogo_tree.load_proteins('background', my_collection)

The obogo_tree represents each GO term as a straight newtworkx node. The load_proteins call will set the for each node the value of their 'background' key to a list of UniprotDatum.

In most ORA analysis the population of proteins attached to a given node is the union of the proteins attached to its descendant ("GO annotation goes up": "any specific GO term implicitly carries the meaning of a less specific"). Hence, an additional operation is required to propagate protein populations up the tree.

obogo_tree.percolate(percol_type="background")

This currently takes around 2mn for E.Coli proteome.

NB: At this stage, serializing the obogo_tree could be handy
import pickle
pik_fpath = "obogo_ecoliK12.pik"
with open(pik_fpath, "wb") as fp:
    pickle.dump(obogo_tree, fp)

Load the experimental protein set

For this tutorial, we will create a dummy collection of experimental proteins based on a slice of 1200 protein from the proteome and load it into obogo_tree. Note that this time, it is loaded using the 'measured' argument. Then, we also propagate this additional protein population up the tree.

obo_tree.load_proteins('measured', my_collection[1000:2200])
obo_tree.percolate(percol_type='measured')

Define sample protein set

We now define a subset of measured proteins as "of interest" (aka: over-abundant).

sample = my_collection[1100:1180]

Compute ORA of the GO terms within the sample

For a particular GO term

from obogo.statistics import compute_node_ora
print( compute_node_ora(obo_tree, sample, 'GO:0006811') )
print( compute_node_ora(obo_tree, sample, 'metal ion transport') )
print( compute_node_ora(obo_tree, sample, 'GO:0006811', norm='measured') )

The sample parameter can also be a straight Uniprot AC iterator (eg: ['P02930', 'P03819', 'P0A910']). The `norm`` parameter controls the reference population for the Fisher statistic:

  • 'background' : the whole proteome (default)
  • 'measured' : the proteins of the experiment

The returned value is a tuple of the form:

(GO_identfier, GO_name, total_sample protein carrying the GO term, Fisher test log_odd, Fisher test pvalue, contingency table)

A similar operation can be applied to the entiere tree, where a generator of score tuples will be returned

from obogo.statistics import score_ora_tree
for go_score in score_ora_tree(obo_tree, sample):
    print(go_score)

Metadata

Release files for obogo 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for obogo 0.4.0
File Size Uploaded
obogo-0.4.0.tar.gz 58.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for obogo 0.4.0
File Interpreter ABI Platform
obogo-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 81.6 kB

Release files / obogo-0.4.0.tar.gz

Download URL obogo-0.4.0.tar.gz
Size 58.0 kB
Tags Source
SHA-256 checksum
How to use checksums
be577770720a312788c9dbe9c2b8ce20059af3d3269dea2da6abb85eabf984c8
BLAKE2b-256 checksum
How to use checksums
2073e9db547c098b7240ec1f0b0cf70ba4617fe6d02f41ea4feca3c15d9ee19f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.3

Release files / obogo-0.4.0-py3-none-any.whl

Download URL obogo-0.4.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57d3a6f07519f15f384951d893b5505f1a4785a16edffece3e7f0f2913372427
BLAKE2b-256 checksum
How to use checksums
d8e8010a0595411ab8bbd13b40849b4d854c2668e7f72d2e33596bd29a495314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.3

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page