ReportsΒΆ

From Snakemake 5.1 on, it is possible to automatically generate detailed self-contained HTML reports that encompass runtime statistics, provenance information, workflow topology and results. For the latter, the Snakefile has to be annotated with additional information. Each output file that shall be part of the report has to be marked with the report flag, which optionally points to a caption in restructured text format. Moreover, a global workflow description can be defined via the report directive. Consider the following example:

report: "report/workflow.rst"


rule all:
    input:
        ["fig1.svg", "fig2.png"]


rule c:
    output:
        "test.{i}.out"
    singularity:
        "docker://continuumio/miniconda3:4.4.10"
    conda:
        "envs/test.yaml"
    shell:
        "sleep `shuf -i 1-3 -n 1`; touch {output}"


rule a:
    input:
        expand("test.{i}.out", i=range(10))
    output:
        report("fig1.svg", caption="report/fig1.rst")
    shell:
        "sleep `shuf -i 1-3 -n 1`; cp data/fig1.svg {output}"


rule b:
    input:
        expand("test.{i}.out", i=range(10))
    output:
        report("fig2.png", caption="report/fig2.rst")
    shell:
        "sleep `shuf -i 1-3 -n 1`; cp data/fig2.png {output}"

As can be seen, we define a global description which is contained in the file report/workflow.rst. In addition, we mark fig1.svg and fig2.png for inclusion into the report, while in both cases specifying a caption text via again referring to a restructured text file. Note the paths to the .rst-files are interpreted relative to the current Snakefile. Inside the .rst-files you can use Jinja2 templating to access context information. In case of the global description, you can access the config dictionary via {{ snakemake.config }}, (e.g., use {{ snakemake.config["mykey"] }} to access the key mykey). In case of output files, you can access the same values as available with the script directive.

To create the report simply run

snakemake --report report.html

after your workflow has finished. All other information contained in the report (e.g. runtime statistics) is automatically collected during creation. These statistics are obtained from the metadata that is stored in the .snakemake directory inside your working directory. The report for above example can be found here.

Note that the report can be restricted to particular jobs and results by specifying targets at the command line, analog to normal Snakemake execution. For example, with

snakemake fig1.svg --report report-short.html

the report contains only fig1.svg.