pyhpo


Namepyhpo JSON
Version 3.3.0 PyPI version JSON
download
home_pagehttps://github.com/anergictcell/pyhpo
SummaryA Python package to work with the HPO Ontology
upload_time2024-03-23 19:13:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords hpo phenotype genotype bioinformatics rare diseases
VCS
bugtrack_url
requirements pandas scipy pydantic backports.cached-property importlib_metadata
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://codecov.io/gh/anergictcell/pyhpo/branch/master/graph/badge.svg?token=33ZGNQD61W 
    :target: https://codecov.io/gh/anergictcell/pyhpo

.. image:: https://github.com/anergictcell/pyhpo/actions/workflows/test_coverage.yml/badge.svg
    :target: https://github.com/anergictcell/pyhpo/actions/workflows/test_coverage.yml/

.. image:: https://img.shields.io/pypi/dm/pyhpo.svg?label=Pypi%20downloads
    :target: https://pypi.org/project/pyhpo/

.. image:: https://img.shields.io/pypi/v/pyhpo?label=Latest%20Release
    :target: https://pypi.org/project/pyhpo/#history


*****
PyHPO
*****

A Python library to work with, analyze, filter and inspect the `Human Phenotype Ontology`_

Visit the `PyHPO Documentation`_ for a more detailed overview of all the functionality.

.. _Human Phenotype Ontology: https://hpo.jax.org/
.. _PyHPO Documentation: https://pyhpo.readthedocs.io/en/latest/

Main features
=============

* πŸ‘« Identify patient cohorts based on clinical features
* πŸ‘¨β€πŸ‘§β€πŸ‘¦ Cluster patients or other clinical information for GWAS
* πŸ©»β†’πŸ§¬ Phenotype to Genotype studies
* 🍎🍊 HPO similarity analysis
* πŸ•ΈοΈ Graph based analysis of phenotypes, genes and diseases


**PyHPO** allows working on individual terms ``HPOTerm``, a set of terms ``HPOSet`` and the full ``Ontology``.

The library is helpful for discovery of novel gene-disease associations and GWAS data analysis studies. At the same time, it can be used for oragnize clinical information of patients in research or diagnostic settings.

Internally the ontology is represented as a branched linked list, every term contains pointers to its parent and child terms. This allows fast tree traversal functionality.

It provides an interface to create ``Pandas Dataframe`` from its data, allowing integration in already existing data anlysis tools.

.. hint::

    Check out `hpo3 <https://pypi.org/project/hpo3/>`_ (`Documentation <https://hpo3.readthedocs.io/en/stable/>`_) for an alternative implementation. ``hpo3`` has the exact same functionality, but is much faster πŸš€ and supports multithreading for even faster large data processing.

Getting started
===============

The easiest way to install **PyHPO** is via pip

.. code:: bash

    pip install pyhpo

This will install a base version of **PyHPO** that offers most functionality.

.. note::

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

    Without installing ``pandas``, you won't be able to export the Ontology as a ``Dataframe``, everything else will work fine.

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


If you want to do enrichment analysis, you must also install ``scipy``.

.. code:: bash

    pip install 'pyhpo[scipy]'

If you want to work with **PyHPO** using ``pandas`` dataframes, you can install the ``pandas`` dependency

.. code:: bash

    pip install 'pyhpo[pandas]'

Or simply install both together:

.. code:: bash

    # Include all dependencies
    pip install 'pyhpo[all]'



Usage example
=============

Basic use cases
---------------

Some examples for basic functionality of PyHPO

