Tutorial:Merging multiple vcf files into Single vcf file
Entering edit mode
5.0 years ago
jaybee ▴ 160

To merge multiple vcf files into a single vcf file from different samples, we can try the code below:

 /PATH/to/bcftools merge Home/data/*vcf.gz -Oz -o Merged.vcf.gz

considering that your files A.vcf.gz, B.vcf.gz and so on are in the Home directory, under the folder data

If your bcftools is installed in the usr/bin directory then simply use:

/usr/bin/bcftools merge Home/data/*vcf.gz -Oz -o Merged.vcf.gz

For selective merging:

One may create a list of selected vcf files using the command:

ls *.vcf.gz > vcfout.list

Then merge the selected files using the vcfout.list (file):

bcftools merge -m none --file-list vcfout.list -Oz -o ProjectMerge.vcf.gz

Courtesy: Pierre Lindenbaum, finswimmer, Kevin Blighe

This should work fine!

vcf bcftools • 12k views
Entering edit mode

Just to add that this will merge any file in Home/data/ that has vcf.gz at the end of the filename. Using the method that I showed you elsewhere, jaybee, one can have a list (stored as single column in a file) of the specific files that they want to merge. Each has pros and cons.


Login before adding your answer.

Traffic: 1513 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6