Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,9 @@ import pandas as pd
|
|
6 |
import xlsxwriter
|
7 |
from io import BytesIO
|
8 |
from collections import Counter
|
9 |
-
import matplotlib.pyplot as plt
|
|
|
|
|
10 |
# π COMBINED STREAMLIT PROTEIN ANALYSIS TOOL WITH COLORED COMPARISON
|
11 |
|
12 |
import os
|
@@ -238,27 +240,28 @@ if app_choice == "π Protein Repeat Finder":
|
|
238 |
st.dataframe(result_df)
|
239 |
|
240 |
if st.checkbox("Repeat Cluster Visualization"):
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
262 |
|
263 |
|
264 |
elif app_choice == "π Protein Comparator":
|
|
|
6 |
import xlsxwriter
|
7 |
from io import BytesIO
|
8 |
from collections import Counter
|
9 |
+
import matplotlib.pyplot as plt
|
10 |
+
import seaborn as sns
|
11 |
+
# For pie chart
|
12 |
# π COMBINED STREAMLIT PROTEIN ANALYSIS TOOL WITH COLORED COMPARISON
|
13 |
|
14 |
import os
|
|
|
240 |
st.dataframe(result_df)
|
241 |
|
242 |
if st.checkbox("Repeat Cluster Visualization"):
|
243 |
+
repeat_counts = defaultdict(int)
|
244 |
+
for seq_data in st.session_state.all_sequences_data:
|
245 |
+
for _, _, freq_dict in seq_data:
|
246 |
+
for repeat, count in freq_dict.items():
|
247 |
+
repeat_counts[repeat] += count
|
248 |
+
|
249 |
+
if repeat_counts:
|
250 |
+
sorted_repeats = sorted(repeat_counts.items(), key=lambda x: x[1], reverse=True)
|
251 |
+
top_n = st.slider("Select number of top repeats to visualize", min_value=5, max_value=50, value=20)
|
252 |
+
top_repeats = sorted_repeats[:top_n]
|
253 |
+
repeats, counts = zip(*top_repeats)
|
254 |
+
|
255 |
+
plt.figure(figsize=(12, 6))
|
256 |
+
sns.barplot(x=list(repeats), y=list(counts), palette="viridis")
|
257 |
+
plt.xticks(rotation=45, ha='right')
|
258 |
+
plt.xlabel("Repeats")
|
259 |
+
plt.ylabel("Total Frequency")
|
260 |
+
plt.title("Top Repeat Clusters Across All Sequences")
|
261 |
+
st.pyplot(plt.gcf())
|
262 |
+
else:
|
263 |
+
st.warning("No repeat data available to visualize. Please upload files first.")
|
264 |
+
|
265 |
|
266 |
|
267 |
elif app_choice == "π Protein Comparator":
|