I am attempting to call a system command from within an R script. The system command I want to call is a name of a software that I load as a module on a shared computing cluster (using singularity). The problem I am having is that the software is not able to run when I use the system command.
system_trial.R) has only one line:
system('STAR')
hostname[1] Rscript system_trial.R
sh: STAR: command not found
Warning message:
In system("STAR") : error in running command
Of course, the software works if I call it from the shell directly.
hostname[2] STAR
Usage: STAR [options]... --genomeDir /path/to/genome/index/ --readFilesIn R1.fq R2.fq
Spliced Transcripts Alignment to a Reference (c) Alexander Dobin, 2009-2020
If I run
which STAR
, I getsingularity exec /apps/singularity-3/star/star-2.7.5a--0.sif STAR $@
Replacing
system('STAR')
withsystem('singularity exec /apps/singularity-3/star/star-2.7.5a--0.sif STAR $@')
actually executes the software.Replacing
system('STAR')
withsystem('which STAR')
, returnswhich: no STAR in (/bin:etc...)
Using
system2('STAR')
givessh: STAR: command not found
.
I would like to simply use system('STAR')
. How can I achieve this?
Related post without an answer: R: calling a system command