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:
ContinuousPartitioningEndpoint computes survival for the analyzed individual.
Example endpoints include
death(),disease_onset(), or onset of a phenotypic feature (hpo_onset()).
- class gpsea.analysis.temporal.SurvivalAnalysis(statistic: SurvivalStatistic)[source]
Bases:
objectSurvivalAnalysis 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
AnalysisExceptionif 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:
MonoPhenotypeAnalysisResultSurvivalAnalysisResult 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 asSurvivalobject.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.
- plot_kaplan_meier_curves(ax, colors: Sequence[str] = ('#990F0F', '#A72929', '#B64343', '#C45D5D', '#D27676', '#E19090', '#EFAAAA'), **plot_kwargs)[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.
plot_kwargs – keyword arguments passed directly to
matplotlib.axes.Axes.step(). Unless overridden,where='post'.
- class gpsea.analysis.temporal.Survival(value: float, is_censored: bool)[source]
Bases:
objectInformation regarding individual’s survival.