Singularity and workflow management systems

Singularity + (snakemake || nextflow)

Michael Hall - Iqbal Group (EBI)


GitHub followers Twitter Follow

Singularity + Snakemake 

Run entire pipeline inside a given Singularity container

singularity: "docker://quay.io/biocontainers/bwa:0.7.3a--h84994c4_4"

rule map:
    input: 
        query = "data/query.fastq",
        ref = "data/ref.fa"
    output:
        "data/query.sam"
    shell:
        "bwa mem {input.ref} {input.query} > {output}"

Singularity + Snakemake 

Run single rule inside a given Singularity container

rule map:
    input: 
        query = "data/query.fastq",
        ref = "data/ref.fa"
    output:
        "data/query.sam"
    singularity: "docker://quay.io/biocontainers/bwa:0.7.3a--h84994c4_4"
    shell:
        "bwa mem {input.ref} {input.query} > {output}"

Singularity + Snakemake 

When executing the pipeline you just need to add the use-singularity option.

snakemake --use-singularity

Singularity + Snakemake 

Inception

singularity: "docker://continuumio/miniconda3:4.4.10"

rule plot:
    input:
        "table.txt"
    output:
        "plots/myplot.pdf"
    conda:
        "envs/ggplot.yaml"
    script:
        "scripts/plot-stuff.R"
singularity: "docker://continuumio/miniconda3:4.4.10"

rule plot:
    input:
        "table.txt"
    output:
        "plots/myplot.pdf"
    conda:
        "envs/ggplot.yaml"
    script:
        "scripts/plot-stuff.R"

Will run the whole pipeline inside a container with miniconda installed. For our plot rule we then specify a conda environment.

Note: Still need conda installed locally and use --use-conda when running snakemake.

Singularity + Nextflow 

nextflow run <your script> -with-singularity [singularity image file]

Run whole workflow in a container

Or specify the container in the nextflow.config file

process.container = '/path/to/singularity.img'
singularity.enabled = true

Singularity + Nextflow 

process {
    withName:foo {
        container = 'image_name_1'
    }
    withName:bar {
        container = 'image_name_2'
    }
}
singularity {
    enabled = true
}

Or specify multiple containers in the nextflow.config file

Made with Slides.com