Hi, I am learning about vcf file formatting and sorry for asking a dumb question. 

I have a multi-sample (>300) vcf file and I want to **group** (take) **samples with shared mutations/GT**. 

Can someone suggest a tool/command/script solve this problem?

Thanks
I dont't know if this is exactly what you want.

For each genotype you are interested run this:

    $ bcftools query -i 'GT="0/1"' -f '%CHROM\t%POS\t0/1\t%REF\t%ALT\t[%SAMPLE,]\n' input.vcf|sed 's/,$//'|awk -v OFS="\t" '{counts = split($6, samples, ","); print $1, $2, $3, counts, $4, $5, $6}' > stats_01.csv

In this example `bcftools query` looks for samples with genotype `0/1` and print out CHROM, POS, `0/1`, REF, ALT and a comma seperated list of sample names.

`sed` removes the additional `,` at the end. `awk` counts the number of sample names in each row and add this column.

fin swimmer