Snakebutt Mac OS
Here we provide a short tutorial that guides you through the main features of Snakemake.Note that this is not suited to learn Snakemake from scratch, rather to give a first impression.To really learn Snakemake (starting from something simple, and extending towards advanced features), use the main Snakemake Tutorial.
All products from the Snake Bite Company - 100% made in the USA. Custom options available. SUBSCRIBE: guys asked for a new LittleBigSnake.io video and here it is! This time the Happy Hamburger Snake eats so much he transfo.
You play as a snake's butt. You head has a nose, so it can find its way to food, so you can follow the head to get fed, but you can also choose to not follow the head, if it's heading into danger. Sometimes, it's best not to follow mindlessly, but to take control and avoid. As you can see, instead of writing a command line parser for passing parameters like input and output files, you have direct access to the properties of the rule via a magic snakemake object, that Snakemake automatically inserts into the script before executing the rule. Finally, we have to define a conda environment for the rule, say envs/stats.yaml, that provides the required Python.
This document shows all steps performed in the official Snakemake live demo,such that it becomes possible to follow them at your own pace.Solutions to each step can be found at the bottom of this document.
The examples presented in this tutorial come from Bioinformatics.However, Snakemake is a general-purpose workflow management system for any discipline.For an explanation of the steps you will perform here, have a look at Background.More thorough explanations are provided in the full Snakemake Tutorial.
Prerequisites¶
First, install Snakemake via Conda, as outlined in Installation via Conda/Mamba.The minimal version of Snakemake is sufficient for this demo.
Second, download and unpack the test data needed for this example fromhere,e.g., via
Step 1¶
First, create an empty workflow in the current directory with:
Once a Snakefile is present, you can perform a dry run of Snakemakewith:
Since the Snakefile is empty, it will report that nothing has to bedone. In the next steps, we will gradually fill the Snakefile with anexample analysis workflow.
Step 2¶
The data folder in your working directory looks as follows:
You will create a workflow that maps the sequencing samples in thedata/samples
folder to the reference genome data/genome.fa
.Then, you will call genomic variants over the mapped samples, and createan example plot.
First, create a rule called bwa
, with input files
data/genome.fa
data/samples/A.fastq
and output file
mapped/A.bam
To generate output from input, use the shell command
Providing a shell command is not enough to run your workflow on anunprepared system. For reproducibility, you also have to provide therequired software stack and define the desired version. This can be donewith the Conda package manager, which is directlyintegrated with Snakemake: add a directiveconda:'envs/mapping.yaml'
that points to a Conda environmentdefinition,with the following content
Upon execution, Snakemake will automatically create that environment,and execute the shell command within.
Now, test your workflow by simulating the creation of the filemapped/A.bam
via
to perform a dry-run and
to perform the actual execution.
Step 3¶
Now, generalize the rule bwa
by replacing the concrete sample nameA
with a wildcard {sample}
in input and output file the rulebwa
. This way, Snakemake can apply the rule to map any of the threeavailable samples to the reference genome.
Test this by creating the file mapped/B.bam
.
Step 4¶
Next, create a rule sort
that sorts the obtained .bam
file bygenomic coordinate. The rule should have the input file
mapped/{sample}.bam
and the output file
mapped/{sample}.sorted.bam
and uses the shell command
to perform the sorting. Moreover, use the same conda:
directive asfor the previous rule.
Test your workflow with
and
Step 5¶
Now, we aggregate over all samples to perform a joint calling of genomicvariants. First, we define a variable
at the top of the Snakefile
. This serves as a definition of thesamples over which we would want to aggregate. In real life, you wouldwant to use an external sample sheet or a configfilefor things like this.
For aggregation over many files, Snakemake provides the helper functionexpand
(see thedocs).Create a rule call
with input files
fa='data/genome.fa'
bam=expand('mapped/{sample}.sorted.bam',sample=samples)
output file
'calls/all.vcf'
and shell command
Further, define a new conda environment file with the following content:
Step 6¶
Finally, we strive to calculate some exemplary statistics. This time, wedon’t use a shell command, but rather employ Snakemake’s ability tointegrate with scripting languages like R and Python.
First, we create a rule stats
with input file
'calls/all.vcf'
and output file
'plots/quals.svg'
.
Instead of a shell command, we write
and create the corresponding script and its containing folder in ourworking directory with
We open the script in the editor and add the following content
As you can see, instead of writing a command line parser for passingparameters like input and output files, you have direct access to theproperties of the rule via a magic snakemake
object, that Snakemakeautomatically inserts into the script before executing the rule.
Finally, we have to define a conda environment for the rule, sayenvs/stats.yaml
, that provides the required Python packages toexecute the script:
Make sure to test your workflow with
Step 7¶
So far, we have always specified a target file at the command line wheninvoking Snakemake. When no target file is specified, Snakemake tries toexecute the first rule in the Snakefile
. We can use this property todefine default target files.
At the top of your Snakefile
define a rule all
, with input files
'calls/all.vcf'
'plots/quals.svg'
and neither a shell command nor output files. This rule simply serves asan indicator of what shall be collected as results.
Step 8¶
As a last step, we strive to annotate our workflow with some additionalinformation.
Automatic reports¶
Snakemake can automatically create HTML reports with
Such a report contains runtime statistics, a visualization of theworkflow topology, used software and data provenance information.
In addition, you can mark any output file generated in your workflow forinclusion into the report. It will be encoded directly into the report,such that it can be, e.g., emailed as a self-contained document. Thereader (e.g., a collaborator of yours) can at any time download theenclosed results from the report for further use, e.g., in a manuscriptyou write together. In this example, please mark the output file'plots/quals.svg'
for inclusion by replacing it withreport('plots/quals.svg',caption='report/calling.rst')
and adding afile report/calling.rst
, containing some description of the outputfile. This description will be presented as caption in the resultingreport.
Threads¶
The first rule bwa
can in theory use multiple threads. You can makeSnakemake aware of this, such that the information can be used forscheduling. Add a directive threads:8
to the rule and alter theshell command to
Snakebutt Mac Os Catalina
This passes the threads defined in the rule as a command line argumentto the bwa
process.
Temporary files¶
The output of the bwa
rule becomes superfluous once the sortedversion of the .bam
file is generated by the rule sort
.Snakemake can automatically delete the superfluous output once it is notneeded anymore. For this, mark the output as temporary by replacing'mapped/{sample}.bam'
in the rule bwa
withtemp('mapped/{sample}.bam')
.
Solutions¶
Only read this if you have a problem with one of the steps.
Step 2¶
The rule should look like this:
Step 3¶
The rule should look like this:
Step 4¶
The rule should look like this:
Step 5¶
The rule should look like this:
Step 6¶
The rule should look like this:
Step 7¶
The rule should look like this:
It has to appear as first rule in the Snakefile
.
Step 8¶
The complete workflow should look like this:
'A snake's butt is his conscience and his only companion.' --Descartes
You play as a snake's butt. You head has a nose, so it can find its way to food, so you can follow the head to get fed, but you can also choose to not follow the head, if it's heading into danger. Sometimes, it's best not to follow mindlessly, but to take control and avoid disaster.
Status | Released |
Platforms | Windows, macOS, Linux |
Author | spill |
Genre | Puzzle |
Tags | Arcade, snake |
Install instructions
Snakebutt Mac Os Update
The game runs on the LÖVE game engine, which can be downloaded at https://love2d.org/
Download
Log in with itch.io to leave a comment.
Love the idea. The head is so stupid though :D (0:30)