This is a test version of Biostars. For the public version, visit https://www.biostars.org.
RC an entire bam file?

Hello everyone,

I've been trying for ages to get IGV to show me reverse complemented reads, but I only find the button to RC the reference track and corresponding genes track.

I'm trying to prepare a screenshot for a poster presentation and the gene whose mutation I'm interested in showing is on the reverse strand so IGV is showing the RC of the mutation, which is confusing...

Is there a more elegant solution than what I'm considering?

Thanks in advance and merry weekend! Joel

sam genome complement viewer alignment bam reverse

2 answers

Pull out the reads that aligned, realign them to a smaller ref that runs the right way.

Or to be thorough, re-do the alignments with an index of complementary strand of original reference.

I am trying this, let's see how it works out :-] Thanks!

You can get IGV to color alignments by strand.

If you need full separation then filter your SAM file and create a distinct alignment file for each strand.

samtools view -b -F 16 all.bam > fwd.bam
samtools view -b -f 16 all.bam > rev.bam

This will not fix the problem I think. Regardless of strandedness, the reads were aligned to the reference genome and will show a G instead of a C. :(

The BAM format, by definition, was designed to refer to both positions and bases on the forward strand.

Inside the BAM file, alignments on the reverse strand will store a reverse complemented version of the original read and only the flag indicates that the read originally came from the reverse strand.

This is so that you can easily compare two reads that overlap on the same region in different directions. The main use-case was variation detection and validation by visual inspection.

What exactly is your use case? Perhaps there is a different solution to it.

My use case is that I need the reads to be RC'd, so that the mutation I need to screenshot and put on my poster for presentation shows the right base. Now it shows a G, but it should show a C. What do you think of swbarnes2's suggestion? It should work...

my suggestion is to avoid displaying an IGV screenshot that shows mutations the "wrong" and "unnatural" way.

it would confuse everyone that knows how IGV works and would mislead everyone else that does not know how IGV works, then when they load their data is backwards,

olor the reads by strand, then it is immediately apparent how many reads carry the same mutation.

that is the whole point of showing the same mutation, it is much easier to the consistency across strands when the base is the same,

compare

CCCCCCCTC to CCCGCCGCTG

I was unclear, I meant that ALL the reads would be rc'd, or, equivalently, the reference genome rc'd before mapping. I tried this and it works. :-]

Log in to answer this question.