File size: 2,598 Bytes
35fa1f1
 
 
5bb9f6b
 
 
35fa1f1
 
5bb9f6b
 
35fa1f1
 
 
 
 
 
 
 
 
5bb9f6b
35fa1f1
 
 
 
5bb9f6b
 
35fa1f1
 
5bb9f6b
 
35fa1f1
 
5bb9f6b
 
35fa1f1
 
5bb9f6b
 
35fa1f1
 
5bb9f6b
 
35fa1f1
5bb9f6b
35fa1f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5bb9f6b
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
""")

with gr.Column(scale=1):
miss_sample = gr.Slider(5, 50, value=30, step=5, label="Max sample missing (%)")
miss_marker = gr.Slider(5, 50, value=30, step=5, label="Max marker missing (%)")
maf_thr = gr.Slider(0, 25, value=3, step=1, label="Min MAF (%)")

with gr.Column(scale=1):
lod_thresh = gr.Slider(0.5, 10.0, value=3.0, step=0.1, label="LOD threshold")
n_pc = gr.Slider(2, 20, value=5, step=1, label="Number of PCs")
gr.Markdown("### Models")
with gr.Row():
    chk_glm = gr.Checkbox(value=True, label="GLM")
    chk_mlm = gr.Checkbox(value=True, label="MLM")
    chk_cmlm = gr.Checkbox(value=True, label="CMLM")
    chk_bslmm = gr.Checkbox(value=False, label="BSLMM")
    chk_farmcpu = gr.Checkbox(value=True, label="FarmCPU")

run_btn = gr.Button("πŸš€ Run GWAS Analysis", variant="primary", size="lg")
gr.Markdown("---")

summary_out = gr.Markdown()

with gr.Row():
man_model_sel = gr.Dropdown(label="πŸ—ΊοΈ Manhattan β€” select model", choices=[], value=None, interactive=True)
qq_model_sel = gr.Dropdown(label="πŸ“ˆ QQ Plot β€” select model", choices=[], value=None, interactive=True)

with gr.Row():
man_out = gr.Image(label="πŸ—ΊοΈ Manhattan Plot (βˆ’log₁₀P top | LOD bottom)")
qq_out = gr.Image(label="πŸ“ˆ QQ Plot (genomic inflation Ξ»)")

with gr.Row():
pca_out = gr.Image(label="πŸ”¬ PCA Analysis (Scree + PC1v2 + PC2v3)")
ld_out = gr.Image(label="🧬 LD Decay (Hill-Weir model)")

with gr.Row():
circos_out = gr.Image(label="🌐 Circos β€” Multi-Model MTA")
cmp_out = gr.Image(label="βš–οΈ Model P-value Concordance")

with gr.Row():
ph_out = gr.Image(label="πŸ“Š Phenotype Distribution")
kin_out = gr.Image(label="πŸ”₯ Kinship Matrix Heatmap")

dl_out = gr.File(label="πŸ“¦ Download All Results (ZIP)")

man_paths_state = gr.State({})
qq_paths_state = gr.State({})

run_btn.click(
fn=run_analysis,
inputs=[input_file, miss_sample, miss_marker, maf_thr,
    lod_thresh, n_pc,
    chk_glm, chk_mlm, chk_cmlm, chk_bslmm, chk_farmcpu],
outputs=[summary_out, man_out, qq_out, pca_out,
     ld_out, circos_out, cmp_out, ph_out,
     dl_out, kin_out,
     man_model_sel, qq_model_sel,
     man_paths_state, qq_paths_state],
show_progress="full"
)

def switch_manhattan(model, paths):
return paths.get(model) if paths else None

def switch_qq(model, paths):
return paths.get(model) if paths else None

man_model_sel.change(switch_manhattan, [man_model_sel, man_paths_state], [man_out])
qq_model_sel.change(switch_qq, [qq_model_sel, qq_paths_state], [qq_out])

if __name__ == "__main__":
app.launch(share=False, show_error=True, max_threads=4, allowed_paths=[str(OUTPUT_DIR)])