The question might seem confusing, but I really have this problem.
I have an aligned.bam file for a sample. I want to separate the bam file: 1) above a certain coverage 2) and bam file not in that coverage range.
I have selected the aligned reads above a certain coverage using: samtools coverage > creation bed file > reads in this bed region i.e selected.bam. Now, I want to get the portion of the bam file that is not in the selected.bam. So, basically its a complement of the selected.bam
Step01: Aligned.bam > calculate coverage (bed file) > select region above certain coverage (selected.bed)
Step 02: Aligned.bam selected.bed (filter) > selected.bam
Step 03: How to get unselected.bam?
Note: I cannot use complement of the bed file because an aligned read may span the bed boundary. Using the complement of the bed file will cause some of the reads to be selected in both the categories.