Hello everyone,
I have some STAR_aligned bam file. I want to add color tags to some reads in the file using pysam, in order to track them better in IGV.
Here is the code part which adds the tag:
red = '255,0,0'
r = pysam.AlignedRead()
r.tags += [('YC', red)]
This updates the file with new tag, which however does not work properly in IGV. I think some casting is missing here which I cannot think of.
Has anyone done this before? Thank for your help :)
can you see this YC tag in your bam using samtools view ?
Yes, and it looks like a decent one:
But in IGV I get this error once I try hover over these reads (and of course no view):
"Error encountered querying alignments: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String"
Hi Pierre, you are right one tag is not of correct type. That's curious! Please take a look at these two queries of the same read, before and after adding the color tag:
after:
I did not make any changes to the RG tag, but somehow its type has changed. Any theories? Tag parsing maybe??
yes, you should change your read group to a two-letter code.