Skip to main content

Build annotated ontologies for BioCyc objects

Project description

Setup

python -m pip install ontologize

Usage

Vignette: Genes

Suppose we have a list of genes, perhaps ones that are upregulated in a certain environment, and we wish to understand the functional changes in the cell.

We can first build an Ontology object from a list of the genes' BioCyc IDs:

from ontologize.ontology import build_ontology

# cadA EG10131
# lacA EG10524 
# xylA EG11074 
ont = build_ontology(objects=["EG10131", "EG10524", "EG11074"], schema_type="Gene")

Ontology objects store an annotated ontology graph, as a networkX DiGraph:

import networkx as nx
assert isinstance(ont.graph, nx.DiGraph)

Rich printing options are supported, including truncation of the graph at a given depth, inclusion/exclusion of leaf nodes, whether to color by depth.

print(ont.to_string(max_depth=None, include_leaves=False, colors=True))

alt text

In this example, we see that lacA and xylA are both involved in carbon utilization, while cadA is related to pH adaptation.

Command-Line Interface

Once exposed, ontologize exposes a runnable script, and can also be called as a module:

ontologize <file> <schema_type> [flags]
python -m ontologize <file> <schema_type> [flags]

The required arguments are given as follows:

  • file: Path to a .csv, .tsv, or .xlsx file with BioCyc object IDs to ontologize. By default, assumes a (header-less, if .csv or .tsv) first column containing the IDs to be ontologized. If a .xlsx file is given, then by default, IDs are assumed to be in the first sheet in the first column, treating the first entry as a header.

  • schema_type : Type of the objects (or properties) to be ontologized in the Biocyc Schema. For example, this might be Gene, Pathway, Compound, etc.

Note that schema_type uses the singular form of the class name!

Example:

# TODO

Flags

Ontology-building options:

  • -s <sheet_name>, --sheet <sheet_name>: For a .xlsx file, the name of the sheet containing BioCyc IDs. Ignored if file is not a .xlsx file.
  • -o <objects>, --objects <objects>: For a multi-column file, the name of the column containing BioCyc IDs for the objects to ontologize. Requires a header row containing column names.
  • -p <objects>, --property <objects>: For a multi-column file, the name of the column containing BioCyc IDs for the property to ontologize. Requires a header row containing column names. When using this option, the objects must also be specified using the -o option.
  • WARNING: -p, --property NOT YET IMPLEMENTED

  • --database <orgid>: BioCyc organism ID, used to specify the organism-specific database within to search. ECOLI by default.

Printing options:

  • --depth <depth>: Maximum depth of the ontology to print. No limit by default.
  • --leaves: Whether to show leaf nodes, i.e., the ontologized objects themselves. Not shown by default.
  • --coloroff: Turns off colorful printing.

TODO: graph options (not implemented), pkl options, --interactive (allows maintaining session)

References

[BioCyc19] Karp, P.D., et al., The BioCyc collection of microbial genomes and metabolic pathways Briefings in Bioinformatics (2019).

Project details


Download files

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

Source Distribution

ontologize-0.2.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ontologize-0.2.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file ontologize-0.2.0.tar.gz.

File metadata

  • Download URL: ontologize-0.2.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ontologize-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6c6cac698bb96636b47c31f771068a67fed65fe09b97d98fd005c1086fa9ae0d
MD5 e00e00d3c9b070c958c3d23683f22696
BLAKE2b-256 bcd52faadf22d6ea767902d1c4b82803ea2f4b091f93fbf9a9cb49e65f942a6d

See more details on using hashes here.

File details

Details for the file ontologize-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ontologize-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ontologize-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e615fa28a6ef34b5d4825f2b5c428fe9095dba21aeb6ab982a536f808dbf157
MD5 dff8a3cbc7e772548c7399cd4066fcee
BLAKE2b-256 c0fb4b53b62a9d775cb710bd8fa839fd0bb6972f7c64d985f4d572ed4c0d4d08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page