dylanplummer commited on
Commit
55d7f2c
·
1 Parent(s): d6226ba

make ui better

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -444,31 +444,31 @@ def perturb(gene, locus1, locus2, use_max_gene, tf_knockout):
444
  return image_from_plot, violin_img, violin_img_new, violin_img_fc
445
 
446
 
447
- def update_on_tf_ko(tf_knockout):
448
  if tf_knockout:
449
- return gr.update(visible=False)
450
  else:
451
- return gr.update(visible=True)
452
 
453
 
454
  with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
455
  with gr.Row():
456
  with gr.Column():
457
- in_locus = gr.Textbox(label="Target Gene", elem_id='in-locus', scale=1)
458
  with gr.Row():
459
  max_gene_checkbox = gr.Checkbox(label="Max Gene", elem_id='max-gene-checkbox', scale=1, checked=False)
460
  tf_ko = gr.Checkbox(label="TF KO", elem_id='tf-ko', scale=1, checked=False)
461
- with gr.Column() as heatmap_col:
462
- anchor1 = gr.Textbox(label="Locus 1 (gene or genomic coords)", elem_id='anchor1', scale=1)
463
- anchor2 = gr.Textbox(label="Locus 2 (gene or genomic coords)", elem_id='anchor2', scale=1)
464
- heatmap_x = gr.Textbox(label="Heatmap X", elem_id='heatmap-x', scale=1, visible=False)
465
- heatmap_y = gr.Textbox(label="Heatmap Y", elem_id='heatmap-y', scale=1, visible=False)
466
- heatmap_size = gr.Slider(label="Heatmap Range", info="kb range aroung input gene locus to expand", minimum=50, maximum=5000, value=250)
467
- heatmap_button = gr.Button(value="Generate Heatmaps", elem_id='heatmap-button', scale=1)
468
- with gr.Row():
469
- out_heatmaps = []
470
- for celltype in cooler_celltypes:
471
- out_heatmaps.append(gr.Image(label=celltype, elem_id=f'out-heatmap-{celltype}', scale=1))
472
  with gr.Row():
473
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
474
  with gr.Row():
@@ -499,7 +499,7 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
499
  fn=perturb, cache_examples=os.getenv('SYSTEM') == 'spaces')
500
  run_button.click(perturb, inputs, outputs=outputs)
501
  heatmap_button.click(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
502
- tf_ko.change(update_on_tf_ko, tf_ko, outputs=heatmap_col)
503
  anchor1.change(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
504
  anchor2.change(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
505
  def set_loop(img, gene, locus1, locus2, heatmap_range, evt: gr.SelectData):
 
444
  return image_from_plot, violin_img, violin_img_new, violin_img_fc
445
 
446
 
447
+ def update_on_tf_ko(tf_knockout, use_max_gene):
448
  if tf_knockout:
449
+ return gr.update(visible=False), True
450
  else:
451
+ return gr.update(visible=True), use_max_gene
452
 
453
 
454
  with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
455
  with gr.Row():
456
  with gr.Column():
457
+ in_locus = gr.Textbox(label="Gene/TF", elem_id='in-locus', scale=1)
458
  with gr.Row():
459
  max_gene_checkbox = gr.Checkbox(label="Max Gene", elem_id='max-gene-checkbox', scale=1, checked=False)
460
  tf_ko = gr.Checkbox(label="TF KO", elem_id='tf-ko', scale=1, checked=False)
461
+ with gr.Column() as heatmap_col:
462
+ anchor1 = gr.Textbox(label="Locus 1 (gene or genomic coords)", elem_id='anchor1', scale=1)
463
+ anchor2 = gr.Textbox(label="Locus 2 (gene or genomic coords)", elem_id='anchor2', scale=1)
464
+ heatmap_x = gr.Textbox(label="Heatmap X", elem_id='heatmap-x', scale=1, visible=False)
465
+ heatmap_y = gr.Textbox(label="Heatmap Y", elem_id='heatmap-y', scale=1, visible=False)
466
+ heatmap_size = gr.Slider(label="Heatmap Range", info="kb range aroung input gene locus to expand", minimum=50, maximum=5000, value=250)
467
+ heatmap_button = gr.Button(value="Generate Heatmaps", elem_id='heatmap-button', scale=1)
468
+ with gr.Row():
469
+ out_heatmaps = []
470
+ for celltype in cooler_celltypes:
471
+ out_heatmaps.append(gr.Image(label=celltype, elem_id=f'out-heatmap-{celltype}', scale=1))
472
  with gr.Row():
473
  run_button = gr.Button(value="Run", elem_id='run-button', scale=1)
474
  with gr.Row():
 
499
  fn=perturb, cache_examples=os.getenv('SYSTEM') == 'spaces')
500
  run_button.click(perturb, inputs, outputs=outputs)
501
  heatmap_button.click(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
502
+ tf_ko.change(update_on_tf_ko, [tf_ko, max_gene_checkbox], outputs=[heatmap_col, max_gene_checkbox])
503
  anchor1.change(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
504
  anchor2.change(get_heatmaps, [in_locus, anchor1, anchor2, heatmap_size], outputs=out_heatmaps)
505
  def set_loop(img, gene, locus1, locus2, heatmap_range, evt: gr.SelectData):