import pandas as pd
import plotnine as p9
import numpy as np
from scipy.integrate import odeint
from plotnine import ggplot, aes, geom_point, geom_line, facet_wrap
p9.theme_set(p9.theme_bw())
def dict_to_tuple(x):
return tuple(x.values())
Elena’s paper
Elena’s paper
Started to play with Elena’s paper: Link to the paper
def get_p_and_y0(df, d = 1, i = 1):
= df.iloc[i].to_dict()
pp = {key: pp[key] for key in ['Pz', 'Pyx', 'Pxy', 'TKI', 'Kz', 'Ky', 'Py', 'm', 'rz', 'a']}
p 'd'] = d
p[= {key: pp[key] for key in ['X(0)', 'Y(0)', 'Z(0)']}
y_0 return p, y_0
= pd.read_csv('ParameterSets.csv')
params_df
= get_p_and_y0(params_df, 1)
p, y0 params_df
FileNotFoundError: [Errno 2] No such file or directory: 'ParameterSets.csv'
def cml_model(y, t, Pz, Pyx, Pxy, TKI, Kz, Ky, Py, m, rz, a, d):
= y
X, Y, Z = Pyx * Y - Pxy * X
dX = Pxy * X - Pyx * Y + Py * (1 - Y / Ky) * Y - m * Z * Y - d * TKI * Y
dY = rz + Z * Pz * (Y / (Kz ** 2 + Y ** 2)) - a * Z
dZ return (dX, dY, dZ)
= tuple(range(0, len(params_df) - 1))
ii = tuple(range(0, 9)) ii
= np.arange(0.0, 100, 0.01)
t = []
result_list
for i in ii:
= get_p_and_y0(params_df, i = i)
p, y0 = odeint(cml_model,
result
dict_to_tuple(y0),
t,=dict_to_tuple(p))
args= pd.DataFrame(result, columns = ['X', 'Y', 'Z'])
df = df.assign(t = t)
df 'PatID'] = i
df[
result_list.append(df)
= pd.concat(result_list, ignore_index=True)
result 'PatID'] = result['PatID'].astype('category') result[
= pd.melt(result,
result_long = ['t', 'PatID'],
id_vars = ['X', 'Y', 'Z'],
value_vars = 'cell_count')
value_name
('t', 'cell_count', color = 'variable')) +
ggplot(result_long, aes(+
geom_line() 'PatID')+ p9.scale_y_continuous(trans='log10') +
facet_wrap(=(12,9)) +
p9.theme(figure_size='Cell count', color = 'Compartment')
p9.labs(y
)
('t', 'Y', color = 'PatID')) +
ggplot(result, aes(+ p9.scale_y_continuous(trans='log10')
geom_line() )
def LRATIO(Y, KY=1e6):
return Y / (Y + 2 * (KY - Y))
'LRATIO'] = LRATIO(result["Y"])
result[
('t', 'LRATIO', color='PatID')) +
ggplot(result, aes(+ p9.scale_y_continuous(trans='log10',
geom_line() =(1, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6),
breaks=('MR0 (100%)', 'MR1 (10%)', 'MR2 (1%)', 'MR3 (0.1%)', 'MR4 (0.01%)', 'MR5 (0.001%)', 'MR6 (0.0001)')) +
labels=(10, 7))
p9.theme(figure_size )