Question: Reading fastq file after narrowing sequences
0
gravatar for ioannis.vardaxis
23 months ago by
Norway/Oslo
ioannis.vardaxis30 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?

 

 

shortread fastqstreamer • 409 views
ADD COMMENTlink modified 23 months ago • written 23 months ago by ioannis.vardaxis30
Answer: Reading fastq file after narrowing sequences
1
gravatar for ioannis.vardaxis
23 months ago by
Norway/Oslo
ioannis.vardaxis30 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 23 months ago by ioannis.vardaxis30

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

ADD REPLYlink written 23 months ago by Martin Morgan ♦♦ 23k
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 16.09
Traffic: 410 users visited in the last hour