-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresults_proteomicslfq.py
More file actions
101 lines (82 loc) · 3.15 KB
/
results_proteomicslfq.py
File metadata and controls
101 lines (82 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from pathlib import Path
import streamlit as st
import pandas as pd
import numpy as np
import plotly.express as px
from src.common.common import page_setup
from src.common.results_helpers import get_abundance_data
# ================================
# Page setup
# ================================
params = page_setup()
st.title("ProteomicsLFQ Results")
# ================================
# Workspace check
# ================================
if "workspace" not in st.session_state:
st.warning("Please initialize your workspace first.")
st.stop()
# ================================
# Load abundance data
# ================================
res = get_abundance_data(st.session_state["workspace"])
if res is None:
st.info(
"Abundance data not available or incomplete. "
"Please run the workflow and configure sample groups first."
)
st.stop()
pivot_df, expr_df, group_map = res
# ================================
# Tabs
# ================================
protein_tab, = st.tabs(["🧬 Protein Table"])
# ================================
# Protein-level results
# ================================
with protein_tab:
st.markdown("### 🧬 Protein-Level Abundance Table")
st.info(
"This protein-level table is generated by grouping all PSMs that map to the "
"same protein and aggregating their intensities across samples.\n\n"
"Additionally, log2 fold change and p-values are calculated between sample groups."
)
if pivot_df.empty:
st.info("No protein-level data available.")
else:
st.session_state["pivot_df"] = pivot_df
st.dataframe(pivot_df.sort_values("p-value"), use_container_width=True)
# ======================================================
# GO Enrichment Results
# ======================================================
st.markdown("---")
st.subheader("🧬 GO Enrichment Analysis")
results_dir = Path(st.session_state["workspace"]) / "topp-workflow" / "results" / "go-terms"
go_json_file = results_dir / "go_results.json"
if not go_json_file.exists():
st.info("GO Enrichment results are not available yet. Please run the analysis first.")
else:
import json
import plotly.io as pio
with open(go_json_file, "r") as f:
go_data = json.load(f)
bp_tab, cc_tab, mf_tab = st.tabs([
"🧬 Biological Process",
"🏠 Cellular Component",
"⚙️ Molecular Function",
])
for tab, go_type in zip([bp_tab, cc_tab, mf_tab], ["BP", "CC", "MF"]):
with tab:
if go_type not in go_data:
st.info(f"No enriched {go_type} terms found.")
continue
fig_json = go_data[go_type]["fig_json"]
df_dict = go_data[go_type]["df_dict"]
fig = pio.from_json(fig_json)
df_go = pd.DataFrame(df_dict)
if df_go.empty:
st.info(f"No enriched {go_type} terms found.")
else:
st.plotly_chart(fig, use_container_width=True)
st.markdown(f"#### {go_type} Enrichment Results")
st.dataframe(df_go, use_container_width=True)