I have a merged vcf file for 4 samples and I want to unmerge it and get one vcf per each sample. How can I do that? I’ve found vcftools has only merge-vcf tool … is there any tools to unmerge vcf files?
I know this is an old question but, as I've already stated in this post, there's a very efficient way of doing this that hasn't been reported yet. hope it helps:
for file in *.vcf*; do
for sample in `bcftools view -h $file | grep "^#CHROM" | cut -f10-`; do
bcftools view -c1 -Oz -s $sample -o ${file/.vcf*/.$sample.vcf.gz} $file
done
done