Annotations
The Annotations module contains the gene and disease associations of HPOTerms.
from pyhpo import Ontology
from pyhpo.annotations import Omim, Orpha
Ontology()
# All genes and diseases can be accessed through the Ontology
for gene in Ontology.genes:
print(gene.name)
# >> "EZH2"
# ...
for orpha in Ontology.orpha_diseases:
print(orpha.id)
# >> 231401
# ...
# or accessed directly from the `Orpha`, `Omim`, `Gene` class
orpha_disease = Orpha.get(77260)
omim_disease = Omim.get(230900)
# Annotations can be converted to `HPOSet`
orpha_set = orpha_disease.hpo_set()
omim_set = omim_disease.hpo_set()
similarity = orpha_set.similarity(omim_set)
print(similarity)
# >> 0.6620065792484546
- class GeneSingleton
An instance of a gene, associated to several
pyhpo.term.HPOTern.Note
Since version 4.0 genes do not contain references to HPOTerms transitively, i.e. only directly associated HPOTerms are linked to the gene.
- id
- Return Type:
int- Returns:
The HGNC ID of the gene
- name
- Return Type:
str- Returns:
The HUGO gene synbol of the gene
- symbol
- Return Type:
str- Returns:
The HUGO gene synbol of the gene (alias of
GeneSingleton.name)
- hpo
- Return Type:
set(int)- Returns:
The HPO-IDs of all associated
pyhpo.term.HPOTerms
- toJSON(self, verbose=False)
Backwards compatibility method BaseModel include
.jsonmethod- Parameters:
verbose (
bool, default:False) – Return all associated HPOTerms- Returns:
A dict with the following keys (additional keys might be present, depending on the class)
id - The gene or disease ID
name - The gene or disease name
hpo - (If
verbose=True): set ofpyhpo.term.HPOTerm
- Return type:
dict
- hpo_set(self)
Returns an
HPOSetof all associatedHPOTerm- Returns:
An
HPOSetcontaining all associatedHPOTerm- Return type:
Examples
from pyhpo import Ontology Ontology() gene = list(Ontology.genes)[0] gene.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) omim_disease = list(Ontology.omim_diseases)[0] omim_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) orpha_disease = list(Ontology.orpha_diseases)[0] orpha_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....)
- class Gene
Geneholds allGeneSingletoninstances and ensures they are not duplicated. It does not need to be instantiated, as it is already created as a singleton during the setup of the Ontology.- get(query, default=None)
Get the Gene based on query parameters. This method is the fastest and safest way to retrieve a single Gene instance.
- Parameters:
query (
strorint) – The gene symbol or HGNC-ID- Returns:
If a gene is found, it is returned. Otherwise an Error is raised
- Return type:
- Raises:
KeyError – The queried gene does not exist
Examples
from pyhpo import Ontology from pyhpo.annotations import Gene Ontology() ezh2 = Gene.get("EZH2") print(ezh2.id) # >> 2146 print(len(ezh2.hpo)) # >> 99
- __call__(hgncid, symbol)
Instantiates a new
GeneSingletonor returns an already existing one.The method will first check if the gene already exists. It does so by first searching via the gene symbol and then via hgncid. If both don’t exist, a new instance will be created.
Warning
There is rarely ever any need to instantiate genes manually. All genes that are present in JAX’s HPO masterdata are automatically added and can be retrieved using
Gene.get().pyhpocontains logic to ensure that the same gene is not instantiated multiple times and will return an already existing gene instance, whenever possible.- Parameters:
hgncid (
int) – The gene’s HGNC-IDsymbol (
str) – The gene’s HUGO gene synbol
- Returns:
Either creates a new instance or returns an existing one, if already present
- Return type:
- class OmimDisease
An instance of an Omim disease, associated to several
pyhpo.term.HPOTerm.- id
- Return Type:
int- Returns:
The Omim ID
- name
- Return Type:
str- Returns:
The Omim disease name
- hpo
- Return Type:
set(int)- Returns:
The HPO-ID of all associated
HPOTerms
- toJSON(self, verbose=False)
Backwards compatibility method BaseModel include
.jsonmethod- Parameters:
verbose (
bool, default:False) – Return all associated HPOTerms- Returns:
A dict with the following keys (additional keys might be present, depending on the class)
id - The gene or disease ID
name - The gene or disease name
hpo - (If
verbose=True): set ofpyhpo.term.HPOTerm
- Return type:
dict
- hpo_set(self)
Returns an
HPOSetof all associatedHPOTerm- Returns:
An
HPOSetcontaining all associatedHPOTerm- Return type:
Examples
from pyhpo import Ontology Ontology() gene = list(Ontology.genes)[0] gene.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) omim_disease = list(Ontology.omim_diseases)[0] omim_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) orpha_disease = list(Ontology.orpha_diseases)[0] orpha_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....)
- class Omim
Omimholds allOmimDiseaseinstances and ensures they are not duplicated. It does not need to be instantiated, as it is already created as a singleton during the setup of the Ontology.- get(self, query, default=None)
Get the disease based on query parameters. This method is the fastest and safest way to retrieve a single disease instance.
- Parameters:
query (int) – The (most likely user supplied) query for Disease ID.
- Returns:
If a disease is found, it is returned. Otherwise a
KeyErroris raised- Return type:
DiseaseSingleton (based on disease type)
Examples
from pyhpo import Ontology from pyhpo.annotations import Omim, Orpha Ontology() orpha_disease = Orpha.get(77260) omim_disease = Omim.get(230900) print(orpha_disease.name) # >> "Gaucher disease type 2" print(omim_disease.name) # >> "Gaucher disease, type II"
- Return type:
- __call__(self, diseaseid, name)
Instantiates a new
DiseaseSingletonor returns an already existing one.The method will first check if the disease already exists. If it doesn’t exist, a new instance will be created.
Warning
There is rarely ever any need to instantiate diseases manually. All diseases that are present in JAX’s HPO masterdata are automatically added and can be retrieved using the diseases
getmethod.pyhpocontains logic to ensure that the same disease is not instantiated multiple times and will return an already existing disease instance, whenever possible.- Parameters:
diseaseid (
int) – The ID of the diseasename (
str) – The diseases’s name
- Returns:
Either creates a new instance or returns an existing one, if already present
- Return type:
DiseaseSingleton
- class OrphaDisease
An instance of an Orpha disease, associated to several
pyhpo.term.HPOTerm.- id
- Return Type:
int- Returns:
The Orpha ID
- name
- Return Type:
str- Returns:
The Orpha disease name
- hpo
- Return Type:
set(int)- Returns:
The HPO-ID of all associated
HPOTerms
- toJSON(self, verbose=False)
Backwards compatibility method BaseModel include
.jsonmethod- Parameters:
verbose (
bool, default:False) – Return all associated HPOTerms- Returns:
A dict with the following keys (additional keys might be present, depending on the class)
id - The gene or disease ID
name - The gene or disease name
hpo - (If
verbose=True): set ofpyhpo.term.HPOTerm
- Return type:
dict
- hpo_set(self)
Returns an
HPOSetof all associatedHPOTerm- Returns:
An
HPOSetcontaining all associatedHPOTerm- Return type:
Examples
from pyhpo import Ontology Ontology() gene = list(Ontology.genes)[0] gene.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) omim_disease = list(Ontology.omim_diseases)[0] omim_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) orpha_disease = list(Ontology.orpha_diseases)[0] orpha_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....)
- class Orpha
Orphaholds allOrphaDiseaseinstances and ensures they are not duplicated. It does not need to be instantiated, as it is already created as a singleton during the setup of the Ontology.- get(self, query, default=None)
Get the disease based on query parameters. This method is the fastest and safest way to retrieve a single disease instance.
- Parameters:
query (int) – The (most likely user supplied) query for Disease ID.
- Returns:
If a disease is found, it is returned. Otherwise a
KeyErroris raised- Return type:
DiseaseSingleton (based on disease type)
Examples
from pyhpo import Ontology from pyhpo.annotations import Omim, Orpha Ontology() orpha_disease = Orpha.get(77260) omim_disease = Omim.get(230900) print(orpha_disease.name) # >> "Gaucher disease type 2" print(omim_disease.name) # >> "Gaucher disease, type II"
- Return type:
- __call__(self, diseaseid, name)
Instantiates a new
DiseaseSingletonor returns an already existing one.The method will first check if the disease already exists. If it doesn’t exist, a new instance will be created.
Warning
There is rarely ever any need to instantiate diseases manually. All diseases that are present in JAX’s HPO masterdata are automatically added and can be retrieved using the diseases
getmethod.pyhpocontains logic to ensure that the same disease is not instantiated multiple times and will return an already existing disease instance, whenever possible.- Parameters:
diseaseid (
int) – The ID of the diseasename (
str) – The diseases’s name
- Returns:
Either creates a new instance or returns an existing one, if already present
- Return type:
DiseaseSingleton
- class DecipherDisease
An instance of an Decipher disease, associated to several
pyhpo.term.HPOTerm.- id
- Return Type:
int
- Returns:
The Decipher ID
- name
- Return Type:
str- Returns:
The Decipher disease name
- hpo
- Return Type:
set(int)- Returns:
The HPO-ID of all associated
HPOTerms
- toJSON(self, verbose=False)
Backwards compatibility method BaseModel include
.jsonmethod- Parameters:
verbose (
bool, default:False) – Return all associated HPOTerms- Returns:
A dict with the following keys (additional keys might be present, depending on the class)
id - The gene or disease ID
name - The gene or disease name
hpo - (If
verbose=True): set ofpyhpo.term.HPOTerm
- Return type:
dict
- hpo_set(self)
Returns an
HPOSetof all associatedHPOTerm- Returns:
An
HPOSetcontaining all associatedHPOTerm- Return type:
Examples
from pyhpo import Ontology Ontology() gene = list(Ontology.genes)[0] gene.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) omim_disease = list(Ontology.omim_diseases)[0] omim_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....) orpha_disease = list(Ontology.orpha_diseases)[0] orpha_disease.hpo_set() # >> HPOSet.from_serialized(7+118+152+234+271+315, ....)
- class Decipher
Decipherholds allDecipherDiseaseinstances and ensures they are not duplicated.- get(self, query, default=None)
Get the disease based on query parameters. This method is the fastest and safest way to retrieve a single disease instance.
- Parameters:
query (int) – The (most likely user supplied) query for Disease ID.
- Returns:
If a disease is found, it is returned. Otherwise a
KeyErroris raised- Return type:
DiseaseSingleton (based on disease type)
Examples
from pyhpo import Ontology from pyhpo.annotations import Omim, Orpha Ontology() orpha_disease = Orpha.get(77260) omim_disease = Omim.get(230900) print(orpha_disease.name) # >> "Gaucher disease type 2" print(omim_disease.name) # >> "Gaucher disease, type II"
- Return type:
- __call__(self, diseaseid, name)
Instantiates a new
DiseaseSingletonor returns an already existing one.The method will first check if the disease already exists. If it doesn’t exist, a new instance will be created.
Warning
There is rarely ever any need to instantiate diseases manually. All diseases that are present in JAX’s HPO masterdata are automatically added and can be retrieved using the diseases
getmethod.pyhpocontains logic to ensure that the same disease is not instantiated multiple times and will return an already existing disease instance, whenever possible.- Parameters:
diseaseid (
int) – The ID of the diseasename (
str) – The diseases’s name
- Returns:
Either creates a new instance or returns an existing one, if already present
- Return type:
DiseaseSingleton