jfaustin commited on
Commit
30947ef
·
1 Parent(s): fe7692a

show corr plot on button click

Browse files
folding_studio_demo/app.py CHANGED
@@ -10,7 +10,7 @@ from gradio_molecule3d import Molecule3D
10
  from folding_studio_demo.correlate import (
11
  SCORE_COLUMNS,
12
  fake_predict_and_correlate,
13
- select_correlation_plot,
14
  )
15
  from folding_studio_demo.predict import predict, predict_comparison
16
 
@@ -187,7 +187,7 @@ def create_correlation_tab():
187
  with gr.Row():
188
  # User can select the columns to display in the correlation plot
189
  correlation_column = gr.Dropdown(
190
- label="Score data to display", choices=SCORE_COLUMNS, multiselect=False
191
  )
192
  correlation_plot = gr.Plot(label="Correlation with binding affinity")
193
 
@@ -196,12 +196,12 @@ def create_correlation_tab():
196
  spr_data_with_scores, SCORE_COLUMNS, ["Antibody Name", "KD (nM)"]
197
  ),
198
  inputs=None,
199
- outputs=[prediction_dataframe, correlation_ranking_plot],
200
  )
201
 
202
  # Call function to update the correlation plot when the user selects the columns
203
  correlation_column.change(
204
- fn=lambda score: select_correlation_plot(spr_data_with_scores, score),
205
  inputs=correlation_column,
206
  outputs=correlation_plot,
207
  )
 
10
  from folding_studio_demo.correlate import (
11
  SCORE_COLUMNS,
12
  fake_predict_and_correlate,
13
+ make_correlation_plot,
14
  )
15
  from folding_studio_demo.predict import predict, predict_comparison
16
 
 
187
  with gr.Row():
188
  # User can select the columns to display in the correlation plot
189
  correlation_column = gr.Dropdown(
190
+ label="Score data to display", choices=SCORE_COLUMNS, multiselect=False, value=SCORE_COLUMNS[0]
191
  )
192
  correlation_plot = gr.Plot(label="Correlation with binding affinity")
193
 
 
196
  spr_data_with_scores, SCORE_COLUMNS, ["Antibody Name", "KD (nM)"]
197
  ),
198
  inputs=None,
199
+ outputs=[prediction_dataframe, correlation_ranking_plot, correlation_plot],
200
  )
201
 
202
  # Call function to update the correlation plot when the user selects the columns
203
  correlation_column.change(
204
+ fn=lambda score: make_correlation_plot(spr_data_with_scores, score),
205
  inputs=correlation_column,
206
  outputs=correlation_plot,
207
  )
folding_studio_demo/correlate.py CHANGED
@@ -68,9 +68,11 @@ def fake_predict_and_correlate(spr_data_with_scores: pd.DataFrame, score_cols: l
68
  cols_to_show = main_cols[:]
69
  cols_to_show.extend(score_cols)
70
 
71
- return spr_data_with_scores[cols_to_show].round(2), corr_ranking_plot
72
 
73
- def select_correlation_plot(spr_data_with_scores: pd.DataFrame, score: str) -> go.Figure:
 
 
74
  """Select the correlation plot to display."""
75
  # corr_plot is a scatter plot of the correlation between the binding affinity and each of the scores
76
  scatter = go.Scatter(
 
68
  cols_to_show = main_cols[:]
69
  cols_to_show.extend(score_cols)
70
 
71
+ corr_plot = make_correlation_plot(spr_data_with_scores, score_cols[0])
72
 
73
+ return spr_data_with_scores[cols_to_show].round(2), corr_ranking_plot, corr_plot
74
+
75
+ def make_correlation_plot(spr_data_with_scores: pd.DataFrame, score: str) -> go.Figure:
76
  """Select the correlation plot to display."""
77
  # corr_plot is a scatter plot of the correlation between the binding affinity and each of the scores
78
  scatter = go.Scatter(