Question: Converting Fastq to Fasta in R
0
5 months ago by
christinafragel0 wrote:

I am working on converting multiple fastq.gz files of raw sequence data into fasta files. I am trying to use the following lines of code to access the files in my directory based on pattern and convert them to fasta format. I have used two variations. The first which gives and error and the second does not. However, the second variation does not seem to produce a file. Any ideas???

1. writeFasta(readFastq("C:/Users/Christina/Desktop/Colucoides fastq", pattern = ".fastq.gz"), pattern = ".fa")

Error in isSingleString(filepath) : argument "file" is missing, with no default

2. writeFasta(readFastq("C:/Users/Christina/Desktop/Colucoides fastq", pattern = ".fastq.gz"), pattern = ".fa")

R bioinformatics fasta fastq • 364 views
modified 5 months ago by James W. MacDonald50k • written 5 months ago by christinafragel0
Answer: Converting Fastq to Fasta in R
0
5 months ago by
United States
James W. MacDonald50k wrote:

That's never going to work. You are asking R to read in all the FASTQ files in a directory and then hoping that it will then write them back out with the same names, but as FASTA files instead. But R isn't a mind reader. You have to be more specific. One alternative would be to pre-specify the input and output names.

whereitsat <- "C:/Users/Christina/Desktop/Colucoides fastq"
inny <- dir(whereitsat, pattern = "fastq.gz\$")
outie <- paste0(whereitsat, "/",  gsub("fastq.gz","fa", inny))

for(i in seq(along = inny)) writeFasta(readFastq(whereitsat, inny[i]), outie[i])