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

I have a python cell in my Quarto notebook like:

#| echo: false

print(type(run_fastqc))
if run_fastqc:
    print(run_fastqc)
    fastqc_seqgc_plot = multiqc.get_plot("fastqc", "Per Sequence GC Content")
    fastqc_seqgc_plot.show()

However the plot is not showing up. The panel only shows:

<class 'bool'>
True

If I move the plot to outside the if statement

#| echo: false

print(type(run_fastqc))
if run_fastqc:
    print(run_fastqc)

fastqc_seqgc_plot = multiqc.get_plot("fastqc", "Per Sequence GC Content")
fastqc_seqgc_plot.show()

The plot shows up. Am I doing something silly (I have little understanding of python) or is this a bug?

Repo with reproducible example:GitHub - mahesh-panchal/nextflow-quarto-multiqc-demo: Using Quarto within Nextflow to make a MultiQC report

Open in Gitpod and use

pixi run nextflow

The last process makes the quarto notebook. The qmd is located in docs/multiqc_report. The html is written to results/report.

It seems using a ternary conditional is the solution here ( even with MultiQC 1.25 )

#| echo: false

# Have to use the ternary style syntax for if to make the plot show
# This doesn't work!
# if run_fastqc:
#     multiqc.get_plot("fastqc", "Sequence Counts").show()
# This does!
multiqc.get_plot("fastqc", "Sequence Counts").show() if run_fastqc else ""
1 Like

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