Skip to content

Commit

Permalink
Merge pull request #70 from ielis/release-v0.5.1
Browse files Browse the repository at this point in the history
Make release `v0.5.1`
  • Loading branch information
ielis authored May 20, 2024
2 parents c3dea26 + e53ca09 commit 5912542
Show file tree
Hide file tree
Showing 24 changed files with 556 additions and 357 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ jobs:
python-version: ${{ matrix.python }}
- name: Install hpo-toolkit
run: |
python3 -m pip install --editable .[test,docs]
- name: Run tests
python3 -m pip install --editable .[test]
- name: Run all tests
run: |
pytest
- name: Run documentation tests
run: |
cd docs
sphinx-apidoc --separate --module-first -d 2 -H "API reference" -o apidocs ../src/hpotk
make doctest
pytest src docs tests
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# hpo-toolkit

![Build status](https://img.shields.io/github/actions/workflow/status/TheJacksonLaboratory/hpo-toolkit/python_ci.yml)
![PyPi downloads](https://img.shields.io/pypi/dm/hpo-toolkit.svg?label=Pypi%20downloads)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hpo-toolkit)
![PyPi downloads](https://img.shields.io/pypi/dm/hpo-toolkit.svg?label=Pypi%20downloads)
![Build status](https://img.shields.io/github/actions/workflow/status/ielis/hpo-toolkit/python_ci.yml)
[![GitHub release](https://img.shields.io/github/release/ielis/hpo-toolkit.svg)](https://github.com/ielis/hpo-toolkit/releases)

A toolkit for working with Human Phenotype Ontology (HPO) and HPO disease annotations in Python.

Expand Down Expand Up @@ -38,5 +39,5 @@ You got yourself phenotype annotations of 12,468 rare diseases.

Find more info in our detailed documentation:

- [Stable documentation](https://thejacksonlaboratory.github.io/hpo-toolkit/stable) (last release on `main` branch)
- [Latest documentation](https://thejacksonlaboratory.github.io/hpo-toolkit/latest) (bleeding edge, latest commit on `development` branch)
- [Stable documentation](https://ielis.github.io/hpo-toolkit/stable) (last release on `main` branch)
- [Latest documentation](https://ielis.github.io/hpo-toolkit/latest) (bleeding edge, latest commit on `development` branch)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

hpotk_src = os.path.abspath(os.path.join('..', 'src'))
sys.path.insert(0, hpotk_src)
# The import order is crucial to prevent having to install the library before generating documetation.
# The import order is crucial to prevent having to install the library before generating documentation.
import hpotk


Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Feedback
--------

The best place to leave feedback, ask questions, and report bugs is the
`HPO Toolkit's Issue Tracker <https://github.com/TheJacksonLaboratory/hpo-toolkit/issues>`_.
`HPO Toolkit's Issue Tracker <https://github.com/ielis/hpo-toolkit/issues>`_.

19 changes: 5 additions & 14 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The bleeding edge code

To access the bleeding edge features, the development version can be installed by::

git clone https://github.com/TheJacksonLaboratory/hpo-toolkit.git
git clone https://github.com/ielis/hpo-toolkit.git
cd hpo-toolkit
git checkout development && git pull
python3 -m pip install .
Expand All @@ -33,23 +33,14 @@ Run tests

The contributors may want to run the unit tests and the integration tests to ensure all features work as expected.

Before running tests, make sure you install HPO toolkit with `test` and `docs` dependencies::
Before running tests, make sure you install HPO toolkit with `test` dependencies::

python3 -m pip install .[test,docs]
python3 -m pip install .[test]

The unit tests and the integration tests can the be running by invoking the `pytest` runner::
The unit tests, integration tests, doctests, and the tutorial scripts can the be running by invoking the `pytest` runner::

pytest

We go extra mile to ensure the documentation is always up-to-date, and, therefore, we also run the documentation tests.
The documentation tests are run by::

cd docs
sphinx-apidoc --separate --module-first -d 2 -H "API reference" -o apidocs ../src/hpotk
make doctest

.. note::

The library *must* be installed in the environment before running all tests. Otherwise, the test discovery will fail.

Run benches
Expand All @@ -58,7 +49,7 @@ Run benches
Bench suites provide an idea about the performance of the library.
Running a bench requires checking out the GitHub repository and installing HPO toolkit with `bench` dependencies::

git clone https://github.com/TheJacksonLaboratory/hpo-toolkit.git
git clone https://github.com/ielis/hpo-toolkit.git
cd hpo-toolkit
python3 -m pip install .[bench]

Expand Down
48 changes: 23 additions & 25 deletions docs/user-guide/sort-term-ids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ HPO toolkit provides logic for sorting HPO terms such that the similar terms are

Let's illustrate this on example. Suppose having a subject annotated with the following terms:

.. doctest:: sort-term-ids

>>> subject = (
... 'HP:0001744', # Splenomegaly
... 'HP:0020221', # Clonic seizure
... 'HP:0001238', # Slender finger
... 'HP:0011153', # Focal motor seizure
... 'HP:0002240' # Hepatomegaly
... )
>>> term_ids = tuple(TermId.from_curie(curie) for curie in subject)
>>> import hpotk
>>> subject = (
... 'HP:0001744', # Splenomegaly
... 'HP:0020221', # Clonic seizure
... 'HP:0001238', # Slender finger
... 'HP:0011153', # Focal motor seizure
... 'HP:0002240' # Hepatomegaly
... )
>>> term_ids = tuple(hpotk.TermId.from_curie(curie) for curie in subject)


The order of HPO annotations does not reflect that *Splenomegaly* is more "similar" to *Hepatomegaly* than
Expand All @@ -39,18 +38,18 @@ The algorithm iteratively chooses the most similar term ID pairs and places them

We'll use a toy HPO with several terms to present the functionality:

.. doctest:: sort-term-ids
>>> import os
>>> fpath_hpo = os.path.join('docs', 'data', 'hp.toy.json')
>>> hpo = hpotk.load_minimal_ontology(fpath_hpo)

>>> from hpotk.util.sort import HierarchicalEdgeTermIdSorting
>>> hpo = hpotk.load_minimal_ontology('data/hp.toy.json')
>>> sorting = HierarchicalEdgeTermIdSorting(hpo)
>>> from hpotk.util.sort import HierarchicalEdgeTermIdSorting
>>> sorting = HierarchicalEdgeTermIdSorting(hpo)

We can obtain the indices that will sort the HPO terms and prepare a `tuple` with sorted terms:

.. doctest:: sort-term-ids

>>> indices = sorting.argsort(term_ids)
>>> ordered = tuple(term_ids[idx] for idx in indices)
>>> indices = sorting.argsort(term_ids)
>>> ordered = tuple(term_ids[idx] for idx in indices)

Now let's look at the order. Originally, the HPO terms were ordered as follows::

Expand All @@ -62,14 +61,13 @@ Now let's look at the order. Originally, the HPO terms were ordered as follows::

After the sorting, we get this order:

.. doctest:: sort-term-ids

>>> for term_id in ordered:
... print(hpo.get_term(term_id).name)
Focal motor seizure
Clonic seizure
Hepatomegaly
Splenomegaly
Slender finger
>>> for term_id in ordered:
... print(hpo.get_term(term_id).name)
Focal motor seizure
Clonic seizure
Hepatomegaly
Splenomegaly
Slender finger

which is much better, right?
39 changes: 17 additions & 22 deletions docs/user-guide/use-hierarchy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ HPO toolkit enables accessing the ontology hierarchy through the :class:`hpotk.g
in turn available through :class:`hpotk.ontology.MinimalOntology`. In other words, each ontology has the ontology graph
as a property:

.. doctest:: traverse-hierarchy
>>> import os
>>> import hpotk

>>> import hpotk
>>> hpo = hpotk.load_minimal_ontology('data/hp.toy.json')
>>> hpo.graph
CsrIndexedOntologyGraph(root=HP:0000001, n_nodes=393)
>>> fpath_hpo = os.path.join('docs', 'data', 'hp.toy.json')
>>> hpo = hpotk.load_minimal_ontology(fpath_hpo)
>>> hpo.graph
CsrIndexedOntologyGraph(root=HP:0000001, n_nodes=393)


We can leverage the hierarchy to infer a lot of extra information about the concepts, and, for instance,
Expand All @@ -37,23 +38,19 @@ a term instead of successor/predecessors of a node. Let's illustrate this on a c
We can get term IDs of the *parents* of a term, such as `Seizure <https://hpo.jax.org/app/browse/term/HP:0001250>`_
[`HP:0001250`] by calling:

.. doctest:: traverse-hierarchy

>>> for parent in hpo.graph.get_parents('HP:0001250'):
... print(parent)
HP:0012638
>>> for parent in hpo.graph.get_parents('HP:0001250'):
... print(parent)
HP:0012638

`HP:0012638` corresponds to
`Abnormal nervous system physiology <https://hpo.jax.org/app/browse/term/HP:0012638>`_.

*Children* are accessed in a similar fashion:

.. doctest:: traverse-hierarchy

>>> for child in hpo.graph.get_children('HP:0001250'):
... print(child)
HP:0020219
HP:0007359
>>> for child in hpo.graph.get_children('HP:0001250'):
... print(child)
HP:0020219
HP:0007359


We will leave finding the ancestors or descendants of a term as an exercise for the interested reader.
Expand All @@ -66,13 +63,11 @@ ancestors/descendants of each other.

We can test if Seizure [`HP:0001250`] is a parent or an ancestor of Clonic seizure [`HP:0020221`]:

.. doctest:: traverse-hierarchy

>>> hpo.graph.is_parent_of('HP:0001250', 'HP:0020221')
False
>>> hpo.graph.is_parent_of('HP:0001250', 'HP:0020221')
False

>>> hpo.graph.is_ancestor_of('HP:0001250', 'HP:0020221')
True
>>> hpo.graph.is_ancestor_of('HP:0001250', 'HP:0020221')
True

Similar methods exist for checking if a term is a child or a descendant of another term.

Expand Down
Loading

0 comments on commit 5912542

Please sign in to comment.