【问题标题】:Snakemake: Ignore Rprofile when executing an R scriptSnakemake:执行 R 脚本时忽略 Rprofile
【发布时间】:2018-09-17 09:15:29
【问题描述】:

我在我的 snakemake 工作流程中执行 R 脚本时遇到了一些问题。似乎我的个人 .Rprofile 已加载到 R 脚本中。该作业在奇异容器中运行,问题是我自动在我的 R 配置文件中加载了一些未安装在容器中的包。我当然可以通过编辑我的 R 配置文件来解决这个问题,但是其他想要使用管道的人都必须这样做,这是我不喜欢的。有没有人知道如何解决这个问题?

谢谢!

【问题讨论】:

  • 我刚刚在snakemake的源代码中发现了这个(script.py):elif path.endswith(".R"): shell("Rscript {f.name}", bench_record=bench_record)。所以我想目前不可能传递参数。

标签: r snakemake


【解决方案1】:

你会发现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中使用(同时仍然使用“脚本:”界面,因为否则我在R中没有可用的snakemake对象)。
【解决方案2】:

正如@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)

暂时有效。

干杯!

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多