Obtain Number of PE Reads in BAM file Mapped to Each Chromosome
1
0
Entering edit mode
5.2 years ago
ssm87 • 0

Given a sorted/indexed BAM file (or SAM file if that is easier) which was produced by aligning PE reads to a reference genome, how can I enumerate the:

1) number of read pairs with both reads mapping to a particular chromosome

2) number of read pairs with only one of the reads mapping to a particular chromosome

i.e. scenario #1

--R1--> <--R2--

scenario #2

--R1-->

OR

<--R2--

alignment bam genome • 1.7k views
ADD COMMENT
1
Entering edit mode
5.2 years ago
goodez ▴ 640

1) Number of properly paired, mapped reads only on chr1:

samtools view -f 1 -F 12 -b file.bam chr1 | wc -l

2) It's possible for only first pair to be unmapped, or only second pair, so combine two commands:

samtools view -f 4 -F 264 file.bam chr1 | wc -l   

samtools view -f 8 -F 260 file.bam chr1 | wc -l

Add those two output together to get total number of reads where one pair is unmapped


Change the chromosome name as needed, this example was for chr1

ADD COMMENT

Login before adding your answer.

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