This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract info of samples of interest from VCF file?

Hi,

Now I am starting a GWAS project. VCF files have been generated. However, I only need the information of a subset of genotyped individuals (around 10%). The whole original VCF files contain too many samples and are too large.

How can I extract the information of the subset I am interested in?

Thanks.

unix vcf subset command gwas

1 answer

Hi,

You need to use: bcftools view --samples

For example, the following command would subset the VCF, myvariants.vcf.gz, for samples with IDs POH12 and POH13:

bcftools view --samples POH12,POH13 myvariants.vcf.gz

For more information, please just type and execute bcftools view from the command line.

Kevin

Thanks Kevin. This is very nice!

What if i have a thousand sample list? Can I also do it with one command or?

Neste caso / In that case, I would keep the sample IDs in a file and use the flag:

-S, --samples-file [^]<file>  file of samples to include (or exclude with "^" prefix)

Log in to answer this question.