dge_workflow: echoing R code in to Rscript not loading personal library packages
The function 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:
- Replace
--vanilla
flag with--no-save --no-restore --no-site-file
sincevanilla
is 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
R
code (echo '[some code]' | R --no-save --no-restore --no-site-file -q
) we could the approachRscript - <<"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
.R
files, or as functions, a call them withRscript some_function.R
.
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.