I wanted to know how can I extract separate sample vcf files for each sample from a multi sample vcf file containing data of more than 1000 samples.
Splitting vcf files to individual samples ; Split a VCF file into individual sample files ; split vcf by individual ; split vcf file into multiple files ; etc... etc...
You can use bcftools view with -s parameter.
Here I need to give samples names separately as input which is too tedious for all samples . I need all samples regardless of any particular one .
bcftools query -l prints all the samples which you can loop over. Here is an example snippet I use. It gonna create a directory and write each individual sample with their sample name in to that directory.
bcftools query -l
mkdir -p "$OUTDIR"
for sample in $(bcftools query -l "$MULTISAMPLEVCF"); do
bcftools view -c 1 -s $sample $MULTISAMPLEVCF -Oz -o "$OUTDIR/$sample"
Thank you Sir
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy