Пример #1
0
def plot_survival_curves_and_histograms(sim_outcomes_mono, sim_outcomes_combo):
    """ draws the survival curves and the histograms of time until HIV deaths
    :param sim_outcomes_mono: outcomes of a cohort simulated under mono therapy
    :param sim_outcomes_combo: outcomes of a cohort simulated under combination therapy
    """

    # get survival curves of both treatments
    survival_curves = [
        sim_outcomes_mono.nLivingPatients, sim_outcomes_combo.nLivingPatients
    ]

    # graph survival curve
    Path.plot_sample_paths(sample_paths=survival_curves,
                           title='Survival curve',
                           x_label='Simulation time step (year)',
                           y_label='Number of alive patients',
                           legends=['Mono Therapy', 'Combination Therapy'],
                           color_codes=['green', 'blue'])

    # histograms of survival times
    set_of_survival_times = [
        sim_outcomes_mono.survivalTimes, sim_outcomes_combo.survivalTimes
    ]

    # graph histograms
    Hist.plot_histograms(data_sets=set_of_survival_times,
                         title='Histogram of patient survival time',
                         x_label='Survival time (year)',
                         y_label='Counts',
                         bin_width=1,
                         legends=['Mono Therapy', 'Combination Therapy'],
                         color_codes=['green', 'blue'],
                         transparency=0.6)
Пример #2
0
def plot_survival_curves_and_histograms(sim_outcomes_none, sim_outcomes_anticoag):
    """ draws the survival curves and the histograms of time until HIV deaths
    :param sim_outcomes_none: outcomes of a cohort simulated under no therapy
    :param sim_outcomes_anticoag: outcomes of a cohort simulated under anticoagulation
    """

    # get survival curves of both treatments
    survival_curves = [
        sim_outcomes_none.nLivingPatients,
        sim_outcomes_anticoag.nLivingPatients
    ]

    # graph survival curve
    Path.plot_sample_paths(
        sample_paths=survival_curves,
        title='Survival curve',
        x_label='Simulation time step (year)',
        y_label='Number of alive patients',
        legends=['No Therapy', 'Anticoagulation'],
        color_codes=['red', 'blue']
    )

    # histograms of survival times
    set_of_strokes = [
        sim_outcomes_none.nStrokes,
        sim_outcomes_anticoag.nStrokes
    ]

    # graph histograms
    Hist.plot_histograms(
        data_sets=set_of_strokes,
        title='Histogram of number of strokes',
        x_label='Number of Strokes',
        y_label='Counts',
        bin_width=1,
        legends=['No Therapy', 'Anticoagulation'],
        color_codes=['red', 'blue'],
        transparency=0.5
    )
Пример #3
0
def draw_survival_curves_and_histograms(cohort_no_drug, cohort_with_drug):
    """ draws the survival curves and the histograms of survival time
    :param cohort_no_drug: a cohort simulated when drug is not available
    :param cohort_with_drug: a cohort simulated when drug is available
    """

    # get survival curves of both treatments
    survival_curves = [
        cohort_no_drug.cohortOutcomes.nLivingPatients,
        cohort_with_drug.cohortOutcomes.nLivingPatients
    ]

    # graph survival curve
    Path.plot_sample_paths(sample_paths=survival_curves,
                           title='Survival curve',
                           x_label='Simulation time step',
                           y_label='Number of alive patients',
                           legends=['No Drug', 'With Drug'],
                           color_codes=['blue', 'orange'],
                           transparency=0.5)

    # histograms of survival times
    set_of_survival_times = [
        cohort_no_drug.cohortOutcomes.survivalTimes,
        cohort_with_drug.cohortOutcomes.survivalTimes
    ]

    # graph histograms
    Hist.plot_histograms(data_sets=set_of_survival_times,
                         title='Histogram of patient survival time',
                         x_label='Survival time',
                         y_label='Counts',
                         bin_width=2,
                         legends=['No Drug', 'With Drug'],
                         color_codes=['blue', 'orange'],
                         transparency=0.5)
Пример #4
0
    size=Sets.PRIOR_N)

# create multiple cohorts
multiCohort = Cls.MultiCohort(
    ids=range(Sets.PRIOR_N),
    pop_sizes=[Sets.SIM_POP_SIZE] * Sets.PRIOR_N,
    mortality_probs=mortality_samples  # [p1, p2, ....]
)

# simulate all cohorts
multiCohort.simulate(Sets.TIME_STEPS)

# plot the sample paths
Path.plot_sample_paths(
    sample_paths=multiCohort.multiCohortOutcomes.survivalCurves,
    title='Survival Curves',
    x_label='Time-Step (Year)',
    y_label='Number Survived',
    transparency=0.5)

# plot the histogram of average survival time
Hist.plot_histogram(
    data=multiCohort.multiCohortOutcomes.meanSurvivalTimes,
    title='Histogram of Mean Survival Time',
    x_label='Mean Survival Time (Year)',
    y_label='Count',
    x_range=[2.5, 21.5],
    bin_width=0.5)

# create the histogram of the mortality probabilities
Hist.plot_histogram(
    data=mortality_samples,
Пример #5
0
                      color_code='r',
                      connect='step')

# plot path 3 only
Path.plot_sample_path(
    sample_path=path3,
    title='Plotting a single sample path that is updated in batch',
    x_label='time',
    y_label='observed value',
    legend='Path 3',
    color_code='r')

# plot both paths
Path.plot_sample_paths(sample_paths=[path1, path2],
                       title='Plot two sample paths with different color',
                       x_label='time',
                       y_label='observed value',
                       legends=['Path 1', 'Path 2'],
                       transparency=0.75)

Path.plot_sample_paths(sample_paths=[path1, path2],
                       title='Plot 2 sample paths with the same color',
                       x_label='time',
                       y_label='observed value',
                       legends='Path',
                       transparency=0.5,
                       common_color_code='g')

Path.plot_sets_of_sample_paths(sets_of_sample_paths=[[path1, path2],
                                                     [path3, path4]],
                               title='Plot 2 sets of sample paths',
                               x_label='time',