Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -603,26 +603,29 @@ def analyze_sequence_comparison(file1, file2, fasta1="", fasta2=""):
|
|
603 |
frac_different = np.mean(substantial_diffs)
|
604 |
|
605 |
# Generate comparison text
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
""
|
|
|
|
|
|
|
626 |
|
627 |
# Create comparison heatmap
|
628 |
heatmap_fig = plot_comparative_heatmap(shap_diff)
|
@@ -636,7 +639,7 @@ Negative values (blue) indicate regions where Sequence 1 is more "human-like"
|
|
636 |
hist_img = fig_to_image(hist_fig)
|
637 |
|
638 |
return comparison_text, heatmap_img, hist_img
|
639 |
-
|
640 |
###############################################################################
|
641 |
# 9. BUILD GRADIO INTERFACE
|
642 |
###############################################################################
|
|
|
603 |
frac_different = np.mean(substantial_diffs)
|
604 |
|
605 |
# Generate comparison text
|
606 |
+
# Format the numbers without using f-string with `:,`
|
607 |
+
len1_formatted = "{:,}".format(len(shap1))
|
608 |
+
len2_formatted = "{:,}".format(len(shap2))
|
609 |
+
frac_formatted = "{:.2%}".format(frac_different)
|
610 |
+
|
611 |
+
comparison_text = (
|
612 |
+
f"Sequence Comparison Results:\n"
|
613 |
+
f"Sequence 1: {results1[4]}\n"
|
614 |
+
f"Length: {len1_formatted} bases\n"
|
615 |
+
f"Classification: {results1[0].split('Classification: ')[1].split('\\n')[0]}\n\n"
|
616 |
+
f"Sequence 2: {results2[4]}\n"
|
617 |
+
f"Length: {len2_formatted} bases\n"
|
618 |
+
f"Classification: {results2[0].split('Classification: ')[1].split('\\n')[0]}\n\n"
|
619 |
+
f"Comparison Statistics:\n"
|
620 |
+
f"Average SHAP difference: {avg_diff:.4f}\n"
|
621 |
+
f"Standard deviation: {std_diff:.4f}\n"
|
622 |
+
f"Max difference: {max_diff:.4f} (Seq2 more human-like)\n"
|
623 |
+
f"Min difference: {min_diff:.4f} (Seq1 more human-like)\n"
|
624 |
+
f"Fraction of positions with substantial differences: {frac_formatted}\n\n"
|
625 |
+
f"Interpretation:\n"
|
626 |
+
f"Positive values (red) indicate regions where Sequence 2 is more 'human-like'\n"
|
627 |
+
f"Negative values (blue) indicate regions where Sequence 1 is more 'human-like'"
|
628 |
+
)
|
629 |
|
630 |
# Create comparison heatmap
|
631 |
heatmap_fig = plot_comparative_heatmap(shap_diff)
|
|
|
639 |
hist_img = fig_to_image(hist_fig)
|
640 |
|
641 |
return comparison_text, heatmap_img, hist_img
|
642 |
+
|
643 |
###############################################################################
|
644 |
# 9. BUILD GRADIO INTERFACE
|
645 |
###############################################################################
|