gpsea.analysis.temporal package

The gpsea.analysis.temporal package implements comparison of survivals between genotype groups.

See Survival analysis for an example.

class gpsea.analysis.temporal.Endpoint[source]

Bases: ContinuousPartitioning

Endpoint computes survival for the analyzed individual.

Example endpoints include death(), disease_onset(), or onset of a phenotypic feature (hpo_onset()).

abstract compute_survival(patient: Patient) Survival | None[source]

Compute a survival for a given patient or None if the patient lacks the required data (e.g. age of death or age at last investigation).

class gpsea.analysis.temporal.SurvivalAnalysis(statistic: SurvivalStatistic)[source]

Bases: object

SurvivalAnalysis compares the survivals of genotype groups with respect to an Endpoint.

The cohort is partitioned into groups using a genotype predicate and survival is computed for each cohort member. The difference between survivals is tested with selected SurvivalStatistic.

The analysis may raise an AnalysisException if issues are encountered. The exception includes the reason(s) in args as well as any partial data, to help with troubleshooting.

compare_genotype_vs_survival(cohort: Iterable[Patient], gt_clf: GenotypeClassifier, endpoint: Endpoint) SurvivalAnalysisResult[source]

Execute the survival analysis on a given cohort.

class gpsea.analysis.temporal.SurvivalAnalysisResult(gt_clf: GenotypeClassifier, endpoint: Endpoint, statistic: SurvivalStatistic, data: DataFrame, statistic_result: StatisticResult)[source]

Bases: MonoPhenotypeAnalysisResult

SurvivalAnalysisResult includes the results of a SurvivalAnalysis.

The genotype categories and survival are reported in the data data frame with the following structure:

patient_id

genotype

phenotype

patient_1

0

Survival(value=123.4, is_censored=False)

patient_2

0

None

patient_3

None

Survival(value=456.7, is_censored=True)

patient_4

1

None

The index includes the individual IDs (patient_id), and then there are 2 columns with the genotype group id (cat_id) and the phenotype with the survival represented as Survival object.

A genotype value may be missing (None) if the individual cannot be assigned into a genotype category. Similarly, a survival is None if computing the survival for an individual is impossible.

property endpoint: Endpoint

Get the endpoint used to compute the survival of the individuals.

plot_kaplan_meier_curves(ax)[source]

Plot genotype group survivals on the provided axes.

The axes includes legend. However, if no survival is available for a genotype group, the group name will be missing from the legend.

Parameters:

ax – a Matplotlib Axes to draw on.

class gpsea.analysis.temporal.Survival(value: float, is_censored: bool)[source]

Bases: object

Information regarding individual’s survival.

value: float

The survival value, expressed as a float.

The value must be finite and non-NaN.

is_censored: bool

True if the survival has been censored and False otherwise.

Subpackages