def create_plots(info_path):
    output_dir = os.path.join(os.path.dirname(info_path), 'plots')
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    prior_prob_omega_less_than = 0.0887
    psi_results, omega_results, tau_results = parse_results(info_path)
    cfg_to_psi = {}
    cfg_to_psi_prob = {}
    for cfg, psi in psi_results.iteritems():
        cfg_to_psi[cfg] = psi.mode
        cfg_to_psi_prob[cfg] = psi.prob
    cfg_to_omega = {}
    cfg_to_omega_prob = {}
    cfg_to_omega_true_ests = {}
    cfg_to_omega_true_ests_glm = {}
    for cfg, omega in omega_results.iteritems():
        cfg_to_omega[cfg] = omega.median
        cfg_to_omega_prob[cfg] = omega.prob
        cfg_to_omega_true_ests[cfg] = {'x': omega.true, 'y': omega.median}
        cfg_to_omega_true_ests_glm[cfg] = {'x': omega.true, 'y': omega.mode_glm}

    cfg_to_num_excluded = {}
    cfg_to_num_excluded_glm = {}
    cfg_to_prob_of_exclusion = {}
    cfg_to_prob_of_exclusion_glm = {}
    cfg_to_prob_of_bf_ex = {}
    cfg_to_prob_of_bf_ex_glm = {}
    bf_10_exclusion_prob = None
    for cfg, tau in tau_results.iteritems():
        cfg_to_num_excluded[cfg] = tau.num_excluded
        cfg_to_num_excluded_glm[cfg] = tau.num_excluded_glm
        cfg_to_prob_of_exclusion[cfg] = tau.prob_of_exclusion
        cfg_to_prob_of_exclusion_glm[cfg] = tau.prob_of_exclusion_glm
        cfg_to_prob_of_bf_ex[cfg] = tau.prob_of_bf_exclusion
        cfg_to_prob_of_bf_ex_glm[cfg] = tau.prob_of_bf_exclusion_glm
        if not bf_10_exclusion_prob:
            bf_10_exclusion_prob = tau.bf_10_exclusion_prob

    psi_plot = PowerPlotGrid(observed_config_to_estimates = cfg_to_psi,
            variable = 'psi',
            num_columns = 2)
    fig = psi_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_psi_mode.pdf'))

    psi_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_psi_prob,
            variable = 'psi',
            div_model_prior = 'psi',
            bayes_factor = 10,
            num_columns = 2)
    fig = psi_prob_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_psi_prob.pdf'))

    omega_plot = PowerPlotGrid(observed_config_to_estimates = cfg_to_omega,
            variable = 'omega',
            num_columns = 2)
    fig = omega_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_omega_median.pdf'))

    omega_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_prob,
            variable = 'omega',
            div_model_prior = 'psi',
            bayes_factor = 10,
            bayes_factor_prob = prior_prob_omega_less_than,
            num_columns = 2)
    fig = omega_prob_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_omega_prob.pdf'))
    
    omega_accuracy_plot = AccuracyPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_true_ests,
            num_columns = 2)
    fig = omega_accuracy_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_accuracy_omega_median.pdf'))

    omega_accuracy_plot_glm = AccuracyPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_true_ests_glm,
            num_columns = 2)
    fig = omega_accuracy_plot_glm.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_accuracy_omega_mode_glm.pdf'))

    ex_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_prob_of_exclusion,
            variable = 'tau_exclusion',
            div_model_prior = 'psi',
            bayes_factor = 10,
            bayes_factor_prob = bf_10_exclusion_prob,
            cfg_to_prob_of_bf_exclusion = cfg_to_prob_of_bf_ex,
            num_columns = 2)
    fig = ex_prob_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_prob_exclusion.pdf'))
    ex_prob_plot_glm = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_prob_of_exclusion_glm,
            variable = 'tau_exclusion',
            div_model_prior = 'psi',
            bayes_factor = 10,
            bayes_factor_prob = bf_10_exclusion_prob,
            cfg_to_prob_of_bf_exclusion = cfg_to_prob_of_bf_ex_glm,
            num_columns = 2)
    fig = ex_prob_plot_glm.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_prob_exclusion_glm.pdf'))

    ex_plot = PowerPlotGrid(
            observed_config_to_estimates = cfg_to_num_excluded,
            variable = 'tau_exclusion',
            num_columns = 2)
    fig = ex_plot.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_num_excluded.pdf'))
    ex_plot_glm = PowerPlotGrid(
            observed_config_to_estimates = cfg_to_num_excluded_glm,
            variable = 'tau_exclusion',
            num_columns = 2)
    fig = ex_plot_glm.create_grid()
    fig.savefig(os.path.join(output_dir, 'power_num_excluded_glm.pdf'))
