我正在编写一个 Snakemake 管道来运行一些模拟。关键点是: (1) 我在参数 A、B 和 C 的值空间中运行模拟,并进行 n 次重复, (2) 我绘制了每个参数组合的重复次数的平均结果, (3) 我想组合这些图,以便对于 B 和 C 的每种组合,我生成一个包含不同 A 值的面板的图。
我收到与步骤 3 相关的 MissingInputException 错误。
我的 Snakefile 的最小版本如下所示:
A_lst = [0.0, 0.1, 0.01]
B_lst = [0.0, 0.1, 0.01]
C_lst = [0.0, 0.1, 0.01]
seeds = [2,22,42]
rule all:
input:
expand("sims/A~{A}/B~{B}/C~{C}/{seed}.out", A=A_lst, B=B_lst, C=C_lst, seed=seeds),
expand("sims/A~{A}/B~{B}/C~{C}/plot.png", A=A_lst, B=B_lst, C=C_lst),
expand("plots/combined_B{B}_C{C}.png", B=B_lst, C=C_lst)
rule simulate:
output:
"sims/A~{A}/B~{B}/C~{C}/{seed}.out"
shell:
"simulator {wildcards.A} {wildcards.B} {wildcards.C} {wildcards.rep}"
rule plot:
input:
expand("sims/A~{{A}}/B~{{B}}/C~{{C}}/{seed}.out", seed=seeds)
output:
"sims/A~{A}/B~{B}/C~{C}/plot.png"
shell:
"scripts/plot.py"
rule combine_plots:
input:
expand("output/A~{A}/B~{{B}}/C~{{C}}/plot.png",
A=A_lst)
output:
"plots/combined_B{B}_C{C}.png"
script:
"scripts/combine_plots.py"
这会出现以下错误:
# executing snakemake -n --cores 1 --conda-frontend conda --use-conda
Building DAG of jobs...
MissingInputException in rule all in file /data/username/project/Snakefile, line 67:
Missing input files for rule all:
affected files:
plots/combined_B0.0_C0.0.png
这让我很惊讶。我认为逻辑如下: (1) 询问plots/combined_B{B}_C{C}.png所有可能的参数组合 (2) 对 A 进行扩展,同时匹配输出中的 B 和 C 的值 ...
前两条规则有效。但是,生成plots/combined_B0.0_C0.0.png的所有内容似乎也在那里?我希望得到一些解释和如何修复它的建议!
提前致谢!
我复制并运行了你的Snakefile代码(在snakemake 8.11.3中),我得到了一个不同的错误:
Building DAG of jobs...
MissingInputException in rule combine_plots in file /home/tbooth2/workspace/snakemake_scratch/stack_overflow/Snakefile, line 28:
Missing input files for rule combine_plots:
output: plots/combined_B0.0_C0.0.png
wildcards: B=0.0, C=0.0
affected files:
output/A~0.1/B~0.0/C~0.0/plot.png
output/A~0.0/B~0.0/C~0.0/plot.png
output/A~0.01/B~0.0/C~0.0/plot.png
此错误是有道理的,因为没有规则在
output/
内创建任何文件。如果我更改 rule merge_plots 的 input 来查找 sims/
中的文件,那么我得到:
RuleException in rule simulate in file /home/tbooth2/workspace/snakemake_scratch/stack_overflow/Snakefile, line 13:
AttributeError: 'Wildcards' object has no attribute 'rep', when formatting the following:
simulator {wildcards.A} {wildcards.B} {wildcards.C} {wildcards.rep}
如果我在该 shell 命令中将
{wildcards.rep}
替换为 {wildcards.seed}
,那么你的 DAG 就会构建得很好:
Job stats:
job count
------------- -------
all 1
combine_plots 9
plot 27
simulate 81
total 118
显然我无法在试运行之外进行测试,但它对我来说看起来不错。
如果您自己的文件中具有完全相同的规则,并且仍然收到
MissingInputException in rule all
错误,那么您可能在完整版本的工作流程中的其他位置设置了一些 wildcard_contraints ?