{"id":25248,"date":"2024-01-19T16:52:48","date_gmt":"2024-01-19T08:52:48","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=25248"},"modified":"2024-01-19T16:52:50","modified_gmt":"2024-01-19T08:52:50","slug":"%e6%90%ad%e5%bb%ba%e7%94%9f%e4%bf%a1%e5%88%86%e6%9e%90%e6%b5%81%e6%b0%b4%e7%ba%bf%ef%bc%8c%e5%a6%82%e5%b7%a5%e5%8e%82%e4%b8%80%e6%a0%b724%e5%b0%8f%e6%97%b6%e8%bf%90%e8%bd%acsnakemake","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=25248","title":{"rendered":"\u642d\u5efa\u751f\u4fe1\u5206\u6790\u6d41\u6c34\u7ebf\uff0c\u5982\u5de5\u5382\u4e00\u683724\u5c0f\u65f6\u8fd0\u8f6cSnakemake\u2014\u2014\u8fdb\u9636\u547d\u4ee4"},"content":{"rendered":"<h1><\/h1>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"483\" height=\"183\" class=\"wp-image-25251\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25248-1.png?resize=483%2C183\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25248-1.png?w=483 483w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-25248-1.png?resize=300%2C114 300w\" sizes=\"(max-width: 483px) 100vw, 483px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u5c0f\u679c\u4e0a\u6b21\u4ecb\u7ecd\u4e86\u5206\u6790\u6d41\u7a0b\u7ba1\u7406\u5de5\u5177snakemake\uff0c\u4ee5\u53ca\u8bb2\u89e3\u4e86\u4ed6\u7684\u57fa\u7840\u7528\u6cd5\uff0c\u5e76\u642d\u5efa\u4e86\u4e00\u4e2a\u57fa\u7840\u7684\u5206\u6790\u6d41\u7a0b\u3002\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u5c0f\u679c\u7ee7\u7eed\u5e26\u5927\u5bb6\u5b66\u4e60\u4ed6\u5f3a\u5927\u7684\u8fdb\u9636\u547d\u4ee4\uff0c\u5b8c\u5584\u793a\u4f8b\u6d41\u7a0b\u3002<\/p>\n<p>\u8fd9\u4e9b\u547d\u4ee4\u5305\u62ec\uff1a<\/p>\n<p>\u6307\u5b9a\u6d41\u7a0b\u7684\u7ebf\u7a0b\u6570\u53caCPU\u5185\u6838\u6570\u3002<\/p>\n<p>\u4e3a\u6d41\u7a0b\u6dfb\u52a0\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u5f15\u5165\u8f93\u5165\u6587\u4ef6\u7684\u51fd\u6570\u3002<\/p>\n<p>\u6dfb\u52a0\u89c4\u5219\u53c2\u6570\u3002<\/p>\n<p>\u4e3a\u6d41\u7a0b\u6dfb\u52a0\u65e5\u5fd7\u3002<\/p>\n<p>\u8bbe\u7f6e\u8f93\u51fa\u6587\u4ef6\u4e3a\u4e34\u65f6\u6587\u4ef6\u6216\u8005\u4fdd\u62a4\u6587\u4ef6<\/p>\n<h2>\u6307\u5b9a\u6d41\u7a0b\u7ebf\u7a0b\u6570<\/h2>\n<p>\u5bf9\u4e8e\u751f\u4fe1\u7684\u67d0\u4e9b\u5de5\u5177\uff0c\u5c0f\u679c\u5efa\u8bae\u4f7f\u7528\u591a\u4e2a\u7ebf\u7a0b\u4ee5\u52a0\u5feb\u8ba1\u7b97\u901f\u5ea6\u3002\u8be5\u5982\u4f55\u5b9e\u73b0\u5462\uff1f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7threads\u6307\u4ee4\u8ba9Snakemake\u77e5\u9053\u89c4\u5219\u9700\u8981\u7684\u7ebf\u7a0b\u3002\u4f8b\u5982\uff1a<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>&#8220;data\/samples\/<em>{sample}<\/em>.fastq&#8221;<\/p>\n<p>output:<\/p>\n<p>&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>threads: 8<\/p>\n<p>shell:<\/p>\n<p>&#8220;bwa mem -t <em>{threads}<\/em> <em>{input}<\/em> | samtools view -Sb &#8211; &gt; <em>{output}<\/em>&#8221;<\/p>\n<p>\u6dfb\u52a0\u4e00\u884c\u547d\u4ee4\uff0c\u5c31\u53ef\u4ee5\u6307\u5b9arule bwa_map\u4f7f\u75288\u4e2a\u7ebf\u7a0b\u3002<\/p>\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662fsnakemake\u4f1a\u786e\u4fdd\u540c\u65f6\u8fd0\u884c\u7684\u6240\u6709\u4f5c\u4e1a\u7684\u7ebf\u7a0b\u603b\u6570\uff0c\u4e0d\u8d85\u8fc7\u7ed9\u5b9a\u6570\u91cf\u7684CPU\u5185\u6838\u3002<\/p>\n<p>\u6211\u4eec\u5728\u6267\u884csnakemake\u5de5\u4f5c\u6d41\u7a0b\u65f6\uff0c\u4f7f\u7528&#8211;cores\u53c2\u6570\uff0c\u6307\u5b9a\u4f7f\u7528\u7684CPU\u5185\u6838\u6570\u91cf\u3002<\/p>\n<p>snakemake &#8211;cores 10<\/p>\n<p>\u6bd4\u5982\u8fd9\u6761\u547d\u4ee4\uff0c\u5c31\u4f1a\u752810\u4e2aCPU\u5185\u6838\u6267\u884c\u8be5\u5de5\u4f5c\u6d41\u3002<\/p>\n<p>rule bwa_map\u6307\u5b9a\u4e868\u4e2a\u7ebf\u7a0b\uff0c\u90a3\u4e48snakemake\u5c31\u4f1a\u7528\u5269\u4e0b\u4e24\u4e2a\u5185\u6838\u53bb\u6267\u884c\u5176\u4ed6\u7684\u4efb\u52a1\uff0c\u4f8b\u5982samtools_sort\u3002<\/p>\n<p>\u5f53\u63d0\u4f9b\u7684\u5185\u6838\u5c11\u4e8e\u7ebf\u7a0b\u65f6\uff0c\u89c4\u5219\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\u5c06\u51cf\u5c11\u5230\u7ed9\u5b9a\u5185\u6838\u6570\u3002<\/p>\n<p>\u5982\u679c\u7ed9\u51fa\u7684&#8211;cores\u6ca1\u6709\u6570\u5b57\uff0c\u5219\u4f7f\u7528\u6240\u6709\u53ef\u7528\u7684cores\u3002<\/p>\n<h2>\u8bbe\u7f6e\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>SAMPLES = [&#8220;A&#8221;, &#8220;B&#8221;]<\/p>\n<p>rule bcftools_call:<\/p>\n<p>input:<\/p>\n<p>fa=&#8221;data\/genome.fa&#8221;,<\/p>\n<p>bam=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam&#8221;, sample=SAMPLES),<\/p>\n<p>bai=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam.bai&#8221;, sample=SAMPLES)<\/p>\n<p>output:<\/p>\n<p>&#8220;calls\/all.vcf&#8221;<\/p>\n<p>shell:<\/p>\n<p>&#8220;bcftools mpileup -f <em>{input.fa}<\/em> <em>{input.bam}<\/em> | &#8221;<\/p>\n<p>&#8220;bcftools call -mv &#8211; &gt; <em>{output}<\/em>&#8221;<\/p>\n<p>\u4e0a\u671f\u8bb2\u89e3\u4e2d\u6211\u4eec\u4f7f\u7528SAMPLES\u5217\u8868\uff0c\u6765\u5339\u914d\u6240\u6709\u6211\u4eec\u9700\u8981\u5904\u7406\u7684\u6587\u4ef6\u3002A\uff0cB\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5f53\u65b0\u7684\u6570\u636e\u6765\u4e86\u9700\u8981\u6211\u4eec\u7684\u6d41\u7a0b\u5206\u6790\u65f6\uff0c\u9700\u8981\u624b\u52a8\u5730\u66f4\u6539\uff0c\u96be\u4ee5\u9002\u5e94\u65b0\u7684\u6570\u636e\u3002<\/p>\n<p>Snakemake\u8003\u8651\u5230\u4e86\u8fd9\u79cd\u60c5\u51b5\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u914d\u7f6e\u6587\u4ef6\u673a\u5236\u3002\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u7528JSON\u6216YAML\u7f16\u5199\uff0c\u5e76\u4e0e\u6307\u4ee4\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n<p>configfile: &#8220;config.yaml&#8221;<\/p>\n<p>\u6211\u4eec\u53ea\u9700\u8981\u5728\u5de5\u4f5c\u6d41\u7684\u9876\u7aef\u6dfb\u52a0\u8fd9\u4e00\u884c\u547d\u4ee4\u3002Snakemake\u5c06\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5185\u5bb9\u5b58\u50a8\u5230\u540d\u4e3a\u7684\u5168\u5c40\u53ef\u7528\u5b57\u5178\u4e2d\u3002<\/p>\n<p>\u6211\u4eec\u521b\u5efa\u4e00\u4e2aconfig.yaml\u6587\u4ef6\uff0c\u7f16\u5199samples\u7684\u6587\u4ef6\u8def\u5f84<\/p>\n<p><strong>samples<\/strong>:<\/p>\n<p><strong> A<\/strong>: data\/samples\/A.fastq<\/p>\n<p><strong> B<\/strong>: data\/samples\/B.fastq<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u5c31\u53ef\u4ee5\u53bb\u6389SAMPLES\u5217\u8868\uff0c\u5e76\u5c06rule\u6539\u4e3a<\/p>\n<p>rule bcftools_call:<\/p>\n<p>input:<\/p>\n<p>fa=&#8221;data\/genome.fa&#8221;,<\/p>\n<p>bam=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam&#8221;, sample=config[&#8220;samples&#8221;]),<\/p>\n<p>bai=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam.bai&#8221;, sample=config[&#8220;samples&#8221;])<\/p>\n<p>output:<\/p>\n<p>&#8220;calls\/all.vcf&#8221;<\/p>\n<p>shell:<\/p>\n<p>&#8220;bcftools mpileup -f <em>{input.fa}<\/em> <em>{input.bam}<\/em> | &#8221;<\/p>\n<p>&#8220;bcftools call -mv &#8211; &gt; <em>{output}<\/em>&#8221;<\/p>\n<h2>\u5b9a\u4e49\u8f93\u5165\u51fd\u6570<\/h2>\n<p>\u6211\u4eec\u5df2\u7ecf\u5c06sample\u6587\u4ef6\u7684\u8def\u5f84\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u56e0\u6b64\u6211\u4eec\u8fd8\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u4e3a\u4f7f\u7528\u8fd9\u4e9b\u8def\u5f84\u3002<\/p>\n<p>Snakemake \u5de5\u4f5c\u6d41\u7684\u6267\u884c\u5206\u4e3a\u4e09\u4e2a\u9636\u6bb5\u3002\u5206\u522b\u662f<\/p>\n<ol>\n<li>\u5728\u521d\u59cb\u5316\u9636\u6bb5\uff0c\u5c06\u89e3\u6790\u5b9a\u4e49\u5de5\u4f5c\u6d41\u7684\u6587\u4ef6\uff0c\u5e76\u5b9e\u4f8b\u5316\u6240\u6709\u89c4\u5219\u3002<\/li>\n<li>\u5728DAG\u9636\u6bb5\uff0c\u901a\u8fc7\u586b\u5145\u901a\u914d\u7b26\u5e76\u5c06\u8f93\u5165\u6587\u4ef6\u4e0e\u8f93\u51fa\u6587\u4ef6\u5339\u914d\uff0c\u53ef\u4ee5\u6784\u5efa\u6240\u6709\u4f5c\u4e1a\u7684\u6709\u5411\u65e0\u5faa\u73af\u4f9d\u8d56\u56fe\u3002<\/li>\n<li>\u5728\u8c03\u5ea6\u9636\u6bb5\uff0c\u6267\u884c\u4f5c\u4e1a\u7684DAG\uff0c\u6839\u636e\u53ef\u7528\u8d44\u6e90\u542f\u52a8\u4f5c\u4e1a\u3002<\/li>\n<\/ol>\n<p>\u5728\u521d\u59cb\u5316\u9636\u6bb5\uff0c\u8f93\u5165\u6587\u4ef6\u7684\u51fd\u6570\u4f1a\u88ab\u6267\u884c\uff0c\u4f46\u662f\u5728\u8fd9\u4e2a\u9636\u6bb5\u4f5c\u4e1a\u3001\u901a\u914d\u7b26\u503c\u548c\u89c4\u5219\u4f9d\u8d56\u5173\u7cfb\u8fd8\u4e0d\u77e5\u9053\u3002<\/p>\n<p>\u6211\u4eec\u9700\u8981\u5c06\u8f93\u5165\u6587\u4ef6\u7684\u786e\u5b9a\u63a8\u8fdf\u5230DAG\u9636\u6bb5\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u8f93\u5165\u6307\u4ee4\u4e2d\u6307\u5b9a\u8f93\u5165\u51fd\u6570\u800c\u4e0d\u662f\u5b57\u7b26\u4e32\u6765\u5b9e\u73b0\u3002\u5bf9\u4e8e\u89c4\u5219\uff0c\u5176\u5de5\u4f5c\u539f\u7406\u5982\u4e0b\uff1a<\/p>\n<p><strong>def<\/strong> get_bwa_map_input_fastqs(wildcards):<\/p>\n<p><strong>return<\/strong> config[&#8220;samples&#8221;][wildcards.sample]<\/p>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u83b7\u53d6\u8f93\u5165\u6587\u4ef6\u8def\u5f84\u7684\u51fd\u6570\u3002<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>get_bwa_map_input_fastqs #\u8c03\u7528\u8f93\u5165\u51fd\u6570<\/p>\n<p>output:<\/p>\n<p>&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>threads: 8<\/p>\n<p>shell:<\/p>\n<p>&#8220;bwa mem -t <em>{threads}<\/em> <em>{input}<\/em> | samtools view -Sb &#8211; &gt; <em>{output}<\/em>&#8221;<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u4f1a\u8fd4\u56de\u8f93\u5165\u6587\u4ef6\u7684\u8def\u5f84\uff0c[wildcards.sample]\u901a\u8fc7\u8fd9\u4e2a\u547d\u4ee4\u53ef\u4ee5\u8fd4\u56de\u6587\u4ef6<\/p>\n<h2>\u8bbe\u7f6e\u89c4\u5219\u7684\u53c2\u6570<\/h2>\n<p>\u6709\u65f6\uff0cshell\u547d\u4ee4\u4e0d\u4ec5\u4ec5\u7531\u8f93\u5165\u548c\u8f93\u51fa\u6587\u4ef6\u4ee5\u53ca\u4e00\u4e9b\u9759\u6001\u6807\u5fd7\u7ec4\u6210\u3002\u6709\u65f6\u5019\u53ef\u80fd\u9700\u8981\u6839\u636e\u4f5c\u4e1a\u7684\u901a\u914d\u7b26\u503c\u8bbe\u7f6e\u5176\u4ed6\u53c2\u6570\u3002Snakemake\u5141\u8bb8\u4f7f\u7528\u6307\u4ee4params\u4e3a\u89c4\u5219\u5b9a\u4e49\u4efb\u610f\u53c2\u6570\u3002\u4f8b\u5982<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>get_bwa_map_input_fastqs<\/p>\n<p>output:<\/p>\n<p>&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>params:<\/p>\n<p>rg=r&#8221;@RG\\tID:<em>{sample}<\/em>\\tSM:<em>{sample}<\/em>&#8221;<\/p>\n<p>threads: 8<\/p>\n<p>shell:<\/p>\n<p>&#8220;bwa mem -R &#8216;<em>{params.rg}<\/em>&#8216; -t <em>{threads}<\/em> <em>{input}<\/em> | samtools view -Sb &#8211; &gt; <em>{output}<\/em>&#8221;<\/p>\n<p>\u7a81\u53d8\u5206\u6790\u4f1a\u8003\u8651\u5f88\u591a\u53c2\u6570\u3002\u4e00\u4e2a\u7279\u522b\u91cd\u8981\u7684\u662f\u5148\u524d\u7684\u7a81\u53d8\u7387\uff08\u9ed8\u8ba4\u4e3a1e-3\uff09\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5411\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2akey\u5e76\u4f7f\u7528\u89c4\u5219\u4e2d\u7684\u6307\u4ee4,\u5c06\u5176\u8c03\u7528\u5230shell\u547d\u4ee4\u6765\u914d\u7f6e\u8fd9\u4e2akey\u3002<\/p>\n<h2>\u65e5\u5fd7<\/h2>\n<p>\u5728\u6267\u884c\u4e00\u4e2a\u5927\u578b\u5de5\u4f5c\u6d41\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5c06\u6bcf\u4e2a\u4f5c\u4e1a\u7684\u65e5\u5fd7\u8bb0\u5f55\u8f93\u51fa\u5b58\u50a8\u5230\u4e00\u4e2a\u5355\u72ec\u7684\u6587\u4ef6\u4e2d\uff0c\u800c\u4e0d\u662f\u5728\u591a\u4e2a\u4f5c\u4e1a\u5e76\u884c\u8fd0\u884c\u65f6\u5c06\u6240\u6709\u65e5\u5fd7\u8bb0\u5f55\u8f93\u51fa\u6253\u5370\u5230\u7ec8\u7aef\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u8f93\u51fa\u6df7\u4e71\u3002\u4e3a\u6b64\uff0cSnakemake\u5141\u8bb8\u4e3a\u89c4\u5219\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u3002\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0log\u547d\u4ee4\u6765\u5b8c\u6210\u3002<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>get_bwa_map_input_fastqs<\/p>\n<p>output:<\/p>\n<p>&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>params:<\/p>\n<p>rg=r&#8221;@RG\\tID:<em>{sample}<\/em>\\tSM:<em>{sample}<\/em>&#8221;<\/p>\n<p>log:<\/p>\n<p>&#8220;logs\/bwa_mem\/<em>{sample}<\/em>.log&#8221;<\/p>\n<p>threads: 8<\/p>\n<p>shell:<\/p>\n<p>&#8220;(bwa mem -R &#8216;<em>{params.rg}<\/em>&#8216; -t <em>{threads}<\/em> <em>{input}<\/em> | &#8221;<\/p>\n<p>&#8220;samtools view -Sb &#8211; &gt; <em>{output}<\/em>) 2&gt; <em>{log}<\/em>&#8221;<\/p>\n<p>\u6267\u884cshell\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ba1\u9053\u4f20\u8f93\u5230\u65e5\u5fd7\u6587\u4ef6\u4e2d\u3002<\/p>\n<h2>\u4e34\u65f6\u6587\u4ef6\u548c\u4fdd\u62a4\u6587\u4ef6<\/h2>\n<p>\u5f53\u6211\u4eec\u8fd0\u884c\u4e00\u4e2a\u5927\u578b\u5de5\u4f5c\u6d41\u65f6\uff0c\u4f1a\u4ea7\u751f\u8bb8\u591a\u4e2d\u95f4\u6587\u4ef6\uff0c\u8fd9\u4e9b\u6587\u4ef6\u4f1a\u5360\u7528\u5927\u91cf\u7684\u78c1\u76d8\u7a7a\u95f4\uff0c\u5e76\u4e14\u4e5f\u9700\u8981\u8017\u8d39\u8ba1\u7b97\u8d44\u6e90\u548c\u65f6\u95f4\u3002\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u53ef\u4ee5\u5c06\u8f93\u51fa\u6587\u4ef6\u8bbe\u7f6e\u4e3a\u4e34\u65f6\u6587\u4ef6\uff0c\u4e00\u65e6\u9700\u8981\u5b83\u7684\u4f5c\u4e1a\u6267\u884c\u5b8c\u6bd5\uff0c\u5c31\u4f1a\u5220\u9664\u8fd9\u4e2a\u4e34\u65f6\u6587\u4ef6\uff0c\u907f\u514d\u78c1\u76d8\u5360\u7528\u8fc7\u591a\u3002<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>get_bwa_map_input_fastqs<\/p>\n<p>output:<\/p>\n<p>temp(&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;)<\/p>\n<p>params:<\/p>\n<p>rg=r&#8221;@RG\\tID:<em>{sample}<\/em>\\tSM:<em>{sample}<\/em>&#8221;<\/p>\n<p>log:<\/p>\n<p>&#8220;logs\/bwa_mem\/<em>{sample}<\/em>.log&#8221;<\/p>\n<p>threads: 8<\/p>\n<p>shell:<\/p>\n<p>&#8220;(bwa mem -R &#8216;<em>{params.rg}<\/em>&#8216; -t <em>{threads}<\/em> <em>{input}<\/em> | &#8221;<\/p>\n<p>&#8220;samtools view -Sb &#8211; &gt; <em>{output}<\/em>) 2&gt; <em>{log}<\/em>&#8221;<\/p>\n<p>\u6709\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5df2\u7ecf\u6267\u884c\u5b8c\u4e86\u5de5\u4f5c\u6d41\u7a0b\uff0c\u5f97\u5230\u4e86\u60f3\u8981\u7684\u7ed3\u679c\uff0c\u4e0d\u5e0c\u671b\u7ed3\u679c\u906d\u5230\u7be1\u6539\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u7ed3\u679c\u95ee\u4ef7\u4f60\u8bbe\u7f6e\u4e3a\u4fdd\u62a4\u6587\u4ef6\u3002Snakemake\u4f1a\u5bf9\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8f93\u51fa\u6587\u4ef6\u8fdb\u884c\u5199\u4fdd\u62a4\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u610f\u5916\u5730\u8986\u76d6\u6216\u5220\u9664\u5b83\u3002<\/p>\n<h2>\u6d41\u7a0b\u603b\u7ed3<\/h2>\n<p>\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n<p><strong>samples<\/strong>:<\/p>\n<p><strong>A<\/strong>: data\/samples\/A.fastq<\/p>\n<p><strong>B<\/strong>: data\/samples\/B.fastq<\/p>\n<p><strong>prior_mutation_rate<\/strong>: 0.001<\/p>\n<p>Snakemake\u5de5\u4f5c\u6d41\u7a0b\u6587\u4ef6Snakefile<\/p>\n<p>configfile: &#8220;config.yaml&#8221; #\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>rule all:<\/p>\n<p>input:<\/p>\n<p>&#8220;plots\/quals.svg&#8221;<\/p>\n<p><strong>def<\/strong> get_bwa_map_input_fastqs(wildcards): #\u5b9a\u4e49\u8f93\u5165\u51fd\u6570<\/p>\n<p><strong>return<\/strong> config[&#8220;samples&#8221;][wildcards.sample]<\/p>\n<p>rule bwa_map:<\/p>\n<p>input:<\/p>\n<p>&#8220;data\/genome.fa&#8221;,<\/p>\n<p>get_bwa_map_input_fastqs<\/p>\n<p>output:<\/p>\n<p>temp(&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;)#\u8bbe\u7f6e\u4e34\u65f6\u6587\u4ef6<\/p>\n<p>params:<\/p>\n<p>rg=r&#8221;@RG\\tID:<em>{sample}<\/em>\\tSM:<em>{sample}<\/em>&#8221;<\/p>\n<p>log:<\/p>\n<p>&#8220;logs\/bwa_mem\/<em>{sample}<\/em>.log&#8221; #\u8f93\u51fa\u65e5\u5fd7<\/p>\n<p>threads: 8 #\u8bbe\u5b9a\u7ebf\u7a0b<\/p>\n<p>shell:<\/p>\n<p>&#8220;(bwa mem -R &#8216;<em>{params.rg}<\/em>&#8216; -t <em>{threads}<\/em> <em>{input}<\/em> | &#8221;<\/p>\n<p>&#8220;samtools view -Sb &#8211; &gt; <em>{output}<\/em>) 2&gt; <em>{log}<\/em>&#8221;<\/p>\n<p>rule samtools_sort:<\/p>\n<p>input:<\/p>\n<p>&#8220;mapped_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>output:<\/p>\n<p>protected(&#8220;sorted_reads\/<em>{sample}<\/em>.bam&#8221;)<\/p>\n<p>shell:<\/p>\n<p>&#8220;samtools sort -T sorted_reads\/<em>{wildcards.sample}<\/em> &#8221;<\/p>\n<p>&#8220;-O bam <em>{input}<\/em> &gt; <em>{output}<\/em>&#8221;<\/p>\n<p>rule samtools_index:<\/p>\n<p>input:<\/p>\n<p>&#8220;sorted_reads\/<em>{sample}<\/em>.bam&#8221;<\/p>\n<p>output:<\/p>\n<p>&#8220;sorted_reads\/<em>{sample}<\/em>.bam.bai&#8221;<\/p>\n<p>shell:<\/p>\n<p>&#8220;samtools index <em>{input}<\/em>&#8221;<\/p>\n<p>rule bcftools_call:<\/p>\n<p>input:<\/p>\n<p>fa=&#8221;data\/genome.fa&#8221;,<\/p>\n<p>bam=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam&#8221;, sample=config[&#8220;samples&#8221;]),<\/p>\n<p>bai=expand(&#8220;sorted_reads\/<em>{sample}<\/em>.bam.bai&#8221;, sample=config[&#8220;samples&#8221;])<\/p>\n<p>output:<\/p>\n<p>&#8220;calls\/all.vcf&#8221;<\/p>\n<p>params:<\/p>\n<p>rate=config[&#8220;prior_mutation_rate&#8221;]<\/p>\n<p>log:<\/p>\n<p>&#8220;logs\/bcftools_call\/all.log&#8221;<\/p>\n<p>shell:<\/p>\n<p>&#8220;(bcftools mpileup -f <em>{input.fa}<\/em> <em>{input.bam}<\/em> | &#8221;<\/p>\n<p>&#8220;bcftools call -mv -P <em>{params.rate}<\/em> &#8211; &gt; <em>{output}<\/em>) 2&gt; <em>{log}<\/em>&#8221;<\/p>\n<p>rule plot_quals:<\/p>\n<p>input:<\/p>\n<p>&#8220;calls\/all.vcf&#8221;<\/p>\n<p>output:<\/p>\n<p>&#8220;plots\/quals.svg&#8221;<\/p>\n<p>script:<\/p>\n<p>&#8220;scripts\/plot-quals.py&#8221;<\/p>\n<p><strong>\u597d\u4e86\u5c0f\u679c\u4eca\u5929\u7684\u8bb2\u89e3\u5c31\u5230\u8fd9\u91cc\u4e86\uff0c\u4e0b\u671f\u518d\u89c1~<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u679c\u4e0a\u6b21\u4ecb\u7ecd\u4e86\u5206\u6790\u6d41\u7a0b\u7ba1\u7406\u5de5\u5177snakemake\uff0c\u4ee5\u53ca\u8bb2\u89e3\u4e86\u4ed6\u7684\u57fa\u7840\u7528\u6cd5\uff0c\u5e76\u642d\u5efa\u4e86\u4e00\u4e2a\u57fa\u7840\u7684\u5206\u6790\u6d41\u7a0b\u3002\u5728\u6b64\u57fa\u7840 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25248"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25248"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25248\/revisions"}],"predecessor-version":[{"id":25252,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/25248\/revisions\/25252"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25248"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}