Location: Reproducibility of the computational model of induced pluripotent stem-cell derived cardiomyocytes @ 430939c5c1b8 / Experiments / fig6-new.py

Author:
David Nickerson <david.nickerson@gmail.com>
Date:
2021-11-25 11:13:34+13:00
Desc:
making internal links in overview relative instead of absolute
Permanent Source URI:
https://staging.physiomeproject.org/workspace/702/rawfile/430939c5c1b887fcf0d899b0dd11370b77bf495f/Experiments/fig6-new.py

import os

import matplotlib
matplotlib.use('agg')

import numpy as np
import matplotlib.pyplot as plt

import opencor as opencor


# root = "C:/Nima/ABI/Physiome Journal/pluripotent stem cell/src/cellml/Channels/"


def load_sedml(filename):
    return opencor.open_simulation(filename)

def get_data(filename):
    data = filename.data()
    data.set_ending_point(10)
    data.set_point_interval(1)
    return data


def run_sim(data, filename, var1, var2):

    voltage = np.arange(-100, 101, 1)


    x1_list = [0.0478, 0.0591, 0.0591, 0.0544, 1.5665e-4, 3.9748e-4, 4.7856e-4, 3.4423e-4]
    x2_list = [15.1653, 9.9436, 9.9437, 11.6842, -11.3965, -21.8363, -19.6705, -17.6345]
    x5_list = [5.2098, 3.3789, 3.3788, 3.9892, 235.6863, 247.8116, 76.7837, 186.7605]
    x6_list = [-14.6505, -9.2454, -9.2455, -11.0471, 7.3083, 7.2455, 9.989, 8.1809]
    x7_list = [0.3680, 0.8611, 0.8611, 0.6968, 9.1434, 15.3766, 9.1533, 11.2245]
    key_ids = ["one", "two", "three", "four", "five", "six", "seven", "eight"]
    results1 = {}
    results2 = {}
    file = load_sedml(filename)
    for x1, x2, x5, x6, x7, index in zip(x1_list, x2_list, x5_list, x6_list, x7_list, key_ids):
        file.reset(True)
        file.clear_results()
        data.constants()["main/x1"] = x1
        data.constants()["main/x2"] = x2
        data.constants()["main/x5"] = x5
        data.constants()["main/x6"] = x6
        data.constants()["main/x7"] = x7
        results1[index] = []
        results2[index] = []
        for v in voltage:
            data.constants()["main/v"] = v
            file.run()
            ds = file.results().data_store()

            value1 = ds.voi_and_variables()["main/%s" % var1].values()[-1]
            value2 = ds.voi_and_variables()["main/%s" % var2].values()[-1]
            results1[index].append(value1)
            results2[index].append(value2)
    return results1, results2


if __name__ == '__main__':
    act_inact_file = "act_inact.sedml"
    # inact_file = "inact.sedml"

    act_inact = load_sedml(act_inact_file)
    # inact = load_sedml(inact_file)

    data1 = get_data(act_inact)
    # data2 = get_data(inact)

    #
    act_inact_list = run_sim(data1, act_inact_file, 'act_inact', 'tau')
    # inact_list = run_sim(data2, inact_file, 'inact', 'tau_h')
    #
    # tau_m_list = run_sim(data1, act_file, 'tau_m')
    # tau_h_list = run_sim(data2, inact_file, 'tau_h')



    voltage = np.arange(-100, 101, 1)

    plt.figure(figsize= (14,12))
    plt.subplot(2,2,1)
    plt.plot(voltage, act_inact_list[0]['one'], color='blue', label= 'Ma et al.',  linewidth= 4)
    plt.plot(voltage, act_inact_list[0]['five'], color='blue',  linewidth= 4)
    plt.plot(voltage, act_inact_list[0]['three'], color='green', label='Cordeiro et al.', linewidth=4)
    plt.plot(voltage, act_inact_list[0]['six'], color='green', linewidth=4)
    plt.plot(voltage, act_inact_list[0]['two'], color='orange', label= 'Veerman et al.',  linewidth= 4)
    plt.plot(voltage, act_inact_list[0]['seven'], color='orange',  linewidth= 4)
    plt.plot(voltage, act_inact_list[0]['four'], color='black', label= 'Baseline Model',  linewidth= 4)
    plt.plot(voltage, act_inact_list[0]['eight'], color='black',  linewidth= 4)



    plt.xlabel('Voltage (mV)', fontsize= 18)
    plt.ylabel('Normalized I$_{to}$', fontsize= 18)
    plt.tick_params(axis='both', labelsize='18')
    plt.xlim(-100,100,50)
    plt.ylim(0,1,0.5)
    plt.title('A', fontsize=18)
    plt.legend(fontsize= '16')

    plt.subplot(2,2,3)
    plt.plot(voltage, act_inact_list[1]['one'], color='blue', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['three'], color='orange', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['two'], color='green', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['four'], color='black', linewidth=4)

    #
    plt.xlabel('Voltage (mV)', fontsize= 18)
    plt.ylabel('Tau$_{act}$ (ms)', fontsize= 18)
    plt.tick_params(axis= 'both', labelsize= '18')
    plt.xlim(-100, 100, 50)
    plt.ylim(0, 6, 1)
    plt.title('C', fontsize= '18')


    #
    # #
    plt.subplot(2,2,4)
    plt.plot(voltage, act_inact_list[1]['five'], color='blue', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['seven'], color='orange', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['six'], color='green', linewidth=4)
    plt.plot(voltage, act_inact_list[1]['eight'], color='black', linewidth=4)


    plt.xlabel('Voltage (mV)', fontsize= 18)
    plt.ylabel('Tau$_{inact}$ (ms)', fontsize= 18)
    plt.tick_params(axis= 'both', labelsize= '18')
    plt.xlim(-100, 100, 50)
    plt.ylim(0, 300, 100)
    plt.title('D', fontsize=18)

    # plt.show()
    plt.savefig('Figure06.png')