HPOTerm

class HPOTerm
all_parents

A set of all parents

Returns

All direct and indirect parents

Return type

Set[HPOTerm]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(108)
term.all_parents  # >> {large set}
categories

A list of the root phenotypical or modifier categories the term belongs to

Returns

The root phenotypical terms or modifier categories

Return type

Set[HPOTerm]

Raises
  • NameError – Ontology not yet constructed

  • KeyError – No HPO term is found for the provided query

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(10049)
for cat in term.categories:
    print(cat.name)
child_of(other)

Returns true if the term is a child of other

Parameters

other (HPOTerm) – The other HPOTerm

Returns

Whether the term is a child of other

Return type

bool

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[10049]
term2 = Ontology[118]

term.child_of(term2)
# >> True
children

A set of direct children

Returns

All direct children

Return type

Set[HPOTerm]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(1)
term.children  # >> {<HpoTerm (HP:0000005)>, <HpoTerm (HP:0000118)>, <HpoTerm (HP:0012823)>, <HpoTerm (HP:0032443)>, <HpoTerm (HP:0040279)>, <HpoTerm (HP:0032223)>}
common_ancestors(other)

Returns common ancestor HPOTerm

Parameters

other (HPOTerm) – The other HPOTerm

Returns

All terms that are common ancestors

Return type

set[HPOTerm]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[2650]
term2 = Ontology[9121]

term.common_ancestors(term2)
# >> {<HpoTerm (HP:0000001)>, <HpoTerm (HP:0011842)>,
# >> <HpoTerm (HP:0033127)>, <HpoTerm (HP:0000118)>,
# >> <HpoTerm (HP:0000924)>}
count_parents()

Returns the number of direct parents of the term

Returns

The number of parents of the term

Return type

int

Examples

from pyhpo import Ontology
Ontology()
Ontology[100490].count_parents()
# >> 3
genes

Returns a set of associated genes

The list includes “inherited” genes that are not directly linked to the term, but to one of its children

Returns

All associated genes

Return type

Set[pyhpo.Gene]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(188)
for gene in term.genes:
    print(gene.name)
id

Returns the HPO Term ID

Returns

The term identifier, e.g.: HP:0011968

Return type

str

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(11968)
term.id    # >> 'HP:0011968'
information_content

Returns the Information Content of the HPO Term

Returns

The term’s information content

Return type

pyhpo.types.InformationContent

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(11968)
term.information_content.omim  # >> 2.5363943576812744
term.information_content.gene  # >> 1.457185983657837
is_obsolete

Indicates if the term is flagged as obsolete

Obsolete terms are ususally not linked to parents or children and should not be used.

In most cases, you can find a replacement using HPOTerm::replaced_by()

Returns

True if the term is obsolete

Return type

bool

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[10049]
term.is_obsolete # ==> False
name

Returns the name of the HPO Term

Returns

The term name, e.g.: Feeding difficulties

Return type

str

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(11968)
term.name  # >> 'Feeding difficulties'
omim_diseases

Returns a set of associated OMIM diseases

The list includes “inherited” diseases that are not directly linked to the term, but to one of its children

Returns

All associated Omim diseases

Return type

Set[pyhpo.Omim]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(188)
for disease in term.omim_diseases:
    print(disease.name)
parent_ids()

Returns a list of all direct parent’s HPO-IDs

Returns

A list of int representations of the parent terms

Return type

List[int]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[10049]

term.parent_ids()
# >> [3026, 5914]
parent_of(other)

Returns true if the term is a parent of other

Parameters

other (HPOTerm) – The other HPOTerm

Returns

Whether the term is a parent of other

Return type

bool

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[10049]
term2 = Ontology[118]

term2.parent_of(term)
# >> True
parents

A set of direct parents

Returns

All direct parents

Return type

Set[HPOTerm]

Examples

from pyhpo import Ontology
Ontology()
term = Ontology.hpo(108)
term.parents  # >> {<HpoTerm (HP:0011035)>, <HpoTerm (HP:0000107)>, <HpoTerm (HP:0100957)>}
path_to_other(other)

Calculates the shortest path to another HPO Term

Note

This method is not correctly implemented: It will always return 0 for the sub-paths distances.

Parameters

other (HPOTerm) – The other HPOTerm

Returns

  • int – The number of terms between self and the other term (excluding self, but including other)

  • List[HPOTerm] – The terms between and including self and other

  • int – Always 0

  • int – Always 0

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[40064]
term2 = Ontology[769]
term.path_to_other(term2)
# >> (
# >>    2,
# >>    [<HpoTerm (HP:0040064)>, <HpoTerm (HP:0000118)>, <HpoTerm (HP:0000769)>],
# >>    0,
# >>    0
# >> )
replace()

Returns the replacement term, if the term is obsolete

Returns

The HPOterm

Return type

HPOTerm

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[100637]
replacement = term.replace()
replacement.id # >> 'HP:0012720'
replaced_by

Returns the replacement term name, if the term is obsolete

Returns

The HPO term id, e.g. HP:0003026

Return type

str

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[100637]
term.replaced_by # >> 'HP:0012720'
shortest_path_to_parent(other)

Calculates the shortest path to an ancestor HPO Term

If other is not a parent term, the distance will be Inf.

As a minor difference to PyHPO, this method does not return a Tuple, but a list of terms.

Parameters

