Shortread convert S4 vector qualityScore to vector
1
0
Entering edit mode
Radek ▴ 90
@radek-8889
Last seen 6.0 years ago
Belgium

Hello!

I having some difficulties to convert a S4 vector to a vector in the shortRead package.

I simply would like to trim the sequences contained in a shortReadQ object and their associated quality scores based on a vector (filterTable$start).

Such as:

# Read the fastq file

fq <- readFastq(fastq, as.string=TRUE)

# Trim the Sequences

sequences<- substr(sread(fq), start=1, stop=filterTable$start)    

# Trim the quality scores                   

qualities <- substr(quality(fq), start=1, stop=filterTable$start)        

# Save the file

ShortReadQ(DNAStringSet(sequences),BStringSet(qualities),BStringSet(id(fq)))       

It is perfectly working for the sequences but not for the qualities. I tried different approaches to trim them, but I'm always stopped by a "Cannot convert S4 vector to vector".

Does someone know the right approach to transform the quality into a vector?

Thanks in advance!

shortread • 1.6k views
ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 4 months ago
United States

For a repeatable example, I ran

example(readFastq)

I then have an object rfq, which I trimmed with

> end = sample(20:36, 256, TRUE)
> trimmed = narrow(rfq, 1, end)
> trimmed
class: ShortReadQ
length: 256 reads; width: 20..36 cycles

The help page ?filterFastq might suggest another approach.

 

ADD COMMENT
0
Entering edit mode

Thanks! 

Exactly what I was looking for. 

ADD REPLY

Login before adding your answer.

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