Error in if (is.na(sra_acc$run[i])) { : argument is of length zero 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 &quot;Error in if (is.na(sra_acc$run[i])) { : argument is of length zero&quot; right after I run this code. Any suggestions on what might be going wrong? My code is as follows:
library(SRAdb)
sqlfile &lt;-'SRAmetadb.sqlite'
if(!file.exists('SRAmetadb.sqlite')) sqlfile &lt;&lt;- getSRAdbFile()
sra_con &lt;- dbConnect(SQLite(),sqlfile)
sraInf &lt;- getSRAinfo(&quot;SRP045534&quot;,sra_con, sraType=&quot;sra&quot;)

Error in if (is.na(sra_acc$run[i])) { : argument is of length zero
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:
runlist&lt;-sraConvert(&quot;SRP045534&quot;,sra_con=sra_con)
runlist[1:2,]

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

for (dloadrun in runlist$run) 
{
    getSRAfile(dloadrun,sra_con=sra_con,fileType=&quot;fastq&quot;)
}

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.