Maximilian Zinke commited on
Commit Β·
af2fccd
1
Parent(s): 9c0592a
feat(ui): rename residual-SS tabs, add "when to use" captions, stacked-bar figure
Browse filesRenames tabs to disambiguate the three SS readouts:
"Residual SS β geometric (IDP fingerprint)" -> "Basin sampling (Ο/Ο fingerprint)"
"Residual SS β structural (d2D-style)" -> "Cooperative SS β retrieval-based"
Adds a short "When to use" caption under each tab explaining which
readout to consult for folded proteins vs IDPs vs ensemble-reweighting
work, and where each can mislead (retrieval-based cooperative mode
over-estimates helix on pure IDPs).
Figure title strings match the new tab labels.
visualization.plot_residual_ss is now a single stacked-bar track per
row (Ξ±/Ξ²/PPII/other stacked bottom-up, total height 1.0) instead of
four tracks β denser and easier to read as a per-residue mixture.
Files changed (2)
- app.py+30-4
- facet/visualization.py+38-51
685 unmodified lines68668768868969069169213 unmodified lines706707708709710711712285 unmodified lines9989991000100110021003100410051006100710081009101010111012101310141015685 unmodified linestry:fig_residual = plot_residual_ss(result, residual_path, mode="geometric",title=f"Residual SS populations (geometric basins) β {input_label}",)plt.close(fig_residual)except Exception as e:13 unmodified linestry:fig_struct = plot_residual_ss(result, residual_struct_path, mode="structural",title=f"Structural SS populations (d2D-style) β {input_label}",)plt.close(fig_struct)except Exception as e:285 unmodified lines# IDPs and flexible regions). Users switch via tabs.with gr.Tabs():with gr.TabItem("Sequence + SS"):sequence_plot = gr.Image(label="",interactive=False,show_label=False,)with gr.TabItem("Residual SS β geometric (IDP fingerprint)"):residual_plot = gr.Image(label="",interactive=False,show_label=False,)with gr.TabItem("Residual SS β structural (d2D-style)"):residual_struct_plot = gr.Image(label="",interactive=False,685 unmodified lines68668768868969069169213 unmodified lines706707708709710711712285 unmodified lines998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041685 unmodified linestry:fig_residual = plot_residual_ss(result, residual_path, mode="geometric",title=f"Basin sampling (Ο/Ο fingerprint) β {input_label}",)plt.close(fig_residual)except Exception as e:13 unmodified linestry:fig_struct = plot_residual_ss(result, residual_struct_path, mode="structural",title=f"Cooperative SS β retrieval-based β {input_label}",)plt.close(fig_struct)except Exception as e:285 unmodified lines# IDPs and flexible regions). Users switch via tabs.with gr.Tabs():with gr.TabItem("Sequence + SS"):gr.Markdown("**When to use:** folded / well-structured proteins. ""Shows the canonical H/E/C cartoon along the sequence. ""Degenerates to mostly-C on IDPs β use the other tabs there.")sequence_plot = gr.Image(label="",interactive=False,show_label=False,)with gr.TabItem("Basin sampling (Ο/Ο fingerprint)"):gr.Markdown("**When to use:** IDPs and ensemble reweighting ""(BME / ENSEMBLE / flexible-meccano). Shows which ""Ramachandran region the retrieved neighbours fall ""in per residue β Ξ±_R / Ξ² / PPII / other. ""Reads transient-helix propensity directly off the ""Ξ± column. **This is the honest per-residue ""conformational fingerprint, not a cooperative-SS ""claim.**")residual_plot = gr.Image(label="",interactive=False,show_label=False,)with gr.TabItem("Cooperative SS β retrieval-based"):gr.Markdown("**When to use:** cross-check against published ""Gaussian / HMM SS-population tools on folded or ""partially-folded samples. Kernel-weighted Bayesian ""posterior over DSSP-state labels from the 220 K ""reference index. On pure IDPs this mode slightly ""over-estimates helix (neighbour DSSP labels carry ""folded-protein context) β compare against the ""Gaussian FACET-D2 number shown in the per-residue ""inspector for a retrieval-free cross-check.")residual_struct_plot = gr.Image(label="",interactive=False,
683 unmodified lines6846856866876886896906916922 unmodified lines6956966976986997007017027037047057067077087097107117127137147152 unmodified lines71871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875918 unmodified lines7787797807817827837847854 unmodified lines790791792793794795796797798799800801802803804805806807808683 unmodified linesother_arr[pos] = on_rows = math.ceil(total_positions / residues_per_row)# Match plot_sequence_ss row-height budget so the two figures visually# stack at the same cadence.row_height_in = 1.6fig, axes = plt.subplots(n_rows, 1,2 unmodified lines)axes = axes.flatten()# Track layout inside each row: four tracks stacked vertically with# a small gap, each track 1.0 unit tall. Y_SEQ/Y_NUM mirror the# sequence-plot offsets so the two figures line up visually._labels_for_mode = (BASIN_LABELS_STRUCT if mode == "structural" else BASIN_LABELS_GEOM)track_order = ["other", "ppii", "beta", "alpha"]TRACK_HEIGHT = 1.0TRACK_GAP = 0.15track_bases = {name: i * (TRACK_HEIGHT + TRACK_GAP) for i, name in enumerate(track_order)}Y_TOP = track_bases["alpha"] + TRACK_HEIGHTY_SEQ_IDP = -0.7Y_NUM_IDP = -1.35for row_idx in range(n_rows):ax = axes[row_idx]2 unmodified linesrow_len = p1 - p0xs = np.arange(row_len)for name, values in [("alpha", alpha_arr),("beta", beta_arr),("ppii", ppii_arr),("other", other_arr),]:color = BASIN_COLORS[name]base = track_bases[name]vals = values[p0:p1]heights = np.where(np.isnan(vals), 0.0, vals)ax.bar(xs, heights,width=0.82, # match sequence-plot bar widthbottom=base,color=color,edgecolor="none",zorder=2,)# Track baselineax.plot([-0.5, row_len - 0.5], [base, base],color="#D5D8DC", linewidth=0.7, zorder=1,)# Track label β match sequence-plot label font size (9, bold)ax.text(-1.5, base + TRACK_HEIGHT / 2, _labels_for_mode[name],ha="right", va="center",fontsize=9, fontweight="bold",color=color,)# Sequence letters β match plot_sequence_ss exactly:# assigned residue β bold one-letter code in near-black# unassigned (gap) β one-letter code in light gray if a# reader-supplied sequence is available,# else a dot placeholder. Also in light gray.for i, pos in enumerate(range(p0, p1)):r = position_to_residue.get(pos)if r is None:18 unmodified linescolor=COLOR_SEQ,)# Residue numbers β same cadence + style as plot_sequence_ss# (every 10 + row termini).for i, pos in enumerate(range(p0, p1)):seq_id = pos + seq_id_baseif seq_id % 10 == 0 or i == 0 or i == row_len - 1:4 unmodified linescolor=COLOR_NUM,)# Keep the x-range identical across rows so the two figures align# when stacked (partial last row β short content but full x-extent).ax.set_xlim(-2.5, residues_per_row)ax.set_ylim(Y_NUM_IDP - 0.25, Y_TOP + 0.15)ax.axis("off")if title is None:source = result.source or "FACET"mode_suffix = ("structural (d2D-style)" if mode == "structural" else "geometric basins")title = (f"Residual SS populations ({mode_suffix}) β "f"{Path(source).stem if source else 'prediction'}")# Match plot_sequence_ss title styling.683 unmodified lines6846856866876886896906916922 unmodified lines6956966976986997007017027037047057067077087097107117127137142 unmodified lines71771871972072172272372472572672772872973073173273373473573673773873974074174274374474574618 unmodified lines7657667677687697707714 unmodified lines776777778779780781782783784785786787788789790791792793794795683 unmodified linesother_arr[pos] = on_rows = math.ceil(total_positions / residues_per_row)# Stacked-bar layout is more compact than the old 4-track version β# one track per row instead of four β so row height shrinks accordingly.row_height_in = 0.95fig, axes = plt.subplots(n_rows, 1,2 unmodified lines)axes = axes.flatten()# Single stacked-bar track per row: each residue is one vertical bar# of total height 1.0, segmented by basin fraction (alpha at bottom,# then beta, PPII, other at top). The stack order is the d2D/CheSPI# convention β alpha/beta are the "structured" fractions, PPII and# other are the "flexible" fractions, so they read bottom-up from# structured to flexible._labels_for_mode = (BASIN_LABELS_STRUCT if mode == "structural" else BASIN_LABELS_GEOM)STACK_ORDER = ("alpha", "beta", "ppii", "other")STACK_HEIGHT = 1.0Y_TOP = STACK_HEIGHTY_SEQ_IDP = -0.32Y_NUM_IDP = -0.72for row_idx in range(n_rows):ax = axes[row_idx]2 unmodified linesrow_len = p1 - p0xs = np.arange(row_len)# Draw stacked bars, alpha at the bottom.bottom = np.zeros(row_len, dtype=np.float64)arr_by_name = {"alpha": alpha_arr, "beta": beta_arr,"ppii": ppii_arr, "other": other_arr}for name in STACK_ORDER:vals = arr_by_name[name][p0:p1]heights = np.where(np.isnan(vals), 0.0, vals)ax.bar(xs, heights,width=0.9, # wider bars (one track means no stacking gap)bottom=bottom,color=BASIN_COLORS[name],edgecolor="none",zorder=2,)bottom = bottom + heights# Light baseline under the bar band.ax.plot([-0.5, row_len - 0.5], [0.0, 0.0],color="#D5D8DC", linewidth=0.7, zorder=1,)# Sequence letters below the bar band.for i, pos in enumerate(range(p0, p1)):r = position_to_residue.get(pos)if r is None:18 unmodified linescolor=COLOR_SEQ,)# Residue numbers β every 10 + row termini.for i, pos in enumerate(range(p0, p1)):seq_id = pos + seq_id_baseif seq_id % 10 == 0 or i == 0 or i == row_len - 1:4 unmodified linescolor=COLOR_NUM,)# Keep x-range identical across rows so partial last row aligns.ax.set_xlim(-2.5, residues_per_row)ax.set_ylim(Y_NUM_IDP - 0.18, Y_TOP + 0.08)ax.axis("off")if title is None:source = result.source or "FACET"mode_suffix = ("Cooperative SS β retrieval-based"if mode == "structural"else "Basin sampling (Ο/Ο fingerprint)")title = (f"{mode_suffix} β "f"{Path(source).stem if source else 'prediction'}")# Match plot_sequence_ss title styling.
app.py+30-4
facet/visualization.py+38-51