MultiQC plots in Quarto don't display generally

Related: Plot.show() in Quarto notebook after if statement is not showing

I’m trying to display plots in a html report generated by Quarto, but they don’t render. I’ve tried several things with the syntax, and also changing the renderer via .show() and setting the plotly.io default renderer, but those don’t work either.

[ multiqc.get_plot("busco", f"{lineage}").show() if run_busco else "" for lineage in multiqc.list_plots()["busco"] ]

And the keys vary depending on the input so I can’t access the plots one by one.

Can the .show() or some function return html ?

Toy

report.qmd:

---
title: "Quarto MultiQC demo"

format:
  html:
    embed-resources: true
---

```{python}
#| echo: false
#| tags: [parameters]

log_path = 'log_files'
```

```{python}
#| output: true
import multiqc
from pprint import pprint

multiqc.reset() # Important for Quarto preview
# The path appears to be relative to the current notebook location.
multiqc.parse_logs(log_path)
```

## Busco

Plot each busco lineage output

```{python}
[ multiqc.get_plot("busco", f"{lineage}").show() if run_busco else "" for lineage in multiqc.list_plots()["busco"] ]
```

short_summary.specific.bacteria_odb10.genome.fna.txt:

# BUSCO version is: 5.7.1 
# The lineage dataset is: bacteria_odb10 (Creation date: 2024-01-08, number of genomes: 4085, number of BUSCOs: 124)
# Summarized benchmarking in BUSCO notation for file /workspace/nextflow-quarto-multiqc-demo/work/79/bbd01e1f3e73905544d9ec11f1d329/input_seqs/genome.fna
# BUSCO was run in mode: prok_genome_prod
# Gene predictor used: prodigal

	***** Results: *****

	C:98.4%[S:97.6%,D:0.8%],F:1.6%,M:0.0%,n:124	   
	122	Complete BUSCOs (C)			   
	121	Complete and single-copy BUSCOs (S)	   
	1	Complete and duplicated BUSCOs (D)	   
	2	Fragmented BUSCOs (F)			   
	0	Missing BUSCOs (M)			   
	124	Total BUSCO groups searched		   

Assembly Statistics:
	1	Number of scaffolds
	1	Number of contigs
	1890469	Total length
	0.000%	Percent gaps
	1 MB	Scaffold N50
	1 MB	Contigs N50


Dependencies and versions:
	hmmsearch: 3.1
	bbtools: 39.01
	prodigal: 2.6.3
	python: sys.version_info(major=3, minor=9, micro=19, releaselevel='final', serial=0)
	busco: 5.7.1

Seems I need to force it to display ( after rummaging through the code to see show() returned a HTML object )

```{python}
from IPython.core.display import display
if run_busco:
    for lineage in multiqc.list_plots()["busco"]:
        display(multiqc.get_plot("busco", f"{lineage}").show())
```
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

This is a related question to Plot.show() in Quarto notebook after if statement is not showing - #4 by vlad.savelyev - responded there! Basically you are correct, the Jupyter’s built-in display is needed to be called, as show only outputs HTML, but it can’t tell Jupyter to display things.

Updated the documentation to make it more clear: Document use of display to show plots in notebooks by vladsavelyev · Pull Request #2938 · MultiQC/MultiQC · GitHub