Jayesh13 commited on
Commit
4dd55d2
Β·
verified Β·
1 Parent(s): 0c63d43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
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 # For pie chart
 
 
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
- 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":
 
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":