Skip to content

Commit 914022b

Browse files
authored
Merge pull request #28 from anergictcell/feature/non-transitive-genes
Make Gene-HPOTerm associations non-transitive
2 parents d18a4df + f5e3476 commit 914022b

25 files changed

+317151
-274
lines changed

.github/workflows/test_python_versions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ on:
1010

1111
jobs:
1212
test_all_python_versions:
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
16+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Set up Python ${{ matrix.python-version }}

CHANGELOG.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
Changelog
22
=========
33

4+
4.0.0
5+
-----
6+
Removed Ontology export to dataframe and pandas dependencies
7+
Change logic of gene-HPO association parsing to be non-transitive by default
8+
Add method to convert genes or diseases to HPOSet
9+
Update documentation
10+
Update minimum Python requirement to 3.8
11+
Remove dependencies for backporting logic to Python 3.7
12+
413
3.3.2
514
-----
615
Data update to 2025-01-16
716

8-
917
3.3.1
1018
-----
1119
Data update to 2024-04-26

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ include CHANGELOG.rst
33
include pyhpo/data/phenotype_to_genes.txt
44
include pyhpo/data/hp.obo
55
include pyhpo/data/phenotype.hpoa
6-
6+
include pyhpo/data/genes_to_phenotype.txt

README.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ This will install a base version of **PyHPO** that offers most functionality.
5757

5858
.. note::
5959

60-
Some features of PyHPO require ``pandas`` and ``scipy``. The standard installation via pip will not include pandas or scipy and PyHPO will work just fine. (You will get a warning on the initial import though).
61-
62-
Without installing ``pandas``, you won't be able to export the Ontology as a ``Dataframe``, everything else will work fine.
60+
Some features of PyHPO require ``scipy``. The standard installation via pip will not include scipy and PyHPO will work just fine. (You will get a warning on the initial import though).
6361

6462
Without installing ``scipy``, you won't be able to use the ``stats`` module, especially the enrichment calculations.
6563

@@ -70,13 +68,7 @@ If you want to do enrichment analysis, you must also install ``scipy``.
7068
7169
pip install 'pyhpo[scipy]'
7270
73-
If you want to work with **PyHPO** using ``pandas`` dataframes, you can install the ``pandas`` dependency
74-
75-
.. code:: bash
76-
77-
pip install 'pyhpo[pandas]'
78-
79-
Or simply install both together:
71+
Or simply install all optional dependencies:
8072

8173
.. code:: bash
8274

docs/annotations.rst

Lines changed: 191 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,205 @@
11
Annotations
22
===========
33

4-
The ``Annotations`` section contains various metadata annotations for HPO terms.
4+
The ``Annotations`` module contains the gene and disease associations of HPOTerms.
55

