I encountered an error when invoking fastq-dump function from RStudio (using system(), following the instruction from an article from Nature Protocol (DOI: 10.1038/nprot.2013.099 or https://www.nature.com/articles/nprot.2013.099). The puzzling part is: fastq-dump cannot be found when invoked from RStudio, but executed perfectly OK when from the command line (see the codes below).
RStudio code
>system("pwd")
/Users/Yeats
> system("fastq-dump")
sh: fastq-dump: command not found
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Command line code
Rs-MacBook-Pro:~ Yeats$ fastq-dump
Usage:
fastq-dump [options] <path> [<path>...]
fastq-dump [options] <accession>
Use option --help for more information
fastq-dump : 2.9.1
I guess the system() use a different searching directory than command line, but I couldn't identify the right nomenclature to get relevant results from Google search. BTW: sratoolkits was installed into the default directory with the conda: conda install sra-tools
Any suggestion of the problem itself or similar are verily welcome. Thank you very much for your time and help.
This is a question, not a forum post. I've made the necessary changes. Also, Please use the formatting bar (especially the
code
option) to present your post better. I've done it for you this time.Thanks a lot for your tips Ram.
I'm unfamiliar with using R for this, but what does
system("echo $PATH")
show you? Is it different from your "shell $PATH"?system(unix_command)
is the same as runningunix_command
on the SHELL atgetwd()
location.Since R-studio is not R, try the same in R. Launch R and try to run OP code. If it works, it is R-studio issue. If it is R-studio issue, launch OS terminal and type
open -a RStudio
within terminal. Check if r-studio still shows the issue.Amazingly that R code works when launch RStudio from terminal. Thanks a lot for your tips! :)
this means Rstudio can't read user local env. Try to configure R studio to read local env.