def test_plot_steps(self):
     figs, AX = ta.plot_steps(traces, 
                               skip=[], 
                               palette={}, 
                               legend_args={}, 
                               plot_args={'marker': '+', 'linewidth':0}
                               )
     assert figs
     assert AX
Example #2
0
        's': The scipy return value if applicable
        'f': The full trace including calls to local optimizers if applicable
        '''
        accepted = result['a']

        plot_index = {1: ['OD600', 'Glu', 'Fluor', specific_growth]}

        titles = {1: dict(zip(plot_index[1], plot_index[1]))}

        #Create our own Figure and Axes objects for cutom layouts
        fig = plt.figure()
        AX_ = [fig.add_subplot(2, 2, i + 1) for i in range(4)]
        AX = {
            1: {
                'OD600': AX_[0],
                'Fluor': AX_[1],
                'Glu': AX_[2],
                specific_growth: AX_[3]
            }
        }
        cf.plot(posterior=accepted.tail(10),
                models=sampler_args['models'],
                guess=sampler_args['guess'],
                data=data_mu,
                plot_index=plot_index,
                titles=titles,
                figs=[fig],
                AX=AX)

        ta.plot_steps({1: accepted}, skip=sampler_args['fixed_parameters'])
    trace_figs = [plt.figure() for i in range(n_figs)]
    trace_AX_ = [
        trace_figs[i].add_subplot(5, 2, ii + 1) for i in range(len(trace_figs))
        for ii in range(10)
    ]
    trace_AX = dict(zip(trace_params, trace_AX_))
    print('\ntrace_params:\n', trace_params)
    print('\ntrace_AX:\n', trace_AX)
    print('\ntraces:\n', traces)

    #export the traces for all parameters into csv for ease of visualization
    traces[1].to_csv(output_folder / 'Traces_dataframe.csv')

    trace_figs, trace_AX = ta.plot_steps(traces,
                                         skip=sampler_args['fixed_parameters'],
                                         legend_args=legend_args,
                                         figs=trace_figs,
                                         AX=trace_AX)
    print('\ntrace_AX\n', trace_AX)
    #modify the figure setting else all the labels overlapped.
    for tax in trace_AX.values():
        tax.set_xticks(tax.get_xticks()[::2])
        tax.set_yticks(tax.get_yticks()[::2])
        tax.tick_params(axis='both', labelsize=16)
        tax.xaxis.label.set_size(fontsize=16)
        tax.yaxis.label.set_size(fontsize=16)

    plt.tight_layout(pad=1.0)  # set spacing between figures

    #Rank models
    table = ac.calculate_aic(data=sampler_args['data'],
            'Fluor/OD': 'Pep',
            'm': 'mRNA',
            'indi': 'Inducer(Internal)'
        }
    }
    labels = {
        1: inducer_conc_str,
        2: inducer_conc_str,
        3: inducer_conc_str,
        4: inducer_conc_str
    }
    legend_args = {'loc': 'upper left'}

    figs, AX = cf.plot(posterior=posterior,
                       models=sampler_args['models'],
                       data=data_mu,
                       data_sd=data_sd,
                       plot_index=plot_index,
                       labels=labels,
                       titles=titles,
                       legend_args=legend_args,
                       figs=None,
                       AX=None)

    for model_num in sampler_args['models']:
        params = sampler_args['models'][model_num]['params']
        traces_ = {key: traces[key][params] for key in traces}
        figs, AX = ta.plot_steps(traces_,
                                 skip=sampler_args['fixed_parameters'],
                                 legend_args=legend_args)
Example #5
0
    seeder = seed(sampler_args['guess'], sampler_args['fixed_parameters'],
                  sampler_args['bounds'])

    for i in range(10):
        print('Run ' + str(i + 1))
        sampler_args['guess'] = seeder()
        result = cf.simulated_annealing(**sampler_args)
        accepted = result['a']
        traces[i + 1] = accepted.iloc[::5]  #Thin the trace

    for model_num in sampler_args['models']:
        params = sampler_args['models'][model_num]['params']
        traces_ = {key: traces[key][params] for key in traces}
        t_figs, t_AX = ta.plot_steps(traces_,
                                     skip=sampler_args['fixed_parameters'],
                                     legend_args=legend_args)

        k_figs, k_AX = ta.plot_steps(traces_,
                                     skip=sampler_args['fixed_parameters'],
                                     legend_args=legend_args)
        h_figs, h_AX = ta.plot_steps(traces_,
                                     skip=sampler_args['fixed_parameters'],
                                     legend_args=legend_args)
    '''
    To save time, we recommend you thin the trace at your discretion!
    '''
    '''
    9. A Priori Identifiability Analysis
    '''
    '''