dge_workflow: echoing R code in to Rscript not loading personal library packages
dge_star_counts2matrix, located in dge_utils stops with the error:
devtools::source_url("https://git.mpi-cbg.de/bioinfo/datautils/raw/v1.40/R/core_commons.R") Error in loadNamespace(name) : there is no package called ‘devtools’ Calls: :: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution halted
I tracked it down and this occurs because of the flag "--vanilla" in:
| R --no-save --no-restore --no-site-file -q. This flag keeps the R environment "clean" but that also means R packages installed in personal libraries are not loaded - thus the error despite
devtools being installed.
There are two (three) solutions for this:
--no-save --no-restore --no-site-filesince
vanillais in fact a wrapper for
--no-save, --no-restore, --no-site-file, --no-init-file and --no-environ. Removing the flags causing the issue will work (I tested it).
- Instead of echoing the
echo '[some code]' | R --no-save --no-restore --no-site-file -q) we could the approach
Rscript - <<"EOF" [some code] EOF. This was also tested and also works, but I have not looked into unintended consequences (loading of hidden R files for instance).
- More of a long term solution, and probably not feasible, keep these R snippets in their separate
.Rfiles, or as functions, a call them with
For the time being I would suggest either of 1. and 2. @herseman If you have any preference let me know so that I make the PR.
A consequence of this bug, and that was how I found it, is that
star_align.kts will not produce the count matrix table and, afaik, finish successfully with a reported warning.