Closed russHyde closed 3 years ago
Attempt to get nextflow pipeline to run with renv was a failure.
Since nextflow processes run in a temp directory, they don't necessarily have access to files that are implicitly required.
Here,
.Rprofile
, renv/
in the command-line call to run an R scriptSo, we need a way to copy / link implicit file-dependencies into the working directory for any process that runs an R script; but I can't find a good explanation for how to do that within nextflow.
I think I resolved this issue. All you need for an R script to use the renv
packages is to have the R_LIBS_USER
environment variable pointing to the underlying R library path. You can get this path in R by activating the renv
and then typing cat(paste0(.libPaths(), collapse = ":"))
. According to the Nextflow documentation on configuration, "The env
scope allows the definition one or more variable that will be exported in the environment where the workflow tasks will be executed." Therefore, if your Nextflow configuration file contains the line env.R_LIBS_USER = /path/to/renv/libs
, then each process will have access to your renv
libraries. You can even carry out the above steps programmatically in a bash script as follows:
RENV_R_LIBS_USER=$(Rscript -e '
renv::activate();
cat(paste0(.libPaths(), collapse = ":"))')
echo "env.R_LIBS_USER = \"$RENV_R_LIBS_USER\"" > nextflow.config
Hope this helps!
Amazing. I'd recently started looking back at this project (though I don't use nextflow for work nowadays). Thanks for posting your solution.
fixes #29
Initially had a conda environment (plus some
install_github
s)Had trouble updating the env: both slowness of solving env, and impossibility
of installing some packages (pkgnet)
The initial env was based on R-3.5 and had rstudio inside it
So it was a reluctant beast
Also needed to have a separate ./setup script to ensure that github packages
were installed correctly, once the conda-env was in place.
Recommendation
conda install r-base r-renv r-rstudioapi
would only install r-base=3.6.1conda install r-base=4.0.3 r-renv r-rstudioapi
threw conflictsconda update
did nothingconda env create --file envs/environment.yml --name code-as-data
ran fine - but installing r-base r-renv and r-rstudioapi on that failedconda install -c conda-forge -c bioconda \ snakemake=5.10.0 nextflow=19.10.0 r-base=4.0.3 r-renv r-rstudioapi
- Run renv::initTODO:
workflow_tools
pipelines all still work