Skip to content

Instantly share code, notes, and snippets.

@adefelicibus
Created January 31, 2017 18:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save adefelicibus/e668b2f03c157b3b272c871030c5d0b9 to your computer and use it in GitHub Desktop.
Save adefelicibus/e668b2f03c157b3b272c871030c5d0b9 to your computer and use it in GitHub Desktop.
Split a vcf file by samples
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment