You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/snakefiles/deployment.rst
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,8 +285,12 @@ At the moment, only a single, random conda environment is shown.
285
285
286
286
.. note::
287
287
288
-
Note that conda environments are only used with ``shell``, ``script``, ``notebook`` and the ``wrapper`` directive, not the ``run`` directive.
289
-
The reason is that the ``run`` directive has access to the rest of the Snakefile (e.g. globally defined variables) and therefore must be executed in the same process as Snakemake itself. If used with ``notebook`` directive, the associated conda environment should have package ``jupyter`` installed (this package contains dependencies required to execute the notebook).
288
+
Note that conda environments can be used with the ``shell``, ``script``, ``notebook``, ``wrapper`` and ``run`` directives.
289
+
290
+
However, the ``run`` directive is a special case, as it has access to the rest of the Snakefile (e.g. globally defined variables) and therefore must be executed in the same process as Snakemake itself.
291
+
The ``conda`` directive for rules with a ``run`` directive therefore only affects ``shell`` function calls that are executed from the within ``run`` script.
292
+
293
+
If used with ``notebook`` directive, the associated conda environment should have package ``jupyter`` installed (this package contains dependencies required to execute the notebook).
290
294
291
295
Further, note that search path modifying environment variables like ``R_LIBS`` and ``PYTHONPATH`` can interfere with your conda environments.
292
296
Therefore, Snakemake automatically deactivates them for a job when a conda environment definition is used.
@@ -457,8 +461,10 @@ Defining global container images
457
461
458
462
.. note::
459
463
460
-
Note that apptainer integration is only used with ``shell``, ``script`` and the ``wrapper`` directive, not the ``run`` directive.
461
-
The reason is that the ``run`` directive has access to the rest of the Snakefile (e.g. globally defined variables) and therefore must be executed in the same process as Snakemake itself.
464
+
Note that apptainer integration can be used with the ``shell``, ``script``, ``wrapper`` and ``run`` directives.
465
+
466
+
However, the ``run`` directive is a special case, as it has access to the rest of the Snakefile (e.g. globally defined variables) and therefore must be executed in the same process as Snakemake itself.
467
+
The ``container`` directive for rules with a ``run`` directive therefore only affects ``shell`` function calls that are executed from within the ``run`` script.
462
468
463
469
A global definition of a container image can be given:
Copy file name to clipboardExpand all lines: docs/snakefiles/reporting.rst
+68-18Lines changed: 68 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,17 @@
4
4
Reports
5
5
=======
6
6
7
-
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.
7
+
From Snakemake 5.1 on, it is possible to automatically generate detailed self-contained HTML reports that you can easily move and share.
8
+
They encompass runtime statistics, provenance information and workflow topology by default, and workflow developers can also specify and annotate results for inclusion.
9
+
For smaller default reports, these can be a single :ref:`snakefiles-self_contained_html_file`.
10
+
For more complex reports, one can generate a :ref:`snakefiles-self_contained_zip_archive`, with a contained ``report.html`` as the main entry point.
8
11
**As an example, the report of the Snakemake rolling paper can be found** `here <https://snakemake.github.io/resources/report.html>`__.
9
12
13
+
.. _snakefiles-including_results_in_a_report:
14
+
15
+
Including results in a report
16
+
-----------------------------
17
+
10
18
For including results into the report, the Snakefile has to be annotated with additional information.
11
19
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 <https://docutils.sourceforge.io/docs/user/rst/quickstart.html>`_ and allows to define a ``category`` for grouping purposes.
12
20
Moreover, a global workflow description can be defined via the ``report`` directive.
@@ -94,7 +102,7 @@ This works as follows:
94
102
"""
95
103
96
104
Defining file labels
97
-
--------------------
105
+
^^^^^^^^^^^^^^^^^^^^
98
106
99
107
In addition to category, and subcategory, it is possible (and highly recommended!) to define a dictionary of labels for each report item.
100
108
By that, the actual filename will be hidden in the report and instead a table with the label keys as columns and the values in the respective row for the file will be displayed.
@@ -131,17 +139,17 @@ This behavior can be used to, for example, switch between different versions of
131
139
132
140
133
141
Determining category, subcategory, and labels dynamically via functions
Similar to e.g. with input file and parameter definition (see :ref:`snakefiles-input_functions`), ``category`` and a ``subcategory`` and ``labels`` can be specified by pointing to a function that takes ``wildcards`` as the first argument (and optionally in addition ``input``, ``output``, ``params`` in any order).
137
145
The function is expected to return a string or number (int, float, numpy types), or, in case of labels, a dict with strings as keys and strings or numbers as values.
138
146
139
147
140
148
Linking between items
141
-
---------------------
149
+
^^^^^^^^^^^^^^^^^^^^^
142
150
143
151
From captions
144
-
^^^^^^^^^^^^^
152
+
"""""""""""""
145
153
146
154
In every ``.rst`` document (i.e. in the captions), you can link to
147
155
@@ -153,7 +161,7 @@ In every ``.rst`` document (i.e. in the captions), you can link to
153
161
For details about the hyperlink mechanism of restructured text see `here <https://docutils.sourceforge.io/docs/user/rst/quickref.html#hyperlink-targets>`__.
154
162
155
163
From results
156
-
^^^^^^^^^^^^
164
+
""""""""""""
157
165
158
166
From within results that are included into the report, you can link to other report items.
159
167
This works by using the ``snakemake.report_href()`` method that is available from within :ref:`python scripts <snakefiles-external_scripts>`.
@@ -246,36 +254,78 @@ Further, using ``url_args()`` you can add URL arguments and using ``anchor()`` y
246
254
file=f,
247
255
)
248
256
257
+
.. _snakefiles-rendering_reports:
258
+
249
259
Rendering reports
250
260
-----------------
251
261
252
-
To create the report simply run
262
+
All the metadata contained in the report (e.g. runtime statistics) are automatically collected during the rendering of the report.
263
+
These statistics are obtained from the metadata that is stored in the ``.snakemake`` directory inside your working directory.
264
+
265
+
.. _snakefiles-self_contained_html_file:
266
+
267
+
Self-contained HTML file
268
+
^^^^^^^^^^^^^^^^^^^^^^^^
269
+
270
+
To create a default report simply run
253
271
254
272
.. code-block:: bash
255
273
256
-
snakemake --report report.html
274
+
snakemake --report
257
275
258
-
after your workflow has finished.
259
-
All other information contained in the report (e.g. runtime statistics) is automatically collected during creation.
260
-
These statistics are obtained from the metadata that is stored in the ``.snakemake`` directory inside your working directory.
276
+
after your workflow has finished successfully.
277
+
This will create a self-contained HTML report with the default filename ``report.html``.
278
+
If you want to give your report a custom name, you can do so by specifying this on the command-line:
279
+
280
+
.. code-block:: bash
281
+
282
+
snakemake --report my_report.html
283
+
284
+
As specifying an HTML file for the report will always embed any user-defined report outputs into the same HTML file, this report output type is only suitable for smaller reports.
261
285
286
+
.. _snakefiles-self_contained_zip_archive:
262
287
263
-
You can define an institute specific stylesheet with:
288
+
Self-contained ZIP archive
289
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
290
+
291
+
For anything more complex, it is recommended to generate a ``ZIP`` archive report.
292
+
For example, if you have lots of samples you report on, or if you specified lots of different workflow outputs for report inclusion.
293
+
To get such a self-contained ``ZIP`` archive, simply specify a ``.zip`` file name instead:
In particular, this allows you to e.g. set a logo at the top (by using CSS to inject a background for the placeholder ``<div id="brand">``, or overwrite colors.
270
-
For an example custom stylesheet defining the logo, see :download:`here <../../tests/test_report/custom-stylesheet.css>`.
271
-
The report for above example can be found :download:`here <../../tests/test_report/expected-results/report.html>` (with a custom branding for the University of Duisburg-Essen).
272
-
The full example source code can be found `here <https://github.com/snakemake/snakemake/tree/main/tests/test_report/>`__.
299
+
You can move this file wherever you want to view it and then unpack it right there.
300
+
This includes sending this file to collaboration partners or customers for whom you might have done an analysis.
301
+
The main entry point is always the ``report.html`` file in the main folder that this creates (for the above example, this folder will be named ``some_report``).
302
+
Just open that file in a web browser and explore your results.
273
303
274
-
Note that the report can be restricted to particular jobs and results by specifying targets at the command line, analog to normal Snakemake execution.
304
+
Partial reports
305
+
^^^^^^^^^^^^^^^
306
+
307
+
The report can be restricted to particular jobs and results by specifying targets at the command line, analog to normal Snakemake execution.
275
308
For example, with
276
309
277
310
.. code-block:: bash
278
311
279
312
snakemake fig1.svg --report report-short.html
280
313
281
314
the report contains only ``fig1.svg``.
315
+
This can be useful when a larger workflow has not yet run to completion, but you already want to explore some intermediate outputs in the report.
316
+
Or when you have multiple alternative target rules within the same workflow.
317
+
318
+
Custom layout
319
+
^^^^^^^^^^^^^
320
+
321
+
You can define an institute specific layout by providing a custom stylesheet:
For example, this allows you to set a logo at the top (by using CSS to inject a background for the placeholder ``<div id="brand">``), or overwrite colors.
328
+
329
+
For an example with a custom stylesheet defining a logo, see :download:`the report here <../../tests/test_report/expected-results/report.html>` (with a custom branding for the University of Duisburg-Essen).
330
+
For the complete mechanics, you can also have a look at the `full example source code <https://github.com/snakemake/snakemake/tree/main/tests/test_report/>`__ and :download:`the custom stylesheet with the logo definition <../../tests/test_report/custom-stylesheet.css>`.
Copy file name to clipboardExpand all lines: docs/snakefiles/rules.rst
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1631,6 +1631,27 @@ as ``"${snakemake_input[0]}"`` and ``"${snakemake_input[1]}"``.
1631
1631
1632
1632
For technical reasons, scripts are executed in ``.snakemake/scripts``. The original script directory is available as ``scriptdir`` in the ``snakemake`` object.
Because Xonsh is a superset of Python, you can use a Xonsh script as you would a Python script (see above), but with all the additional shell primitives that Xonsh provides.
0 commit comments