I have mapped reads to a reference genome of a related species. I want to remove reads which map to a specific region (chromosome) of the reference, but I don't know what the best way to go about it is. I'm doing variant calling, and I've been using the -t ^ option in bcftools call to exclude the relevant chromosomes, but does this target regions in the reference, or in the mapped reads? Is it the same thing? Is it better to do this during mpileup phase?
I feel completely lost and would appreciate an ELI5.
1 answer
use bedtools complement to get the complement of your blacklisted.bed and then use samtools view -L complement.bed -O BAM -o out.bam in.bam
or use samtools view -M -L blacklisted.bed -O BAM --unoutput out.bam in.bam > /dev/null
Log in to answer this question.
Not sure if this would help but
samtools viewnow has the optionYou could create intervals for parts you want to keep.