Reading fastq file after narrowing sequences
1
0
Entering edit mode
@ioannisvardaxis-11763
Last seen 9 months ago
Norway/Oslo

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 • 1.5k views
ADD COMMENT
1
Entering edit mode
@ioannisvardaxis-11763
Last seen 9 months ago
Norway/Oslo

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

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

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