Exemplo n.º 2
0
def create_plots(info_path):
    dmc_sim = DMCSimulationResults(info_path)
    prior_configs = {}
    for k, v in dmc_sim.prior_index_to_config.iteritems():
        prior_configs[k] = MsBayesConfig(v)
    output_dir = os.path.join(os.path.dirname(info_path), 'plots')
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    (psi_res, cv_res, prior_index_to_name,
     prior_index_to_model_type) = parse_results(dmc_sim)
    for prior_index, prior_name in prior_index_to_name.iteritems():
        cfg_to_psi = {}
        cfg_to_psi_prob = {}
        cfg_to_cv = {}
        cfg_to_cv_prob = {}
        cfg_to_cv_true_ests = {}
        prefix = prior_name
        for observed_name in psi_res.iterkeys():
            div_model_prior = prior_index_to_model_type[prior_index]
            dpp_concentration_mean = None
            if div_model_prior == 'dpp':
                dpp_concentration_mean = prior_configs[
                    prior_index].dpp_concentration.mean
            psi_results = psi_res[observed_name][prior_index]
            cv_results = cv_res[observed_name][prior_index]
            for cfg, psi in psi_results.iteritems():
                cfg_to_psi[cfg] = psi.mode
                cfg_to_psi_prob[cfg] = psi.prob
            for cfg, cv in cv_results.iteritems():
                cfg_to_cv[cfg] = cv.median
                cfg_to_cv_prob[cfg] = cv.prob
                cfg_to_cv_true_ests[cfg] = {'x': cv.true, 'y': cv.median}

        psi_plot = PowerPlotGrid(observed_config_to_estimates=cfg_to_psi,
                                 variable='psi',
                                 variable_symbol=r'|\mathbf{\tau}|',
                                 num_columns=2,
                                 margin_top=0.975)
        fig = psi_plot.create_grid()
        fig.savefig(os.path.join(output_dir, prefix + '_power_psi_mode.pdf'))

        psi_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates=cfg_to_psi_prob,
            variable='psi',
            variable_symbol=r'|\mathbf{\tau}|',
            div_model_prior=div_model_prior,
            dpp_concentration_mean=dpp_concentration_mean,
            bayes_factor=10,
            num_columns=2)
        fig = psi_prob_plot.create_grid()
        fig.savefig(os.path.join(output_dir, prefix + '_power_psi_prob.pdf'))

        cv_accuracy_plot = AccuracyPowerPlotGrid(
            observed_config_to_estimates=cfg_to_cv_true_ests,
            variable_symbol=r'CV_T',
            num_columns=2,
            padding_between_vertical=2.0,
            margin_left=0.04,
            margin_bottom=0.03)
        fig = cv_accuracy_plot.create_grid()
        fig.savefig(
            os.path.join(output_dir, prefix + '_accuracy_cv_median.pdf'))
