在Snakemake中使用通配符捕获不同的数据集



我想使用通配符在蛇形以一种非常简单的方式启动两个数据集的脚本。遗憾的是,我找不到合适的方法来做这件事。

我的数据文件夹包含三个文件:gene_list.txtexpression_JGI.txtexpression_ubg .txt.

我的蛇形文件是这样的:

rule extract:
input:
genes="data/gene_list.txt",
expression="data/expression_{dataset}.txt"
output:
"data/expression_{dataset}_subset.txt"
shell:
"bash scripts/extract.sh {input.genes} {input.expression} {output}"

当我使用snakemake -c1 extract时,我得到以下错误消息:

Building DAG of jobs…WorkflowError:目标规则不能包含通配符。请在命令行中指定具体的文件或不使用通配符的规则,或者在工作流的最顶端指定不使用通配符的规则(例如典型的"规则all")。它只收集您最终想要生成的所有结果)。

我尝试在蛇形文件的开头添加rule all,并将所需的结果文件作为输入,但没有成功:

rule all:
input:
"data/expression_JGI_subset.txt",
"data/expression_UBC_subset.txt"

我还尝试了扩展:

DATASETS = ["JGI", "UBC"]
rule all:
input:
expand("data/expression_{dataset}_subset.txt", dataset=DATASETS)

但是我得到相同的错误信息。

当我在Snakemake外部使用它时,脚本工作正常。

我怎样才能达到我想要的?

当您执行snakemake -c1 extract时,您要求snakemake仅执行规则extract及其依赖项(如果有的话)。然而,由于extract包含通配符,snakemake不知道用什么来替换它们。(注意规则all不是extract的依赖项)。

所以要么执行snakemake -c1来运行整个管道,要么指定你想要生成的具体文件,例如:

snakemake -c1 -- data/expression_JGI_subset.txt data/expression_UBC_subset.txt

最新更新