Filter SAM file for read pairs that align on same strand
1
0
Entering edit mode
7 months ago
kmyers2 ▴ 90

I want to filter a SAM file for read pairs that align to the same strand. That is for R1 and R2, I want the alignment to be either both on the forward strand (FF) or both on the reverse strand (RR).

I used samtools view -F 0x2 to exclude any instance where the pairs align correctly (FR) but it looks like it's still including some FR reads with short read 1 lengths.

How can I filter a SAM file to only give me read pairs that align on the same strand, either both reads on the forward strand or both reads on the reverse strand?

samtools alignment sam • 529 views
ADD COMMENT
3
Entering edit mode
7 months ago
samtools view -e 'flag.paired && !flag.unmap && !flag.munmap && ((flag.reverse && flag.mreverse) || (!flag.reverse && !flag.mreverse))' in.bam
ADD COMMENT

Login before adding your answer.

Traffic: 2815 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6