Question: Splitting paired end bam files
1
gravatar for tharveshliyakat
3.7 years ago by
France
tharveshliyakat60 wrote:

Hello all,

Any efficient way to split the bam file to two separate files, say one file with only singletons(mate unmapped) and other with paired reads(no matter if it is discordant).

I have already used.

(i) samtools view -f 8 -F 4 -b foo.bam > foo.singletons.bam

(ii) samtools view -f 1 -F 12 -b foo.bam > foo.paired.bam

Is this correct solution to go ahead.

PS: This file has already been filtered for uniquely mapped reads using NH:i:1 tags.

rna-seq next-gen • 1.9k views
ADD COMMENTlink modified 3.7 years ago by Dan D6.7k • written 3.7 years ago by tharveshliyakat60
2

if you -f 1 to the second command, you should really -f 9 to the first to be fair :)
Even though its unlikely youll ever come across a bam file with both single reads and paired reads, the first command would match both. The single reads it would match would also be pretty random - not all of them.

ADD REPLYlink written 3.7 years ago by John12k
1
gravatar for Dan D
3.7 years ago by
Dan D6.7k
Tennessee
Dan D6.7k wrote:

That looks good to me. To save space, you might also try outputting to a named pipe:

A: Filtering Stream Bam Output Idealy From Pysam/Python.

ADD COMMENTlink modified 3.7 years ago • written 3.7 years ago by Dan D6.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1606 users visited in the last hour