improve corr plot
Browse files
folding_studio_demo/app.py
CHANGED
@@ -178,7 +178,7 @@ def create_correlation_tab():
|
|
178 |
correlation_plot = gr.Plot(label="Correlation with binding affinity")
|
179 |
|
180 |
fake_predict_btn.click(
|
181 |
-
fn=lambda x: fake_predict_and_correlate(spr_data_with_scores, SCORE_COLUMNS),
|
182 |
inputs=None,
|
183 |
outputs=[prediction_dataframe, correlation_ranking_plot]
|
184 |
)
|
|
|
178 |
correlation_plot = gr.Plot(label="Correlation with binding affinity")
|
179 |
|
180 |
fake_predict_btn.click(
|
181 |
+
fn=lambda x: fake_predict_and_correlate(spr_data_with_scores, SCORE_COLUMNS, ["Antibody Name", "KD (nM)"]),
|
182 |
inputs=None,
|
183 |
outputs=[prediction_dataframe, correlation_ranking_plot]
|
184 |
)
|
folding_studio_demo/correlate.py
CHANGED
@@ -30,7 +30,7 @@ SCORE_COLUMNS = [
|
|
30 |
"interface_ptm_multimer"
|
31 |
]
|
32 |
|
33 |
-
def fake_predict_and_correlate(spr_data_with_scores: pd.DataFrame, score_cols: list[str]) -> tuple[pd.DataFrame, go.Figure]:
|
34 |
"""Fake predict structures of all complexes and correlate the results."""
|
35 |
corr_data = []
|
36 |
spr_data_with_scores["log_kd"] = np.log10(spr_data_with_scores["KD (nM)"])
|
@@ -65,7 +65,7 @@ def fake_predict_and_correlate(spr_data_with_scores: pd.DataFrame, score_cols: l
|
|
65 |
showlegend=False
|
66 |
)
|
67 |
|
68 |
-
cols_to_show = [
|
69 |
cols_to_show.extend(score_cols)
|
70 |
|
71 |
return spr_data_with_scores[cols_to_show].round(2), corr_ranking_plot
|
@@ -78,13 +78,21 @@ def select_correlation_plot(spr_data_with_scores: pd.DataFrame, score: str) -> g
|
|
78 |
y=spr_data_with_scores[score],
|
79 |
name=f"KD (nM) vs {score}",
|
80 |
mode='markers', # Only show markers/dots, no lines
|
81 |
-
hovertemplate="<i>Score:</i> %{y}<br><i>KD:</i> %{x:.2f}<br>"
|
|
|
82 |
)
|
83 |
corr_plot = go.Figure(data=scatter)
|
84 |
corr_plot.update_layout(
|
85 |
xaxis_title="KD (nM)",
|
86 |
yaxis_title=score,
|
87 |
template="simple_white",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# xaxis_type="log" # Set x-axis to logarithmic scale
|
89 |
)
|
90 |
# compute the correlation line
|
@@ -96,6 +104,7 @@ def select_correlation_plot(spr_data_with_scores: pd.DataFrame, score: str) -> g
|
|
96 |
x=corr_line_x,
|
97 |
y=corr_line_y,
|
98 |
mode='lines',
|
99 |
-
name=f"Correlation
|
|
|
100 |
))
|
101 |
return corr_plot
|
|
|
30 |
"interface_ptm_multimer"
|
31 |
]
|
32 |
|
33 |
+
def fake_predict_and_correlate(spr_data_with_scores: pd.DataFrame, score_cols: list[str], main_cols: list[str]) -> tuple[pd.DataFrame, go.Figure]:
|
34 |
"""Fake predict structures of all complexes and correlate the results."""
|
35 |
corr_data = []
|
36 |
spr_data_with_scores["log_kd"] = np.log10(spr_data_with_scores["KD (nM)"])
|
|
|
65 |
showlegend=False
|
66 |
)
|
67 |
|
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
|
|
|
78 |
y=spr_data_with_scores[score],
|
79 |
name=f"KD (nM) vs {score}",
|
80 |
mode='markers', # Only show markers/dots, no lines
|
81 |
+
hovertemplate="<i>Score:</i> %{y}<br><i>KD:</i> %{x:.2f}<br>",
|
82 |
+
marker=dict(color='#1f77b4') # Set color to match default first color
|
83 |
)
|
84 |
corr_plot = go.Figure(data=scatter)
|
85 |
corr_plot.update_layout(
|
86 |
xaxis_title="KD (nM)",
|
87 |
yaxis_title=score,
|
88 |
template="simple_white",
|
89 |
+
legend=dict(
|
90 |
+
orientation="h",
|
91 |
+
yanchor="bottom",
|
92 |
+
y=1.02,
|
93 |
+
xanchor="right",
|
94 |
+
x=1
|
95 |
+
)
|
96 |
# xaxis_type="log" # Set x-axis to logarithmic scale
|
97 |
)
|
98 |
# compute the correlation line
|
|
|
104 |
x=corr_line_x,
|
105 |
y=corr_line_y,
|
106 |
mode='lines',
|
107 |
+
name=f"Correlation",
|
108 |
+
line=dict(color='#1f77b4') # Set same color as scatter points
|
109 |
))
|
110 |
return corr_plot
|