How similar are the phenotypes of two patients
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    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
^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    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
    """


HPOTerm
-------
An ``HPOTerm`` contains various metadata about the term, as well as pointers to its parents and children terms. You can access its information-content, calculate similarity scores to other terms, find the shortest or longes connection between two terms. List all associated genes or diseases, etc.

Examples:
^^^^^^^^^

Basic functionalities of an HPO-Term

.. code:: python

    from pyhpo import Ontology

    # initilize the Ontology ()
    _ = Ontology()

    # Retrieve a term e.g. via its HPO-ID
    term = Ontology.get_hpo_object('Scoliosis')

    print(term)
    #> HP:0002650 | Scoliosis

    # Get information content from Term <--> Omim associations
    term.information_content['omim']
    #> 2.39

    # Show how many genes are associated to the term
    # (Note that this includes indirect associations, associations
    # from children terms to genes.)
    len(term.genes)
    #> 947

    # Show how many Omim Diseases are associated to the term
    # (Note that this includes indirect associations, associations
    # from children terms to diseases.)
    len(term.omim_diseases)
    #> 730

    # Get a list of all parent terms
    for p in term.parents:
        print(p)
    #> HP:0010674 | Abnormality of the curvature of the vertebral column

    # Get a list of all children terms
    for p in term.children:
        print(p)
    """
    HP:0002943 | Thoracic scoliosis
    HP:0008458 | Progressive congenital scoliosis
    HP:0100884 | Compensatory scoliosis
    HP:0002944 | Thoracolumbar scoliosis
    HP:0002751 | Kyphoscoliosis
    """

*(This script is complete, it should run "as is")*


Some additional functionality, working with more than one term

.. code:: python

    from pyhpo import Ontology
    _ = Ontology()
    term = Ontology.get_hpo_object('Scoliosis')

    # Let's get a second term, this time using it HPO-ID
    term_2 = Ontology.get_hpo_object('HP:0009121')

    print(term_2)
    #> HP:0009121 | Abnormal axial skeleton morphology

    # Check if the Scoliosis is a direct or indirect child
    # of Abnormal axial skeleton morphology

    term.child_of(term_2)
    #> True

    # or vice versa
    term_2.parent_of(term)
    #> True

    # show all nodes between two term:
    path = term.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
    """

    print(f'Steps from Term 1 to Term 2: {path[0]}')
    #> Steps from Term 1 to Term 2: 3


    # Calculate the similarity between two terms
    term.similarity_score(term_2)
    #> 0.442

*(This script is complete, it should run "as is")*


Ontology
--------
The ``Ontology`` contains all HPO terms, their connections to each other and associations to genes and diseases.
It provides some helper functions for ``HPOTerm`` search functionality

Examples
^^^^^^^^

.. code:: python

    from pyhpo import Ontology, HPOSet

    # initilize the Ontology (this must be done only once)
    _ = Ontology()

    # Get a term based on its name
    term = Ontology.get_hpo_object('Scoliosis')
    print(term)
    #> HP:0002650 | Scoliosis

    # ...or based on HPO-ID
    term = Ontology.get_hpo_object('HP:0002650')
    print(term)
    #> HP:0002650 | Scoliosis

    # ...or based on its index
    term = Ontology.get_hpo_object(2650)
    print(term)
    #> HP:0002650 | Scoliosis

    # shortcut to retrieve a term based on its index
    term = Ontology[2650]
    print(term)
    #> HP:0002650 | Scoliosis

    # Search for term
    for term in Ontology.search('olios'):
        print(term)

    """
    HP:0002211 | White forelock
    HP:0002290 | Poliosis
    HP:0002650 | Scoliosis
    HP:0002751 | Kyphoscoliosis
    HP:0002943 | Thoracic scoliosis
    HP:0002944 | Thoracolumbar scoliosis
    HP:0003423 | Thoracolumbar kyphoscoliosis
    HP:0004619 | Lumbar kyphoscoliosis
    HP:0004626 | Lumbar scoliosis
    HP:0005659 | Thoracic kyphoscoliosis
    HP:0008453 | Congenital kyphoscoliosis
    HP:0008458 | Progressive congenital scoliosis
    HP:0100884 | Compensatory scoliosis
    """

*(This script is complete, it should run "as is")*

The Ontology is a Singleton and should only be initiated once.
It can be reused across several modules, e.g:

``main.py``

.. code:: python

    from pyhpo import Ontology, HPOSet

    import module2

    # initilize the Ontology
    _ = Ontology()

    if __name__ == '__main__':
        module2.find_term('Compensatory scoliosis')


``module2.py``

.. code:: python

    from pyhpo import Ontology

    def find_term(term):
        return Ontology.get_hpo_object(term)


