A simple example snakemake workflow

public public 1yr ago Version: v0.1 0 bookmarks

A simple snakemake workflow comparing three genomes.

Run it like so:

snakemake -j 4 --use-conda

Information and links

This repo provides a snakemake workflow that uses sourmash to compare three genomes and generate a similarity matrix. All of the necessary software is installed by conda .

The snakemake workflow is described in the Snakefile .

The required software is listed in binder/environment.yml .

Workflow diagram

workflow diagram

Code Snippets

 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
args = commandArgs(trailingOnly=TRUE)

cat(args, sep="\n")

input_file <- args[1]

cat(input_file)

output_format = "html_document"
if (length(args)==3) {
  output_format = args[2]
}

rmarkdown::render(input_file, output_format=output_format)
R From line 2 of main/knit-Rmd.R
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(ggplot2) ## plotting! may not be needed.
library(pheatmap) ## for heatmap generation
library(ggplotify) ## convert pheatmap to ggplot2 compatibility
library(viridis) ## color palette stuff.

args <- commandArgs(trailingOnly=TRUE)

cat(args)

mat_csv <- args[1]
out_fig <- args[2]

# read matrix CSV file, as output by sourmash compare --csv
sourmash_comp_matrix <- read.csv(mat_csv)

# Label the rows
rownames(sourmash_comp_matrix) <- colnames(sourmash_comp_matrix)

# make heatmap!
heatmap_gg <- as.ggplot(pheatmap(sourmash_comp_matrix))
ggsave(out_fig) #, device="png")
23
24
25
shell: """
    curl -JL {params.url} -o {output}
"""
SnakeMake From line 23 of main/Snakefile
34
35
36
37
shell: """
    sourmash sketch dna -p k=31 {input.genome_file} -o {output.sketch} \
        --name-from-first
"""
SnakeMake From line 34 of main/Snakefile
47
48
49
shell: """
    sourmash compare {input.sketches} -o {output.matrix} --csv {output.csv}
"""
SnakeMake From line 47 of main/Snakefile
58
59
60
shell: """
    sourmash plot {input} --labels
"""
SnakeMake From line 58 of main/Snakefile
68
69
70
shell: """
    Rscript plot-compare.R {input} {output}
"""
SnakeMake From line 68 of main/Snakefile
79
80
81
shell: """
    Rscript knit-Rmd.R {input.Rmd} html_document
"""
SnakeMake From line 79 of main/Snakefile
ShowHide 7 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Free

Created: 1yr ago
Updated: 1yr ago
Maitainers: public
URL: https://github.com/ngs-docs/2023-ggg298-sourmash-compare
Name: 2023-ggg298-sourmash-compare
Version: v0.1
Badge:
workflow icon

Insert copied code into your website to add a link to this workflow.

Downloaded: 0
Copyright: Public Domain
License: BSD 3-Clause "New" or "Revised" License
  • Future updates

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...