gpsea.analysis.predicate.phenotype package

The gpsea.analysis.predicate.phenotype package provides the PhenotypePolyPredicate for assigning Patient into a phenotype group.

An individual can be assigned based on presence/absence of a disease diagnosis (DiseasePresencePredicate) or using the phenotype features encoded into HPO terms (PropagatingPhenotypePredicate).

class gpsea.analysis.predicate.phenotype.PhenotypePolyPredicate[source]

Bases: Generic[P], PolyPredicate[PhenotypeCategorization[P]]

PhenotypePolyPredicate investigates a patient in context of one or more phenotype categories P.

Each phenotype category P can be a TermId representing an HPO term or an OMIM/MONDO term.

Only one category can be investigated, and phenotype returns the investigated phenotype (e.g. Arachnodactyly HP:0001166).

As another hallmark of this predicate, one of the categorizations must correspond to the group of patients who exibit the investigated phenotype. The categorization is provided via present_phenotype_categorization property.

abstract property phenotype: P

Get the phenotype entity of interest.

abstract property present_phenotype_categorization: PhenotypeCategorization[P]

Get the categorization which represents the group of the patients who exibit the investigated phenotype.

property present_phenotype_category: PatientCategory

Get the patient category that correspond to the group of the patients who exibit the investigated phenotype.

class gpsea.analysis.predicate.phenotype.HpoPredicate(hpo: MinimalOntology, query: TermId, missing_implies_phenotype_excluded: bool = False)[source]

Bases: PhenotypePolyPredicate[TermId]

HpoPredicate tests if a patient is annotated with an HPO term.

Note, query must be a term of the provided hpo!

See HPO predicate section for an example usage.

Parameters:
  • hpo – HPO ontology

  • query – the HPO term to test

  • missing_implies_phenotype_excludedTrue if lack of an explicit annotation implies term’s absence`.

get_question_base() str[source]

Prepare a str with the question the predicate can answer.

property phenotype: TermId

Get the phenotype entity of interest.

property present_phenotype_categorization: PhenotypeCategorization[TermId]

Get the categorization which represents the group of the patients who exibit the investigated phenotype.

get_categorizations() Sequence[PhenotypeCategorization[TermId]][source]

Get a sequence of all categories which the PolyPredicate can produce.

test(patient: Patient) PhenotypeCategorization[TermId] | None[source]

An HPO TermID is given when initializing the class. Given a Patient class, this function tests whether the patient has the given phenotype.

Parameters:

patient (Patient) – A Patient class representing a patient.

Returns:

PhenotypeCategorization,

either “YES” if the phenotype is listed and is not excluded, or “NO” if the phenotype is listed and excluded, otherwise will return None. Unless _missing_implies_phenotype_excluded is True, then will return “NO” if the phenotype is listed and excluded or not listed.

Return type:

Optional[PhenotypeCategorization[P]]

class gpsea.analysis.predicate.phenotype.DiseasePresencePredicate(disease_id_query: TermId)[source]

Bases: PhenotypePolyPredicate[TermId]

DiseasePresencePredicate tests if the patient was diagnosed with a disease.

The predicate tests if the patient’s diseases include a disease ID formatted as a TermId.

Parameters:

disease_id_query – the Disease ID to test

get_question_base() str[source]

Prepare a str with the question the predicate can answer.

property phenotype: TermId

Get the phenotype entity of interest.

property present_phenotype_categorization: PhenotypeCategorization[TermId]

Get the categorization which represents the group of the patients who exibit the investigated phenotype.

get_categorizations() Sequence[PhenotypeCategorization[TermId]][source]

Get a sequence of all categories which the PolyPredicate can produce.

test(patient: Patient) PhenotypeCategorization[TermId] | None[source]

Test if the patient was diagnosed with a disease.

Parameters:

patient (Patient) – a patient instance to be tested.

Returns:

PhenotypeCategorization,

either “YES” if the phenotype is listed and is not excluded, or “NO” if the disease is not listed or is excluded.

Return type:

Optional[PhenotypeCategorization[P]]

class gpsea.analysis.predicate.phenotype.PhenotypeCategorization(category: PatientCategory, phenotype: P)[source]

Bases: Generic[P], Categorization

On top of the attributes of the Categorization, PhenotypeCategorization keeps track of the target phenotype P.

property phenotype: P
gpsea.analysis.predicate.phenotype.prepare_predicates_for_terms_of_interest(cohort: Iterable[Patient], hpo: GraphAware, missing_implies_excluded: bool = False, min_n_of_patients_with_term: int = 2) Sequence[PhenotypePolyPredicate[TermId]][source]

A convenience method for creating a battery of PropagatingPhenotypePredicate predicates for testing all phenotypes of interest.

Parameters:
  • cohort – a cohort of individuals to investigate.

  • hpo – an entity with an HPO graph (e.g. MinimalOntology).

  • missing_implies_excludedTrue if absence of an annotation should be counted as its explicit exclusion.

  • min_n_of_patients_with_term – the minimum number of patients that must feature an HPO term (either directly or indirectly) for the term to be included in the analysis.

gpsea.analysis.predicate.phenotype.prepare_hpo_terms_of_interest(cohort: Iterable[Patient], hpo: GraphAware, min_n_of_patients_with_term: int = 2) Sequence[TermId][source]

Prepare a collection of HPO terms to test.

This includes the direct HPO patient annotations as well as the ancestors of the present terms and the descendants of the excluded terms.

Parameters:
  • cohort – a cohort of individuals to investigate.

  • hpo – an entity with an HPO graph (e.g. MinimalOntology).

  • min_n_of_patients_with_term – the minimum number of patients that must feature an HPO term (either directly or indirectly) for the term to be included in the analysis.