Many analysis pipelines are chains of scripts where each step’s outputs feed the next; running them by hand is easy to skip and hard to reproduce. Snakemake is a workflow system for reproducible, scalable data analysis: workflows are described in a human-readable, Python-based language; the same definition can scale to servers, clusters, grids, or the cloud without changing the workflow text; required software can be declared and deployed automatically; and runs can become interactive browser reports that combine results with parameters, code, and software.[1] The commands here use Snakemake 9.27.2.[1] When using Snakemake, cite the “rolling” paper: Mölder et al., 2021, Sustainable data analysis with Snakemake, F1000Research 10:33. The paper is updated as features land.[1][3] The GitHub LICENSE text is MIT (Copyright 2012–2024 The Snakemake team).[2] A first workflow starts with installation, one rule, and a dry run.[1][4][5]
Install via Pixi, Conda, or WSL on Windows
Use a terminal on Linux or macOS. For Windows, open the Setup on Windows section for platform-specific steps.[4] Snakemake is available through pixi, conda, or pip, and packaged for several Linux distributions; building from source is also possible.[4] Pixi is the recommended install: a global example is pixi global install snakemake conda -c conda-forge -c bioconda, without root; including conda keeps conda available for rule-level software via the conda directive—omit conda if you deploy software another way.[4] A directory-scoped pixi environment is also documented: pixi init in the target folder, then follow the page to add packages and pixi shell.[4] For Conda/Mamba, Miniforge is recommended; a full install example is conda create -c conda-forge -c bioconda -c nodefaults -n snakemake snakemake, then conda activate snakemake.[4] pip install snakemake is also possible.[4] On Windows 10, install WSL (Ubuntu is the popular choice), then use any of the Linux methods inside that environment.[4]
Basics: rules, wildcards, and dry-runs
A workflow lives in a Snakefile: rules break the pipeline into small steps that create sets of output files from sets of input files; Snakemake determines dependencies by matching file names.[5] The language extends Python with keyword-led blocks, either on the same line or indented.[5] The Basics example comes from genome analysis—mapping reads and calling variants—without requiring biology background.[5] The first sample rule is named bwa_map with input, output, and shell: the shell string runs bwa mem and pipes into samtools to write a compressed BAM; curly braces such as {input} and {output} refer to rule fields, and multiple inputs are joined with spaces before execution.[5] Targets can be named on the command line, for example snakemake -np mapped_reads/A.bam: -n/--dry-run prints the plan only, and -p also prints the resulting shell commands.[5] Real runs must specify cores; the tutorial example is snakemake --cores 1 mapped_reads/A.bam.[5] Snakemake applies rules top-down: each application is a job, and inputs are resolved recursively into a directed acyclic graph (DAG).[5] If an output is already present and still consistent with inputs and the rule definition, a second run will not redo it without reason; changed inputs, missing outputs, or relevant definition changes reschedule affected jobs.[5]

Figure: Rules linked by file names (schematic). This publication, Basics tutorial[5]
To reuse one rule across samples, Basics Step 2 generalizes paths with named wildcards: replace the sample name in the second input and in the output with {sample}, yielding data/samples/{sample}.fastq and mapped_reads/{sample}.bam, while keeping the fixed input data/genome.fa (which has no sample wildcard).[5] You can have multiple wildcards in output and input paths; however, to avoid conflicts with other jobs of the same rule, all output files of a rule must contain exactly the same wildcards; when Snakemake determines the rule can produce a target, it propagates that wildcard value to every occurrence of the wildcard in the rule and thereby determines the job’s input files.[5] Inside shell commands, {wildcards.sample} exposes the job’s wildcard value.[5] Use expand to build lists of file names for multiple samples in targets or inputs.[5] Put later steps in separate, unique output folders for a tidy workspace and faster rule lookup by directory prefixes.[5] Before a local tutorial run, Setup describes installing the environment and curling the snakemake-tutorial-data tarball, or using free GitHub Codespaces in the browser—both preparation paths are written in the docs.[6]
Where the tutorial and best practices go next
Start with Tutorial: General use, then consult the FAQ or workflow best practices as needed.[1][7][8] Snakemake 5.11 and later include a linter. with a Snakefile or workflow/Snakefile reachable from the working directory, snakemake --lint analyzes the workflow and highlights issues for readability and reproducibility.[8] After Basics, the tutorial overview continues with Advanced decoration of the example, additional features, and chapters on interaction, visualization, and reporting—read by task rather than absorbing every cluster or cloud executor plugin at once.[7] To fold analysis steps into a Snakefile: install via Pixi or Conda for the current docs version, write input/output/shell rules from Basics and inspect with -np before adding wildcards and expand; cite Mölder et al. 2021 and treat the repository MIT text as the license source.[1][2][3][4][5]
References
-
Snakemake. Documentation home (9.27.2).
-
Snakemake. MIT License (GitHub).
-
Mölder, F., et al. (2021). Sustainable data analysis with Snakemake. F1000Research 10:33. https://doi.org/10.12688/f1000research.29032.2
-
Snakemake. Installation.
-
Snakemake. Basics: An example workflow.
-
Snakemake. Setup.
-
Snakemake. Tutorial: General use.
-
Snakemake. Best practices.