I am trying to write a code for importing sra files as fastq files in Rstudio (for obtaining and aligning RNA-seq reads from public repositories). I keep getting "Error in if (is.na(sra_acc$run[i])) { : argument is of length zero" right after I run this code. Any suggestions on what might be going wrong? My code is as follows:

sqlfile <-'SRAmetadb.sqlite'
if(!file.exists('SRAmetadb.sqlite')) sqlfile <<- getSRAdbFile()
sra_con <- dbConnect(SQLite(),sqlfile)
sraInf <- getSRAinfo("SRP045534",sra_con, sraType="sra")

Error in if (is.na(sra_acc$run[i])) { : argument is of length zero
  • 1
    $\begingroup$ Have you confirmed whether file.exists('SRAmetadb.sqlite') is TRUE or FALSE? Or generally, what the value of any of your variables is? I am not familiar with this library but having sqlfile be a string that is overwritten by the return value of getSRAdbFile() (don't know what that is) seems like it might cause an issue. Also, are you intending to use the superassignment operator (<<-)? I believe that you are using it in a non-standard way: stat.ethz.ch/pipermail/r-help/2011-April/275905.html $\endgroup$ Jan 29 at 20:34

After checking with file.exists(), I would suggest you try the same command with another SRA run. It may happen that some runs are not accessible for reasons I do not know. I always have problems in accessing sra formatted files and use a workaround to download fastq.

Here is my not official workaround:


study submission    sample experiment        run
1 SRP045534  SRA179382 SRS685546  SRX681992 SRR1552451
2 SRP045534  SRA179382 SRS685544  SRX681990 SRR1552449

for (dloadrun in runlist$run) 

This should iteratively download all the runs associated to the project you are studying. It is possible that you can do the same with sra type file, but I have never been able to use them with sraDB, and never investigated the issue.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.