HPOTermο
HPOTerm
instances contain all relevant information about a single HPO term. They are part of an Ontology
and contain links to parental and offspring HPOTerm
s.
HPOTerm
ο
- class pyhpo.term.HPOTerm(**kwargs)[source]ο
An HPOTerm instance can be build solely by itself, without knowledge of the actual Ontology. This is not recommended because it would miss all ontology features, such as parents, children, associated genes and diseaases etc.
An HPOTerm instance should always be derived from the
pyhpo.Ontology
- Parameters:
id (str) β
name (str) β
index (int) β
comment (str) β
definition (str) β
synonym (List[str]) β
xref (List[str]) β
alt_id (List[str]) β
is_obsolete (bool) β
replaced_by (str | None) β
consider (List[str]) β
parents (Set[HPOTerm]) β
children (Set[HPOTerm]) β
genes (Set[GeneSingleton]) β
omim_diseases (Set[OmimDisease]) β
omim_excluded_diseases (Set[OmimDisease]) β
orpha_diseases (Set[OrphaDisease]) β
orpha_excluded_diseases (Set[OrphaDisease]) β
decipher_diseases (Set[DecipherDisease]) β
decipher_excluded_diseases (Set[DecipherDisease]) β
information_content (InformationContent) β
Attributesο
- HPOTerm.id:
str
οThe HPO identifier, e.g.
HP:0000118
- HPOTerm.name:
str
οThe name of the HPO term, e.g.
Abnormal axial skeleton morphology
- HPOTerm.information_content:
InformationContent
οThe
InformationContent
of the HPO term. Multiple kinds of IC are automatically calculated, others can be manually calculated.
- HPOTerm.comment:
str
οThe comment from the OBO source file
- HPOTerm.definition:
str
οThe definition from the OBO source file
- HPOTerm.synonym:
List
[str
]οA list of synonymous names for the term
- HPOTerm.parents:
Set
[HPOTerm]οA set of all direct parent terms
- HPOTerm.children:
Set
[HPOTerm]οA set of all direct child terms
- HPOTerm.genes:
Set
[GeneSingleton
]οA set of all associated genes. Associated genes are inversely inherited from child terms as well
- HPOTerm.omim_diseases:
Set
[OmimDisease
]οA set of all associated Omim diseases. Associated diseases are inversely inherited from child terms as well
- HPOTerm.orpha_diseases:
Set
[OrphaDisease
]οA set of all associated Orpha diseases. Associated diseases are inversely inherited from child terms as well
- HPOTerm.decipher_diseases:
Set
[DecipherDisease
]οA set of all associated Decipher diseases. Associated diseases are inversely inherited from child terms as well
parent_ofο
child_ofο
parent_idsο
common_ancestorsο
count_parentsο
longest_path_to_rootο
shortest_path_to_rootο
shortest_path_to_parentο
longest_path_to_bottomο
path_to_otherο
- HPOTerm.path_to_other(other)[source]ο
Identifies the shortest connection between two HPO terms
- Parameters:
other (HPOTerm) β Target HPO term for path finding
- Return type:
Tuple
[int
,Tuple
[HPOTerm
,...
],int
,int
]- Returns:
int β Length of path
tuple β Tuple of HPOTerms in the path
int β Number of steps from term-1 to the common parent
int β Number of steps from term-2 to the common parent
similarity_scoreο
- HPOTerm.similarity_score(other, kind=None, method=None)[source]ο
Calculate the similarity between this and another HPO-Term It uses
pyhpo.similarity.base._Similarity
underneath- Parameters:
other (HPOTerm) β Other HPO term to compare similarity to
kind (str, default
''
) βWhich kind of information content should be calculated. Default option is defined in pyhpo.similarity.base._Similarity
Available options:
omim
orpha
decipher
gene
method (string, default
''
) βThe method to use to calculate the similarity. Default option is defined in pyhpo.similarity.base._Similarity
Available options:
resnik -
pyhpo.similarity.defaults.Resnik
jc2 -
pyhpo.similarity.defaults.JC
(deprecated)Additional methods can be registered separately ( see Custom Similarity algorithms)
- Raises:
RuntimeError β The specified
method
does not existNotImplementedError β This error can only occur with custom Similarity-Score methods that do not have a
similarity
method defined.AttributeError β The information content for
kind
does not exist
- Return type:
float
toJSONο
- HPOTerm.toJSON(verbose=False)[source]ο
Creates a JSON-like object of the HPOTerm
- Parameters:
verbose (bool, default
False
) β Include extra properties- Returns:
A dictionary with the main properties of the HPOTerm
- Return type:
dict
Example:
>>> terms[2].toJSON() { 'name': 'Abnormality of body height', 'id': 'HP:0000002', 'int': 2 } >>> terms[2].toJSON(verbose=True) { 'name': 'Abnormality of body height', 'synonym': ['Abnormality of body height'], 'comment': None, 'def': '"Deviation from the norm of height with respect [...]', 'xref': ['UMLS:C4025901'], 'is_a': ['HP:0001507 ! Growth abnormality'], 'id': 'HP:0000002', 'int': 2 }
InformationContent
ο
- class pyhpo.term.InformationContent(**data)[source]ο
InformationContent contains automatically calculated IC based on direct/indirect associations with genes, omim, orpha and decipher. IC instances are created automatically and accessed through
pyhpo.term.HPOTerm
instances.Users can also register and calculate custom IC scores via
pyhpo.term.InformationContent.set_custom()
.- Parameters:
gene (float) β
omim (float) β
orpha (float) β
decipher (float) β
custom (Dict[str, float]) β
Default attributesο
set_customο
- InformationContent.set_custom(key, value)[source]ο
Set the IC of a custom score
- Parameters:
key (str) β The name of the information-content metric
value (float) β The actual information content
- Return type:
None
Example:
for term in Ontology: # For some reason, you want to base the information content # on the depths of the Term in the ontology term.setcustom('depth', term.shortest_path_to_root()) # and now calculate similarity of two sets my_similarity = term_set_1.similarity(term_set_2, kind='depth')