Trying to find regions with a coverage less than 9 in a BAM file, I used:
bedtools genomecov -bga -ibam infile.bam | awk '$4<9' > lessthan9cov.bed
The output file is something like:
scaffold1 12861 12866 7
scaffold1 12866 12877 1
scaffold1 12877 12896 3
scaffold1 31141 31193 8
scaffold2 31193 31229 5
..
This output has too many rows. Is there a way to have a file which for any continuous region with any coverage less than 9, has a single row?
The desired file should have:
scaffold1 12861 12896
scaffold1 31141 31193
scaffold2 31193 31229
Thank you
Is your
genomecov
command correct? Don't you need to specify genome file?As much as I know, when working with BAM files, you do not need to specify genome file.