Location: Model of Excitation-Contraction in a uterine SMC @ 77e3c05d5c08 / Simulation / src / Fig11_plot.py

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2021-07-19 18:24:55+12:00
Desc:
Output rho_vCa, and add input inhPump to inhibit J_Ca,pump for Fig2; Make K_Cahalf control para for Fig 7; Add Unit_uSMC.cellml to decouple Cai. Add Multi_stim, Vramp and Nai experiments; Add original figures and derived data; Add simulation and plot scripts
Permanent Source URI:
https://staging.physiomeproject.org/workspace/6bb/rawfile/77e3c05d5c087de8b306f4578136aebd2c365954/Simulation/src/Fig11_plot.py

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# The prefix of the saved output file name 
prefilenames = ['simFig11A','simFig11B']
ofilenames = ['fig11A', 'fig11B']
# Figure name
prefig = 'Fig11'
figfile = 'sim%s' % prefig
# Set figure dimension (width, height) in inches.
fw, fh = 6, 6
fig = plt.figure(figsize=(fw,fh))
ax, lns = {}, {}
# This gives list with the colors from the cycle, which you can use to iterate over.
cycle = plt.rcParams['axes.prop_cycle'].by_key()['color']
# Set subplots
lfontsize, labelfontsize = 12, 12 # legend, label fontsize
duration = [160]
# Read data from the files
t_ss =[20, 20]
x_name = ['time','time']
y_name = ["stress","Cai"]
y_labels = ['Stress (%)', '[Ca]$_i$ (nM)']
x_labels = ['Time (s)','Time (s)',]
Nai=[ 16.55]
# Set subplots
subpRow, subpCol = len(prefilenames)*2, 1

for h, plotN in enumerate(prefilenames):
         
    for i in range(2):
        ax[h*2+i] = fig.add_subplot(subpRow, subpCol, h*2+i+1)
        ofilename ='../originalData/%s%d.csv' % (ofilenames[h],i+1)
        odata = pd.read_csv(ofilename)
        ox_data = odata['x']   
        oy_data = odata['Curve1']    
        ax[h*2+i].plot(ox_data, oy_data, '.',  color=cycle[i], label = 'Bursztyn_et_al_uSMC') 
        
        filename='../simulatedData/%s.csv' % (prefilenames[h])
        data = pd.read_csv(filename)
        x_data = data[x_name[i]]-t_ss[i]
        if i ==0:
            y_data = data[y_name[i]]*100
        else:      
            y_data = data[y_name[i]]*1000000
            ax[h*2+i].set_xlabel (x_labels[i], fontsize= labelfontsize)

        ax[h*2+i].plot(x_data, y_data,  color=cycle[i], label = 'CellML')
        ax[h*2+i].set_ylabel (y_labels[i], fontsize= labelfontsize)
        
        if h+i == 0:
            ax[h*2+i].set_title('%s in the primary publication' % (prefig))
    
                
    plt.tick_params(direction='in', axis='both')    
    ax[h*2+i].legend(loc = 'best', fontsize=lfontsize, frameon=False)

figfiles = '../%s.png' % (figfile)
plt.savefig(figfiles)        
plt.show()