HPOSet
------
An ``HPOSet`` is a collection of ``HPOTerm`` and can be used to represent e.g. a patient's clinical information. It provides APIs for filtering, comparisons to other ``HPOSet`` and term/gene/disease enrichments.


Examples:
^^^^^^^^^

.. code:: python

    from pyhpo import Ontology, HPOSet

    # initilize the Ontology
    _ = Ontology()

    # create HPOSets, corresponding to 
    # e.g. the clinical information of a patient
    # You can initiate an HPOSet using either
    # - HPO-ID: 'HP:0002943'
    # - HPO-Name: 'Scoliosis'
    # - HPO-ID (int): 2943

    ci_1 = HPOSet.from_queries([
        'HP:0002943',
        'HP:0008458',
        'HP:0100884',
        'HP:0002944',
        'HP:0002751'
    ])

    ci_2 = HPOSet.from_queries([
        'HP:0002650',
        'HP:0010674',
        'HP:0000925',
        'HP:0009121'
    ])

    # Compare the similarity
    ci_1.similarity(ci_2)
    #> 0.7593552670152157

    # Remove all non-leave nodes from a set
    ci_leaf = ci_2.child_nodes()
    len(ci_2)
    #> 4
    len(ci_leaf)
    #> 1
    ci_2
    #> HPOSet.from_serialized("925+2650+9121+10674")
    ci_leaf
    #> HPOSet.from_serialized("2650")

    # Check the information content of an HPOSet
    ci_1.information_content()
    """
    {
        'mean': 6.571224974009769,
        'total': 32.856124870048845,
        'max': 8.97979449089521,
        'all': [5.98406221734122, 8.286647310335265, 8.97979449089521, 5.5458072864100645, 4.059813565067086]
    }
    """

*(This script is complete, it should run "as is")*


Get genes enriched in an ``HPOSet``
-----------------------------------

Examples:
^^^^^^^^^

.. code:: python

    from pyhpo import Ontology, HPOSet
    from pyhpo.stats import EnrichmentModel

    # initilize the Ontology
    _ = Ontology()

    ci = HPOSet.from_queries([
        'HP:0002943',
        'HP:0008458',
        'HP:0100884',
        'HP:0002944',
        'HP:0002751'
    ])

    gene_model = EnrichmentModel('gene')
    genes = gene_model.enrichment(method='hypergeom', hposet=ci)
    
    print(genes[0]['item'])
    #> PAPSS2

*(This script is complete, it should run "as is")*


For a more detailed description of how to use PyHPO, visit the `PyHPO Documentation <https://pyhpo.readthedocs.io/en/latest/>`_.



Contributing
============

Yes, please do so. We appreciate any help, suggestions for improvement or other feedback. Just create a pull-request or open an issue.

License
=======

PyHPO is released under the `MIT license`_.


PyHPO is using the Human Phenotype Ontology. Find out more at http://www.human-phenotype-ontology.org

Sebastian KΓΆhler, Leigh Carmody, Nicole Vasilevsky, Julius O B Jacobsen, et al. Expansion of the Human Phenotype Ontology (HPO) knowledge base and resources. Nucleic Acids Research. (2018) doi: 10.1093/nar/gky1105

