is there any way to covert SRA files to Fasta in R ?
3
2
Entering edit mode
9.1 years ago
Mo ▴ 920

Hello,

I was wondering whether there is any way to read several sra and convert them in R?

There are quite some links here but none helps me out

fasta sra RNA-Seq r • 6.1k views
ADD COMMENT
2
Entering edit mode

Why use R for this task?

ADD REPLY
1
Entering edit mode

@Ram there are many available functions to work this out in unix etc. I am interested in R since I want to do all my analysis in R and not jumping from one to another! These days I sleep with R and wake up with R :-p so that is why I am searching for it in R :-D

ADD REPLY
3
Entering edit mode
9.1 years ago
Mo ▴ 920

This solved my problem using Mac

Open a terminal

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then

brew install sratoolkit

Then you can use the command line given by fridaymeetssunday or Devon Ryan

ADD COMMENT
0
Entering edit mode

You answered your own question... extra points for that :)

To be fair we should have explicitly told you that you needed fastq-dump in your system to execute that command.

ADD REPLY
2
Entering edit mode
9.1 years ago

Not that it makes any sense but:

system(sprintf("fastq-dump --fasta %s", sra_file_name_or_accession))
ADD COMMENT
0
Entering edit mode

@Devon Ryan why it does not make any sense? My main problem now is how to import the sra file in R. because this function is working only if you have already loaded the files in R

ADD REPLY
2
Entering edit mode

This doesn't require loading anything other than a file name or accession number into R (presumably done via SRAdb). The system() command just runs fastq-dump from the command line. You're actually using the command line, just from R. So while technically this is using R, it's also cheating by not doing so. This sort of thing is convenient if you need to automagically download and process stuff from SRA, but there are probably more convenient APIs for doing this than in R.

Look through some threads here where people discuss languages for writing pipelines. R comes up as an option, since you can do things like I did above, however there's a reason it's not a popular method (it ends up not being that convenient).

ADD REPLY
0
Entering edit mode

@Devon Ryan sorry for basic questions! I see, however, I will check whether I see any differences in result using other ways than R or not . if this is a command line, then why I cannot get it run

> system(sprintf("fastq-dump --fasta %s", SRR000648.lite.sra))
Error in sprintf("fastq-dump --fasta %s", SRR000648.lite.sra) :
  object 'SRR000648.lite.sra' not found
ADD REPLY
0
Entering edit mode

I think you need the full path to the file. The system call does not start from the current R session working directory.

ADD REPLY
0
Entering edit mode

@Matt Shirley not really I have tried to link the full path to the file but other types of error come up like sh: fastq-dump: command not found

ADD REPLY
0
Entering edit mode

My advice at this point: try running the command in your unix shell first. It seems that you have not installed the SRA toolkit, or that the shell invoked by R's system call does not find your PATH env variable, or both.

ADD REPLY
0
Entering edit mode

Dump the command in to your system. :)

ADD REPLY
2
Entering edit mode
9.1 years ago
A. Domingues ★ 2.7k

Not in R as such, but of you can use the package SRAdb to download the SRA and then:

system("fastq-dump SRR000648.lite.sra")

As simple as that.

ADD COMMENT
0
Entering edit mode

Looks like I posted just after you clicked on the question :P

ADD REPLY
1
Entering edit mode

Pretty much ;) The time it took me to add the link to SRAdb was enough to be thwarted!

ADD REPLY
0
Entering edit mode

@fridaymeetssunday Seems like yours does not work or I am doing something wrong

> system("fastq-dump SRR000648.lite.sra")
sh: fastq-dump: command not found
ADD REPLY

Login before adding your answer.

Traffic: 2517 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6