首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Snakemake:如何有效地使用配置文件

Snakemake:如何有效地使用配置文件
EN

Stack Overflow用户
提问于 2018-05-02 15:21:21
回答 1查看 6.7K关注 0票数 2

我在snakemake中使用以下配置文件格式进行一些排序分析实践(我有大量样本,每个样本包含2个fastq文件:

代码语言:javascript
运行
复制
samples:
Sample1_XY:
    - fastq_files/SRR4356728_1.fastq.gz
    - fastq_files/SRR4356728_2.fastq.gz
Sample2_AB:
    - fastq_files/SRR6257171_1.fastq.gz
    - fastq_files/SRR6257171_2.fastq.gz 

我在管道开始时使用以下规则来运行fastqc和对fastqc文件:

代码语言:javascript
运行
复制
import os
# read config info into this namespace
configfile: "config.yaml"

rule all:
    input:
    expand("FastQC/{sample}_fastqc.zip", sample=config["samples"]),
    expand("bam_files/{sample}.bam", sample=config["samples"]),
    "FastQC/fastq_multiqc.html"

rule fastqc:
    input:
        sample=lambda wildcards: config['samples'][wildcards.sample]
    output:
        # Output needs to end in '_fastqc.html' for multiqc to work
        html="FastQC/{sample}_fastqc.html",
        zip="FastQC/{sample}_fastqc.zip"
    params: ""
        wrapper:
        "0.21.0/bio/fastqc"

rule bowtie2:
    input:
         sample=lambda wildcards: config['samples'][wildcards.sample]
    output:
         "bam_files/{sample}.bam"
    log:
         "logs/bowtie2/{sample}.txt"
    params:
         index=config["index"],  # prefix of reference genome index (built with bowtie2-build),
    extra=""
         threads: 8
    wrapper:
         "0.21.0/bio/bowtie2/align"

 rule multiqc_fastq:
    input:
         expand("FastQC/{sample}_fastqc.html", sample=config["samples"])
    output:
         "FastQC/fastq_multiqc.html"
    params:
    log:
         "logs/multiqc.log"
    wrapper:
         "0.21.0/bio/multiqc"

我的问题是fastqc规则。

目前,fastqc规则和bowtie2规则都创建了一个使用两个输入SRRXXXXXXX_1.fastq.gzSRRXXXXXXX_2.fastq.gz生成的输出文件。

我需要fastq规则来生成两个文件,每个fastq.gz文件都有一个单独的文件,但是我不知道如何从fastqc规则输入语句中正确地索引配置文件,或者如何组合展开和通配符命令来解决这个问题。通过将[0][1]添加到输入语句的末尾,我可以获得一个单独的fastq文件,但不能单独/单独运行。

我一直在试图获得正确的索引格式来分别访问每个文件。当前格式是我管理的唯一允许snakemake -np生成作业列表的格式。

任何提示都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-03 16:21:35

似乎每个示例都有两个fastq文件,它们以***_1.fastq.gz***_2.fastq.gz格式命名。在这种情况下,下面的配置和代码将起作用。

config.yaml:

代码语言:javascript
运行
复制
samples:
    Sample_A: fastq_files/SRR4356728
    Sample_B: fastq_files/SRR6257171

蛇形:

代码语言:javascript
运行
复制
# read config info into this namespace
configfile: "config.yaml"
print (config['samples'])

rule all:
    input:
        expand("FastQC/{sample}_{num}_fastqc.zip", sample=config["samples"], num=['1', '2']),
        expand("bam_files/{sample}.bam", sample=config["samples"]),
        "FastQC/fastq_multiqc.html"

rule fastqc:
    input:
        sample=lambda wildcards: f"{config['samples'][wildcards.sample]}_{wildcards.num}.fastq.gz"
    output:
        # Output needs to end in '_fastqc.html' for multiqc to work
        html="FastQC/{sample}_{num}_fastqc.html",
        zip="FastQC/{sample}_{num}_fastqc.zip"
    wrapper:
        "0.21.0/bio/fastqc"

rule bowtie2:
    input:
         sample=lambda wildcards: expand(f"{config['samples'][wildcards.sample]}_{{num}}.fastq.gz", num=[1,2])
    output:
         "bam_files/{sample}.bam"
    wrapper:
         "0.21.0/bio/bowtie2/align"

rule multiqc_fastq:
    input:
        expand("FastQC/{sample}_{num}_fastqc.html", sample=config["samples"], num=['1', '2'])
    output:
        "FastQC/fastq_multiqc.html"
    wrapper:
        "0.21.0/bio/multiqc"
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50138171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档