Question: Shortread convert S4 vector qualityScore to vector
0
gravatar for Radek
3.2 years ago by
Radek60
Belgium
Radek60 wrote:

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 • 575 views
ADD COMMENTlink modified 3.2 years ago by Martin Morgan ♦♦ 23k • written 3.2 years ago by Radek60
Answer: Shortread convert S4 vector qualityScore to vector
1
gravatar for Martin Morgan
3.2 years ago by
Martin Morgan ♦♦ 23k
United States
Martin Morgan ♦♦ 23k wrote:

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 COMMENTlink written 3.2 years ago by Martin Morgan ♦♦ 23k

Thanks! 

Exactly what I was looking for. 

ADD REPLYlink written 3.2 years ago by Radek60
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: 326 users visited in the last hour