hssling commited on
Commit
9db18e2
·
1 Parent(s): 71529c6

Update space app

Browse files
Files changed (3) hide show
  1. README.md +14 -13
  2. app.py +46 -0
  3. requirements.txt +11 -0
README.md CHANGED
@@ -1,14 +1,15 @@
1
- ---
2
- title: Tbmeta Space
3
- emoji: 🌖
4
- colorFrom: green
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 6.8.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: tb transscriptomic met analysis
12
- ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Space Setup
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ 1. Create a new Space (`Streamlit`) in your Hugging Face account.
4
+ 2. Push these files to the Space root:
5
+ - `app.py`
6
+ - `requirements.txt`
7
+ 3. Also include this repository content (or mount it as a submodule) so the `tbmeta` CLI and config are available.
8
+ 4. Set optional secrets in Space settings:
9
+ - `OPENAI_API_KEY`
10
+ - `OPENCLAW_API_KEY`
11
+ 5. Launch the Space and use the "Run Full Pipeline" button.
12
+
13
+ Note:
14
+ - Free CPU Spaces may be slow for full runs.
15
+ - For heavy runs, execute pipeline in CI/Kaggle and use Space primarily as a dashboard.
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+ import subprocess
6
+ import sys
7
+
8
+ import streamlit as st
9
+
10
+
11
+ ROOT = Path(__file__).resolve().parents[2]
12
+ RESULTS = ROOT / "results" / "tables"
13
+ FIGS = ROOT / "results" / "figures"
14
+
15
+
16
+ def _run_pipeline() -> tuple[int, str]:
17
+ cmd = ["tbmeta", "all", "--config", "configs/config.yaml", "--force"]
18
+ p = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True)
19
+ return p.returncode, (p.stdout + "\n" + p.stderr).strip()
20
+
21
+
22
+ st.set_page_config(page_title="TB Meta Dashboard", layout="wide")
23
+ st.title("TB Progression Transcriptome Meta-analysis")
24
+ st.caption("Hugging Face Space wrapper for results exploration and reruns.")
25
+
26
+ if st.button("Run Full Pipeline"):
27
+ with st.spinner("Running pipeline..."):
28
+ code, logs = _run_pipeline()
29
+ if code == 0:
30
+ st.success("Pipeline completed.")
31
+ else:
32
+ st.error(f"Pipeline failed with code {code}.")
33
+ st.text_area("Logs", logs, height=320)
34
+
35
+ st.subheader("Key Tables")
36
+ for name in ["loco_performance.csv", "signature_genes.csv", "pathway_enrichment.csv", "window_sensitivity.csv"]:
37
+ p = RESULTS / name
38
+ if p.exists():
39
+ st.markdown(f"- `{name}`")
40
+
41
+ st.subheader("Figures")
42
+ if FIGS.exists():
43
+ for fig in sorted(FIGS.glob("*.png")):
44
+ st.image(str(fig), caption=fig.name)
45
+ else:
46
+ st.info("No figure outputs found yet.")
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ streamlit>=1.40
2
+ pandas>=2.2
3
+ numpy>=1.26
4
+ scikit-learn>=1.5
5
+ matplotlib>=3.9
6
+ scipy>=1.13
7
+ requests>=2.32
8
+ gseapy>=1.1
9
+ GEOparse>=2.0
10
+ pyarrow>=17.0
11
+ tbmeta