Question: ShortRead- how to edit the id in a fastq
gravatar for newmanss
2.8 years ago by
United States
newmanss0 wrote:

I need to edit the fragment IDs in a MiSeq fastq file. I'm using ShortRead to load the fastq and I've successfully managed to insert the substring needed  but I can't use my code to substitute the new ID into the id slot of my fastq.  Here is my current code:

fqr <- sub(" ",barcodestr, ShortRead::id(fqr))

In this case, the result is a list with only the ids.  I've lost the reads and quality values.

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘id’ for signature ‘"character"’
> head(fqr)
[1] "M00967:43:000000000-A3JHG:1:1101:17304:1428;barcodelabel=F3D8; 1:N:0:196"
[2] "M00967:43:000000000-A3JHG:1:1101:17368:2241;barcodelabel=F3D8; 1:N:0:196"
[3] "M00967:43:000000000-A3JHG:1:1101:15330:2396;barcodelabel=F3D8; 1:N:0:196"
[4] "M00967:43:000000000-A3JHG:1:1101:11983:2593;barcodelabel=F3D8; 1:N:0:196"
[5] "M00967:43:000000000-A3JHG:1:1101:20789:2650;barcodelabel=F3D8; 1:N:0:196"
[6] "M00967:43:000000000-A3JHG:1:1101:12794:3085;barcodelabel=F3D8; 1:N:0:196"

I've also tried: 

fqr@id <- sub(" ",barcodestr, ShortRead::id(fqr))
Error in checkAtAssignment("ShortReadQ", "id", "character") :
  assignment of an object of class “character” is not valid for @‘id’ in an object of class “ShortReadQ”; is(value, "BStringSet") is not TRUE

Please suggest how I access and overwrite the ID in my fastq.

Many thanks,  Susan


ADD COMMENTlink modified 2.8 years ago by Valerie Obenchain ♦♦ 6.4k • written 2.8 years ago by newmanss0
gravatar for Valerie Obenchain
2.8 years ago by
Valerie Obenchain ♦♦ 6.4k
United States
Valerie Obenchain ♦♦ 6.4k wrote:

Hi Susan,

The id in a ShortReadQ class must be a BStringSet object. The output of sub() is a character. The problem is that you are trying to put a character in a slot that expects a BStringSet.


myids <- sub("", barcodestr, ShortRead::id(fqr))

and then replacing the ids. It looks like there isn't an id<- replacement function and this may be by design. Martin may suggest another approach.


ADD COMMENTlink modified 2.8 years ago • written 2.8 years ago by Valerie Obenchain ♦♦ 6.4k

Thank you.  I will try that strategy.  A moment ago, before I checked for an answer, I tried one more approach that appears to work. 

fqr@id[ ] <- sub(" ",barcodestr, ShortRead::id(fqr))

then to check-

  A BStringSet instance of length 6
    width seq
[1]    72 M00967:43:000000000-A3JHG:1:1101:17304:1428;barcodelabel=F3D8; 1:N:0:196
[2]    72 M00967:43:000000000-A3JHG:1:1101:17368:2241;barcodelabel=F3D8; 1:N:0:196
[3]    72 M00967:43:000000000-A3JHG:1:1101:15330:2396;barcodelabel=F3D8; 1:N:0:196
[4]    72 M00967:43:000000000-A3JHG:1:1101:11983:2593;barcodelabel=F3D8; 1:N:0:196
[5]    72 M00967:43:000000000-A3JHG:1:1101:20789:2650;barcodelabel=F3D8; 1:N:0:196
[6]    72 M00967:43:000000000-A3JHG:1:1101:12794:3085;barcodelabel=F3D8; 1:N:0:196
ADD REPLYlink written 2.8 years ago by newmanss0

Generally it's very bad practice to access slots directly. The recommended way to update these objects is simply to create a new version -- fqr <- ShortReadQ(sread(fqr), quality(frq), BStringSet(sub("", barcodestr, id(fqr))))

ADD REPLYlink written 2.8 years ago by Martin Morgan ♦♦ 20k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 141 users visited in the last hour