Update app.py
Browse files
app.py
CHANGED
@@ -21,13 +21,9 @@ def main():
|
|
21 |
# Input section in the sidebar
|
22 |
sequence = st.sidebar.text_input("Enter your amino acid sequence:")
|
23 |
uploaded_file = st.sidebar.file_uploader("Or upload a CSV file with amino acid sequences", type="csv")
|
24 |
-
|
25 |
-
# Button to analyze sequence
|
26 |
analyze_pressed = st.sidebar.button("Analyze Sequence")
|
27 |
-
|
28 |
-
# Show graphs toggle
|
29 |
show_graphs = st.sidebar.checkbox("Show Prediction Graphs")
|
30 |
-
|
31 |
sequences = [sequence] if sequence else []
|
32 |
if uploaded_file:
|
33 |
df = pd.read_csv(uploaded_file)
|
@@ -54,24 +50,26 @@ def main():
|
|
54 |
results_df = pd.DataFrame(results)
|
55 |
st.write("### Results")
|
56 |
st.dataframe(results_df.style.format(precision=3), width=None, height=None)
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
def plot_prediction_graphs(data):
|
63 |
-
# Function to plot graphs for predictions
|
64 |
for model_name in models.keys():
|
65 |
plt.figure(figsize=(10, 4))
|
66 |
-
predictions = {seq: values[model_name][
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
70 |
sns.barplot(x=sequences, y=conf_values, palette="viridis")
|
71 |
plt.title(f'Confidence Scores for {model_name.capitalize()} Model')
|
72 |
plt.xlabel('Sequences')
|
73 |
plt.ylabel('Confidence')
|
74 |
-
|
|
|
75 |
|
76 |
if __name__ == "__main__":
|
77 |
main()
|
|
|
21 |
# Input section in the sidebar
|
22 |
sequence = st.sidebar.text_input("Enter your amino acid sequence:")
|
23 |
uploaded_file = st.sidebar.file_uploader("Or upload a CSV file with amino acid sequences", type="csv")
|
|
|
|
|
24 |
analyze_pressed = st.sidebar.button("Analyze Sequence")
|
|
|
|
|
25 |
show_graphs = st.sidebar.checkbox("Show Prediction Graphs")
|
26 |
+
|
27 |
sequences = [sequence] if sequence else []
|
28 |
if uploaded_file:
|
29 |
df = pd.read_csv(uploaded_file)
|
|
|
50 |
results_df = pd.DataFrame(results)
|
51 |
st.write("### Results")
|
52 |
st.dataframe(results_df.style.format(precision=3), width=None, height=None)
|
53 |
+
|
54 |
+
if show_graphs and all_data:
|
55 |
+
st.write("## Graphs")
|
56 |
+
plot_prediction_graphs(all_data)
|
57 |
|
58 |
def plot_prediction_graphs(data):
|
59 |
+
# Function to plot graphs for predictions
|
60 |
for model_name in models.keys():
|
61 |
plt.figure(figsize=(10, 4))
|
62 |
+
predictions = {seq: values[model_name][1] for seq, values in data.items()} # Using confidence for ordering
|
63 |
+
# Sorting sequences based on confidence, descending
|
64 |
+
sorted_sequences = sorted(predictions.items(), key=lambda x: x[1], reverse=True)
|
65 |
+
sequences = [x[0] for x in sorted_sequences]
|
66 |
+
conf_values = [x[1] for x in sorted_sequences]
|
67 |
sns.barplot(x=sequences, y=conf_values, palette="viridis")
|
68 |
plt.title(f'Confidence Scores for {model_name.capitalize()} Model')
|
69 |
plt.xlabel('Sequences')
|
70 |
plt.ylabel('Confidence')
|
71 |
+
plt.xticks(rotation=45) # Rotate x labels for better visibility
|
72 |
+
st.pyplot(plt) # Display each plot below the results table
|
73 |
|
74 |
if __name__ == "__main__":
|
75 |
main()
|