I need some help with GATK. I have a multisample vcf file containing 18125 samples. After performing PCA I have around 303 samples as outliers and I wanted to remove these samples from my multisample vcf file.

I tried doing it using the GATK SelectVariant tool. It does some stuff and generates a VCF file which is a bit smaller in size than the original file, but in the end the total count of samples remains the same. As I have no prior knowledge of GATK (working with it for the first time) I am just wondering if you guys can help me out in fixing this issue.

The command that I used was

gatk SelectVariants -V filtered.vcf -xl-sn remove.txt -O test.vcf 

remove.txt contains the sample names in each row (1 sample per row).

After running this command it generated a test.vcf file, for which I counted samples using:

bcftools query -l test.vcf | wc -l

However, I got exactly same number of samples as in the original VCF file filtered.vcf.


1 Answer 1


Based on the way you've called the command (using -xl-sn), I assume you are using GATK 4 and not GATK 3.

If this is the case, the documentation for the -xl-sn flag is available here: https://software.broadinstitute.org/gatk/documentation/tooldocs/current/org_broadinstitute_hellbender_tools_walkers_variantutils_SelectVariants.php#--exclude-sample-name.

By default, the -xl-sn SAMPLE means "exclude the sample called SAMPLE from my VCF". In your case, you're providing an entire list of samples, in a file, which is not the default behaviour. In order to tell GATK that you're providing a file and not a sample name, you need to ensure the file you provide has the extension .args.

From the documentation:

File names must use the extension ".args"

  • $\begingroup$ ok cool it worked thanks mate (Y) $\endgroup$ Commented Jul 30, 2019 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.