Skip to content

Commit a8ae914

Browse files
authored
Merge pull request #18 from PRIDE-Archive/dev
Remove titles from the subplots
2 parents c6b490a + 0deadff commit a8ae914

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/pyprideap/viz/qc/report.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ def qc_report(
13341334
dataset: AffinityDataset,
13351335
output: str | Path,
13361336
sdrf_path: str | Path | None = None,
1337+
strip_plot_title: bool = True,
13371338
) -> Path:
13381339
"""Generate a complete QC HTML report for the dataset.
13391340
@@ -1347,6 +1348,10 @@ def qc_report(
13471348
Optional path to an SDRF TSV file. When provided, differential
13481349
expression volcano plots are added to the report with an
13491350
interactive dropdown to select the grouping variable.
1351+
strip_plot_title : bool
1352+
Remove the Plotly figure title from each plot (default ``True``).
1353+
The card header already displays the title, so the in-plot title
1354+
is redundant. Set to ``False`` to keep the Plotly title.
13501355
"""
13511356
try:
13521357
import plotly # noqa: F401
@@ -1408,7 +1413,7 @@ def qc_report(
14081413

14091414
if pca_data is not None:
14101415
pca_fig = R.render_pca(pca_data)
1411-
pca_fig.update_layout(height=500)
1416+
pca_fig.update_layout(title="" if strip_plot_title else pca_data.title, height=500)
14121417
_compact_fig(pca_fig)
14131418
js = "cdn" if need_plotly_cdn else False
14141419
need_plotly_cdn = False # only include CDN once
@@ -1417,7 +1422,7 @@ def qc_report(
14171422

14181423
if umap_data is not None:
14191424
tsne_fig = R.render_tsne(umap_data)
1420-
tsne_fig.update_layout(height=500)
1425+
tsne_fig.update_layout(title="" if strip_plot_title else umap_data.title, height=500)
14211426
_compact_fig(tsne_fig)
14221427
js = "cdn" if need_plotly_cdn else False
14231428
tsne_html = tsne_fig.to_html(full_html=False, include_plotlyjs=js, default_height="500px")
@@ -1460,6 +1465,8 @@ def qc_report(
14601465
if data is None or not isinstance(data, dtype):
14611466
continue
14621467
fig = renderer(data) # type: ignore[operator]
1468+
if strip_plot_title:
1469+
fig.update_layout(title="")
14631470
# Multi-panel renderers set their own height (e.g. 800px); only
14641471
# apply the default for plots that haven't specified one.
14651472
current_height = fig.layout.height
@@ -1518,6 +1525,8 @@ def qc_report(
15181525

15191526
for comp_idx, (label, vdata) in enumerate(comparisons):
15201527
fig = R.render_volcano(vdata)
1528+
if strip_plot_title:
1529+
fig.update_layout(title="")
15211530
fig.update_layout(height=500)
15221531
_compact_fig(fig)
15231532
js_include: Any = False
@@ -1672,6 +1681,7 @@ def qc_report_split(
16721681
dataset: AffinityDataset,
16731682
output_dir: str | Path,
16741683
no_border: bool = False,
1684+
strip_plot_title: bool = True,
16751685
) -> Path:
16761686
"""Generate individual QC plot HTML files in a directory.
16771687
@@ -1734,6 +1744,8 @@ def qc_report_split(
17341744
if data is None or not isinstance(data, dtype):
17351745
continue
17361746
fig = renderer(data) # type: ignore[operator]
1747+
if strip_plot_title:
1748+
fig.update_layout(title="")
17371749
current_height = fig.layout.height
17381750
if current_height is None:
17391751
fig.update_layout(height=500)
@@ -1764,13 +1776,13 @@ def qc_report_split(
17641776

17651777
if pca_data is not None:
17661778
pca_fig = R.render_pca(pca_data)
1767-
pca_fig.update_layout(height=500)
1779+
pca_fig.update_layout(title="" if strip_plot_title else pca_data.title, height=500)
17681780
pca_html = pca_fig.to_html(full_html=False, include_plotlyjs=False, default_height="500px")
17691781
dimred_parts.append(f'<div class="dimred-panel" id="dimred-pca">{pca_html}</div>')
17701782

17711783
if umap_data is not None:
17721784
tsne_fig = R.render_tsne(umap_data)
1773-
tsne_fig.update_layout(height=500)
1785+
tsne_fig.update_layout(title="" if strip_plot_title else umap_data.title, height=500)
17741786
tsne_html = tsne_fig.to_html(full_html=False, include_plotlyjs=False, default_height="500px")
17751787
hidden = ' style="display:none"' if pca_data is not None else ""
17761788
dimred_parts.append(f'<div class="dimred-panel" id="dimred-tsne"{hidden}>{tsne_html}</div>')

0 commit comments

Comments
 (0)