Exemplo n.º 3
0
def create_plots(info_path):
    dmc_sim = DMCSimulationResults(info_path)
    prior_configs = {}
    for k, v in dmc_sim.prior_index_to_config.iteritems():
        prior_configs[k] = MsBayesConfig(v)
    output_dir = os.path.join(os.path.dirname(info_path), 'plots')
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    (psi_res, cv_res, prior_index_to_name,
            prior_index_to_model_type) = parse_results(dmc_sim)
    for prior_index, prior_name in prior_index_to_name.iteritems():
        cfg_to_psi = {}
        cfg_to_psi_prob = {}
        cfg_to_cv = {}
        cfg_to_cv_prob = {}
        cfg_to_cv_true_ests = {}
        prefix = prior_name
        for observed_name in psi_res.iterkeys():
            div_model_prior = prior_index_to_model_type[prior_index]
            dpp_concentration_mean = None
            if div_model_prior == 'dpp':
                dpp_concentration_mean = prior_configs[
                        prior_index].dpp_concentration.mean
            psi_results = psi_res[observed_name][prior_index]
            cv_results = cv_res[observed_name][prior_index]
            for cfg, psi in psi_results.iteritems():
                cfg_to_psi[cfg] = psi.mode
                cfg_to_psi_prob[cfg] = psi.prob
            for cfg, cv in cv_results.iteritems():
                cfg_to_cv[cfg] = cv.median
                cfg_to_cv_prob[cfg] = cv.prob
                cfg_to_cv_true_ests[cfg] = {'x': cv.true, 'y': cv.median}

        psi_plot = PowerPlotGrid(
                observed_config_to_estimates = cfg_to_psi,
                variable = 'psi',
                variable_symbol = r'|\mathbf{\tau}|',
                num_columns = 2,
                margin_top = 0.975)
        fig = psi_plot.create_grid()
        fig.savefig(os.path.join(output_dir,
                prefix + '_power_psi_mode.pdf'))

        psi_prob_plot = ProbabilityPowerPlotGrid(
                observed_config_to_estimates = cfg_to_psi_prob,
                variable = 'psi',
                variable_symbol = r'|\mathbf{\tau}|',
                div_model_prior = div_model_prior,
                dpp_concentration_mean = dpp_concentration_mean,
                bayes_factor = 10,
                num_columns = 2)
        fig = psi_prob_plot.create_grid()
        fig.savefig(os.path.join(output_dir,
                prefix + '_power_psi_prob.pdf'))

        cv_accuracy_plot = AccuracyPowerPlotGrid(
                observed_config_to_estimates = cfg_to_cv_true_ests,
                variable_symbol = r'CV_T',
                num_columns = 2,
                padding_between_vertical = 2.0,
                margin_left = 0.04,
                margin_bottom = 0.03)
        fig = cv_accuracy_plot.create_grid()
        fig.savefig(os.path.join(output_dir,
                prefix + '_accuracy_cv_median.pdf'))
