.label-wrap { display: none !important; }
+
+.model-quick-btn button {
+ font-size: 12px !important; font-weight: 600 !important;
+ padding: 6px 14px !important; border-radius: 8px !important;
+ border: 1.5px solid #C8D0E7 !important; background: #FFFFFF !important;
+ color: #5A6480 !important; transition: all 0.15s ease !important;
+}
+.model-quick-btn button:hover {
+ border-color: #5BA8E5 !important; color: #2C5F8A !important; background: #EBF5FF !important;
+}
+"""
SAMPLE_DATA = """ID,Phenotype,chr1_134521_SNP1,chr1_134810_SNP2,chr1_178766_SNP3,chr1_210328_SNP4
+chromosome,1,1,1,1
IRRI-1,25.34,0,0,0,2
IRRI-75,23.34,0,0,0,0
IRRI-84,26.67,2,0,2,0
@@ -1457,76 +2103,142 @@ IRRI-34,37,0,0,0,0
IRRI-42,30.67,0,0,0,0
IRRI-50,22,0,0,0,2"""
-ALL_MODELS_10 = ["OLS", "PLINK", "GLM", "MLM", "CMLM", "EMMAX", "GEMMA", "BLINK", "FarmCPU", "GAPIT3"]
-
-CSS = """
-.gradio-container { max-width: 1400px !important; margin: auto !important; }
-h1 { text-align: center; color: #2C5F8A; }
+ALL_MODELS = ["OLS", "MLM", "GLM", "CMLM", "BLINK", "FarmCPU", "EMMAX", "PLINK", "GAPIT3", "GEMMA"]
+
+MODEL_INFO_HTML = """
+
+ OLS/PLINK — baseline, no correction |
+ GLM — PCs only |
+ EMMAX/GEMMA — fast REML LMM ✓ |
+ MLM — exact GLS |
+ FarmCPU/BLINK/GAPIT3 — iterative QTN |
+ CMLM — compressed kinship
+ ⚡ All plots are interactive — hover, zoom, click on SNPs!
+
"""
-with gr.Blocks(css=CSS, title="🧬 GWAS Pipeline - 10 Models", theme=gr.themes.Soft()) as demo:
- gr.Markdown("""
- # 🧬 Complete GWAS Analysis Pipeline - 10 Statistical Models
-
- **Models Available:**
- - **Fast:** OLS, PLINK, GLM
- - **Mixed Models:** MLM, EMMAX, GEMMA, CMLM
- - **Advanced:** BLINK, FarmCPU, GAPIT3
-
- **Features:**
- - All 10 models run in parallel
- - Circos plot shows **top 4 best-performing models** (based on λ inflation + significance)
- - Automatic model selection for primary analysis
- - Comprehensive visualization suite
+# ─────────────────────── GRADIO INTERFACE ─────────────────────────────────────
+with gr.Blocks(css=PASTEL_CSS, title="🧬 GWAS Pipeline", theme=gr.themes.Base()) as demo:
+
+ gr.HTML("""
+
""")
-
- with gr.Row():
- with gr.Column(scale=1):
- file_input = gr.File(label="Upload CSV/TSV file", file_types=[".csv", ".tsv", ".txt"])
- text_input = gr.Textbox(label="Or paste data", lines=8, value=SAMPLE_DATA)
-
- model_selector = gr.CheckboxGroup(choices=ALL_MODELS_10, value=ALL_MODELS_10,
- label="Select Models to Run (10 available)")
-
- maf_threshold = gr.Slider(0, 0.5, value=0.05, step=0.01, label="MAF Threshold")
-
- run_button = gr.Button("🚀 Run GWAS Analysis (10 Models)", variant="primary", size="lg")
-
- gr.Markdown("""
- ***Note:** *
- - **GEMMA/EMMAX** are recommended for most datasets
- - Circos plot automatically selects **top 4 models** based on performance
- - MLM/FarmCPU/BLINK may be slower for large datasets
- """)
-
+
+ with gr.Row(equal_height=False):
+
+ with gr.Column(scale=1, min_width=340):
+ gr.HTML('📂 Data Input
')
+ file_in = gr.File(label="Upload CSV / TSV / TXT",
+ file_types=[".csv", ".tsv", ".txt"])
+ text_in = gr.Textbox(label="Or paste CSV data", lines=7,
+ value=SAMPLE_DATA,
+ placeholder="Paste your CSV data here…")
+
+ gr.HTML('⚙️ Select Models to Run
')
+ gr.HTML(MODEL_INFO_HTML)
+
+ model_sel = gr.CheckboxGroup(
+ choices=ALL_MODELS,
+ value=ALL_MODELS,
+ label="Models",
+ elem_id="model-selector",
+ interactive=True,
+ )
+
+ with gr.Row():
+ gr.Button("✅ All", size="sm", elem_classes=["model-quick-btn"]).click(
+ fn=lambda: ALL_MODELS, outputs=model_sel)
+ gr.Button("☐ None", size="sm", elem_classes=["model-quick-btn"]).click(
+ fn=lambda: [], outputs=model_sel)
+ gr.Button("⚡ Fast", size="sm", elem_classes=["model-quick-btn"]).click(
+ fn=lambda: ["OLS", "GLM", "EMMAX", "PLINK", "GEMMA"], outputs=model_sel)
+ gr.Button("🔬 LMM", size="sm", elem_classes=["model-quick-btn"]).click(
+ fn=lambda: ["MLM", "EMMAX", "GEMMA", "CMLM"], outputs=model_sel)
+
+ gr.HTML('🎛️ Settings
')
+ maf_thr = gr.Slider(0, 0.5, value=0.05, step=0.01, label="MAF Threshold")
+
+ run_btn = gr.Button("🚀 Run GWAS Pipeline", variant="primary")
+
+ gr.HTML('📥 Downloads
')
+ with gr.Column(elem_classes=["download-section"]):
+ excel_out = gr.File(label="📊 Excel — All Results", interactive=False)
+ zip_out = gr.File(label="🖼 Static PNGs (ZIP)", interactive=False)
+
with gr.Column(scale=2):
- summary_output = gr.Textbox(label="Analysis Summary", lines=25, interactive=False)
-
- gr.Markdown("### 📊 Visualization Results")
-
+ gr.HTML('📊 Analysis Summary
')
+ summary_out = gr.Textbox(label="", lines=30,
+ elem_classes=["summary-box"],
+ show_label=False)
+
+ gr.HTML('🖼 Interactive Visualizations
')
+
with gr.Tabs():
- with gr.Tab("Manhattan (Primary)"):
- img1 = gr.Image(type="pil", label="Manhattan Plot - Best Model")
- with gr.Tab("QQ Plot (Primary)"):
- img2 = gr.Image(type="pil", label="QQ Plot - Best Model")
- with gr.Tab("Circos (Top 4 Models)"):
- img3 = gr.Image(type="pil", label="Circos Plot - Best Performing Models")
- with gr.Tab("LD Decay"):
- img4 = gr.Image(type="pil", label="LD Decay")
- with gr.Tab("PCA"):
- img5 = gr.Image(type="pil", label="PCA")
- with gr.Tab("Kinship"):
- img6 = gr.Image(type="pil", label="Kinship Matrix")
- with gr.Tab("All Models Comparison"):
- img7 = gr.Image(type="pil", label="Manhattan - All 10 Models")
- with gr.Tab("Dashboard"):
- img8 = gr.Image(type="pil", label="Summary Dashboard")
-
- run_button.click(
- fn=run_gwas,
- inputs=[file_input, text_input, model_selector, maf_threshold],
- outputs=[img1, img2, img3, img4, img5, img6, img7, img8, summary_output]
+ with gr.Tab("🗺 Manhattan (Primary)"):
+ gr.HTML('Hover SNPs for details · Zoom with scroll · Click legend to toggle chromosomes
')
+ plot1 = gr.Plot(label="Manhattan — Primary Model")
+
+ with gr.Tab("📈 QQ (Primary)"):
+ gr.HTML('Hover points for p-values · λ shows genomic inflation
')
+ plot2 = gr.Plot(label="QQ Plot — Primary Model")
+
+ with gr.Tab("📊 QQ Overlay"):
+ gr.HTML('All models overlaid · Click legend to toggle · Compare λ values
')
+ plot3 = gr.Plot(label="QQ Overlay — All Models")
+
+ with gr.Tab("🔵 Circos (Best Models)"):
+ gr.HTML('Shows top 4 best-controlled models (λ closest to 1) · ◆ = genome-wide significant
')
+ plot4 = gr.Plot(label="Circos — Best Models")
+
+ with gr.Tab("🔗 LD Decay"):
+ gr.HTML('Hover for distance/r² values · Binned mean ± SEM shown
')
+ plot5 = gr.Plot(label="LD Decay")
+
+ with gr.Tab("🔬 PCA"):
+ gr.HTML('Color = phenotype value · Hover for sample ID
')
+ plot6 = gr.Plot(label="PCA")
+
+ with gr.Tab("👨👩👧 Kinship"):
+ gr.HTML('Hover cells for kinship coefficient · Distribution shows population structure
')
+ plot7 = gr.Plot(label="Kinship Matrix")
+
+ with gr.Tab("⚖ Effect Sizes"):
+ gr.HTML('Hover for SNP details · Red = GW significant · Green = positive effect
')
+ plot8 = gr.Plot(label="Effect Sizes & Volcano")
+
+ with gr.Tab("🔄 All Models (Stacked)"):
+ gr.HTML('All models stacked · Hover for SNP identity · λ shown per panel
')
+ plot9 = gr.Plot(label="Manhattan — All Models")
+
+ with gr.Tab("📊 Dashboard"):
+ gr.HTML('Summary statistics · Model concordance · Inflation control
')
+ plot10 = gr.Plot(label="Summary Dashboard")
+
+ def run_wrapper(file_obj, text_data, selected_models, maf):
+ if not selected_models:
+ selected_models = ALL_MODELS
+ out = run_gwas(file_obj, text_data, selected_models, maf)
+ while len(out) < 13:
+ out.append(None)
+ return out
+
+ run_btn.click(
+ fn=run_wrapper,
+ inputs=[file_in, text_in, model_sel, maf_thr],
+ outputs=[
+ plot1, plot2, plot3, plot4, plot5,
+ plot6, plot7, plot8, plot9, plot10,
+ excel_out, zip_out, summary_out
+ ],
)
-
+#
if __name__ == "__main__":
demo.launch(share=True, server_port=7860)
\ No newline at end of file