7
$\begingroup$

I recently installed Ubuntu 16.04 (because I was still using 12.04). But it seems my bedtools scripts don't work properly anymore. I can't figure out how to use the new bedtools for my old ways. What I want to do is get the number of reads from a bam file, per interval from a bed file. It was very simple with my old version of Ubuntu and bedtools:

bedtools coverage -abam file.bam -b All_peaks.bed > file.cov.txt

But this doesn't seem to work anymore. I used to get small files as results (~3MB), but now huge files are created (~4GB) including read names??

I am using bedtools v2.25 now.

$\endgroup$
5
$\begingroup$

The order of -a and -b switched at some point. You want:

bedtools coverage -a All_peaks.bed -b file.bam > file.cov.txt

For reference, this is the end of the help output in version 2.25:

Default Output:  
     After each entry in A, reports: 
       1) The number of features in B that overlapped the A interval.
       2) The number of bases in A that had non-zero coverage.
       3) The length of the entry in A.
       4) The fraction of bases in A that had non-zero coverage.

And this is the equivalent output from version 2.19:

Default Output:  
     After each entry in B, reports: 
       1) The number of features in A that overlapped the B interval.
       2) The number of bases in B that had non-zero coverage.
       3) The length of the entry in B.
       4) The fraction of bases in B that had non-zero coverage.

Update: The change in behavior happened in version 2.24:

We have changed the behavior of the coverage tool such that it is consistent with the other tools. Specifically, coverage is now computed for the intervals in the A file based on the overlaps with the B file, rather than vice versa.

$\endgroup$
  • $\begingroup$ Thanks Devon! I wasn't aware of the 'switch'. Switching -a and -b solves indeed my problem! $\endgroup$ – benn Aug 17 '17 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.