def create_plots(info_path):
    output_dir = os.path.join(os.path.dirname(info_path), 'plots')
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    prior_prob_omega_less_than = 0.0887
    psi_results, omega_results, tau_results = parse_results(info_path)
    cfg_to_psi = {}
    cfg_to_psi_prob = {}
    for cfg, psi in psi_results.iteritems():
        cfg_to_psi[cfg] = psi.mode
        cfg_to_psi_prob[cfg] = psi.prob
    cfg_to_omega = {}
    cfg_to_omega_prob = {}
    cfg_to_omega_true_ests = {}
    cfg_to_omega_true_ests_glm = {}
    for cfg, omega in omega_results.iteritems():
        cfg_to_omega[cfg] = omega.median
        cfg_to_omega_prob[cfg] = omega.prob
        cfg_to_omega_true_ests[cfg] = {'x': omega.true, 'y': omega.median}
        cfg_to_omega_true_ests_glm[cfg] = {'x': omega.true, 'y': omega.mode_glm}

    cfg_to_num_excluded = {}
    cfg_to_num_excluded_glm = {}
    cfg_to_prob_of_exclusion = {}
    cfg_to_prob_of_exclusion_glm = {}
    cfg_to_prob_of_bf_ex = {}
    cfg_to_prob_of_bf_ex_glm = {}
    bf_10_exclusion_prob = None
    for cfg, tau in tau_results.iteritems():
        cfg_to_num_excluded[cfg] = tau.num_excluded
        cfg_to_num_excluded_glm[cfg] = tau.num_excluded_glm
        cfg_to_prob_of_exclusion[cfg] = tau.prob_of_exclusion
        cfg_to_prob_of_exclusion_glm[cfg] = tau.prob_of_exclusion_glm
        cfg_to_prob_of_bf_ex[cfg] = tau.prob_of_bf_exclusion
        cfg_to_prob_of_bf_ex_glm[cfg] = tau.prob_of_bf_exclusion_glm
        if not bf_10_exclusion_prob:
            bf_10_exclusion_prob = tau.bf_10_exclusion_prob

    psi_plot = PowerPlotGrid(observed_config_to_estimates = cfg_to_psi,
            variable = 'psi',
            num_columns = 2,
            x_title = r'Estimated number of divergence events, $\hat{\Psi}$',
            y_title = 'Density',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.835,
            padding_between_horizontal = 0.5)

    fig = psi_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 8.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-psi-mode-6.pdf'))

    psi_plot.width = 10.0
    fig = psi_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 12.0,
            x_tick_label_size = 8.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-psi-mode-4.pdf'))


    omega_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_prob,
            variable = 'omega',
            div_model_prior = 'psi',
            bayes_factor = 10,
            bayes_factor_prob = prior_prob_omega_less_than,
            num_columns = 2,
            x_title = (r'Posterior probability of one divergence, '
                    r'$p(\Omega < 0.01 \, | \, B_{{\epsilon}}(S*))$'),
            y_title = 'Density',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.835,
            padding_between_horizontal = 0.5)
    fig = omega_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-omega-prob-6.pdf'))
    omega_prob_plot.width = 10.0
    fig = omega_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-omega-prob-4.pdf'))
    omega_prob_plot.label_offset = 6
    omega_prob_plot.width = 14.0
    fig = omega_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-omega-prob-6-panel.pdf'))
    omega_prob_plot.label_offset = 4
    omega_prob_plot.width = 10.0
    fig = omega_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-omega-prob-4-panel.pdf'))
    
    omega_accuracy_plot = AccuracyPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_true_ests,
            num_columns = 2,
            x_title = r'True variance of divergence times, $\Omega$',
            y_title = r'$\hat{\Omega}$',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.825,
            padding_between_horizontal = 0.5)
    fig = omega_accuracy_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-median-6.pdf'))
    omega_accuracy_plot.width = 10.0
    fig = omega_accuracy_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-median-4.pdf'))

    omega_accuracy_plot_glm = AccuracyPowerPlotGrid(
            observed_config_to_estimates = cfg_to_omega_true_ests_glm,
            num_columns = 2,
            x_title = r'True variance of divergence times, $\Omega$',
            y_title = r'$\hat{\Omega}$',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.825,
            padding_between_horizontal = 0.5)
    fig = omega_accuracy_plot_glm.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-mode-glm-6.pdf'))
    omega_accuracy_plot_glm.width = 10.0
    fig = omega_accuracy_plot_glm.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-mode-glm-4.pdf'))
    omega_accuracy_plot_glm.label_offset = 6
    omega_accuracy_plot_glm.width = 14.0
    fig = omega_accuracy_plot_glm.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-mode-glm-6-panel.pdf'))
    omega_accuracy_plot_glm.label_offset = 4
    omega_accuracy_plot_glm.width = 10.0
    fig = omega_accuracy_plot_glm.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = False,
            share_y = False)
    fig.savefig(os.path.join(output_dir, 'power-accuracy-omega-mode-glm-4-panel.pdf'))

    ex_prob_plot = ProbabilityPowerPlotGrid(
            observed_config_to_estimates = cfg_to_prob_of_exclusion,
            variable = 'tau_exclusion',
            div_model_prior = 'psi',
            bayes_factor = 10,
            bayes_factor_prob = bf_10_exclusion_prob,
            draw_bayes_factor_line = False,
            cfg_to_prob_of_bf_exclusion = cfg_to_prob_of_bf_ex,
            num_columns = 2,
            x_title = (r'Posterior probability of excluding true parameters, $p(\mathbf{\tau} \, \notin \, '
                        r'M \, | \, B_{\epsilon}(S*))$'),
            y_title = 'Density',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.835,
            padding_between_horizontal = 0.5)
    fig = ex_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-prob-exclusion-6.pdf'))
    ex_prob_plot.width = 10.0
    fig = ex_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-prob-exclusion-4.pdf'))
    ex_prob_plot.label_offset = 6
    ex_prob_plot.width = 14.0
    fig = ex_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-prob-exclusion-6-panel.pdf'))
    ex_prob_plot.label_offset = 4
    ex_prob_plot.width = 10.0
    fig = ex_prob_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            add_column_labels = False,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 10.0,
            x_tick_label_size = 10.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-prob-exclusion-4-panel.pdf'))


    ex_plot = PowerPlotGrid(
            observed_config_to_estimates = cfg_to_num_excluded,
            variable = 'tau_exclusion',
            num_columns = 2,
            x_title = r'Number of true $\tau$ excluded',
            y_title = 'Density',
            width = 14.0,
            height = 2.8,
            auto_height = False,
            auto_adjust_margins = False,
            margin_left = 0.025,
            margin_bottom = 0.1,
            margin_right = 1,
            margin_top = 0.835,
            padding_between_horizontal = 0.5)

    fig = ex_plot.create_column_grid(
            subplot_indices_to_exclude = [],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            x_tick_label_size = 8.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-num-excluded-6.pdf'))
    ex_plot.width = 10.0
    fig = ex_plot.create_column_grid(
            subplot_indices_to_exclude = [1,3],
            x_title_size = 14.0,
            y_title_size = 14.0,
            column_label_size = 16.0,
            column_label_offset = 0.14,
            right_text_size = 12.0,
            x_tick_label_size = 8.0,
            share_x = True,
            share_y = True)
    fig.savefig(os.path.join(output_dir, 'power-num-excluded-4.pdf'))
def create_plots(info_path):
    dmc_sim = DMCSimulationResults(info_path)
    prior_configs = {}
    for k, v in dmc_sim.prior_index_to_config.iteritems():
        prior_configs[k] = MsBayesConfig(v)
    output_dir = os.path.join(os.path.dirname(info_path), 'plots')
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    prior_prob_omega_less_than = {
            1: 0.0025575,
            2: 0.049283,
            3: 0.002171,
            4: 0.049191}
    psi_res, omega_res, prior_index_to_name = parse_results(dmc_sim)
    for observed_name in psi_res.iterkeys():
        for prior_index in psi_res[observed_name].iterkeys():
            prior_name = prior_index_to_name[prior_index]
            div_model_prior = prior_name
            if prior_name in ['old', 'u-shaped']:
                div_model_prior = 'psi'
            dpp_concentration_mean = None
            if div_model_prior == 'dpp':
                dpp_concentration_mean = prior_configs[
                        prior_index].dpp_concentration.mean
            prior_prob_omega = prior_prob_omega_less_than[prior_index]
            psi_results = psi_res[observed_name][prior_index]
            omega_results = omega_res[observed_name][prior_index]
            prefix = '_'.join([observed_name, prior_name])
            cfg_to_psi = {}
            cfg_to_psi_prob = {}
            cfg_to_psi_glm = {}
            cfg_to_psi_prob_glm = {}
            for cfg, psi in psi_results.iteritems():
                cfg_to_psi[cfg] = psi.mode
                cfg_to_psi_prob[cfg] = psi.prob
                cfg_to_psi_glm[cfg] = psi.mode_glm
                cfg_to_psi_prob_glm[cfg] = psi.prob_glm
            cfg_to_omega = {}
            cfg_to_omega_prob = {}
            cfg_to_omega_glm = {}
            cfg_to_omega_prob_glm = {}
            cfg_to_omega_true_ests = {}
            cfg_to_omega_true_ests_glm = {}
            for cfg, omega in omega_results.iteritems():
                cfg_to_omega[cfg] = omega.median
                cfg_to_omega_prob[cfg] = omega.prob
                cfg_to_omega_glm[cfg] = omega.mode_glm
                cfg_to_omega_prob_glm[cfg] = omega.prob_glm
                cfg_to_omega_true_ests[cfg] = {'x': omega.true, 'y': omega.median}
                cfg_to_omega_true_ests_glm[cfg] = {'x': omega.true, 'y': omega.mode_glm}

            psi_plot = PowerPlotGrid(
                    observed_config_to_estimates = cfg_to_psi,
                    variable = 'psi',
                    variable_symbol = r'|\mathbf{\tau}|',
                    num_columns = 2,
                    margin_top = 0.975)
            fig = psi_plot.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_psi_mode.pdf'))

            psi_plot_glm = PowerPlotGrid(
                    observed_config_to_estimates = cfg_to_psi_glm,
                    variable = 'psi',
                    variable_symbol = r'|\mathbf{\tau}|',
                    num_columns = 2,
                    margin_top = 0.975)
            fig = psi_plot_glm.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_psi_mode_glm.pdf'))

            psi_prob_plot = ProbabilityPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_psi_prob,
                    variable = 'psi',
                    variable_symbol = r'|\mathbf{\tau}|',
                    div_model_prior = div_model_prior,
                    dpp_concentration_mean = dpp_concentration_mean,
                    bayes_factor = 10,
                    num_columns = 2)
            fig = psi_prob_plot.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_psi_prob.pdf'))

            psi_prob_plot_glm = ProbabilityPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_psi_prob_glm,
                    variable = 'psi',
                    variable_symbol = r'|\mathbf{\tau}|',
                    div_model_prior = div_model_prior,
                    dpp_concentration_mean = dpp_concentration_mean,
                    bayes_factor = 10,
                    num_columns = 2)
            fig = psi_prob_plot_glm.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_psi_prob_glm.pdf'))

            omega_plot = PowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega,
                    variable = 'omega',
                    variable_symbol = r'D_T',
                    num_columns = 2)
            fig = omega_plot.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_omega_median.pdf'))

            omega_plot_glm = PowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega_glm,
                    variable = 'omega',
                    variable_symbol = r'D_T',
                    num_columns = 2)
            fig = omega_plot_glm.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_omega_mode_glm.pdf'))

            omega_prob_plot = ProbabilityPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega_prob,
                    variable = 'omega',
                    variable_symbol = r'D_T',
                    div_model_prior = div_model_prior,
                    dpp_concentration_mean = dpp_concentration_mean,
                    bayes_factor = 10,
                    bayes_factor_prob = prior_prob_omega,
                    num_columns = 2,
                    text_size = 10.0)
            fig = omega_prob_plot.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_omega_prob.pdf'))

            omega_prob_plot_glm = ProbabilityPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega_prob_glm,
                    variable = 'omega',
                    variable_symbol = r'D_T',
                    div_model_prior = div_model_prior,
                    dpp_concentration_mean = dpp_concentration_mean,
                    bayes_factor = 10,
                    bayes_factor_prob = prior_prob_omega,
                    num_columns = 2,
                    text_size = 10.0)
            fig = omega_prob_plot_glm.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_omega_prob_glm.pdf'))
            
            omega_accuracy_plot = AccuracyPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega_true_ests,
                    variable_symbol = r'D_T',
                    num_columns = 2,
                    padding_between_vertical = 2.0,
                    margin_left = 0.04,
                    margin_bottom = 0.03)
            fig = omega_accuracy_plot.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_accuracy_omega_median.pdf'))

            omega_accuracy_plot_glm = AccuracyPowerPlotGrid(
                    observed_config_to_estimates = cfg_to_omega_true_ests_glm,
                    variable_symbol = r'D_T',
                    num_columns = 2,
                    padding_between_vertical = 2.0,
                    margin_left = 0.04,
                    margin_bottom = 0.03)
            fig = omega_accuracy_plot_glm.create_grid()
            fig.savefig(os.path.join(output_dir,
                    prefix + '_power_accuracy_omega_mode_glm.pdf'))