dylanplummer commited on
Commit
3acd654
·
1 Parent(s): 2ff282d

test select from img

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -173,7 +173,8 @@ def get_heatmap(gene, locus1, locus2):
173
  a1_start = peaks.loc[a1, 'chromStart']
174
  a2_start = peaks.loc[a2, 'chromStart']
175
  interaction_dist = abs(a1_start - a2_start)
176
- heatmap_locus = f'{chrom}:{max(0, chromStart - interaction_dist - heatmap_range)}-{chromEnd + interaction_dist + heatmap_range}'
 
177
  print(heatmap_locus)
178
  mat = beta_cooler.matrix().fetch(heatmap_locus)
179
  #img = draw_heatmap(mat, 0, return_image=True)
@@ -194,6 +195,15 @@ def get_heatmap(gene, locus1, locus2):
194
  plt.close()
195
  return img
196
 
 
 
 
 
 
 
 
 
 
197
  def perturb(gene, locus1, locus2):
198
  locus1 = locus1.replace(',', '')
199
  locus2 = locus2.replace(',', '')
@@ -348,7 +358,7 @@ with gr.Blocks(theme='WeixuanYuan/Soft_dark') as demo:
348
  fn=perturb, cache_examples=os.getenv('SYSTEM') == 'spaces')
349
  run_button.click(perturb, inputs, outputs=outputs)
350
  heatmap_button.click(get_heatmap, inputs, outputs=[out_heatmap])
351
- #out_heatmap.select(set_loop, [in_locus, anchor1, anchor2], outputs=[anchor1, anchor2])
352
 
353
 
354
  if __name__ == "__main__":
 
173
  a1_start = peaks.loc[a1, 'chromStart']
174
  a2_start = peaks.loc[a2, 'chromStart']
175
  interaction_dist = abs(a1_start - a2_start)
176
+ chrom_size = beta_cooler.chromsizes[chrom]
177
+ heatmap_locus = f'{chrom}:{max(0, chromStart - interaction_dist - heatmap_range)}-{min(chrom_size, chromEnd + interaction_dist + heatmap_range)}'
178
  print(heatmap_locus)
179
  mat = beta_cooler.matrix().fetch(heatmap_locus)
180
  #img = draw_heatmap(mat, 0, return_image=True)
 
195
  plt.close()
196
  return img
197
 
198
+
199
+ def set_loop(gene, locus1, locus2, evt: gr.SelectData):
200
+ print(evt)
201
+ idx = evt.index
202
+ value = evt.value
203
+ print(idx)
204
+ print(value)
205
+ return idx[0], idx[1]
206
+
207
  def perturb(gene, locus1, locus2):
208
  locus1 = locus1.replace(',', '')
209
  locus2 = locus2.replace(',', '')
 
358
  fn=perturb, cache_examples=os.getenv('SYSTEM') == 'spaces')
359
  run_button.click(perturb, inputs, outputs=outputs)
360
  heatmap_button.click(get_heatmap, inputs, outputs=[out_heatmap])
361
+ out_heatmap.select(set_loop, [in_locus, anchor1, anchor2], outputs=[anchor1, anchor2])
362
 
363
 
364
  if __name__ == "__main__":