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!
Thank you for the reply! I was attempting to avoid using bcftools isec after the merge because it outputs four extremely large data sets- however if this is the only option I will work with it.
Hello, how would someone do this? From what I can tell, isec produces a list of sites but doesn't produce a merged file. Would you need to then use
merge -R isec_output.vcf.gz myfile1.vcf.gz myfile2.vcf.gz
to get the merged file for only unique sites?