Search
Question: Shortread convert S4 vector qualityScore to vector
0
gravatar for Radek
15 months ago by
Radek40
Belgium
Radek40 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!

ADD COMMENTlink modified 15 months ago by Martin Morgan ♦♦ 20k • written 15 months ago by Radek40
1
gravatar for Martin Morgan
15 months ago by
Martin Morgan ♦♦ 20k
United States
Martin Morgan ♦♦ 20k 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 15 months ago by Martin Morgan ♦♦ 20k

Thanks! 

Exactly what I was looking for. 

ADD REPLYlink written 15 months ago by Radek40
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: 181 users visited in the last hour