Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 48 additions & 32 deletions generate_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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"]
Expand All @@ -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"]
Expand All @@ -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

Expand Down Expand Up @@ -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"]
Expand All @@ -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"]
Expand All @@ -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()


Expand Down
Binary file added results/images/pr_complete_inferred_networks.pdf
Binary file not shown.
Binary file removed results/images/pr_complete_inferred_networks.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added results/images/roc_complete_inferred_networks.pdf
Binary file not shown.
Binary file removed results/images/roc_complete_inferred_networks.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added results/images/rw_pr.pdf
Binary file not shown.
Binary file removed results/images/rw_pr.png
Binary file not shown.
Binary file added results/images/rw_roc.pdf
Binary file not shown.
Binary file removed results/images/rw_roc.png
Binary file not shown.
Loading