I am trying to create a BAM file merging two different BAM files simulating at different level of contamination. Suppose I have two bam files for SampleA and SampleB. I want to generate 5 different BAM files at contamination level of 10%, 20%, 30%,40% and 50%. I understand that I should extract reads from one of the two bam files at the given dilution percentage and reassign to the other bam file, but I don't know exactly how to do this. Can someone please explain me the procedure? Thanks
Sub-sample BAM to get # of alignments you want: Subsample BAM to fixed number of alignments Then merge with your other BAM (and shuffle if needed randomly shuffle BAM file ).