Snakemake:执行 R 脚本时忽略 Rprofile

4
我在我的snakemake工作流中执行R脚本时遇到了一些问题。似乎我的个人.Rprofile文件被加载到了R脚本中。该作业在一个singularity容器内运行,问题是我在R配置文件中自动加载了一些未安装在容器中的软件包。当然,我可以通过编辑我的R配置文件来解决这个问题,但是任何想要使用该流水线的其他人都必须做同样的事情,这是我不喜欢的。有没有人有其他解决方法呢?
谢谢!

2
我在snakemake的源代码(script.py)中找到了这个:elif path.endswith(".R"): shell("Rscript {f.name}", bench_record=bench_record)。所以我猜目前还不能传递参数。 - fakechek
2个回答

4
你会发现 Rscript
$ Rscript
Usage: /path/to/Rscript [--options] [-e expr [-e expr2 ...] | file] [args]

--options accepted are
  --no-environ        Don't read the site and user environment files
  --no-site-file      Don't read the site-wide Rprofile
  --no-init-file      Don't read the user R profile
  --vanilla           Combine --no-save, --no-restore, --no-site-file
                        --no-init-file and --no-environ

而且R有一些选项可以帮助您解决这个问题:

$ R --help

Usage: R [options] [< infile] [> outfile]
   or: R CMD command [arguments]

Start R, a system for statistical computation and graphics, with the
specified options, or invoke an R tool via the 'R CMD' interface.

Options:
  --no-environ          Don't read the site and user environment files
  --no-site-file        Don't read the site-wide Rprofile
  --no-init-file        Don't read the user R profile
  --vanilla   Combine --no-save, --no-restore, --no-site-file,
      --no-init-file and --no-environ

(为简洁起见,省略了其他选项)

谢谢,现在我只需要看看这些选项是否可以在snakemake内部使用(同时仍然使用“script:”接口,否则我就无法在R中使用snakemake对象)。 - fakechek

1
正如@hrbrmstr已经建议的那样,--vanilla是我想使用的参数。然而,我找不到一种方法在snakemake中传递该参数,同时仍然将R脚本作为脚本运行(这样做的优点是在R环境中有所有snakemake参数可用)。相反,我去了源代码并编辑了script.py文件.../lib/python3.6/site-packages/snakemake/script.py:
shell("Rscript {f.name}", bench_record=bench_record)shell("Rscript --vanilla {f.name}", bench_record=bench_record) 现在可以工作了。
干杯!

1
这似乎很重要,值得提交一个问题报告:https://bitbucket.org/snakemake/snakemake/issues/new - merv

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接