.. _MIT license: http://www.opensource.org/licenses/mit-license.php



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/anergictcell/pyhpo",
    "name": "pyhpo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "hpo, phenotype, genotype, bioinformatics, rare diseases",
    "author": null,
    "author_email": "Jonas Marcello <jonas.marcello@esbme.com>",
    "download_url": "https://files.pythonhosted.org/packages/85/54/c16c5aa681be3f1446a991c0102ade2e341e46b0c013bbd115c5f09b6135/pyhpo-3.3.0.tar.gz",
    "platform": null,
    "description": ".. image:: https://codecov.io/gh/anergictcell/pyhpo/branch/master/graph/badge.svg?token=33ZGNQD61W \n    :target: https://codecov.io/gh/anergictcell/pyhpo\n\n.. image:: https://github.com/anergictcell/pyhpo/actions/workflows/test_coverage.yml/badge.svg\n    :target: https://github.com/anergictcell/pyhpo/actions/workflows/test_coverage.yml/\n\n.. image:: https://img.shields.io/pypi/dm/pyhpo.svg?label=Pypi%20downloads\n    :target: https://pypi.org/project/pyhpo/\n\n.. image:: https://img.shields.io/pypi/v/pyhpo?label=Latest%20Release\n    :target: https://pypi.org/project/pyhpo/#history\n\n\n*****\nPyHPO\n*****\n\nA Python library to work with, analyze, filter and inspect the `Human Phenotype Ontology`_\n\nVisit the `PyHPO Documentation`_ for a more detailed overview of all the functionality.\n\n.. _Human Phenotype Ontology: https://hpo.jax.org/\n.. _PyHPO Documentation: https://pyhpo.readthedocs.io/en/latest/\n\nMain features\n=============\n\n* \ud83d\udc6b Identify patient cohorts based on clinical features\n* \ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d\udc66 Cluster patients or other clinical information for GWAS\n* \ud83e\ude7b\u2192\ud83e\uddec Phenotype to Genotype studies\n* \ud83c\udf4e\ud83c\udf4a HPO similarity analysis\n* \ud83d\udd78\ufe0f Graph based analysis of phenotypes, genes and diseases\n\n\n**PyHPO** allows working on individual terms ``HPOTerm``, a set of terms ``HPOSet`` and the full ``Ontology``.\n\nThe library is helpful for discovery of novel gene-disease associations and GWAS data analysis studies. At the same time, it can be used for oragnize clinical information of patients in research or diagnostic settings.\n\nInternally the ontology is represented as a branched linked list, every term contains pointers to its parent and child terms. This allows fast tree traversal functionality.\n\nIt provides an interface to create ``Pandas Dataframe`` from its data, allowing integration in already existing data anlysis tools.\n\n.. hint::\n\n    Check out `hpo3 <https://pypi.org/project/hpo3/>`_ (`Documentation <https://hpo3.readthedocs.io/en/stable/>`_) for an alternative implementation. ``hpo3`` has the exact same functionality, but is much faster \ud83d\ude80 and supports multithreading for even faster large data processing.\n\nGetting started\n===============\n\nThe easiest way to install **PyHPO** is via pip\n\n.. code:: bash\n\n    pip install pyhpo\n\nThis will install a base version of **PyHPO** that offers most functionality.\n\n.. note::\n\n    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).\n\n    Without installing ``pandas``, you won't be able to export the Ontology as a ``Dataframe``, everything else will work fine.\n\n    Without installing ``scipy``, you won't be able to use the ``stats`` module, especially the enrichment calculations.\n\n\nIf you want to do enrichment analysis, you must also install ``scipy``.\n\n.. code:: bash\n\n    pip install 'pyhpo[scipy]'\n\nIf you want to work with **PyHPO** using ``pandas`` dataframes, you can install the ``pandas`` dependency\n\n.. code:: bash\n\n    pip install 'pyhpo[pandas]'\n\nOr simply install both together:\n\n.. code:: bash\n\n    # Include all dependencies\n    pip install 'pyhpo[all]'\n\n\n\nUsage example\n=============\n\nBasic use cases\n---------------\n\nSome examples for basic functionality of PyHPO\n\nHow similar are the phenotypes of two patients\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n    from pyhpo import Ontology\n    from pyhpo.set import HPOSet\n\n    # initilize the Ontology ()\n    _ = Ontology()\n\n    # Declare the clinical information of the patients\n    patient_1 = HPOSet.from_queries([\n        'HP:0002943',\n        'HP:0008458',\n        'HP:0100884',\n        'HP:0002944',\n        'HP:0002751'\n    ])\n\n    patient_2 = HPOSet.from_queries([\n        'HP:0002650',\n        'HP:0010674',\n        'HP:0000925',\n        'HP:0009121'\n    ])\n\n    # and compare their similarity\n    patient_1.similarity(patient_2)\n    #> 0.7594183905785477\n\n\nHow close are two HPO terms\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n    from pyhpo import Ontology\n\n    # initilize the Ontology ()\n    _ = Ontology()\n\n    term_1 = Ontology.get_hpo_object('Scoliosis')\n    term_2 = Ontology.get_hpo_object('Abnormal axial skeleton morphology')\n\n    path = term_1.path_to_other(term_2)\n    for t in path[1]:\n        print(t)\n\n    \"\"\"\n    HP:0002650 | Scoliosis\n    HP:0010674 | Abnormality of the curvature of the vertebral column\n    HP:0000925 | Abnormality of the vertebral column\n    HP:0009121 | Abnormal axial skeleton morphology\n    \"\"\"\n\n\nHPOTerm\n-------\nAn ``HPOTerm`` contains various metadata about the term, as well as pointers to its parents and children terms. You can access its information-content, calculate similarity scores to other terms, find the shortest or longes connection between two terms. List all associated genes or diseases, etc.\n\nExamples:\n^^^^^^^^^\n\nBasic functionalities of an HPO-Term\n\n.. code:: python\n\n    from pyhpo import Ontology\n\n    # initilize the Ontology ()\n    _ = Ontology()\n\n    # Retrieve a term e.g. via its HPO-ID\n    term = Ontology.get_hpo_object('Scoliosis')\n\n    print(term)\n    #> HP:0002650 | Scoliosis\n\n    # Get information content from Term <--> Omim associations\n    term.information_content['omim']\n    #> 2.39\n\n    # Show how many genes are associated to the term\n    # (Note that this includes indirect associations, associations\n    # from children terms to genes.)\n    len(term.genes)\n    #> 947\n\n    # Show how many Omim Diseases are associated to the term\n    # (Note that this includes indirect associations, associations\n    # from children terms to diseases.)\n    len(term.omim_diseases)\n    #> 730\n\n    # Get a list of all parent terms\n    for p in term.parents:\n        print(p)\n    #> HP:0010674 | Abnormality of the curvature of the vertebral column\n\n    # Get a list of all children terms\n    for p in term.children:\n        print(p)\n    \"\"\"\n    HP:0002943 | Thoracic scoliosis\n    HP:0008458 | Progressive congenital scoliosis\n    HP:0100884 | Compensatory scoliosis\n    HP:0002944 | Thoracolumbar scoliosis\n    HP:0002751 | Kyphoscoliosis\n    \"\"\"\n\n*(This script is complete, it should run \"as is\")*\n\n\nSome additional functionality, working with more than one term\n\n.. code:: python\n\n    from pyhpo import Ontology\n    _ = Ontology()\n    term = Ontology.get_hpo_object('Scoliosis')\n\n    # Let's get a second term, this time using it HPO-ID\n    term_2 = Ontology.get_hpo_object('HP:0009121')\n\n    print(term_2)\n    #> HP:0009121 | Abnormal axial skeleton morphology\n\n    # Check if the Scoliosis is a direct or indirect child\n    # of Abnormal axial skeleton morphology\n\n    term.child_of(term_2)\n    #> True\n\n    # or vice versa\n    term_2.parent_of(term)\n    #> True\n\n    # show all nodes between two term:\n    path = term.path_to_other(term_2)\n    for t in path[1]:\n        print(t)\n\n    \"\"\"\n    HP:0002650 | Scoliosis\n    HP:0010674 | Abnormality of the curvature of the vertebral column\n    HP:0000925 | Abnormality of the vertebral column\n    HP:0009121 | Abnormal axial skeleton morphology\n    \"\"\"\n\n    print(f'Steps from Term 1 to Term 2: {path[0]}')\n    #> Steps from Term 1 to Term 2: 3\n\n\n    # Calculate the similarity between two terms\n    term.similarity_score(term_2)\n    #> 0.442\n\n*(This script is complete, it should run \"as is\")*\n\n\nOntology\n--------\nThe ``Ontology`` contains all HPO terms, their connections to each other and associations to genes and diseases.\nIt provides some helper functions for ``HPOTerm`` search functionality\n\nExamples\n^^^^^^^^\n\n.. code:: python\n\n    from pyhpo import Ontology, HPOSet\n\n    # initilize the Ontology (this must be done only once)\n    _ = Ontology()\n\n    # Get a term based on its name\n    term = Ontology.get_hpo_object('Scoliosis')\n    print(term)\n    #> HP:0002650 | Scoliosis\n\n    # ...or based on HPO-ID\n    term = Ontology.get_hpo_object('HP:0002650')\n    print(term)\n    #> HP:0002650 | Scoliosis\n\n    # ...or based on its index\n    term = Ontology.get_hpo_object(2650)\n    print(term)\n    #> HP:0002650 | Scoliosis\n\n    # shortcut to retrieve a term based on its index\n    term = Ontology[2650]\n    print(term)\n    #> HP:0002650 | Scoliosis\n\n    # Search for term\n    for term in Ontology.search('olios'):\n        print(term)\n\n    \"\"\"\n    HP:0002211 | White forelock\n    HP:0002290 | Poliosis\n    HP:0002650 | Scoliosis\n    HP:0002751 | Kyphoscoliosis\n    HP:0002943 | Thoracic scoliosis\n    HP:0002944 | Thoracolumbar scoliosis\n    HP:0003423 | Thoracolumbar kyphoscoliosis\n    HP:0004619 | Lumbar kyphoscoliosis\n    HP:0004626 | Lumbar scoliosis\n    HP:0005659 | Thoracic kyphoscoliosis\n    HP:0008453 | Congenital kyphoscoliosis\n    HP:0008458 | Progressive congenital scoliosis\n    HP:0100884 | Compensatory scoliosis\n    \"\"\"\n\n*(This script is complete, it should run \"as is\")*\n\nThe Ontology is a Singleton and should only be initiated once.\nIt can be reused across several modules, e.g:\n\n``main.py``\n\n.. code:: python\n\n    from pyhpo import Ontology, HPOSet\n\n    import module2\n\n    # initilize the Ontology\n    _ = Ontology()\n\n    if __name__ == '__main__':\n        module2.find_term('Compensatory scoliosis')\n\n\n``module2.py``\n\n.. code:: python\n\n    from pyhpo import Ontology\n\n    def find_term(term):\n        return Ontology.get_hpo_object(term)\n\n\nHPOSet\n------\nAn ``HPOSet`` is a collection of ``HPOTerm`` and can be used to represent e.g. a patient's clinical information. It provides APIs for filtering, comparisons to other ``HPOSet`` and term/gene/disease enrichments.\n\n\nExamples:\n^^^^^^^^^\n\n.. code:: python\n\n    from pyhpo import Ontology, HPOSet\n\n    # initilize the Ontology\n    _ = Ontology()\n\n    # create HPOSets, corresponding to \n    # e.g. the clinical information of a patient\n    # You can initiate an HPOSet using either\n    # - HPO-ID: 'HP:0002943'\n    # - HPO-Name: 'Scoliosis'\n    # - HPO-ID (int): 2943\n\n    ci_1 = HPOSet.from_queries([\n        'HP:0002943',\n        'HP:0008458',\n        'HP:0100884',\n        'HP:0002944',\n        'HP:0002751'\n    ])\n\n    ci_2 = HPOSet.from_queries([\n        'HP:0002650',\n        'HP:0010674',\n        'HP:0000925',\n        'HP:0009121'\n    ])\n\n    # Compare the similarity\n    ci_1.similarity(ci_2)\n    #> 0.7593552670152157\n\n    # Remove all non-leave nodes from a set\n    ci_leaf = ci_2.child_nodes()\n    len(ci_2)\n    #> 4\n    len(ci_leaf)\n    #> 1\n    ci_2\n    #> HPOSet.from_serialized(\"925+2650+9121+10674\")\n    ci_leaf\n    #> HPOSet.from_serialized(\"2650\")\n\n    # Check the information content of an HPOSet\n    ci_1.information_content()\n    \"\"\"\n    {\n        'mean': 6.571224974009769,\n        'total': 32.856124870048845,\n        'max': 8.97979449089521,\n        'all': [5.98406221734122, 8.286647310335265, 8.97979449089521, 5.5458072864100645, 4.059813565067086]\n    }\n    \"\"\"\n\n*(This script is complete, it should run \"as is\")*\n\n\nGet genes enriched in an ``HPOSet``\n-----------------------------------\n\nExamples:\n^^^^^^^^^\n\n.. code:: python\n\n    from pyhpo import Ontology, HPOSet\n    from pyhpo.stats import EnrichmentModel\n\n    # initilize the Ontology\n    _ = Ontology()\n\n    ci = HPOSet.from_queries([\n        'HP:0002943',\n        'HP:0008458',\n        'HP:0100884',\n        'HP:0002944',\n        'HP:0002751'\n    ])\n\n    gene_model = EnrichmentModel('gene')\n    genes = gene_model.enrichment(method='hypergeom', hposet=ci)\n    \n    print(genes[0]['item'])\n    #> PAPSS2\n\n*(This script is complete, it should run \"as is\")*\n\n\nFor a more detailed description of how to use PyHPO, visit the `PyHPO Documentation <https://pyhpo.readthedocs.io/en/latest/>`_.\n\n\n\nContributing\n============\n\nYes, please do so. We appreciate any help, suggestions for improvement or other feedback. Just create a pull-request or open an issue.\n\nLicense\n=======\n\nPyHPO is released under the `MIT license`_.\n\n\nPyHPO is using the Human Phenotype Ontology. Find out more at http://www.human-phenotype-ontology.org\n\nSebastian K\u00f6hler, Leigh Carmody, Nicole Vasilevsky, Julius O B Jacobsen, et al. Expansion of the Human Phenotype Ontology (HPO) knowledge base and resources. Nucleic Acids Research. (2018) doi: 10.1093/nar/gky1105\n\n.. _MIT license: http://www.opensource.org/licenses/mit-license.php\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package to work with the HPO Ontology",
    "version": "3.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/anergictcell/pyhpo/issues",
        "Documentation": "https://pyhpo.readthedocs.io/",
        "Homepage": "https://github.com/anergictcell/pyhpo",
        "Repository": "https://github.com/anergictcell/pyhpo"
    },
    "split_keywords": [
        "hpo",
        " phenotype",
        " genotype",
        " bioinformatics",
        " rare diseases"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a09646d5f44d760b25df18dea7f02c5f8fdbd90fbccb44ace0ea69cf2a8d01bb",
                "md5": "106800531bb677eb8fcbad5cbcec610f",
                "sha256": "268539da76c6471190e40f2d10d86626fc50ef1570f3d979e46fe5ec1f3bf008"
            },
            "downloads": -1,
            "filename": "pyhpo-3.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "106800531bb677eb8fcbad5cbcec610f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14189256,
            "upload_time": "2024-03-23T19:13:00",
            "upload_time_iso_8601": "2024-03-23T19:13:00.969731Z",
            "url": "https://files.pythonhosted.org/packages/a0/96/46d5f44d760b25df18dea7f02c5f8fdbd90fbccb44ace0ea69cf2a8d01bb/pyhpo-3.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8554c16c5aa681be3f1446a991c0102ade2e341e46b0c013bbd115c5f09b6135",
                "md5": "8ac5adb87e4d549900ae78dd6bfd95c3",
                "sha256": "9f5497170a9d1ec1ce7730c6decb0535df9e566f33221d8912eb083bda88d0d2"
            },
            "downloads": -1,
            "filename": "pyhpo-3.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8ac5adb87e4d549900ae78dd6bfd95c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13832231,
            "upload_time": "2024-03-23T19:13:04",
            "upload_time_iso_8601": "2024-03-23T19:13:04.851385Z",
            "url": "https://files.pythonhosted.org/packages/85/54/c16c5aa681be3f1446a991c0102ade2e341e46b0c013bbd115c5f09b6135/pyhpo-3.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-23 19:13:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "anergictcell",
    "github_project": "pyhpo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "scipy",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2"
                ]
            ]
        },
        {
            "name": "backports.cached-property",
            "specs": [
                [
                    "==",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "importlib_metadata",
            "specs": []
        }
    ],
    "lcname": "pyhpo"
}
        
Elapsed time: 0.27572s