This notebook provides a reproducible analysis for a model of the T cell inhibitor checkpoints.
It contains the following results:
Authors: Celine Hernandez, Aurélien Naldi
import ginsim
import biolqm
from colomoto_jupyter import tabulate
import pandas as pd
import numpy as np
# Load and view the model
gs_model = ginsim.load("Hernandez_TcellCheckPoints_13april2020.zginml")
lqm_model = ginsim.to_biolqm(gs_model)
ginsim.show(gs_model, save="figure_interaction_graph_model")
Here we define some helper functions and color mapping rules to perform value propagation and visualize the result.
# Transforms a dictionary into a dash-like pattern used for space restrictions.
# If a model has 4 components A, B, C, D in this order,
# {A:0, D:1} => "0--1"
def dash_pattern(model, dict_vals):
specific_comps = dict_vals.keys()
str_pattern = ""
for comp in model.getComponents():
if comp.toString() in specific_comps:
str_pattern += str(dict_vals.get(comp.toString()))
else :
str_pattern += "-"
return(str_pattern)
def restrict_model(model, **dict_vals):
pattern = dash_pattern(lqm_model, dict_vals)
return biolqm.restrict(lqm_model, pattern)
def fill_fixed(data, names, functions, mddman):
all_values = [f for f in functions]
for comp, func in zip(names, functions):
if mddman.isleaf(func): data[comp] = func
else: data[comp] = -1
def get_fixed_pattern(all_names, model, as_dict=False):
# Build a container for the results
pattern = {key: 100 for key in all_names}
# Model manager and core components
mddman = model.getMDDManager()
core_components = [node.getNodeID() for node in model.getComponents()]
extra_components = [node.getNodeID() for node in model.getExtraComponents()]
# 1/ Non-extra values: if the model was not reduced, core components may also contain fixed values
fill_fixed(pattern, core_components, model.getLogicalFunctions(), mddman)
# Special value for input components
for node in model.getComponents():
if node.isInput():
pattern[node.getNodeID()] = -2
# 2/ Extra values : only available after reduction/percolation
# Functions of each component
fill_fixed(pattern, extra_components, model.getExtraLogicalFunctions(), mddman)
if as_dict: return pattern
return pd.Series(pattern, dtype=np.byte).values.tobytes()
def compare_fixed_pattern(all_names, model1, model2, as_dict=False):
pattern1 = get_fixed_pattern(all_names, model1, as_dict=True)
pattern2 = get_fixed_pattern(all_names, model2, as_dict=True)
pattern = {}
for c in pattern1:
v1 = pattern1[c]
v2 = pattern2[c]
if v1 == v2: pattern[c] = v1
elif v1 < 0: pattern[c] = 10 + v2
elif v2 < 0: pattern[c] = 20 + v1
else: pattern[c] = 100
if as_dict: return pattern
return pd.Series(pattern, dtype=np.byte).values.tobytes()
def show_fixed_comparison(gs_model, restricted_model1, restricted_model2, styler, save=None):
name_components = [ n.getId() for n in gs_model.getNodeOrder() ]
pattern = compare_fixed_pattern(name_components, restricted_model1, restricted_model2)
styler.setState( pattern )
return ginsim.show(gs_model, style=styler, save=save)
def show_fixed(gs_model, restricted_model, styler, save=None):
name_components = [ n.getId() for n in gs_model.getNodeOrder() ]
fixed_pattern = get_fixed_pattern(name_components, restricted_model)
styler.setState(fixed_pattern)
return ginsim.show(gs_model, style=styler, save=save)
# Define color mapping rules
# Style for a single fixed pattern
styler_fixed = ginsim.lrg_style(gs_model)
styler_fixed.mapState2Color(0, 200, 25, 25)
styler_fixed.mapState2Color(1, 100, 175, 100)
styler_fixed.mapState2Color(2, 100, 225, 100)
styler_fixed.mapState2Color(-1, 255, 255, 255)
styler_fixed.mapState2Color(-2, 175, 175, 175)
# Style for comparing two patterns
styler_comp = ginsim.lrg_style(gs_model)
styler_comp.mapState2Color(-2, 175, 175, 175) # INPUT: gray
styler_comp.mapState2Color(0, 255, 255, 180) # OFF in both: light yellow
styler_comp.mapState2Color(1, 255, 180, 120) # ON in both: light orange
styler_comp.mapState2Color(2, 255, 180, 120) # HIGH in both: light orange
styler_comp.mapState2Color(-1, 255, 255, 255) # FREE in both: white
styler_comp.mapState2Color(10, 200, 255, 200) # OFF in the first: light green
styler_comp.mapState2Color(11, 125, 200, 125) # ON in the first: dark green
styler_comp.mapState2Color(20, 200, 200, 255) # OFF in the second: light green
styler_comp.mapState2Color(21, 125, 125, 200) # ON in the second: dark green
styler_comp.mapState2Color(100, 255, 180, 180) # Other (different values?): red
# Model simplification:
# * Fix all inputs to their inactive state.
fixed = { str(n):0 for n in lqm_model.getComponents() if n.isInput()}
# Keep 'i_pMHCII_binding', 'i_pMHCII_agonist', (not 'i_pMHCII_dose'), 'i_pMHCII_affinity', 'i_CD80' as proper inputs
for n in ('i_pMHCII_binding', 'i_pMHCII_agonist', 'i_pMHCII_affinity', 'i_CD80', 'i_CD274'):
del(fixed[n])
# Fix inputs to their active state
fixed['CTLA4'] = 0
# Apply the simplifications defined above to reduce the model
m_reduced = biolqm.perturbation(lqm_model, " ".join([ "%s%%%s" % (k,v) for (k,v) in fixed.items() ]))
m_reduced = biolqm.reduce(m_reduced, ":fixed :purge :no-extra")
# Define reporter components
reporter_components = ["TCRalphabeta", "CD28", "NFAT_nuc", "FOS", "JUN", "NF_KB", "IL2", "Proliferation", "DGKA", "Anergy", "Quiescence"]
fps = biolqm.fixpoints(m_reduced, autoconvert=False
).project_on_components( reporter_components )
df = biolqm.states_to_dataframe(fps)
df
TCRalphabeta | CD28 | Quiescence | Proliferation | NF_KB | NFAT_nuc | DGKA | Anergy | FOS | JUN | IL2 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
3 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
4 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
5 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
6 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
7 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 |
# Define reporter components
reporter_components = ["TCRalphabeta", "CD28", "NFAT_nuc", "FOS", "JUN", "NF_KB", "IL2", "Proliferation", "DGKA", "Anergy", "Quiescence"]
if False:
fps = biolqm.trapspaces(m_reduced, autoconvert=False
).project_on_components( reporter_components )
biolqm.states_to_dataframe(fps)
First we want to visualize fixed values on the model without any constraint. Fixed values will appear in white. This will be used as a reference to see if percolating a value will change anything from this default setting.
# Reduce fixed values
lqm_model_fixed_reduced = biolqm.reduce(lqm_model, ":fixed :purge")
show_fixed(gs_model, lqm_model_fixed_reduced, styler_fixed)
# Percolate a value of 0 for CTLA4
lqm_model_restricted_ctla4_0 = restrict_model(lqm_model, CTLA4=0)
show_fixed(gs_model, lqm_model_restricted_ctla4_0, styler_fixed)