Reputation: 241
I'm experiencing some problems with executing R scripts in my snakemake workflow. It seems that my personal .Rprofile is loaded inside the R script. The job is run inside a singularity container and the problem is that I automatically load some packages in my R profile that are not installed in the container. I could of course solve this by editing my R profile but everybody else who wants to use the pipeline would have to do the same which is something I don't like. Does anybody have an idea how to solve this otherwise?
Thanks!
Upvotes: 4
Views: 789
Reputation: 241
As @hrbrmstr already suggest, --vanilla
was the parameter I wanted to use. However, I couldn't find a way to pass this parameter inside snakemake while still running the R script as a script (which has the advantage of having all the snakemake parameters available inside the R environment). Instead, I went to the source code and edited the script.py file .../lib/python3.6/site-packages/snakemake/script.py
:
From
shell("Rscript {f.name}", bench_record=bench_record)
to
shell("Rscript --vanilla {f.name}", bench_record=bench_record)
Works for now.
Cheers!
Upvotes: 1
Reputation: 78832
You'll find that 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
and R
have some options to help you with this:
$ 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
(other options omitted for brevity)
Upvotes: 5