This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract Reads From A Bam File That Fall OUTSIDE A Given Region

Using samtools view -L FILE command we can extract reads which are in the FILE regions. Is there a way to extract reads which are OUTSIDE of the FILE regions?

Thanks

bam

I would suggest 2 options: 1) Create a bed file with the complementary regions to your current region file and run samtools with that new bed file. 2) Use bedtools intersect, applying -v argument.

1 answer

samtools view -L in.bed --unoutput out.bam in.bam > /dev/null

Log in to answer this question.