首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >workflow02-可视化展示snakemake流程

workflow02-可视化展示snakemake流程

作者头像
北野茶缸子
发布2022-07-07 14:49:13
发布2022-07-07 14:49:13
1.1K0
举报
  • Date : [[2022-05-27_Fri]]
  • Tags : #工作流/snakemake

Directed acyclic graph

对于工作流来说,Directed acyclic graph,有向非循环图是一个非常不错的展示的策略。

我们可以很直观的看到文件经过怎样的处理,从何种格式,最终转成了何种格式。

snakemake选项

首先构建我们的rule:

代码语言:javascript
复制
rule bwa_map:
    input:
        "data/genome.fa",
        "data/samples/{sample}.fastq"
    output:
        "mapped_reads/{sample}.bam"
    shell:
        "bwa mem {input} | samtools view -Sb - > {output}"

rule samtools_sort:
    input:
        "mapped_reads/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam"
    shell:
        "samtools sort -T sorted_reads/{wildcards.sample} "
        "-O bam {input} > {output}"
  
rule samtools_index:
    input:
        "sorted_reads/{sample}.bam"
    output:
        "sorted_reads/{sample}.bam.bai"
    shell:
        "samtools index {input}"

以及创立模拟文件:

代码语言:javascript
复制
mkdir -p data/samples
touch data/genome.fa data/samples/{A..D}.fastq

尝试运行 --dag 选项:

代码语言:javascript
复制
snakemake --dag sorted_reads/{A,B}.bam.bai

直接运行会输出一些图像内容文本:

代码语言:javascript
复制
$ snakemake --dag sorted_reads/{A,B}.bam.bai
Building DAG of jobs...
digraph snakemake_dag {
    graph[bgcolor=white, margin=0];
    node[shape=box, style=rounded, fontname=sans,                 fontsize=10, penwidth=2];
    edge[penwidth=2, color=grey];
        0[label = "samtools_index", color = "0.44 0.6 0.85", style="rounded"];
        1[label = "samtools_sort", color = "0.22 0.6 0.85", style="rounded"];
        2[label = "bwa_map\nsample: A", color = "0.00 0.6 0.85", style="rounded"];
        3[label = "samtools_index", color = "0.44 0.6 0.85", style="rounded"];
        4[label = "samtools_sort", color = "0.22 0.6 0.85", style="rounded"];
        5[label = "bwa_map\nsample: B", color = "0.00 0.6 0.85", style="rounded"];
        1 -> 0
        2 -> 1
        4 -> 3
        5 -> 4
}

这里我们可以使用graphviz 的dot 命令将其画出来。

代码语言:javascript
复制
# conda install -y graphviz 
snakemake --dag sorted_reads/{A,B}.bam.bai | dot -Tpng > output/dag.png

还是挺小清新的。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-06-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 北野茶缸子 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Directed acyclic graph
  • snakemake选项
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档