This is a test version of Biostars. For the public version, visit https://www.biostars.org.
vcftools on 2 snpeff vcf files

I got my annotated variants in file1.vcf(control) and file2.vcf(clown) and now I need to find which non-synonymous SNPs are different between Sample Control and sample Clown. which command of vcftools I can use?

snpeff vcftools

1 answer

Something like this should do the trick:

bcftools merge -m snps -Ou file1.vcf file2.vcf | bcftools norm -m- -Ou | bcftools view -i 'ANN~"non_synonymous" & N_PASS(gt="alt")=1' -Oz -o output.vcf.gz

1st command merges the 2 samples 2nd splits multeallic records that may appear during the emerging process 3rd selects records where only 1 sample is bearing alternative allele (het or hom)

Just as a recommandation, it is better if you can, to call your 2 samples together. Indeed, if you have a record in one file but none in the other at the same location, you have no way of knowing if this is because second sampes if hom ref at this location or if it is just a no call due to a technical issue.

I am trying this command :

 bcftools merge -m snps -Ou ctrl.vcf.gz clownvar.vcf.gz | bcftools norm -m- -Ou | bcftools view -i 'ANN~"non_synonymous" & N_PASS(gt="alt")=1'

But it throwing following error:

Error: Duplicate sample names (unknown), use --force-samples to proceed anyway.
Failed to read from standard input: unknown file type
Failed to read from standard input: unknown file type

How can I solve this issue?

Your 2 samples have the same names Just as the error message suggests, you can run bcftools merge with the --force-samples to ignore the problem.

do i need bgzip compressed vcf files with -merge?

Log in to answer this question.