This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to filter out passed SNVs to create new files using bcftools isec.

So I have 2 vcf files, I need to make 3 files, where one is unique to file1.vcf and the other is unique to file2.vcf and the last is all common variants that are shared by both files. I need to this all by filtering out the passed SNVs only for each file. I just got started with bcftools yesterday, so I am very new here, but this is my closest attempt on making it happen.

bcftools isec -f 'PASS,.' --types 'snps' [file1.vcf.gz] [file2.vcf.gz] -p dir

Please help me out. My internship depends on it. Thanks!

isec snv

Where did you get the --types argument from? Which version of bcftools are you using?

1 answer

Take a look at the bcftools isec documentation, in particular to the --exclude expression. According to the documentation:

exclude sites for which EXPRESSION is true. If -e (or -i) appears only once, the same filtering expression will be applied to all input files. [...] For valid expressions see EXPRESSIONS.

If you look at the EXPRESSIONS list, you can find the TYPE expression, which refers to the variant type.

Your command then should look like this one:

bcftools isec -f 'PASS,.' -e 'TYPE!="snp"' [file1.vcf.gz] [file2.vcf.gz] -p dir

This will exclude all the variants that are not SNVs.

Log in to answer this question.