Converting Fastq to Fasta in R
1
0
Entering edit mode
@christinafragel-19563
Last seen 2.7 years ago

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 Fastq Fasta • 1.8k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 10 hours ago
United States

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])
ADD COMMENT
0
Entering edit mode

Thanks. I'll try that and work from there.

ADD REPLY

Login before adding your answer.

Traffic: 261 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