1+ '''Creates the plots used in the paper.'''
2+
3+ from src .biomodels_iterator import BiomodelsIterator
4+ import src .constants as cn
5+ from src .model import Model
6+ from src .score import Score
7+ from src .simulator import Simulator
8+ from src .system_discovery import SystemDiscovery , discoverNetwork
9+ from src .timecourse import Timecourse
10+ from src .timecourse_iterator import TimecourseIterator
11+
12+ IS_PLOT = False
13+
14+ import constants as cn
15+ if not IS_PLOT :
16+ import matplotlib # type: ignore
17+ matplotlib .use ("PDF" ) # Use non-interactive backend for testing
18+ import matplotlib .pyplot as plt # type: ignore
19+ import numpy as np # type: ignore
20+ import os
21+ import pandas as pd # type: ignore
22+ from typing import Optional
23+
24+ NUM_POINT = 1000
25+
26+ ############### Helper Functions####################
27+
28+ def doPlot (model_num : int , poly_degree = 1 , threshold = 0.001 , species_names : Optional [list [str ]] = None ,
29+ num_point :int = NUM_POINT ):
30+ start_time = 0
31+ model = Model .makeBiomodel (model_num = model_num )
32+ timecourse = Timecourse (model , start_time = start_time , num_point = num_point )
33+ sdr = discoverNetwork (timecourse .timecourse_df , poly_degree = poly_degree , threshold = threshold ,
34+ plot_species_names = species_names , is_plot = IS_PLOT , subtitle = f"BioModel { model_num } " ,
35+ is_plot_heatmap = False , is_print_equations = False , is_plot_comparisons = True , is_print_accuracy = False )
36+ return sdr
37+
38+ ################################################
39+ # Linear Fits
40+ ################################################
41+ ############### Time course ####################
42+ sdr = doPlot (968 , species_names = ["SOCS1" , "IL7IL7RJAK1" ])
43+ sdr .fig .savefig (os .path .join (cn .PAPER_DIR , "linear_fit_968.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
44+ ##
45+ sdr = doPlot (1004 , species_names = ["IL6ext" , "STAT3mRNA" ])
46+ sdr .fig .savefig (os .path .join (cn .PAPER_DIR , "linear_fit_1004.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
47+ #
48+ ############### CDFs ####################
49+ path = os .path .join (cn .DATA_DIR , "linear_predictor_scores-0.001.csv" )
50+ score = Score .deserialize (path )
51+ fig = score .plotCDF (["min" , "p10" , "p50" , "max" ], xlabel = "model accuracy" , is_plot_species = False ,
52+ is_plot_model = True , title = f"BioModel Models" ).fig
53+ if IS_PLOT :
54+ plt .show ()
55+ fig .savefig (os .path .join (cn .PAPER_DIR , "linear_fit_model_cdf.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
56+ #
57+ fig = score .plotCDF (["min" , "p10" , "p50" , "max" ], xlabel = "model accuracy" , is_plot_species = True ,
58+ is_plot_model = False , title = f"BioModel Species" ).fig
59+ fig .savefig (os .path .join (cn .PAPER_DIR , "linear_fit_species_cdf.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
60+ if IS_PLOT :
61+ plt .show ()
62+
63+ ################################################
64+ # Perturbations
65+ ################################################
66+ ############### Time course ####################
67+ apr = SystemDiscovery .analyzePerturbations (1004 , perturbations = [- 50 , - 10 , 0 , 10 , 50 ], frac_scatter_skip = 0.05 ,
68+ subtitle = "BioModel 1004" , plot_species_names = ["IL6ext" ,"IL6int" ])
69+ apr .fig .savefig (os .path .join (cn .PAPER_DIR , "perturbation_fit_1004.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
70+ #
71+ apr = SystemDiscovery .analyzePerturbations (968 , perturbations = [- 50 , - 10 , 0 , 10 , 50 ], frac_scatter_skip = 0.05 ,
72+ subtitle = f"BioModel 968" , plot_species_names = ["SOCS1" , "IL7IL7RJAK1" ])
73+ apr .fig .savefig (os .path .join (cn .PAPER_DIR , "perturbation_fit_968.pdf" ), bbox_inches = "tight" , dpi = 300 ) # type: ignore
0 commit comments