6-
``GeneSingleton`` class
7-
***********************
8-
.. autoclass:: pyhpo.annotations.GeneSingleton
9-
:no-private-members:
10-
:no-special-members:
6+
.. code::
117
12-
toJSON
13-
------
14-
.. automethod:: pyhpo.annotations.GeneSingleton.toJSON
8+
from pyhpo import Ontology
9+
from pyhpo.annotations import Omim, Orpha
1510
11+
Ontology()
1612
17-
``GeneDict`` class
18-
******************
19-
.. autoclass:: pyhpo.annotations.GeneDict
20-
:no-private-members:
21-
:no-special-members:
13+
# All genes and diseases can be accessed through the Ontology
2214
15+
for gene in Ontology.genes:
16+
print(gene.name)
17+
# >> "EZH2"
18+
# ...
2319
24-
``DiseaseSingleton`` class
25-
**************************
26-
.. autoclass:: pyhpo.annotations.DiseaseSingleton
27-
:no-private-members:
28-
:no-special-members:
20+
for orpha in Ontology.orpha_diseases:
21+
print(orpha.id)
22+
# >> 231401
23+
# ...
2924
30-
toJSON
31-
------
32-
.. automethod:: pyhpo.annotations.DiseaseSingleton.toJSON
3325
34-
``DiseaseDict`` class
35-
*********************
36-
.. autoclass:: pyhpo.annotations.DiseaseDict
37-
:no-private-members:
38-
:no-special-members:
26+
# or accessed directly from the `Orpha`, `Omim`, `Gene` class
3927
40-
Omim
41-
****
42-
Instance of :class:`pyhpo.annotations.DiseaseDict` to handle Omim diseases. Ensures that diseases are not duplicated through use of Singletons.
28+
orpha_disease = Orpha.get(77260)
29+
omim_disease = Omim.get(230900)
4330
44-
Orpha
45-
*****
46-
Instance of :class:`pyhpo.annotations.DiseaseDict` to handle Orphanet diseases. Ensures that diseases are not duplicated through use of Singletons.
4731
48-
Decipher
49-
********
50-
Instance of :class:`pyhpo.annotations.DiseaseDict` to handle Decipher diseases. Ensures that diseases are not duplicated through use of Singletons.
32+
# Annotations can be converted to `HPOSet`
33+
34+
orpha_set = orpha_disease.hpo_set()
35+
omim_set = omim_disease.hpo_set()
36+
37+
similarity = orpha_set.similarity(omim_set)
38+
print(similarity)
39+
# >> 0.6620065792484546
40+
41+
42+
.. class:: GeneSingleton
43+
44+
An instance of a gene, associated to several :class:`pyhpo.term.HPOTern`.
45+
46+
.. note::
47+
48+
Since version 4.0 genes do not contain references to HPOTerms transitively, i.e. only directly
49+
associated HPOTerms are linked to the gene.
50+
51+
.. attribute:: id
52+
53+
:Return Type: ``int``
54+
55+
:Returns: The HGNC ID of the gene
56+
57+
.. attribute:: name
58+
59+
:Return Type: ``str``
60+
61+
:Returns: The HUGO gene synbol of the gene
62+
63+
.. attribute:: symbol
64+
65+
:Return Type: ``str``
66+
67+
:Returns: The HUGO gene synbol of the gene (alias of :attr:`GeneSingleton.name`)
68+
69+
.. attribute:: hpo
70+
71+
:Return Type: ``set(int)``
72+
73+
:Returns: The HPO-IDs of all associated :class:`pyhpo.term.HPOTerm` s
74+
75+
.. autofunction:: pyhpo.annotations.Annotation.toJSON
76+
77+
.. autofunction:: pyhpo.annotations.Annotation.hpo_set
78+
79+
80+
.. class:: Gene
81+
82+
``Gene`` holds all :class:`GeneSingleton` instances and ensures they are not duplicated.
83+
It does not need to be instantiated, as it is already created as a singleton during the
84+
setup of the Ontology.
85+
86+
.. autofunction:: pyhpo.annotations.Gene.get
87+
.. autofunction:: pyhpo.annotations.Gene.__call__
88+
89+
90+
.. class:: OmimDisease
91+
92+
An instance of an Omim disease, associated to several :class:`pyhpo.term.HPOTerm`.
93+
94+
.. attribute:: id
95+
96+
:Return Type: ``int``
97+
98+
:Returns: The Omim ID
99+
100+
.. attribute:: name
101+
102+
:Return Type: ``str``
103+
104+
:Returns: The Omim disease name
105+
106+
.. attribute:: hpo
107+
108+
:Return Type: ``set(int)``
109+
110+
:Returns: The HPO-ID of all associated :class:`HPOTerm` s
111+
112+
.. autofunction:: pyhpo.annotations.Annotation.toJSON
113+
114+
.. autofunction:: pyhpo.annotations.Annotation.hpo_set
115+
116+
117+
.. class:: Omim
118+
119+
``Omim`` holds all :class:`OmimDisease` instances and ensures they are not duplicated.
120+
It does not need to be instantiated, as it is already created as a singleton during the
121+
setup of the Ontology.
122+
123+
.. autofunction:: pyhpo.annotations.DiseaseDict.get
124+
125+
:Return type: :class:`OmimDisease`
126+
127+
.. autofunction:: pyhpo.annotations.DiseaseDict.__call__
128+
129+
130+
.. class:: OrphaDisease
131+
132+
An instance of an Orpha disease, associated to several :class:`pyhpo.term.HPOTerm`.
133+
134+
.. attribute:: id
135+
136+
:Return Type: ``int``
137+
138+
:Returns: The Orpha ID
139+
140+
.. attribute:: name
141+
142+
:Return Type: ``str``
143+
144+
:Returns: The Orpha disease name
145+
146+
.. attribute:: hpo
147+
148+
:Return Type: ``set(int)``
149+
150+
:Returns: The HPO-ID of all associated :class:`HPOTerm` s
151+
152+
.. autofunction:: pyhpo.annotations.Annotation.toJSON
153+
154+
.. autofunction:: pyhpo.annotations.Annotation.hpo_set
155+
156+
157+
.. class:: Orpha
158+
159+
``Orpha`` holds all :class:`OrphaDisease` instances and ensures they are not duplicated.
160+
It does not need to be instantiated, as it is already created as a singleton during the
161+
setup of the Ontology.
162+
163+
.. autofunction:: pyhpo.annotations.DiseaseDict.get
164+
165+
:Return type: :class:`OrphaDisease`
166+
167+
.. autofunction:: pyhpo.annotations.DiseaseDict.__call__
168+
169+
170+
.. class:: DecipherDisease
171+
172+
An instance of an Decipher disease, associated to several :class:`pyhpo.term.HPOTerm`.
173+
174+
.. attribute:: id
175+
176+
:Return Type: ``int``
177+
178+
:Returns: The Decipher ID
179+
180+
.. attribute:: name
181+
182+
:Return Type: ``str``
183+
184+
:Returns: The Decipher disease name
185+
186+
.. attribute:: hpo
187+
188+
:Return Type: ``set(int)``
189+
190+
:Returns: The HPO-ID of all associated :class:`HPOTerm` s
191+
192+
.. autofunction:: pyhpo.annotations.Annotation.toJSON
193+
194+
.. autofunction:: pyhpo.annotations.Annotation.hpo_set
195+
196+
197+
.. class:: Decipher
198+
199+
``Decipher`` holds all :class:`DecipherDisease` instances and ensures they are not duplicated.
200+
201+
.. autofunction:: pyhpo.annotations.DiseaseDict.get
202+
203+
:Return type: :class:`DecipherDisease`
204+
205+
.. autofunction:: pyhpo.annotations.DiseaseDict.__call__

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"sphinx.ext.viewcode",
4040
"sphinx.ext.napoleon",
4141
"sphinx_autodoc_typehints",
42+
"sphinx_rtd_theme",
4243
]
4344

