Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -594,29 +594,33 @@ def analyze_sequence_comparison(file1, file2, fasta1="", fasta2=""):
|
|
594 |
substantial_diffs = np.abs(shap_diff) > threshold
|
595 |
frac_different = np.mean(substantial_diffs)
|
596 |
|
597 |
-
#
|
598 |
-
|
|
|
|
|
|
|
599 |
len1_formatted = "{:,}".format(len(shap1))
|
600 |
len2_formatted = "{:,}".format(len(shap2))
|
601 |
frac_formatted = "{:.2%}".format(frac_different)
|
602 |
|
|
|
603 |
comparison_text = (
|
604 |
-
|
605 |
f"Sequence 1: {results1[4]}\n"
|
606 |
f"Length: {len1_formatted} bases\n"
|
607 |
-
f"Classification: {
|
608 |
f"Sequence 2: {results2[4]}\n"
|
609 |
f"Length: {len2_formatted} bases\n"
|
610 |
-
f"Classification: {
|
611 |
-
|
612 |
f"Average SHAP difference: {avg_diff:.4f}\n"
|
613 |
f"Standard deviation: {std_diff:.4f}\n"
|
614 |
f"Max difference: {max_diff:.4f} (Seq2 more human-like)\n"
|
615 |
f"Min difference: {min_diff:.4f} (Seq1 more human-like)\n"
|
616 |
f"Fraction of positions with substantial differences: {frac_formatted}\n\n"
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
)
|
621 |
|
622 |
# Create comparison heatmap
|
|
|
594 |
substantial_diffs = np.abs(shap_diff) > threshold
|
595 |
frac_different = np.mean(substantial_diffs)
|
596 |
|
597 |
+
# Extract classifications safely without using f-strings with backslashes
|
598 |
+
classification1 = results1[0].split('Classification: ')[1].split('\n')[0].strip()
|
599 |
+
classification2 = results2[0].split('Classification: ')[1].split('\n')[0].strip()
|
600 |
+
|
601 |
+
# Format numbers
|
602 |
len1_formatted = "{:,}".format(len(shap1))
|
603 |
len2_formatted = "{:,}".format(len(shap2))
|
604 |
frac_formatted = "{:.2%}".format(frac_different)
|
605 |
|
606 |
+
# Build comparison text without f-strings containing backslashes
|
607 |
comparison_text = (
|
608 |
+
"Sequence Comparison Results:\n"
|
609 |
f"Sequence 1: {results1[4]}\n"
|
610 |
f"Length: {len1_formatted} bases\n"
|
611 |
+
f"Classification: {classification1}\n\n"
|
612 |
f"Sequence 2: {results2[4]}\n"
|
613 |
f"Length: {len2_formatted} bases\n"
|
614 |
+
f"Classification: {classification2}\n\n"
|
615 |
+
"Comparison Statistics:\n"
|
616 |
f"Average SHAP difference: {avg_diff:.4f}\n"
|
617 |
f"Standard deviation: {std_diff:.4f}\n"
|
618 |
f"Max difference: {max_diff:.4f} (Seq2 more human-like)\n"
|
619 |
f"Min difference: {min_diff:.4f} (Seq1 more human-like)\n"
|
620 |
f"Fraction of positions with substantial differences: {frac_formatted}\n\n"
|
621 |
+
"Interpretation:\n"
|
622 |
+
"Positive values (red) indicate regions where Sequence 2 is more 'human-like'\n"
|
623 |
+
"Negative values (blue) indicate regions where Sequence 1 is more 'human-like'"
|
624 |
)
|
625 |
|
626 |
# Create comparison heatmap
|