Split a VCF file into individual sample files
I have the thousand genomes VCF file such as the following ALL.chrX.integrated_phase1_v3.20101123.snps_indels_svs.genotypes.vcf.gz and this contains all the samples data in many, many columns. I want to split this file into separate VCF files, one for each sample. I tried the following code with the new bcftools and kept getting error that -h is not defined. Is there some other way I can convert into individual VCF files?
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
Thanks in advance.
• 8.1k views
Read more here: Source link