fuxialexander commited on
Commit
3ca22c6
โ€ข
1 Parent(s): cdb088d

add gene_name dropdown

Browse files
Files changed (1) hide show
  1. app/main.py +49 -21
app/main.py CHANGED
@@ -71,7 +71,7 @@ def visualize_AF2(tf_pair, a):
71
  gr.ErrorText("No such gene pair")
72
 
73
  a = AFPairseg(strcture_dir, fasta_dir)
74
- segpair.choices = list(a.pairs_data.keys())
75
  fig1, ax1 = a.plot_plddt_gene1()
76
  fig2, ax2 = a.plot_plddt_gene2()
77
  fig3, ax3 = a.protein1.plot_plddt()
@@ -91,12 +91,22 @@ def update_dropdown(x, label):
91
  return gr.Dropdown.update(choices=x, label=label)
92
 
93
 
 
 
 
 
 
 
94
  def load_and_plot_celltype(celltype_name, GET_CONFIG, cell):
95
  celltype_id = cell_type_name_to_id[celltype_name]
96
  cell = GETCellType(celltype_id, GET_CONFIG)
97
  cell.celltype_name = celltype_name
 
98
  gene_exp_fig = cell.plotly_gene_exp()
99
- return gene_exp_fig, cell
 
 
 
100
 
101
 
102
  def plot_gene_regions(cell, gene_name, plotly=True):
@@ -139,10 +149,10 @@ if __name__ == "__main__":
139
  seg_pairs = gr.State([""])
140
  af = gr.State(None)
141
  cell = gr.State(None)
 
142
 
143
  gr.Markdown(
144
- """
145
- # ๐ŸŒŸ GET: A Foundation Model of Transcription Across Human Cell Types ๐ŸŒŸ
146
 
147
  Here we introduce GET, an innovative computational model aimed at understanding transcriptional regulation across 235 human fetal and adult cell types.
148
  Built solely on chromatin accessibility and sequence data, GET exhibits unparalleled generalizability and accuracy in predicting gene expression, even in previously unstudied cell types.
@@ -154,10 +164,10 @@ Overall, GET serves as a robust, generalizable framework for understanding cell
154
 
155
  Dive deep into our live demo and experience a revolution in cellular transcription like never before. Here's what you can explore:
156
 
157
- ๐Ÿ” Prediction Performance: Choose your cell type and be amazed as we unveil a vivid plot comparing observed versus forecasted gene expression levels.
158
- ๐Ÿงฌ Cell-type Specific Regulatory Insights: Just pick a gene, and voilร ! Revel in intricate plots revealing the cell-type specific regulatory landscapes and motifs.
159
- ๐Ÿ”— Motif Correlation & Causal Subnetworks: Engage with our intuitive heatmap to witness motif correlations. Go further - choose a motif, define your subnetwork preference, set an effect size threshold, and behold the magic unfold!
160
- ๐Ÿ”ฌ Structural Atlas of Interactions: Step into the realm of transcription factor pairs. Experience heatmaps, pLDDT metrics, and more. And guess what? You can even download the PDB file for select segment pairs!
161
 
162
  Stay tuned! We're set to dazzle you further as we launch our demo on Huggingface this week. Questions, thoughts, or moments of awe? Don't hesitate to reach out!
163
 
@@ -179,17 +189,29 @@ This section enables you to select different cell types and generates a plot tha
179
  )
180
  celltype_btn = gr.Button(value="Load & plot gene expression")
181
  gene_exp_plot = gr.Plot(label="Gene expression prediction vs observation")
 
 
 
 
 
 
 
 
 
 
 
 
182
 
183
  # Right column: Plot gene motifs
184
  with gr.Column():
185
  gr.Markdown(
186
  """
187
- ## ๐Ÿงฌ Cell-type specific regulatory inference
188
 
189
  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.
190
  """
191
  )
192
- gene_name_for_region = gr.Textbox(
193
  label="Get important regions or motifs for gene:", value="BCL11A"
194
  )
195
  with gr.Row() as row:
@@ -258,14 +280,7 @@ You can download specific segment pair PDB files by clicking 'Get PDB.'
258
  """
259
  )
260
 
261
- with gr.Row() as row:
262
- with gr.Column():
263
- protein1_plddt = gr.Plot(label="Protein 1 pLDDT")
264
- interact_plddt1 = gr.Plot(label="Interact pLDDT 1")
265
- with gr.Column():
266
- protein2_plddt = gr.Plot(label="Protein 2 pLDDT")
267
- interact_plddt2 = gr.Plot(label="Interact pLDDT 2")
268
-
269
  with gr.Row() as row:
270
  with gr.Column():
271
  tf_pairs = gr.Dropdown(label="TF pair", choices=gene_pairs)
@@ -273,11 +288,19 @@ You can download specific segment pair PDB files by clicking 'Get PDB.'
273
  heatmap = gr.Plot(label="Heatmap")
274
 
275
  with gr.Column():
276
- segpair = gr.Dropdown(label="Seg pair", choices=seg_pairs.value)
277
  segpair_btn = gr.Button(value="Get PDB")
278
  pdb_html = gr.HTML(label="PDB HTML")
279
  pdb_file = gr.File(label="Download PDB")
280
-
 
 
 
 
 
 
 
 
281
  tf_pairs_btn.click(
282
  visualize_AF2,
283
  inputs=[tf_pairs, af],
@@ -297,7 +320,12 @@ You can download specific segment pair PDB files by clicking 'Get PDB.'
297
  celltype_btn.click(
298
  load_and_plot_celltype,
299
  inputs=[celltype_name, gr.State(GET_CONFIG), cell],
300
- outputs=[gene_exp_plot, cell],
 
 
 
 
 
301
  )
302
  region_plot_btn.click(
303
  plot_gene_regions,
 
71
  gr.ErrorText("No such gene pair")
72
 
73
  a = AFPairseg(strcture_dir, fasta_dir)
74
+ # segpair.choices = list(a.pairs_data.keys())
75
  fig1, ax1 = a.plot_plddt_gene1()
76
  fig2, ax2 = a.plot_plddt_gene2()
77
  fig3, ax3 = a.protein1.plot_plddt()
 
91
  return gr.Dropdown.update(choices=x, label=label)
92
 
93
 
94
+ def filter_gene_records(cell, str):
95
+ if str == '':
96
+ return cell.gene_annot.groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5), cell
97
+ df = cell.gene_annot.query(f"gene_name == '{str}'").groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5)
98
+ return df, cell
99
+
100
  def load_and_plot_celltype(celltype_name, GET_CONFIG, cell):
101
  celltype_id = cell_type_name_to_id[celltype_name]
102
  cell = GETCellType(celltype_id, GET_CONFIG)
103
  cell.celltype_name = celltype_name
104
+ # gene_name.choices = sorted(gene_exp_table.gene_name.unique()
105
  gene_exp_fig = cell.plotly_gene_exp()
106
+ gene_exp_table = cell.gene_annot.groupby('gene_name')[['pred', 'obs', 'accessibility']].mean().reset_index().head(5)
107
+ new_gene_dropdown = update_dropdown(sorted(cell.gene_annot.gene_name.unique()), "Gene name")
108
+ return gene_exp_fig, gene_exp_table, new_gene_dropdown, new_gene_dropdown, cell
109
+
110
 
111
 
112
  def plot_gene_regions(cell, gene_name, plotly=True):
 
149
  seg_pairs = gr.State([""])
150
  af = gr.State(None)
151
  cell = gr.State(None)
152
+ gene_names = gr.State([""])
153
 
