Пример #1
0
def ident_processing(ident_object, ident_result):
    """call all required functions to process identifiability information"""
    # collect, arrange and collate data
    ordered_info = ident_object.order_ident_data(ident_result)
    ident_object.create_dict_for_df(ordered_info)

    # write all ident data to file
    ident_object.write_ident_info_file()

    # process ident info for further analysis
    ident_object.process_ident()

    # extract parameter va;ues for model validation
    ident_object.get_parameter_value()

    default_parameter_values = true_parameter_values()
    ident_object.parameter_values_plot(default_parameter_values,
                                       violin=True,
                                       box=False,
                                       bins=1)

    ident_object.identifiability_plot()

    ident_object.exp_info_plot()

    return None
Пример #2
0
# retrieve identifiability data from file and process information
ident_index_label = ['sample_name', 'data_set_id']
# retrieve identifiability info from file
ident_df = retrieve_experimental_data_from_file(storage_file_name,
                                                ident_index_label)
all_parameter_info = process_ident(ident_df, arranged_data_df)

# run dynamic simulations to obtain ss data based on estimated parameter values
# get info from data sets that identify all 3 parameters
validation_file_name = os.path.join(
    os.getcwd(), 'validate/ident_validate_v3_root_1_mwc_data')
from process_ident_data import get_parameter_value
validation_info = get_parameter_value(all_parameter_info, ident_df)
# get default parameter values
default_parameter_values = true_parameter_values()

# initial value used to generate experimental data
# from validate_estimation import validate_model
# import numpy as np
# y0 = np.array([5, 1, 1])
# # integrator options
# cvode_options = {'iter': 'Newton', 'discr': 'Adams', 'atol': 1e-10, 'rtol': 1e-10, 'time_points': 200,
#                  'display_progress': False, 'verbosity': 50}
# validate_model(y0, cvode_options, default_parameter_values, validation_info,
#                save_file_name=validation_file_name,
#                ss=1, dyn=0, noise=0, kinetics=2)

# retrieve validation info from file
validate_index_labels = [
    'estimate_id', 'sample_name', 'data_set_id', 'experiment_id'
Пример #3
0
def v1_kcat_mwc_validate():
    name = MPI.Get_processor_name()
    rank = MPI.COMM_WORLD.Get_rank()
    size = MPI.COMM_WORLD.Get_size()

    if rank == 0:
        # create ident object first
        v1_ident = ModelIdent(
            ident_fun=kotte_model.flux_1_kcat_ident,
            arranged_data_file_name=os.path.join(
                os.getcwd(), 'exp/exp_v1_2_experiments_mwc'),
            ident_data_file_name=os.path.join(os.getcwd(),
                                              'ident/ident_v1_kcat_mwc'),
            **{
                'original_exp_file':
                os.path.join(os.getcwd(), 'exp/experiments_mwc'),
                'flux_id':
                1,
                'flux_choice':
                2,
                'values_figure':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_parameter_values.eps'),
                'ident_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_ident.eps'),
                'exp_figure':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_exp.eps'),
                'figure_format':
                'eps',
                'ident_index_label': ['sample_name', 'data_set_id']
            })

        # retrieve identifiability data and process it for validation
        v1_ident.validation_info()

        user_ode_opts = {
            'iter': 'Newton',
            'discr': 'Adams',
            'atol': 1e-10,
            'rtol': 1e-10,
            'time_points': 200,
            'display_progress': True,
            'verbosity': 30
        }
        # initial ss to begin all simulations from
        y0 = np.array([5, 1, 1])
        # get and set true parameter values, if available separately
        default_parameters = true_parameter_values()

        v1_valid_obj = ValidateSim(
            kotte_model.kotte_ode, kotte_model.kotte_flux, **{
                'kinetics':
                1,
                'ode_opts':
                user_ode_opts,
                't_final':
                200,
                'wt_y0':
                y0,
                'i_parameter':
                default_parameters,
                'sample_size':
                1,
                'noise_std':
                0.05,
                'validate_index_label':
                ['estimate_id', 'sample_name', 'data_set_id', 'experiment_id'],
                'validate_file_name':
                os.path.join(os.getcwd(), 'validate/v1_kcat_mwc_validate'),
                'original_exp_file':
                v1_ident.original_exp_file,
                'c_validate_file':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_c_validate.eps'),
                'f_validate_file':
                os.path.join(os.getcwd(),
                             'results/v1_kcat_mwc_f_validate.eps'),
                'c_exp_file':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_c_exp.eps'),
                'v_exp_file':
                os.path.join(os.getcwd(), 'results/v1_kcat_mwc_f_exp.eps'),
                'format':
                v1_ident.figure_format
            })

        parameter_estimates, estimate_info = v1_valid_obj.create_parameter_list(
            v1_ident.select_values)

        job = ParallelValidate(slaves=range(1, size))

        validate_results = job.run_all(task='initial_sim',
                                       **{
                                           'parameters': parameter_estimates,
                                           'estimate_info': estimate_info,
                                           'sim_obj': v1_valid_obj
                                       })
        job.terminate_slaves()

        # process validation data for plots
        validate_processing(v1_valid_obj, validate_results)

    else:

        print('I am %s Slave with rank %s of %s' %
              (name, str(rank), str(size)))
        ValidateSlave().run()

    return None
