2
$\begingroup$

I have 6 VCF files, where I would like to obtain the SNPs that are common (by position) in all the 6 files. I have tried this command

bcftools isec  -p trial2 -n=6 -c all A2_SNP.vcf.gz A_SNP.vcf.gz B_SNP.vcf.gz C_SNP.vcf.gzD_SNP.vcf.gz E_SNP.vcf.gz

But this produces 6 files, and through the README file, I think each of the VCF contains the unique SNPs for each of the 6 files, and I could only get sites.txt file that ocntain the positions that are common. Are there any way to get a VCF file that have the common SNPs ?

Thanks

New contributor
Mohamed Samir is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$

1 Answer 1

2
$\begingroup$

You've used the right tool and gotten the right results. What you need to understand is that VCF contains variant loci as well as the genotypes for >=1 sample(s) at those loci. The intersect operation will extract common loci, but it does not know which genotypes you're interested in, which is why it generates one file per input, giving you the genotypes from each VCF for the common loci.

You could use the sites file to do a bcftools merge operation, limiting to just the common sites using the -R <regions-file> option so you'd get a VCF with all the samples across all 6 input VCFs but only for the variant loci.

$\endgroup$
4
  • $\begingroup$ Thanks a lot. For my understanding: Do you means that the output 6 files from isec tool I used is a VCF for each sample and contains the genotype (and other info) for only that common sites (that are also in site.txt) ? If so, do you assume that if I merge this using -R, then that merged VCF file contains all 6 samples. How can I get the genotype or alleles for the 6 individuals ? $\endgroup$ May 23 at 22:37
  • $\begingroup$ Yes, each VCF output should contain information from its corresponding VCF input. You could either use sites file to merge all 6 original inputs or simply merge all 6 isec outputs get to the merged common-loci VCF. $\endgroup$
    – Ram RS
    May 24 at 15:11
  • $\begingroup$ So, merging the 6 VCF file will justput them side by side on sample basis ? Could you advise on a code for that ? $\endgroup$ May 24 at 15:19
  • $\begingroup$ Try the command, look at the output and come back if you have further questions. $\endgroup$
    – Ram RS
    May 24 at 17:52

Your Answer

Mohamed Samir is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.