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

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 • 833 views
ADD COMMENT
2
Entering edit mode
4.0 years 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
4.0 years ago
ATpoint 81k

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: 2581 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