IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
Simple_spatiotemporal_example.py
1# Example of model without temporal scoring -----------------------------------------------------------------
2
3# import relevant modules
4import pandas
5import IMP.spatiotemporal as spatiotemporal
6import os
7
8# Input variables.
9# dict is a the state dictionary, which returns the number of states at each time point, for each time point.
10# Input is the directory where the data is stored.
11# Output is the directory to which the output will be written
12dict={'0min':2,'5min':3,'10min':2}
13input=spatiotemporal.get_example_path('toy/data')
14output=spatiotemporal.get_example_path('toy/output_notemp')
15
16# create DAG
17# Set draw_dag to True if you want to write out the DAG to a file.
18# This requires that you have the 'graphviz' Python package installed.
19draw_dag = False
20nodes,graph,graph_prob,graph_scores=spatiotemporal.create_DAG(dict,input_dir=input,output_dir=output,draw_dag=draw_dag)
21
22# Example of model with temporal scoring -----------------------------------------------------------------
23
24# Input variables.
25dict={'0min':2,'5min':3,'10min':2}
26input=spatiotemporal.get_example_path('toy/data')
27output=spatiotemporal.get_example_path('toy/output_temp')
28# expected_subcomplexes is a list of all possible subcomplex strings in the model. Should match the configuration files
29subcomplexes=['A1','A2','B1','B2']
30
31nodes,graph,graph_prob,graph_scores=spatiotemporal.create_DAG(dict,input_dir=input,output_dir=output,spatio_temporal_rule=True,expected_subcomplexes=subcomplexes,draw_dag=draw_dag)
32
33# Example with stoichiometeric data -------------------------------------------------------------------------
34
35# Input variables.
36dict={'0min':2,'5min':3,'10min':2}
37input=spatiotemporal.get_example_path('toy/data')
38output=spatiotemporal.get_example_path('toy/output_stoich')
39subcomplexes=['A1','A2','B1','B2']
40# exp_comp_map is a dictionary that describes protein stoicheometery. The key describes the protein, which should correspond to names within the expected_subcomplexes. For each of these proteins, a csv file should be provided with protein copy number data
41exp_comp={'A':'exp_comp_A.csv','B':'exp_comp_B.csv'}
42
43
44nodes,graph,graph_prob,graph_scores=spatiotemporal.create_DAG(dict,input_dir=input,output_dir=output,spatio_temporal_rule=True,expected_subcomplexes=subcomplexes,score_comp=True,exp_comp_map=exp_comp,draw_dag=draw_dag)
45
46# Example of how model precision depends on the input data ---------------------------------------------------
47
48# Input variables.
49dict={'0min':2,'5min':3,'10min':2}
50input=spatiotemporal.get_example_path('toy/data_precise')
51output=spatiotemporal.get_example_path('toy/output_stoich_precise')
52subcomplexes=['A1','A2','B1','B2']
53exp_comp={'A':'exp_comp_A_precise.csv','B':'exp_comp_B_precise.csv'}
54
55
56nodes,graph,graph_prob,graph_scores=spatiotemporal.create_DAG(dict,out_pdf=True,npaths=2,input_dir=input,output_dir=output,spatio_temporal_rule=True,expected_subcomplexes=subcomplexes,score_comp=True,exp_comp_map=exp_comp,draw_dag=draw_dag)
Spatialtemporal scoring in IMP.