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

<p>If this is the case, the documentation for the <code>-xl-sn</code> flag is available here: <a href="https://software.broadinstitute.org/gatk/documentation/tooldocs/current/org_broadinstitute_hellbender_tools_walkers_variantutils_SelectVariants.php#--exclude-sample-name" rel="nofollow noreferrer">https://software.broadinstitute.org/gatk/documentation/tooldocs/current/org_broadinstitute_hellbender_tools_walkers_variantutils_SelectVariants.php#--exclude-sample-name</a>.</p>

<p>By default, the <code>-xl-sn SAMPLE</code> 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, <strong>you need to ensure the file you provide has the extension <code>.args</code></strong>.</p>

<p>From the documentation:</p>

<blockquote>
  <p>File names must use the extension ".args"</p>
</blockquote>

CC BY-SA 4.0
2019-07-30T13:46:41.787Z
ok cool it worked thanks mate (Y)
Syed M. Ijlal Haider
CC BY-SA 4.0
2019-07-30T13:24:35.680Z
2019-07-30T13:24:35.680Z
Migwell
<p>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.</p>

<p>I tried doing it using the GATK <code>SelectVariant</code> 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. </p>

<p>The command that I used was </p>

<pre><code>gatk SelectVariants -V filtered.vcf -xl-sn remove.txt -O test.vcf 
</code></pre>

<p><code>remove.txt</code> contains the sample names in each row (1 sample per row).</p>

<p>After running this command it generated a <code>test.vcf</code> file, for which I counted samples using:</p>

<pre><code>bcftools query -l test.vcf | wc -l
</code></pre>

<p>However, I got exactly same number of samples as in the original VCF file <code>filtered.vcf</code>.</p>

<vcf><quality-control><gatk>
Subset a multisample VCF file
# Subset a multisample VCF file

(Asked by: username_0 on 2019-07-30)

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.

**Tags:** vcf, quality-control, gatk

---

## 1 answers

### Answer by username_1 on 2019-07-30. Score: 3 | Accepted answer

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"

> **Comments:**
> **username_0**: ok cool it worked thanks mate (Y)  

---

