This is a test version of Biostars. For the public version, visit https://www.biostars.org.
sh: fastq-dump: command not found

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.

rna-seq r software error

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.
code_formatting

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 running unix_command on the SHELL at getwd() 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.

1 answer

try to install sra-toolkit manually on your system (HowTo: Binary Installation). Then add the path of sra-toolkit bin folder to either ~/.bashrc or ~/.profile OR you can just export the same into an environmental variable $PATH using the export command as:

export PATH=/path/to/sra-toolkit/bin/:$PATH

Restart your R environment and check whether it is working or not.

In case, if it is not working try with giving an absolute path to fast-dump. You can do something like this;

system("/opt/program/sratoolkit.2.9.0-ubuntu64/bin/fastq-dump")

Log in to answer this question.