154
  gr.Markdown(
155
+ """# ๐ŸŒŸ GET: A Foundation Model of Transcription Across Human Cell Types ๐ŸŒŸ
 
156
 
157
  Here we introduce GET, an innovative computational model aimed at understanding transcriptional regulation across 235 human fetal and adult cell types.
158
  Built solely on chromatin accessibility and sequence data, GET exhibits unparalleled generalizability and accuracy in predicting gene expression, even in previously unstudied cell types.
 
164
 
165
  Dive deep into our live demo and experience a revolution in cellular transcription like never before. Here's what you can explore:
166
 
167
+ - ๐Ÿ” Prediction Performance: Choose your cell type and be amazed as we unveil a vivid plot comparing observed versus forecasted gene expression levels.
168
+ - ๐Ÿงฌ Cell-type Specific Regulatory Insights: Just pick a gene, and voilร ! Revel in intricate plots revealing the cell-type specific regulatory landscapes and motifs.
169
+ - ๐Ÿ”— Motif Correlation & Causal Subnetworks: Engage with our intuitive heatmap to witness motif correlations. Go further - choose a motif, define your subnetwork preference, set an effect size threshold, and behold the magic unfold!
170
+ - ๐Ÿ”ฌ Structural Atlas of Interactions: Step into the realm of transcription factor pairs. Experience heatmaps, pLDDT metrics, and more. And guess what? You can even download the PDB file for select segment pairs!
171
 
172
  Stay tuned! We're set to dazzle you further as we launch our demo on Huggingface this week. Questions, thoughts, or moments of awe? Don't hesitate to reach out!
173
 
 
189
  )
190
  celltype_btn = gr.Button(value="Load & plot gene expression")
191
  gene_exp_plot = gr.Plot(label="Gene expression prediction vs observation")
192
+ with gr.Row() as row:
193
+ gene_name = gr.Dropdown(value="BCL11A")
194
+ # Button to trigger the filter action
195
+ filter_btn = gr.Button("Filter table by gene name")
196
+ gene_exp_table = gr.Dataframe(
197
+ datatype=["str", "number", "number", "number"],
198
+ row_count=5,
199
+ col_count=(4, "fixed"),
200
+ label='Gene expression table',
201
+ max_rows=5
202
+ )
203
+
204
 
205
  # Right column: Plot gene motifs
206
  with gr.Column():
207
  gr.Markdown(
208
  """
209
+ ### ๐Ÿงฌ Cell-type specific regulatory inference
210
 
211
  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.
212
  """
213
  )
214
+ gene_name_for_region = gr.Dropdown(
215
  label="Get important regions or motifs for gene:", value="BCL11A"
216
  )
217
  with gr.Row() as row:
 
280
  """
281
  )
282
 
283
+
 
 
 
 
 
 
 
284
  with gr.Row() as row:
285
  with gr.Column():
286
  tf_pairs = gr.Dropdown(label="TF pair", choices=gene_pairs)
 
288
  heatmap = gr.Plot(label="Heatmap")
289
 
290
  with gr.Column():
291
+ segpair = gr.Dropdown(label="Seg pair")
292
  segpair_btn = gr.Button(value="Get PDB")
293
  pdb_html = gr.HTML(label="PDB HTML")
294
  pdb_file = gr.File(label="Download PDB")
295
+
296
+ with gr.Row() as row:
297
+ with gr.Column():
298
+ protein1_plddt = gr.Plot(label="Protein 1 pLDDT")
299
+ interact_plddt1 = gr.Plot(label="Interact pLDDT 1")
300
+ with gr.Column():
301
+ protein2_plddt = gr.Plot(label="Protein 2 pLDDT")
302
+ interact_plddt2 = gr.Plot(label="Interact pLDDT 2")
303
+
304
  tf_pairs_btn.click(
305
  visualize_AF2,
306
  inputs=[tf_pairs, af],
 
320
  celltype_btn.click(
321
  load_and_plot_celltype,
322
  inputs=[celltype_name, gr.State(GET_CONFIG), cell],
323
+ outputs=[gene_exp_plot, gene_exp_table, gene_name, gene_name_for_region, cell],
324
+ )
325
+ filter_btn.click(
326
+ filter_gene_records,
327
+ inputs=[cell, gene_name],
328
+ outputs=[gene_exp_table, cell],
329
  )
330
  region_plot_btn.click(
331
  plot_gene_regions,