Examples
This section provides examples for various functions of PyHPO.
Some high-level examples are already provided in the README
file:
Some examples for basic functionality of PyHPO
How similar are the phenotypes of two patients
from pyhpo import Ontology
from pyhpo.set import HPOSet
# initilize the Ontology ()
_ = Ontology()
# Declare the clinical information of the patients
patient_1 = HPOSet.from_queries([
'HP:0002943',
'HP:0008458',
'HP:0100884',
'HP:0002944',
'HP:0002751'
])
patient_2 = HPOSet.from_queries([
'HP:0002650',
'HP:0010674',
'HP:0000925',
'HP:0009121'
])
# and compare their similarity
patient_1.similarity(patient_2)
#> 0.7594183905785477
How close are two HPO terms
from pyhpo import Ontology
# initilize the Ontology ()
_ = Ontology()
term_1 = Ontology.get_hpo_object('Scoliosis')
term_2 = Ontology.get_hpo_object('Abnormal axial skeleton morphology')
path = term_1.path_to_other(term_2)
for t in path[1]:
print(t)
"""
HP:0002650 | Scoliosis
HP:0010674 | Abnormality of the curvature of the vertebral column
HP:0000925 | Abnormality of the vertebral column
HP:0009121 | Abnormal axial skeleton morphology
"""