Search
Question: Reading fastq file after narrowing sequences
0
gravatar for ioannis.vardaxis
6 months ago by
Norway/Trondheim/NTNU
ioannis.vardaxis20 wrote:

Hi,

I have a fastq file named fastq1 which I upload in R using:

StreamFastq1=ShortRead::FastqStreamer(con=fastq1,n=2000000)

fastq1yield=ShortRead::yield(StreamFastq1)

 

I then use the narrow funstion to narrow the reads of fastq1yield:

 fastq1yield_narrowed@sread=Biostrings::narrow(fastq1yield@sread,start=1,end=Cut_pos)

Where Cut_pos is a vector of same length as fastq1yield , but with different values for each entry. So I cut the sequences in different places resulting in different lengths for each sequence in fastq1yield_narrowed.

Then I save the file using:

        ShortRead::writeFastq(object=fastq1yield_narrowed,file="fastq1yield_narrowed.fastq.gz",mode="w",compress=TRUE)

Everything looks good in the new fastq1yield_narrowed file, except when I try to load it in R again using:

StreamFastq1_narrowed=ShortRead::FastqStreamer(con=fastq1yield_narrowed,n=2000000)

fastq1yield_narrowed=ShortRead::yield(StreamFastq1_narrowed)

I get the following error:

Error in add(bin) : internal: buf != <newline>

Why is this happening? Is there any way of solving this?

 

I also tried to read the whole file in R at once using:

fastq1yield_narrowed=ShortRead::readFastq(fastq1yield_narrowed)

And I get the following error:

Error: Input/Output
  file(s):
    fastq1yield_narrowed.fastq.gz
  message: IncompatibleTypes
  message: invalid class “ShortReadQ” object: some sread and quality widths differ

 

Which means that I cant read a fastq file with different lengths. Is there a way to solve this?

 

 

ADD COMMENTlink modified 6 months ago • written 6 months ago by ioannis.vardaxis20
1
gravatar for ioannis.vardaxis
6 months ago by
Norway/Trondheim/NTNU
ioannis.vardaxis20 wrote:

I solved it. I also had to narrow the qualities slot in the fastq file before saving. Now it uploads just fine.

ADD COMMENTlink written 6 months ago by ioannis.vardaxis20

You shouldn't be using direct slot access (@...); ShortRead::narrow() operates on the fastq object.

ADD REPLYlink written 6 months ago by Martin Morgan ♦♦ 21k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 285 users visited in the last hour