This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merge genotypes of two vcf files

Hi,

I have two vcf files, both with the same samples and variants. They come from two methods. I need to create a new vcf file, which merges the genotypes and I will compare if they are identical or not, accordind to the method.

For example :

vcf1 : 2       13958715        AX-325448157    T       C 0/0
vcf2 : 2       13958715        AX-325448157    T       C 0/0

output : 2       13958715        AX-325448157    T       C 0/0:0/0

I used :

vcfgtcompare.sh other 1.vcf 2.vcf > test.vcf

But when I check the test.vcf file, I have wrong merging. Both vcf files are sorted, by chromosome and samples.

Any help?

vcf vcftools

1 answer

both with the same samples and variants.

Same samples and variants ? how about

comm \
     <(bcftools query -f '[%CHROM:%POS:%REF:%ALT:%SAMPLE:%GT\n]' file1.vcf| sort) \
     <(bcftools query -f '[%CHROM:%POS:%REF:%ALT:%SAMPLE:%GT\n]' file2.vcf| sort)

Log in to answer this question.