How to use Samtools to remove reads whose mate does not map as expected
2
2
Entering edit mode
10.4 years ago

Can anyone tell me how to remove reads whose mate does not map as expected? I know GATK is able to do this.

There is an option fixmate in samtools, but it could not be used to remove the reads I described above.

next-gen • 7.0k views
ADD COMMENT
3
Entering edit mode
10.4 years ago
poisonAlien ★ 3.2k

I might be wrong here, but looking at the sam flags;

2 - for read mapped in proper pair

So you can just keep the reads mapped in proper pair.

samtools view -f 2 foo.bam
ADD COMMENT
0
Entering edit mode

Does this mean that I have to convert the Bam file into sam file first? I wonder whether there is a way to remove reads unmapped in proper pair.

ADD REPLY
1
Entering edit mode
10.3 years ago
Ian 6.1k

You can input a BAM or SAM file:

samtools view -f 2 -o foo_proper-pairs.bam foo.bam
samtools view -f 2 -bS -o foo_proper-pairs.bam foo.sam

[this was meant to be a comment on the previous reply]

ADD COMMENT

Login before adding your answer.

Traffic: 2727 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