diff --git a/generate_figures.py b/generate_figures.py index ad2f188..32f96c0 100644 --- a/generate_figures.py +++ b/generate_figures.py @@ -55,7 +55,13 @@ def create_plot(ax, x_data: list, y_data: list, auc: float, type: str, color) -> def main(): print("Generating figures") species_list = ["elegans", "fly", "bsub", "yeast", "zfish"] - species_title = ["C. elegans", "D. melanogaster", "B. subtilis", "S. cerevisiae", "D. rerio"] + species_title = [ + "C. elegans", + "D. melanogaster", + "B. subtilis", + "S. cerevisiae", + "D. rerio", + ] file_directories = [ "./results/final-non-inferred-complete/", @@ -111,13 +117,13 @@ def main(): "precision": precision_list, "recall": recall_list, "pr": pr_auc_list, - "method": ["Overlapping", "Hypergeometric", "Degree", "RW"], + "method": ["One-Hop GO Overlap", "Hypergeometric", "Degree", "RW"], } final_category_data[species].append(species_data) # Create a figure with 2 subplots (one for each species) fig, axes = plt.subplots( - 2, 3, figsize=(18, 10) + 2, 3, figsize=(17, 12) ) # Create a 2x3 grid of subplots axes = axes.flatten() colors = ["red", "green", "blue", "orange", "purple"] @@ -137,19 +143,22 @@ def main(): ax.set_xlim([0.0, 1.0]) ax.set_ylim([0.0, 1.05]) - ax.set_xlabel("False Positive Rate") - ax.set_ylabel("True Positive Rate") - ax.set_title(f"{species_title[idx].capitalize()}") - ax.legend(loc="lower right") + ax.set_xlabel("False Positive Rate" , fontsize=14) + ax.set_ylabel("True Positive Rate" , fontsize=14 ) + ax.set_title(f"${species_title[idx].capitalize()}$", fontsize=14) + ax.legend(loc="lower right", fontsize=12 ) axes[5].set_visible(False) fig.suptitle("ROC Curve for All Species w/ " + subplot_titles[k], fontsize=20) - plt.savefig(Path("./results/images/", f"roc_{subplot_titles[k].lower().replace(" ", "_")}")) - plt.tight_layout() + # Adjust layout to prevent overlap + plt.tight_layout() # Adjust rect to accommodate legends + # Adjust the space between subplots + plt.subplots_adjust(wspace=0.2) + plt.savefig(Path("./results/images/", f"roc_{subplot_titles[k].lower().replace(" ", "_")}.pdf"), format="pdf") plt.show() fig, axes = plt.subplots( - 2, 3, figsize=(18, 10) + 2, 3, figsize=(17, 12) ) # Create a 2x3 grid of subplots axes = axes.flatten() colors = ["red", "green", "blue", "orange", "purple"] @@ -169,18 +178,21 @@ def main(): ax.set_xlim([0.0, 1.0]) ax.set_ylim([0.0, 1.05]) - ax.set_xlabel("Recall") - ax.set_ylabel("Precision") - ax.set_title(f"{species_title[idx].capitalize()}") - ax.legend(loc="lower right") + ax.set_xlabel("Recall" , fontsize=14) + ax.set_ylabel("Precision", fontsize=14) + ax.set_title(f"${species_title[idx].capitalize()}$", fontsize=14) + ax.legend(loc="lower right", fontsize=12 ) axes[5].set_visible(False) fig.suptitle( "Precision/Recall Curve for All Species w/ " + subplot_titles[k], fontsize=20, ) - plt.tight_layout() - plt.savefig(Path("./results/images/", f"pr_{subplot_titles[k].lower().replace(" ", "_")}")) + # Adjust layout to prevent overlap + plt.tight_layout() # Adjust rect to accommodate legends + # Adjust the space between subplots + plt.subplots_adjust(wspace=0.2) + plt.savefig(Path("./results/images/", f"pr_{subplot_titles[k].lower().replace(" ", "_")}.pdf"), format="pdf") plt.show() k += 1 @@ -222,7 +234,7 @@ def main(): final_rw_data[species].append(species_data) # Create a 2x2 subplot layout - fig, axs = plt.subplots(2, 2, figsize=(10, 10)) # 2 rows, 2 columns + fig, axs = plt.subplots(1, 4, figsize=(40, 12)) # 2 rows, 2 columns axs = axs.flatten() # Flatten to easily index the subplots colors = ["red", "green", "blue", "orange", "purple"] @@ -236,26 +248,28 @@ def main(): final_rw_data[species][idx]["tpr"], color=colors[i], lw=2, - label=f"{species_title[i]} (area = %0.2f)" % final_rw_data[species][0]["roc"], + label=f"${species_title[i]}$ (area = %0.2f)" + % final_rw_data[species][idx]["roc"], ) ax.set_xlim([0.0, 1.0]) ax.set_ylim([0.0, 1.05]) - ax.set_xlabel("False Positive Rate") - ax.set_ylabel("True Positive Rate") - ax.set_title(f"{subplot_titles[idx]}") - ax.legend(loc="lower right") + ax.set_xlabel("False Positive Rate", fontsize=30) + ax.set_ylabel("True Positive Rate", fontsize=30) + ax.set_title(f"{subplot_titles[idx]}", fontsize=30) + ax.legend(loc="lower right", fontsize=30) + ax.tick_params(axis="both", which="major", labelsize=20) # Adjust layout and show the plot fig.suptitle( "ROC Curve for RandomWalk Configuration", - fontsize=20, + fontsize=45, ) - plt.savefig(Path("./results/images/rw_roc.png")) plt.tight_layout() + plt.savefig(Path("./results/images/rw_roc.pdf"), format="pdf") plt.show() - fig, axs = plt.subplots(2, 2, figsize=(10, 10)) # 2 rows, 2 columns + fig, axs = plt.subplots(1, 4, figsize=(40, 12)) # 2 rows, 2 columns axs = axs.flatten() # Flatten to easily index the subplots colors = ["red", "green", "blue", "orange", "purple"] @@ -269,23 +283,25 @@ def main(): final_rw_data[species][idx]["precision"], color=colors[i], lw=2, - label=f"{species_title[i]} (area = %0.2f)" % final_rw_data[species][0]["pr"], + label=f"${species_title[i]}$ (area = %0.2f)" + % final_rw_data[species][idx]["pr"], ) ax.set_xlim([0.0, 1.0]) ax.set_ylim([0.0, 1.05]) - ax.set_xlabel("Recall") - ax.set_ylabel("Precision") - ax.set_title(f"{subplot_titles[idx]}") - ax.legend(loc="lower right") + ax.set_xlabel("Recall", fontsize=30) + ax.set_ylabel("Precision", fontsize=30) + ax.set_title(f"{subplot_titles[idx]}", fontsize=30) + ax.legend(loc="lower right", fontsize=30) + ax.tick_params(axis="both", which="major", labelsize=20) # Adjust layout and show the plot fig.suptitle( "Precision/Recall Curve for RandomWalk Configuration", - fontsize=20, + fontsize=45, ) - plt.savefig(Path("./results/images/rw_pr.png")) plt.tight_layout() + plt.savefig(Path("./results/images/rw_pr.pdf"), format="pdf") plt.show() diff --git a/results/images/pr_complete_inferred_networks.pdf b/results/images/pr_complete_inferred_networks.pdf new file mode 100644 index 0000000..dd335b6 Binary files /dev/null and b/results/images/pr_complete_inferred_networks.pdf differ diff --git a/results/images/pr_complete_inferred_networks.png b/results/images/pr_complete_inferred_networks.png deleted file mode 100644 index 0d4c1d6..0000000 Binary files a/results/images/pr_complete_inferred_networks.png and /dev/null differ diff --git a/results/images/pr_complete_non_inferred_networks.pdf b/results/images/pr_complete_non_inferred_networks.pdf new file mode 100644 index 0000000..7fd16af Binary files /dev/null and b/results/images/pr_complete_non_inferred_networks.pdf differ diff --git a/results/images/pr_complete_non_inferred_networks.png b/results/images/pr_complete_non_inferred_networks.png deleted file mode 100644 index 44cae7d..0000000 Binary files a/results/images/pr_complete_non_inferred_networks.png and /dev/null differ diff --git a/results/images/roc_complete_inferred_networks.pdf b/results/images/roc_complete_inferred_networks.pdf new file mode 100644 index 0000000..1c0f89c Binary files /dev/null and b/results/images/roc_complete_inferred_networks.pdf differ diff --git a/results/images/roc_complete_inferred_networks.png b/results/images/roc_complete_inferred_networks.png deleted file mode 100644 index 0796f62..0000000 Binary files a/results/images/roc_complete_inferred_networks.png and /dev/null differ diff --git a/results/images/roc_complete_non_inferred_networks.pdf b/results/images/roc_complete_non_inferred_networks.pdf new file mode 100644 index 0000000..3b91091 Binary files /dev/null and b/results/images/roc_complete_non_inferred_networks.pdf differ diff --git a/results/images/roc_complete_non_inferred_networks.png b/results/images/roc_complete_non_inferred_networks.png deleted file mode 100644 index 70aecb7..0000000 Binary files a/results/images/roc_complete_non_inferred_networks.png and /dev/null differ diff --git a/results/images/rw_pr.pdf b/results/images/rw_pr.pdf new file mode 100644 index 0000000..92b1b82 Binary files /dev/null and b/results/images/rw_pr.pdf differ diff --git a/results/images/rw_pr.png b/results/images/rw_pr.png deleted file mode 100644 index 7153f32..0000000 Binary files a/results/images/rw_pr.png and /dev/null differ diff --git a/results/images/rw_roc.pdf b/results/images/rw_roc.pdf new file mode 100644 index 0000000..b47adcc Binary files /dev/null and b/results/images/rw_roc.pdf differ diff --git a/results/images/rw_roc.png b/results/images/rw_roc.png deleted file mode 100644 index be43fa3..0000000 Binary files a/results/images/rw_roc.png and /dev/null differ