Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -332,8 +332,8 @@ def plot_comparative_heatmap(shap_diff, seq1_length, seq2_length, title="SHAP Di
|
|
332 |
heatmap_data = shap_diff.reshape(1, -1)
|
333 |
extent = max(abs(np.min(shap_diff)), abs(np.max(shap_diff)))
|
334 |
|
335 |
-
# Create figure with additional space
|
336 |
-
fig, ax = plt.subplots(figsize=(12, 3.2))
|
337 |
|
338 |
# Plot main heatmap
|
339 |
cmap = get_zero_centered_cmap()
|
@@ -370,19 +370,22 @@ def plot_comparative_heatmap(shap_diff, seq1_length, seq2_length, title="SHAP Di
|
|
370 |
ax2.set_xticks(tick_positions)
|
371 |
ax2.set_xticklabels([f"S1: {s1}\nS2: {s2}" for s1, s2 in zip(seq1_labels, seq2_labels)])
|
372 |
|
373 |
-
# Add colorbar with
|
374 |
-
cbar = plt.colorbar(cax, orientation='horizontal', pad=0.
|
375 |
cbar.ax.tick_params(labelsize=8)
|
376 |
cbar.set_label('SHAP Difference (Seq2 - Seq1)', fontsize=9, labelpad=5)
|
377 |
|
|
|
|
|
|
|
378 |
# Adjust labels and layout
|
379 |
ax.set_yticks([])
|
380 |
-
ax.set_xlabel('Relative Position (%)', fontsize=10)
|
381 |
-
ax2.set_xlabel('Sequence Positions', fontsize=10)
|
382 |
ax.set_title(title, pad=10)
|
383 |
|
384 |
-
#
|
385 |
-
plt.subplots_adjust(bottom=0.
|
386 |
|
387 |
return fig
|
388 |
|
|
|
332 |
heatmap_data = shap_diff.reshape(1, -1)
|
333 |
extent = max(abs(np.min(shap_diff)), abs(np.max(shap_diff)))
|
334 |
|
335 |
+
# Create figure with additional space
|
336 |
+
fig, ax = plt.subplots(figsize=(12, 3.2))
|
337 |
|
338 |
# Plot main heatmap
|
339 |
cmap = get_zero_centered_cmap()
|
|
|
370 |
ax2.set_xticks(tick_positions)
|
371 |
ax2.set_xticklabels([f"S1: {s1}\nS2: {s2}" for s1, s2 in zip(seq1_labels, seq2_labels)])
|
372 |
|
373 |
+
# Add colorbar at the bottom with more spacing
|
374 |
+
cbar = plt.colorbar(cax, orientation='horizontal', pad=0.6, aspect=40, shrink=0.8)
|
375 |
cbar.ax.tick_params(labelsize=8)
|
376 |
cbar.set_label('SHAP Difference (Seq2 - Seq1)', fontsize=9, labelpad=5)
|
377 |
|
378 |
+
# Remove percentage labels from colorbar
|
379 |
+
cbar.ax.set_xticklabels([f'{x:.3f}' for x in cbar.ax.get_xticks()])
|
380 |
+
|
381 |
# Adjust labels and layout
|
382 |
ax.set_yticks([])
|
383 |
+
ax.set_xlabel('Relative Position (%)', fontsize=10, labelpad=10)
|
384 |
+
ax2.set_xlabel('Sequence Positions', fontsize=10, labelpad=10)
|
385 |
ax.set_title(title, pad=10)
|
386 |
|
387 |
+
# Increase bottom margin to prevent overlap
|
388 |
+
plt.subplots_adjust(bottom=0.55, left=0.05, right=0.95, top=0.85)
|
389 |
|
390 |
return fig
|
391 |
|