This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merge selective vcf files into one vcf file using a single command

Hello

I have a directory named "set" where I have 4 sets namely set1, set2, set3, and set4. Each set has 50 Indel vcf files and 50 SNP vcf files. The files are vcf.gz format along with their index files, .vcf.gz.tbi.

In each set, for Indel as well as for SNP, I created a list for only the vcf files (before creating their respective index files) using

for i in *.vcf.gz;
do ls > vcfindel1.list
done

[vcfindel1.list is the list of vcf files of the indels in set 1 ONLY]

It creates a list file for every indel and SNP for each set.

Now, I use merge command to merge all 50 vcf files into One vcf file using:

command="bcftools merge -Ob -m none " ;

while read vcfindel1
do
    command="${command}"" ""${vcfindel1}" ;
done < vcfindel1.list

command="${command}"" -o ProjectMerge.bcf" ;

echo `$command` ;

bcftools index ProjectMerge.bcf ;

But, I receive the error message:

vcfindel1.list unknown file type

Anybody can help me solve this?

bcftools vcf merge wes

Hello jaybee!

We believe that this post does not fit the main topic of this site.

I closed this post as I have received the solution of my question.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

1 answer

don't

for i in *.vcf.gz;
do ls > vcfindel1.list
done

but

ls *.vcf.gz > vcfindel1.list

or

find . -type f -name "*.vcf.gz" > vcfindel1.list

Then use simply something like:

bctools merge -m none --file-list   vcfindel1.list -O z -o out.vcf.gz

Woah! It works !! Thank you! :)

Log in to answer this question.