This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How do you run a BWA alignnment command in R?

Hi, I'm trying to align my reads to a reference genome using the bwa alignment. I used this command wherein I already specified the path for my BWA folder ("path_bwa"):

system(paste(path_bwa, "/bwa aln -t ", proc, " ", genome, " FASTQ_FILTERED.fq > ", file_sai, sep=""))

However, it always shows this error: sh: /Applications/bwa/bwa: No such file or directory

Somehow, I think it assumes that the "/" in the "/bwa aln -t " is a directory and it is trying to look for it.

I tried deleting the "/" and just put "bwa aln -t " but it still doesn't work. Do you have any idea on what's wrong with the code?

Thank you so much for your help. It will be greatly appreciated.

Best, Carla

alignment r

1) why R ? why ? why ? why not a good-old bash/shell script ?

2) sounds like a path problem. check paste(path_bwa, "/bwa . What is the output of

find  /Applications/ -name "bwa"

and

which bwa

just curious why you don't do it in shell? And whether it's working in shell?

...or why not use one of the many fine pipeline frameworks actually designed for this?

I can easily invoke my BWA program by using full paths like this:

bwa.path <- "/Programs/bwa-0.7.12/"
system(paste(bwa.path, "bwa", " index", sep=""))

What is the value of path_bwa and proc ?

In addition to all comments on why do you want to wrap this on R, are you sure you want to use bwa aln? bwa mem is the recommended algorithm for most uses, unless your reads are really short, bellow 70bp.

citing OP on twitter :

1 answer

Maybe the below wrapper can help

https://rdrr.io/github/flow-r/ngsflows/man/bwa.html

Log in to answer this question.