I have a bed file of coordinates and would like to clip anything outside these regions in my aligned bam files. However, trying programs such as bedtools intersect and samtools ampliconclip (on complementary bed file), they always let some reads slip through outside the ranges. I tried using hard-clip and both-ends options for ampliconclip aswell.
Example (top is clipped bam, middle is unclipped bam and bottom is bed file with regions I would like to keep):
Although most reads outside the designed amplicons are removed, there are still reads outside the regions in the Designed_pool1 file. The problem is that the bed file contains amplicons and outside the amplicons are primers where I do not want to call variants. I cannot get the exact primer sequences because I don't know their length and the manufacturer does not state them, so I cannot use programs that require primer sequences.
Does anyone have some experience with this and know why the programs behave this way?
The exact commands I have used are:
bedtools intersect -a $BamFile -b $BedFile > $BamOut
samtools ampliconclip --hard-clip --both-ends -b $ComplBedFile $BamFile > $BamOut
as well as without --hard-clip and --both-ends options. All methods let some sequences stay out of the regions in bed files.
I am not completely familiar with the bedpe format, but I am not using paired end data. I cannot get primer start and stop positions, only amplicon positions.