How to calculate number of positions covered by at least 10 times in bam file?
2
0
Entering edit mode
19 months ago
rimgubaev ▴ 270

Hello everyone! I wonder if somebody could recommend how to calculate the number of positions covered by at least 10 times in bam file? To calculate the number of positions covered by at least once in the bam file I used this oneliner:

bedtools genomecov -ibam my_alignment.bam -bg | awk '{ s+=($3-$2) } END { print s }'

But I have no idea how to modify it, so please help!

coverage bam alignment bedtools awk • 324 views
ADD COMMENT
2
Entering edit mode
19 months ago
samtools depth in.bam | awk '($3>10)' | wc -l
ADD COMMENT
0
Entering edit mode

Thank you, that works well!

ADD REPLY
2
Entering edit mode
19 months ago
ATpoint 55k

A simple if does the trick.

bedtools genomecov -ibam my_alignment.bam -bg | awk '{ if($4 >= 10) s+=($3-$2) } END { print s }' foo
ADD COMMENT
0
Entering edit mode

Thanks, id is perfect!!!

ADD REPLY

Login before adding your answer.

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