fuxialexander commited on
Commit
39718fc
โ€ข
1 Parent(s): 40af086

revert gene name dropdown and add plotly plddt

Browse files
Files changed (1) hide show
  1. app/main.py +6 -34
app/main.py CHANGED
@@ -109,8 +109,8 @@ def visualize_AF2(tf_pair, a):
109
  # segpair.choices = list(a.pairs_data.keys())
110
  fig1, ax1 = a.plot_plddt_gene1()
111
  fig2, ax2 = a.plot_plddt_gene2()
112
- fig3, ax3 = a.protein1.plot_plddt()
113
- fig4, ax4 = a.protein2.plot_plddt()
114
  fig5, ax5 = a.plot_score_heatmap()
115
  plt.tight_layout()
116
  new_dropdown = update_dropdown(list(a.pairs_data.keys()), "Segment pair")
@@ -126,22 +126,12 @@ def update_dropdown(x, label):
126
  return gr.Dropdown.update(choices=x, label=label)
127
 
128
 
129
- def filter_gene_records(cell, str):
130
- if str == '':
131
- return cell.gene_annot.groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5), cell
132
- df = cell.gene_annot.query(f"gene_name == '{str}'").groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5)
133
- return df, cell
134
-
135
  def load_and_plot_celltype(celltype_name, GET_CONFIG, cell):
136
  celltype_id = cell_type_name_to_id[celltype_name]
137
  cell = GETCellType(celltype_id, GET_CONFIG)
138
  cell.celltype_name = celltype_name
139
- # gene_name.choices = sorted(gene_exp_table.gene_name.unique()
140
  gene_exp_fig = cell.plotly_gene_exp()
141
- gene_exp_table = cell.gene_annot.groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5)
142
- new_gene_dropdown = update_dropdown(sorted(cell.gene_annot.gene_name.unique()), "Gene name")
143
- return gene_exp_fig, gene_exp_table, new_gene_dropdown, new_gene_dropdown, cell
144
-
145
 
146
 
147
  def plot_gene_regions(cell, gene_name, plotly=True):
@@ -184,7 +174,6 @@ if __name__ == "__main__":
184
  seg_pairs = gr.State([""])
185
  af = gr.State(None)
186
  cell = gr.State(None)
187
- gene_names = gr.State([""])
188
 
189
  gr.Markdown(
190
  """# ๐ŸŒŸ GET: A Foundation Model of Transcription Across Human Cell Types ๐ŸŒŸ
@@ -224,18 +213,6 @@ This section enables you to select different cell types and generates a plot tha
224
  )
225
  celltype_btn = gr.Button(value="Load & plot gene expression")
226
  gene_exp_plot = gr.Plot(label="Gene expression prediction vs observation")
227
- with gr.Row() as row:
228
- gene_name = gr.Dropdown(value="BCL11A")
229
- # Button to trigger the filter action
230
- filter_btn = gr.Button("Filter table by gene name")
231
- gene_exp_table = gr.Dataframe(
232
- datatype=["str", "number", "number", "number"],
233
- row_count=5,
234
- col_count=(4, "fixed"),
235
- label='Gene expression table',
236
- max_rows=5
237
- )
238
-
239
 
240
  # Right column: Plot gene motifs
241
  with gr.Column():
@@ -246,8 +223,8 @@ This section enables you to select different cell types and generates a plot tha
246
  In this section, you can choose a specific gene and access visualizations of its cell-type specific regulatory regions and motifs that promote gene expression. When you hover over the highlighted regions (the top 10%), you'll be able to view information about the motifs present in those regions and their corresponding scores. This feature allows for a detailed exploration of the regulatory elements influencing the expression of the selected gene.
247
  """
248
  )
249
- gene_name_for_region = gr.Dropdown(
250
- label="Get important regions or motifs for gene:", value="BCL11A"
251
  )
252
  with gr.Row() as row:
253
  region_plot_btn = gr.Button(value="Regions")
@@ -355,12 +332,7 @@ You can download specific segment pair PDB files by clicking 'Get PDB.'
355
  celltype_btn.click(
356
  load_and_plot_celltype,
357
  inputs=[celltype_name, gr.State(GET_CONFIG), cell],
358
- outputs=[gene_exp_plot, gene_exp_table, gene_name, gene_name_for_region, cell],
359
- )
360
- filter_btn.click(
361
- filter_gene_records,
362
- inputs=[cell, gene_name],
363
- outputs=[gene_exp_table, cell],
364
  )
365
  region_plot_btn.click(
366
  plot_gene_regions,
 
109
  # segpair.choices = list(a.pairs_data.keys())
110
  fig1, ax1 = a.plot_plddt_gene1()
111
  fig2, ax2 = a.plot_plddt_gene2()
112
+ fig3, ax3 = a.protein1.plotly_plddt()
113
+ fig4, ax4 = a.protein2.plotly_plddt()
114
  fig5, ax5 = a.plot_score_heatmap()
115
  plt.tight_layout()
116
  new_dropdown = update_dropdown(list(a.pairs_data.keys()), "Segment pair")
 
126
  return gr.Dropdown.update(choices=x, label=label)
127
 
128
 
 
 
 
 
 
 
129
  def load_and_plot_celltype(celltype_name, GET_CONFIG, cell):
130
  celltype_id = cell_type_name_to_id[celltype_name]
131
  cell = GETCellType(celltype_id, GET_CONFIG)
132
  cell.celltype_name = celltype_name
 
133
  gene_exp_fig = cell.plotly_gene_exp()
134
+ return gene_exp_fig, cell
 
 
 
135
 
136
 
137
  def plot_gene_regions(cell, gene_name, plotly=True):
 
174
  seg_pairs = gr.State([""])
175
  af = gr.State(None)
176
  cell = gr.State(None)
 
177
 
178
  gr.Markdown(
179
  """# ๐ŸŒŸ GET: A Foundation Model of Transcription Across Human Cell Types ๐ŸŒŸ
 
213
  )
214
  celltype_btn = gr.Button(value="Load & plot gene expression")
215
  gene_exp_plot = gr.Plot(label="Gene expression prediction vs observation")
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
  # Right column: Plot gene motifs
218
  with gr.Column():
 
223
  In this section, you can choose a specific gene and access visualizations of its cell-type specific regulatory regions and motifs that promote gene expression. When you hover over the highlighted regions (the top 10%), you'll be able to view information about the motifs present in those regions and their corresponding scores. This feature allows for a detailed exploration of the regulatory elements influencing the expression of the selected gene.
224
  """
225
  )
226
+ gene_name_for_region = gr.Textbox(
227
+ label="Get important regions or motifs for gene:", value="SOX2"
228
  )
229
  with gr.Row() as row:
230
  region_plot_btn = gr.Button(value="Regions")
 
332
  celltype_btn.click(
333
  load_and_plot_celltype,
334
  inputs=[celltype_name, gr.State(GET_CONFIG), cell],
335
+ outputs=[gene_exp_plot, cell],
 
 
 
 
 
336
  )
337
  region_plot_btn.click(
338
  plot_gene_regions,