4445
# Add any paths that contain templates here, relative to this directory.
@@ -57,7 +58,7 @@
5758

5859
# General information about the project.
5960
project = "PyHPO"
60-
copyright = "2023, Jonas Marcello"
61+
copyright = "2025, Jonas Marcello"
6162
author = pyhpo.__author__
6263

6364
# The version info for the project you're documenting, acts as replacement for

docs/ontology.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ Ontology
33

44
The ``Ontology`` contains all ``HPOTerm`` s and thus reflects the full ontology including links and information about inheritance
55

6+
.. note::
7+
8+
Starting with `pyhpo 4.0`, the Ontology will link genes non-transitive to HPO terms.
9+
This means it will be the same behavior as the `hpo3` library.
10+
See https://github.com/anergictcell/hpo/issues/44 and
11+
https://github.com/anergictcell/pyhpo/issues/26 for details about this.
12+
13+
614
``Ontology`` class
715
********************
816
.. autoclass:: pyhpo.ontology.OntologyClass

docs/tutorial/basics.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ It can now be used across all modules. Imagine the following source code:
4343
def get_term_name(term_id: int) -> str:
4444
try:
4545
term = Ontology[term_id]
46+
return term.name
4647
except KeyError:
4748
print("Term not present in Ontology")
4849
return ""

docs/tutorial/data.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ Masterdata
33

44
**PyHPO** ships with a full version of the HP ontology, including gene and disease associations. I try to keep this data up to date, but will frequently fall behind on the release schedule.
55

6-
To build the ontology, the following 3 files are needed from the HPO masterdata:
6+
To build the ontology, the following 4 files are needed from the HPO masterdata:
77

88
* ``http://purl.obolibrary.org/obo/hp.obo``
9-
* ``http://purl.obolibrary.org/obo/hp/hpoa/phenotype_to_genes.txt``
9+
* ``http://purl.obolibrary.org/obo/hp/hpoa/genes_to_phenotype.txt``
1010
* ``http://purl.obolibrary.org/obo/hp/hpoa/phenotype.hpoa``
11+
* ``http://purl.obolibrary.org/obo/hp/hpoa/phenotype_to_genes.txt`` (optional)
1112

1213

1314
Updating to the most recent version

pyhpo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# The following info will be used by setup.py and sphinx documentation
1313
__author__ = "Jonas Marcello"
14-
__version__ = "3.3.2"
14+
__version__ = "4.0.0"
1515

1616
__all__ = (
1717
"Annotation",

0 commit comments

Comments
 (0)