Hi all,

I would like to merge two vcf files chr1g.vcf.gz and chr1hk.vcf.gz. I would like the resulting file to have only the intersection of the two files upon merge.

chr1g.vcf.gz excerpt:

CHROM .POS ....ID... REF... ALT ... QUAL... FILTER....... INFO

chr1 ..... 10031 .. NA .. T ....... C .. NA .. AS_VQSR
..AC=0,etc

chr1 ..... 10055 .. NA .. T ....... C .. NA .. AS_VQSR
..AC=0,etc

chr1 ..... 10061... NA... T........ C .. NA .. AS_VQSR
..AC=0,etc

chr1 ..... 10061... NA ... T ...... TAACC.. .. NA .. AS_VQSR
...AC=0,etc

chr1 .....10109 ... NA ... A....... T .. NA .. AS_VQSR
..AC=0,etc

chr1 .... 10109... NA... AACCCT A .. NA .. AS_VQSR
.. AC=0,etc

..

chr1hk.vcf.gz excerpt:

CHROM .POS ....ID... REF... ALT ... QUAL... FILTER....... INFO

chr1 ..... 10055 .. NA .. T ....... C .. NA .. AS_VQSR
..AC=0,etc

chr1 ..... 10061... NA... T........ C .. NA .. AS_VQSR
..AC=0,etc

chr1 .....10109 ... NA ... A....... T .. NA .. AS_VQSR
..AC=0,etc

chr1 .... 10109... NA... AACCCT A .. NA .. AS_VQSR
.. AC=0,etc

..

Merging goal ex:

CHROM .POS ....ID... REF... ALT ... QUAL... FILTER....... INFO

chr1 ..... 10055 .. NA .. T ....... C .. NA .. AS_VQSR
..AC=0,etc

chr1 ..... 10061... NA... T........ C .. NA .. AS_VQSR
..AC=0,etc

chr1 .....10109 ... NA ... A....... T .. NA .. AS_VQSR
..AC=0,etc

chr1 .... 10109... NA... AACCCT A .. NA .. AS_VQSR
.. AC=0,etc

..
..
The code I have been working with is as follows:
"bcftools merge --merge none chr1g.vcf.gz chr1hk.vcf.gz > chr1merge.vcf"
This code works to merge based off of REF/ALT allele matches, but is the union of the two original files. How can I tweak it to keep only the intersection?

Thank you!



Source link