other (HPOTerm) – The other HPOTerm

Returns

  • float – The number of terms between self and the other term. If other is not a parent, it returns Inf

  • List[HPOTerm] – The terms between self and other

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[100490]
term2 = Ontology[1]
term.shortest_path_to_parent(term2)
# >> (
# >>    8.0,
# >>    [
# >>        <HpoTerm (HP:0006261)>, <HpoTerm (HP:0005918)>,
# >>        <HpoTerm (HP:0001167)>, <HpoTerm (HP:0001155)>,
# >>        <HpoTerm (HP:0002817)>, <HpoTerm (HP:0040064)>,
# >>        <HpoTerm (HP:0000118)>, <HpoTerm (HP:0000001)>
# >>    ]
# >> )
shortest_path_to_root()

Returns the number of terms between self and the root term

Returns

The number of terms between self and the root term

Return type

int

Examples

from pyhpo import Ontology
Ontology()
Ontology[100490].shortest_path_to_root()
# >> 8
similarity_score(other, kind, method)

Calculates the similarity score of two HPO Terms

Parameters
  • other (HPOTerm) – The other HPOTerm

  • kind (str, default: omim) –

    Which kind of information content to use for similarity calculation

    Available options:

    • omim

    • gene

  • method (str, default graphic) –

    The method to use to calculate the similarity.

    Available options:

    • resnik - Resnik P, Proceedings of the 14th IJCAI, (1995)

    • lin - Lin D, Proceedings of the 15th ICML, (1998)

    • jc - Jiang J, Conrath D, ROCLING X, (1997) This is different to PyHPO

    • jc2 - Jiang J, Conrath D, ROCLING X, (1997) Same as jc, but kept for backwards compatibility

    • rel - Relevance measure - Schlicker A, et.al., BMC Bioinformatics, (2006)

    • ic - Information coefficient - Li B, et. al., arXiv, (2010)

    • graphic - Graph based Information coefficient - Deng Y, et. al., PLoS One, (2015)

    • dist - Distance between terms

Returns

The similarity score

Return type

float

Raises
  • KeyError – Invalid kind

  • RuntimeError – Invalid method

Examples

from pyhpo import Ontology

Ontology()
term = Ontology[11968]

term.similarity_score(Ontology[1743])

# compare HP:0011968 and HP:0001743 using Gene
term.similarity_score(Ontology[1743], kind="gene")
similarity_scores(others, kind, method)

Calculates the similarity score between the term and a batch of other terms

This method is useful if you want to compare the term to thousands of other terms. It will utilize all avaible CPU for parallel processing.

Parameters
  • others (List[HPOTerm]) – Lost of HPOTerm to calculate similarity to

  • kind (str, default: omim) –

    Which kind of information content to use for similarity calculation

    Available options:

    • omim

    • gene

  • method (str, default graphic) –

    The method to use to calculate the similarity.

    Available options:

    • resnik - Resnik P, Proceedings of the 14th IJCAI, (1995)

    • lin - Lin D, Proceedings of the 15th ICML, (1998)

    • jc - Jiang J, Conrath D, ROCLING X, (1997) This is different to PyHPO

    • jc2 - Jiang J, Conrath D, ROCLING X, (1997) Same as jc, but kept for backwards compatibility

    • rel - Relevance measure - Schlicker A, et.al., BMC Bioinformatics, (2006)

    • ic - Information coefficient - Li B, et. al., arXiv, (2010)

    • graphic - Graph based Information coefficient - Deng Y, et. al., PLoS One, (2015)

    • dist - Distance between terms

Returns

The similarity scores

Return type

List[float]

Raises
  • KeyError – Invalid kind

  • RuntimeError – Invalid method

Examples

from pyhpo import Ontology

Ontology()
term = Ontology[11968]

term.similarity_scores(list(Ontology))
toJSON(verbose)

Returns a dict/JSON representation the HPOTerm

Parameters

verbose (bool) – if extra attributes should be included

Returns

Dict representation of the HPOTerm with the following keys:

  • namestr

    The name of the HPO term

  • idstr

    The HPO term ID e.g.: HP:0000265

  • intint

    Integer of the term ID, e.g.: 265

  • synonymlist[str]

    Not implemented, will always be []

  • commentstr

    Not implemented, will always be ""

  • definitionstr

    Not implemented, will always be ""

  • xreflist[str]

    Not implemented, will always be []

  • is_alist[str]

    Not implemented, will always be []

  • icdict[str, float]

    The information content scores, see pyhpo.InformationContent

Return type

Dict

Examples

from pyhpo import Ontology
Ontology()
term = Ontology[118]
term.toJSON()
# >> {'name': 'Phenotypic abnormality', 'id': 'HP:0000118', 'int': 118}

Ontology[265].toJSON(True)
# >> {
# >>     'name': 'Mastoiditis',
# >>     'id': 'HP:0000265',
# >>     'int': 265,
# >>     'synonym': [],
# >>     'comment': '',
# >>     'definition': '',
# >>     'xref': [],
# >>     'is_a': [],
# >>     'ic': {
# >>         'gene': 6.7086944580078125,
# >>         'omim': 7.392647743225098,
# >>         'orpha': 0.0,
# >>         'decipher': 0.0
# >>     }
# >> }
class InformationContent

Holds the information content for an HPOTerm

gene

Returns the gene - based information content

omim

Returns the Omim disease - based information content