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 HPOTermBase instance can be build solely by itself, without knowledge of the actual Ontology

Attributes

HPOTerm.id: str

The HPO identifier

HPOTerm.name: str

The name of the HPO term

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
HPOTerm.definition: str
HPOTerm.synonym: List[str]
HPOTerm.parents: Set[HPOTerm]
HPOTerm.children: Set[HPOTerm]
HPOTerm.genes: Set[GeneSingleton]
HPOTerm.omim_diseases: Set[OmimDisease]
HPOTerm.orpha_diseases: Set[OrphaDisease]
HPOTerm.decipher_diseases: Set[DecipherDisease]

parent_of

HPOTerm.parent_of(other)[source]

Checks if self is a direct or indirect parent of other.

Parameters:

other (HPOTerm) – HPOTerm to check for lineage dependency

Returns:

Is the HPOTerm a direct or indirect parent of another HPOTerms

Return type:

bool

child_of

HPOTerm.child_of(other)[source]

Checks if self is a direct or indirect child of other.

Parameters:

other (HPOTerm) – HPOTerm to check for lineage dependency

Returns:

Is the HPOTerm a direct or indirect child of another HPOTerms

Return type:

bool

parent_ids

HPOTerm.parent_ids()[source]
Return type:

List[int]

common_ancestors

HPOTerm.common_ancestors(other)[source]

Identifies all common ancestors of two HPO terms

Parameters:

other (HPOTerm) – Target HPO term for path finding

Returns:

Set of common ancestor HPOTerms

Return type:

set

count_parents

HPOTerm.count_parents()[source]

Calculates total number of ancestral HPO Terms

Returns:

The number of all ancestral HPO Terms

Return type:

int

longest_path_to_root

HPOTerm.longest_path_to_root()[source]

Calculates the longest path to root

Returns:

Maximum number of nodes until the root HPOTerm

Return type:

int

shortest_path_to_root

HPOTerm.shortest_path_to_root()[source]

Calculates the shortest path to root

Returns:

Minimum number of nodes until the root HPOTerm

Return type:

int

shortest_path_to_parent

HPOTerm.shortest_path_to_parent(other)[source]

Calculates the shortest path to another HPO Term

Parameters:

other (HPOTerm) – parent HPOTerm instance

Return type:

Tuple[int, Tuple[HPOTerm, ...]]

Returns:

  • int – Minimum number of nodes until the specified HPOTerm

    (float(‘inf’) if other is not a parent.)

  • tuple – Tuple of all HPOTerm instances on the path

    (None if other is not a parent)

longest_path_to_bottom

HPOTerm.longest_path_to_bottom(level=0)[source]

Calculates how far the most distant child is apart

Parameters:

level (int) – Offset level to indicate for calculation Default: 0

Returns:

Number of steps to most distant child

Return type:

int

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 - 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) Implementation according to R source code

    • jc2 - Jiang J, Conrath D, ROCLING X, (1997) Implementation according to paper from R hposim library Deng Y, et. al., PLoS One, (2015)

    • 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

    • Additional methods can be registered separately ( see :class::pyhpo.similarity.base._Similarity)

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().

Default attributes

InformationContent.gene: float
InformationContent.omim: float
InformationContent.orpha: float
InformationContent.decipher: float

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')