How to subset samples from a VCF file? I have VCF files (SNPs &amp; indels) for WGS on 100 samples, but I want to only use a specific subset of 10 of the samples. Is there a relatively easy way to pull out only the 10 samples, while still keeping all of the data for the entire genome?

I have a script that allows me to pull out regions of the whole genome for all 100 samples, so if I could do something similar but only put regions for the 10 samples that I want that would be ideal. 

Thanks for the help!
Bcftools has sample/individual filtering as an option for most of the commands. You can subset individuals by using the -s or -S option:


  -s, --samples [^]LIST
  
  Comma-separated list of samples to include or exclude if prefixed with "^". Note that in general tags such as INFO/AC, INFO/AN, etc are not updated to correspond to the subset samples. bcftools view is the exception where some
  tags will be updated (unless the -I, --no-update option is used; see bcftools view documentation). To use updated tags for the subset in another command one can pipe from view into that command. For example:
  
  -S, --samples-file FILE
  
  File of sample names to include or exclude if prefixed with "^". One sample per line. See also the note above for the -s, --samples option. The command bcftools call accepts an optional second column indicating ploidy (0, 1 or 2) or sex (as defined by --ploidy, for example "F" or "M"), and can parse also PED files. If the second column is not present, the sex "F" is assumed. With bcftools call -C trio, PED file is expected. File formats examples:

sample1    1
sample2    2
sample3    2

  
  or

sample1    M
sample2    F
sample3    F

  
  or a .ped file (here is shown a minimum working example, the first column is ignored and the last indicates sex: 1=male, 2=female):

ignored daughterA fatherA motherA 2
ignored sonB fatherB motherB 1



Example usage:

bcftools view -s sample1,sample2 file.vcf &gt; filtered.vcf
bcftools view -S sample_file.txt file.vcf &gt; filtered.vcf


See the bcftools manpage for more information.