Skip to content

msto/latch_native_snakemake

Repository files navigation

Latch native Snakemake workflow

Latch offers native Snakemake support. This repository contains a minimal Snakemake workflow and Latch metadata to demonstrate this functionality.

Summary

The pipeline runs a short two-step scatter-gather over a list of samples provided via an input samplesheet.

It also includes a conditional rule that will only execute if a LatchFile does not exist at an expected location. The output of this rule is copied back to this expected location, to cache the results for future workflow executions.

This example workflow is intended to test and demonstrate the following behaviors:

  • Load a sample manifest during Latch's JIT,
  • Use input functions to link metadata provided in the samplesheet to actual file paths on Latch,
  • Conditional rule execution, with cached results

Latch docs

https://wiki.latch.bio/docs/snakemake/quickstart
https://wiki.latch.bio/docs/snakemake/tutorial

Running the pipeline locally

Clone the repo, create and activate the conda environment, and run the pipeline.

git clone [email protected]:msto/latch_native_snakemake.git
cd latch_native_snakemake

mamba env create -f environment.yml
mamba activate latch_native_snakemake

snakemake --configfile config.yml -j 1

Running the pipeline on Latch

Within the working directory, and with the latch_native_snakemake environment activated, register the workflow.

latch register . --snakefile Snakefile

Notes on preparing the pipeline for use on Latch

Following the instructions in the quickstart and tutorial, I generated metadata and a Dockerfile with the Latch CLI.

latch generate-metadata config.yml --snakemake
latch dockerfile . --snakemake

I made the following modifications to the default file contents:

  • latch_metadata/parameters.py: I set download=True for the metadata_tsv parameter, so the list of input samples can be loaded during Latch's JIT (per the docs)
  • latch_metadata/__init__.py: I set appropriate values for the metadata
    output_dir=LatchDir("latch://23203.account/latch_native_snakemake/output"),
    display_name="Native Snakemake Proof-of-Concept",
    author=LatchAuthor(
    name="Matt Stone",
    ),
  • Dockerfile: I update the conda environment created by the Dockerfile to include the additional dependencies specified in my environment.yml
    RUN mamba env update --file /root/environment.yml --name latch_native_snakemake
  • .dockerignore: I set up an allowlist limited to the workflow and Latch files.
    # Ignore everything (all local data, results, analysis, and notebooks)
    *
    # Include the dockerfile
    !Dockerfile
    # Include the workflow, config, environment, and toolkit
    !Snakefile
    !config.yml
    !environment.yml
    # Include Latch metadata
    !latch_metadata
    !.latch
    !version

Other notes:

About

A minimal proof-of-concept workflow for Latch's native Snakemake support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published