How to invoke a system command in R on shared computing cluster?

204 views Asked by At

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 get singularity exec /apps/singularity-3/star/star-2.7.5a--0.sif STAR $@

  • Replacing system('STAR') with system('singularity exec /apps/singularity-3/star/star-2.7.5a--0.sif STAR $@') actually executes the software.

  • Replacing system('STAR') with system('which STAR'), returns which: no STAR in (/bin:etc...)

  • Using system2('STAR') gives sh: 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

0

There are 0 answers