Пример #4
0
def create_experiment_data(save_file_name,
                           noise=0,
                           kinetics=2,
                           number_samples=1,
                           noise_std=0.05):
    """run generate_expdata and store resulting experimental data as csv file from data frame"""
    # generate no-noise experimental data for testing identifiability
    user_ode_opts = {
        'iter': 'Newton',
        'discr': 'Adams',
        'atol': 1e-10,
        'rtol': 1e-10,
        'time_points': 200,
        'display_progress': True,
        'verbosity': 30
    }
    # initial ss to begin all simulations from
    y0 = np.array([5, 1, 1])
    # get and set true parameter values, if available separately
    default_parameters = true_parameter_values()

    # create simulation object to simulate model with above parameters and initial conditions
    model_1 = ModelSim(kotte_model.kotte_ck_ode,
                       kotte_model.kotte_ck_flux,
                       noise=noise,
                       **{
                           'kinetics': kinetics,
                           'ode_opts': user_ode_opts,
                           't_final': 200,
                           'wt_y0': y0,
                           'i_parameter': default_parameters,
                           'sample_size': number_samples,
                           'noise_std': noise_std
                       })
    # initial value determination for wt before perturbation
    wt_ss, wt_dynamic = model_1.run_initial_sim([default_parameters],
                                                ['default_parameters'])

    # all parameter perturbations
    parameter_perturbation = [{
        "wt": 0
    }, {
        "ac": 1
    }, {
        "ac": 4
    }, {
        "ac": 9
    }, {
        "ac": -.1
    }, {
        "ac": -.5
    }, {
        "k1cat": .1
    }, {
        "k1cat": .5
    }, {
        "k1cat": 1
    }, {
        "k1cat": -.1
    }, {
        "k1cat": -.5
    }, {
        "V3max": .1
    }, {
        "V3max": .5
    }, {
        "V3max": 1
    }, {
        "V3max": -.1
    }, {
        "V3max": -.5
    }, {
        "V2max": .1
    }, {
        "V2max": .5
    }, {
        "V2max": 1
    }, {
        "V2max": -.1
    }, {
        "V2max": -.5
    }]

    experiment_id = [
        'experiment_{}'.format(parameter_id)
        for parameter_id, _ in enumerate(parameter_perturbation)
    ]
    experiment_details = model_1.change_parameter_values(
        parameter_perturbation)

    # call model.simulate to get initial (WT) steady state for all parameter sets strating from same y0
    model_1.sim_model(parameter=experiment_details,
                      experiment_ids=experiment_id,
                      initial_value=[wt_ss[0]['y']])

    # create dictionary suitable for writing to df
    experiment_df, multi_index_labels = model_1.create_df(
        parameter_perturbation, experiment_details)

    # get experimental system steady state data without noise using Convenience Kinetics for v3 (kinetics = 2)
    # experiment_df, multi_index_labels, dyn_df, dyn_labels = generate_expdata(y0, cvode_options, ode_parameter_values,
    #                                                                          noise=noise, kinetics=kinetics,
    #                                                                          dynamic_plot=0, perturbation_plot=0,
    #                                                                          number_of_samples=number_samples, noise_std=noise_std)

    # save data frame to csv file
    experiment_df.to_csv(save_file_name, index_label=multi_index_labels)
    # dyn_df.to_csv(save_dyn_file_name, index_label=dyn_labels)
    print(' Experiment Data written to file \n')

    return experiment_df