compute count of position coverage with bedtools
1
1
Entering edit mode
8.5 years ago
sacha ★ 2.4k

I have a bed files with several regions :

exons.bed 
chr4   4    200
chr5   3    100 
chr5   90  110

I want to get the number of position covered by this bed file. For the exemple, I want : (200-4) + (100-3) + 10

bedtools • 1.9k views
ADD COMMENT
1
Entering edit mode

You could use R:

bed = read.delim(exons.bed,as.is=T)
bp_covered = sum(bed[,3]-bed[,2])
ADD REPLY
2
Entering edit mode
8.5 years ago
sacha ★ 2.4k

For now, I success with this oneliner :

bedtools merge -i test.bed|awk '{print $3-$2}'|paste -sd+|bc
ADD COMMENT

Login before adding your answer.

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