So I was wondering if anyone had any advice or tools to help make different BAM or SAM files equivalent. What I mean by that is I have aligned the sequence data of different populations of a species to the same reference genome and due to some reason or another the number of alignments in each BAM file varies widely, for example, 360,000 vs 1,400,000. I'm hoping to do further downstream analysis in popoolation2 and in order to accurately compare these populations I think it will help to only include regions where all the populations aligned to that spot in the reference genome.
So basically I would need something that would compare two bam files and output two new bam files with alignments that were at the same regions on the reference genome.
I have the alignments in SAM, BAM, and sorted BAM formats so that is my starting point! Hopefully, I explained that well enough and thanks for any and all suggestions!