Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -236,6 +236,30 @@ if app_choice == "π Protein Repeat Finder":
|
|
| 236 |
rows.append(row)
|
| 237 |
result_df = pd.DataFrame(rows)
|
| 238 |
st.dataframe(result_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
elif app_choice == "π Protein Comparator":
|
| 241 |
st.write("Upload two Excel files with protein data to compare repeat frequencies.")
|
|
|
|
| 236 |
rows.append(row)
|
| 237 |
result_df = pd.DataFrame(rows)
|
| 238 |
st.dataframe(result_df)
|
| 239 |
+
|
| 240 |
+
if st.checkbox("Repeat Cluster Visualization"):
|
| 241 |
+
repeat_counts = defaultdict(int)
|
| 242 |
+
for seq_data in st.session_state.all_sequences_data:
|
| 243 |
+
for _, _, freq_dict in seq_data:
|
| 244 |
+
for repeat, count in freq_dict.items():
|
| 245 |
+
repeat_counts[repeat] += count
|
| 246 |
+
|
| 247 |
+
if repeat_counts:
|
| 248 |
+
sorted_repeats = sorted(repeat_counts.items(), key=lambda x: x[1], reverse=True)
|
| 249 |
+
top_n = st.slider("Select number of top repeats to visualize", min_value=5, max_value=50, value=20)
|
| 250 |
+
top_repeats = sorted_repeats[:top_n]
|
| 251 |
+
repeats, counts = zip(*top_repeats)
|
| 252 |
+
|
| 253 |
+
plt.figure(figsize=(12, 6))
|
| 254 |
+
sns.barplot(x=list(repeats), y=list(counts), palette="viridis")
|
| 255 |
+
plt.xticks(rotation=45, ha='right')
|
| 256 |
+
plt.xlabel("Repeats")
|
| 257 |
+
plt.ylabel("Total Frequency")
|
| 258 |
+
plt.title("Top Repeat Clusters Across All Sequences")
|
| 259 |
+
st.pyplot(plt.gcf())
|
| 260 |
+
else:
|
| 261 |
+
st.warning("No repeat data available to visualize. Please upload files first.")
|
| 262 |
+
|
| 263 |
|
| 264 |
elif app_choice == "π Protein Comparator":
|
| 265 |
st.write("Upload two Excel files with protein data to compare repeat frequencies.")
|