@@ -55,7 +55,13 @@ def create_plot(ax, x_data: list, y_data: list, auc: float, type: str, color) ->
5555def main ():
5656 print ("Generating figures" )
5757 species_list = ["elegans" , "fly" , "bsub" , "yeast" , "zfish" ]
58- species_title = ["C. elegans" , "D. melanogaster" , "B. subtilis" , "S. cerevisiae" , "D. rerio" ]
58+ species_title = [
59+ "C. elegans" ,
60+ "D. melanogaster" ,
61+ "B. subtilis" ,
62+ "S. cerevisiae" ,
63+ "D. rerio" ,
64+ ]
5965
6066 file_directories = [
6167 "./results/final-non-inferred-complete/" ,
@@ -111,13 +117,13 @@ def main():
111117 "precision" : precision_list ,
112118 "recall" : recall_list ,
113119 "pr" : pr_auc_list ,
114- "method" : ["Overlapping " , "Hypergeometric" , "Degree" , "RW" ],
120+ "method" : ["One-Hop GO Overlap " , "Hypergeometric" , "Degree" , "RW" ],
115121 }
116122 final_category_data [species ].append (species_data )
117123
118124 # Create a figure with 2 subplots (one for each species)
119125 fig , axes = plt .subplots (
120- 2 , 3 , figsize = (18 , 10 )
126+ 2 , 3 , figsize = (17 , 12 )
121127 ) # Create a 2x3 grid of subplots
122128 axes = axes .flatten ()
123129 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -137,19 +143,22 @@ def main():
137143
138144 ax .set_xlim ([0.0 , 1.0 ])
139145 ax .set_ylim ([0.0 , 1.05 ])
140- ax .set_xlabel ("False Positive Rate" )
141- ax .set_ylabel ("True Positive Rate" )
142- ax .set_title (f"{ species_title [idx ].capitalize ()} " )
143- ax .legend (loc = "lower right" )
146+ ax .set_xlabel ("False Positive Rate" , fontsize = 14 )
147+ ax .set_ylabel ("True Positive Rate" , fontsize = 14 )
148+ ax .set_title (f"$ { species_title [idx ].capitalize ()} $" , fontsize = 14 )
149+ ax .legend (loc = "lower right" , fontsize = 12 )
144150
145151 axes [5 ].set_visible (False )
146152 fig .suptitle ("ROC Curve for All Species w/ " + subplot_titles [k ], fontsize = 20 )
147- plt .savefig (Path ("./results/images/" , f"roc_{ subplot_titles [k ].lower ().replace (" " , "_" )} " ))
148- plt .tight_layout ()
153+ # Adjust layout to prevent overlap
154+ plt .tight_layout () # Adjust rect to accommodate legends
155+ # Adjust the space between subplots
156+ plt .subplots_adjust (wspace = 0.2 )
157+ plt .savefig (Path ("./results/images/" , f"roc_{ subplot_titles [k ].lower ().replace (" " , "_" )} .pdf" ), format = "pdf" )
149158 plt .show ()
150159
151160 fig , axes = plt .subplots (
152- 2 , 3 , figsize = (18 , 10 )
161+ 2 , 3 , figsize = (17 , 12 )
153162 ) # Create a 2x3 grid of subplots
154163 axes = axes .flatten ()
155164 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -169,18 +178,21 @@ def main():
169178
170179 ax .set_xlim ([0.0 , 1.0 ])
171180 ax .set_ylim ([0.0 , 1.05 ])
172- ax .set_xlabel ("Recall" )
173- ax .set_ylabel ("Precision" )
174- ax .set_title (f"{ species_title [idx ].capitalize ()} " )
175- ax .legend (loc = "lower right" )
181+ ax .set_xlabel ("Recall" , fontsize = 14 )
182+ ax .set_ylabel ("Precision" , fontsize = 14 )
183+ ax .set_title (f"$ { species_title [idx ].capitalize ()} $" , fontsize = 14 )
184+ ax .legend (loc = "lower right" , fontsize = 12 )
176185
177186 axes [5 ].set_visible (False )
178187 fig .suptitle (
179188 "Precision/Recall Curve for All Species w/ " + subplot_titles [k ],
180189 fontsize = 20 ,
181190 )
182- plt .tight_layout ()
183- plt .savefig (Path ("./results/images/" , f"pr_{ subplot_titles [k ].lower ().replace (" " , "_" )} " ))
191+ # Adjust layout to prevent overlap
192+ plt .tight_layout () # Adjust rect to accommodate legends
193+ # Adjust the space between subplots
194+ plt .subplots_adjust (wspace = 0.2 )
195+ plt .savefig (Path ("./results/images/" , f"pr_{ subplot_titles [k ].lower ().replace (" " , "_" )} .pdf" ), format = "pdf" )
184196 plt .show ()
185197 k += 1
186198
@@ -222,7 +234,7 @@ def main():
222234 final_rw_data [species ].append (species_data )
223235
224236 # Create a 2x2 subplot layout
225- fig , axs = plt .subplots (2 , 2 , figsize = (10 , 10 )) # 2 rows, 2 columns
237+ fig , axs = plt .subplots (1 , 4 , figsize = (40 , 12 )) # 2 rows, 2 columns
226238 axs = axs .flatten () # Flatten to easily index the subplots
227239
228240 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -236,26 +248,28 @@ def main():
236248 final_rw_data [species ][idx ]["tpr" ],
237249 color = colors [i ],
238250 lw = 2 ,
239- label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][0 ]["roc" ],
251+ label = f"${ species_title [i ]} $ (area = %0.2f)"
252+ % final_rw_data [species ][idx ]["roc" ],
240253 )
241254
242255 ax .set_xlim ([0.0 , 1.0 ])
243256 ax .set_ylim ([0.0 , 1.05 ])
244- ax .set_xlabel ("False Positive Rate" )
245- ax .set_ylabel ("True Positive Rate" )
246- ax .set_title (f"{ subplot_titles [idx ]} " )
247- ax .legend (loc = "lower right" )
257+ ax .set_xlabel ("False Positive Rate" , fontsize = 30 )
258+ ax .set_ylabel ("True Positive Rate" , fontsize = 30 )
259+ ax .set_title (f"{ subplot_titles [idx ]} " , fontsize = 30 )
260+ ax .legend (loc = "lower right" , fontsize = 30 )
261+ ax .tick_params (axis = "both" , which = "major" , labelsize = 20 )
248262
249263 # Adjust layout and show the plot
250264 fig .suptitle (
251265 "ROC Curve for RandomWalk Configuration" ,
252- fontsize = 20 ,
266+ fontsize = 45 ,
253267 )
254- plt .savefig (Path ("./results/images/rw_roc.png" ))
255268 plt .tight_layout ()
269+ plt .savefig (Path ("./results/images/rw_roc.pdf" ), format = "pdf" )
256270 plt .show ()
257271
258- fig , axs = plt .subplots (2 , 2 , figsize = (10 , 10 )) # 2 rows, 2 columns
272+ fig , axs = plt .subplots (1 , 4 , figsize = (40 , 12 )) # 2 rows, 2 columns
259273 axs = axs .flatten () # Flatten to easily index the subplots
260274
261275 colors = ["red" , "green" , "blue" , "orange" , "purple" ]
@@ -269,23 +283,25 @@ def main():
269283 final_rw_data [species ][idx ]["precision" ],
270284 color = colors [i ],
271285 lw = 2 ,
272- label = f"{ species_title [i ]} (area = %0.2f)" % final_rw_data [species ][0 ]["pr" ],
286+ label = f"${ species_title [i ]} $ (area = %0.2f)"
287+ % final_rw_data [species ][idx ]["pr" ],
273288 )
274289
275290 ax .set_xlim ([0.0 , 1.0 ])
276291 ax .set_ylim ([0.0 , 1.05 ])
277- ax .set_xlabel ("Recall" )
278- ax .set_ylabel ("Precision" )
279- ax .set_title (f"{ subplot_titles [idx ]} " )
280- ax .legend (loc = "lower right" )
292+ ax .set_xlabel ("Recall" , fontsize = 30 )
293+ ax .set_ylabel ("Precision" , fontsize = 30 )
294+ ax .set_title (f"{ subplot_titles [idx ]} " , fontsize = 30 )
295+ ax .legend (loc = "lower right" , fontsize = 30 )
296+ ax .tick_params (axis = "both" , which = "major" , labelsize = 20 )
281297
282298 # Adjust layout and show the plot
283299 fig .suptitle (
284300 "Precision/Recall Curve for RandomWalk Configuration" ,
285- fontsize = 20 ,
301+ fontsize = 45 ,
286302 )
287- plt .savefig (Path ("./results/images/rw_pr.png" ))
288303 plt .tight_layout ()
304+ plt .savefig (Path ("./results/images/rw_pr.pdf" ), format = "pdf" )
289305 plt .show ()
290306
291307
0 commit comments