Snakemake与R问题:无法找到输出文件。

huangapple go评论71阅读模式
英文:

Snakemake with R Problem cannot find output files

问题

我正在尝试使用Snakemake使生物信息学工作变得“更容易”,但是我的第一次尝试不幸地导致了问题。不幸的是,我在互联网上在所有常见平台上都找不到解决问题的方法。因此,我认为我们的“群体智能/群体经验”在故障排除方面可能更有帮助。

我想用Snakemake自动化我的R分析:

我的Snakefile:

rule hello:
    output:  
        filtered_file = "output.csv"
    input:
        script='scripts/test.r',
        annotations_file="cars.csv"
    shell:
       "Rscript {input.script} \
        --annotations_file {input.annotations_file} \
        --filtered_file {output.filtered_file}"

我的R脚本:

library(dplyr)
annot_data=read.csv2(snakemake@input[["annotations_file"]],header=TRUE)
filtered = annot_data %>% filter(speed > 7)
write.csv2(filtered,snakemake@output[["filtered_file"]])

当我执行“dry run”时,我总是收到找不到“输出文件”的错误消息(如下所示)。第二个问题是,当我运行我的脚本时,出现了一个没有任何解释的错误。你有任何想法我做错了什么,或者如何驯服“snakemake(r)”吗?

Snakemake与R问题:无法找到输出文件。

非常感谢你的帮助!

最好的祝福,

Pavlo

我已经尝试了各种解决方案,例如从互联网上找到的或者修改Snakefile或者这个,但不幸的是都没有成功。

英文:

I'm trying to make bioinformatics work "easier" for myself with Snakemake 😊, but my first attempts unfortunately caused me problems. Unfortunately, I could not find a solution on the internet on all common platforms that would have eliminated the problem. Therefore, I thought that our "swarm intelligence/swarm experience" might be more helpful in troubleshooting 😊.

I would like to automate my R analyses with Snakemake:

My Snakefile:

rule hello:
    output:  
        filtered_file = "output.csv"
    input:
        script='scripts/test.r',
        annotations_file="cars.csv"
    shell:
       "Rscript {input.script} \
        --annotations_file {input.annotations_file} \
        --filtered_file {output.filtered_file}"

My Rscript

library(dplyr)
annot_data=read.csv2(snakemake@input[["annotations_file"]],header=TRUE)
filtered = annot_data %>% filter(speed > 7))
write.csv2(filtered,snakemake@output[["filtered_file"]])

When I perform a "dry run", I always get the error message that the "output files" cannot be found (see below). The second problem, when I run my scripts an Error occurs without any explanations. Do you have any idea what I'm doing wrong or how I can tame the "snakemake(r)" 😊?
Snakemake与R问题:无法找到输出文件。

Any help appreciated
Many thanks in advance for your help

Best regards

Pavlo

I have already tried various solutions ["from the internet"] (https://stackoverflow.com/questions/68620638/how-to-execute-r-inside-snakemake) or e.g. [modification of Snakefile] (https://github.com/fritzbayer/snakemake-with-R) or this - unfortunately without success.

答案1

得分: 2

这是snakemake的预期和正常行为,也是使用该软件的原因之一。

Snakemake告诉你为什么它会执行rule hello:该规则的目的是提供输出文件output.csv,但该文件缺失。因此,snakemake希望运行这个特定的规则以生成输出文件。

英文:

This is intended and normal behaviour for snakemake and one of the reasons to actually use the software.

Snakemake is telling you the reason, why it will execute the rule hello: The purpose of the rule is to provide the output file output.csv and the file is missing. So snakemake would like to run this specific rule in order to produce the output file.

答案2

得分: 0

非常感谢@euronion的回答,不幸的是问题出在其他地方。当我直接启动snakemake而不是在干运行模式下时,日志文件中显示了相同的错误,但没有进一步的解释。后来我发现,这是因为我的r脚本名称中的*.r扩展名是小写的,而互联网上的示例中*.R是大写的。一旦我将脚本名称中的扩展名改为大写,一切都正常工作了😊。显然,snakefile在脚本测试的名称中看不到/接受小写扩展名。你必须首先了解这一点,并找出解决方法。所以,“Snakemake世界”的第一个障碍已经清除,这是一种好的感觉。

最好的祝愿
Pavlo

英文:

Thank you very much @euronion for your answer, unfortunately the problem was elsewhere. When I started snakemake directly and not in dry-run mode, the same error was displayed in the log file without further explanation. Later I found out that it was because the *.r extension in the name of my rscript was lower case, while in examples from the internet *.R is capitalised. Once I changed the extension in the name of my rskript to upper case, everything worked 😊. Apparently the snakefile does not see/accept the lower case extension in the name of a script test. You have to know that first 😊 and figure it out. So, the first hurdle in the "Snakemake world" is cleared and that's a good feeling.

Best regards
Pavlo

huangapple
  • 本文由 发表于 2023年7月27日 15:44:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76777535.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定