modify BAM read appearance based on flags

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

modify BAM read appearance based on flags

Saeed H. Al Turki
Hello,

I have a noob question. 

Is there a code snippet  to show how to change the way BAM reads look based on their flag? Basically, I'd like to modify the CSS/JS so I can differentiate four type of reads with samtools flag (99,147, 83 and 163).

I've seen few examples in the documentation but I am not really a savvy web developer and would appreciate any pointers.

Thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: modify BAM read appearance based on flags

Diesh, Colin M.
Hi Saeed


In general you can change the “color” callback in trackList.json for your track for customize colors, and then you can use feature.get() to retrieve properties of the features, so in the case of your app, you might have something like this

“style” {
    “color”: “function(feature) { if(feature.get(‘_flags’)==99) { return ‘red’; } else { return ‘green’; } }”
 }

There is also a "human readable" list of flags that you can check for with feature.get():

        multi_segment_template:              0x1,
        multi_segment_all_correctly_aligned: 0x2,
        unmapped:                            0x4,
        multi_segment_next_segment_unmapped: 0x8,
        seq_reverse_complemented:            0x10,
        multi_segment_next_segment_reversed: 0x20,
        multi_segment_first:                 0x40,
        multi_segment_last:                  0x80,
        secondary_alignment:                 0x100,
        qc_failed:                           0x200,
        duplicate:                           0x400,
        supplementary_alignment:             0x800


PS gmod-[hidden email] is the main mailing list for jbrowse discussion, but understandably that can be confusing. Try using that mailing list for further questions.


-Colin


On Aug 9, 2015, at 8:19 PM, Saeed H. Al Turki <[hidden email]> wrote:

Hello,

I have a noob question. 

Is there a code snippet  to show how to change the way BAM reads look based on their flag? Basically, I'd like to modify the CSS/JS so I can differentiate four type of reads with samtools flag (99,147, 83 and 163).

I've seen few examples in the documentation but I am not really a savvy web developer and would appreciate any pointers.

Thanks a lot