How to Subset a Human VCF with GATK SelectVariants
By the end of this guide you will have a reproducible set of derived VCFs from your own whole-genome call set. The set holds a SNP-only file, an indel-only file, and a panel-restricted file for a gene list you care about. It also holds a hard-filtered file whose record counts you can defend. You need GATK 4.4 or newer on the path, along with the reference FASTA your caller used and its .fai index and .dict sequence dictionary. You also need bcftools 1.18 or newer and about 8 GB of heap for a single-sample genome. A single human genome called against GRCh38 typically yields roughly 4 to 5 million SNVs and indels, so every command below runs in minutes rather than hours. Nothing here is a diagnosis. If a variant looks medically relevant, that conversation belongs with a clinical geneticist or genetic counselor, backed by an orthogonal confirmation assay.
1. Check the inputs before you subset
Most SelectVariants failures are input problems that surface as a stack trace ten minutes into a run. Check three things first: the tool version, the reference dictionary, and the contig naming convention.
gatk --version
samtools faidx GRCh38.fa # produces GRCh38.fa.fai
gatk CreateSequenceDictionary -R GRCh38.fa # produces GRCh38.dict
bcftools index -t sample.vcf.gz # produces sample.vcf.gz.tbi
Then confirm that the contig names in the VCF header match the reference. A VCF called against a b37 reference uses 1, 2, X. A VCF called against GRCh38 analysis sets uses chr1, chr2, chrX. Mixing them produces an “Input files reference and features have incompatible contigs” error, and there is no flag that papers over it.
bcftools view -h sample.vcf.gz | grep '^##contig' | head -3
head -3 GRCh38.dict
If the two disagree, remap the VCF with bcftools annotate --rename-chrs rather than editing headers by hand. Reference build and analysis-set choice change downstream call sets in ways that are measurable across pipelines, which is why large projects specify the exact reference file and not just the build name 1.
2. Count what you have before you cut
Record the starting numbers so that every later subset can be checked against them. bcftools stats is faster than any GATK equivalent and gives you the breakdown you need.
bcftools stats sample.vcf.gz > pre.stats
grep -E '^SN' pre.stats
bcftools query -l sample.vcf.gz # sample names, exactly as SelectVariants expects them
bcftools query -f '%FILTER\n' sample.vcf.gz | sort | uniq -c | sort -rn | head
The FILTER tally matters. GATK’s VariantFiltration and VQSR both annotate the FILTER column rather than deleting records, so a “filtered” VCF still contains every failing site 2. Knowing how many records carry PASS tells you what --exclude-filtered will remove.
3. Normalize and split multiallelics first
This is the step that prevents the most common silent data loss, and we would run it on every VCF before any type-based selection. GATK assigns one type per record. A record with reference A and alternates G,AT is typed MIXED. It is not typed SNP and not typed INDEL. Ask for --select-type-to-include SNP on an unsplit VCF and that site disappears from the output along with its real SNP allele. The same structure explains the reports of --remove-unused-alternates appearing to drop genuine indels: the tool is dropping alternate alleles that no remaining sample carries, and on a multiallelic record that can change the record’s type or empty it entirely.
Split first, then left-align against the reference:
bcftools norm -m -any -f GRCh38.fa -Oz -o sample.norm.vcf.gz sample.vcf.gz
bcftools index -t sample.norm.vcf.gz
bcftools view -H sample.norm.vcf.gz | wc -l # expect more records than the input
After splitting, every record has exactly one alternate allele and a single unambiguous type. Left-alignment also makes indel positions comparable to any external call set or annotation database you plan to intersect with later. Representation differences are a known source of apparent disagreement between pipelines that are otherwise calling the same underlying variant 3.
4. Select by variant type
Now the type filters behave the way the flag names suggest.
gatk --java-options "-Xmx8g" SelectVariants \
-R GRCh38.fa \
-V sample.norm.vcf.gz \
--select-type-to-include SNP \
-O sample.snps.vcf.gz
gatk --java-options "-Xmx8g" SelectVariants \
-R GRCh38.fa \
-V sample.norm.vcf.gz \
--select-type-to-include INDEL \
--select-type-to-include MIXED \
-O sample.indels.vcf.gz
The accepted types are the following.
SNPINDELMNPMIXEDSYMBOLICNO_VARIATION
Keep MIXED in the indel file even after normalization, since a few callers emit records that survive splitting with mixed representation. Check that the two outputs sum to the input count. If they do not, list the leftovers by type and look at them directly.
Two size flags are useful when you are separating small indels from structural calls: --min-indel-size and --max-indel-size. Passing --max-indel-size 50 keeps the output in the range where short-read callers are reasonably reliable, and pushes larger events into a separate file for a caller designed for them. Long-read sequencing remains the better tool for large or repeat-embedded events, and targeted long reads have been used to resolve variants that short-read pipelines missed 4.
5. Select by sample
If your VCF came out of joint genotyping across a cohort, you will want your own sample pulled out cleanly. Joint calling improves sensitivity for rare variants, and the resulting multi-sample VCF is the normal starting point for per-individual analysis 5.
gatk SelectVariants \
-R GRCh38.fa \
-V cohort.norm.vcf.gz \
-sn NA12878 \
--exclude-non-variants \
--remove-unused-alternates \
-O NA12878.vcf.gz
-sn takes the sample name exactly as it appears in the #CHROM line, and a typo produces a hard error rather than an empty file. --exclude-non-variants drops sites where the retained sample is homozygous reference or no-call. --remove-unused-alternates strips alternate alleles that no retained sample carries and recomputes AC, AN, and AF for the subset. Add --keep-original-ac if you want the cohort-level counts preserved as AC_Orig and AF_Orig, which is often what you want for population context.
Two behaviors surprise people. First, INFO-level annotations such as DP and MQ are not recomputed for the subset, so a per-sample DP in INFO carried over from a cohort file is meaningless. Read FORMAT/DP instead. Second, --exclude-non-variants retains sites where the genotype is no-call in some builds. Control that explicitly with --max-nocall-fraction 0 or --max-nocall-number 0.
6. Restrict to intervals
For a gene panel or a region of interest, pass a BED, an interval list, or a plain chr:start-end string to -L. Intervals are applied before any other selection, so they also make every later command faster.
gatk SelectVariants \
-R GRCh38.fa \
-V sample.norm.vcf.gz \
-L panel.bed \
--interval-padding 50 \
-O sample.panel.vcf.gz
The padding matters more than it looks. Canonical splice sites sit outside coding exons, and a BED built from CDS coordinates alone will exclude them. Fifty base pairs of padding on each side is a reasonable default for a coding panel. Use -XL to exclude regions, for example a blacklist of segmental duplications where mapping quality is unreliable. Combine inclusion and exclusion with --interval-set-rule INTERSECTION when you pass more than one -L.
Remember that BED is zero-based and half-open while VCF and GATK interval lists are one-based and inclusive. GATK handles the conversion for BED input correctly, but hand-written interval strings copied from a BED file will be off by one at the start.
7. Filter on quality with JEXL expressions
-select takes a JEXL expression evaluated against each record’s INFO fields and genotypes. This is where SelectVariants earns its place over bcftools view, because the expressions can reach into genotype fields and attributes by name.
gatk SelectVariants \
-R GRCh38.fa \
-V sample.snps.vcf.gz \
-select "QD > 2.0 && FS < 60.0 && MQ > 40.0 && SOR < 3.0" \
-O sample.snps.hardfilt.vcf.gz
Those thresholds are the GATK hard-filtering starting points for SNPs in a germline short-variant workflow, and they are a fallback for when you lack the sample count or the truth resources for variant quality score recalibration 2. Indels use a different set, typically QD > 2.0 with FS < 200.0 and ReadPosRankSum > -20.0. Treat all of these as defaults to be checked against your own data. They are not constants. Filter thresholds appropriate for research discovery are not the same as those used for clinical reporting, where sensitivity is weighted much more heavily 6.
Genotype-level fields need the vc accessor:
-select 'vc.getGenotype("NA12878").getDP() > 10'
The important failure mode is a missing annotation. If a record lacks SOR because the caller never emitted it, the expression cannot evaluate and GATK logs a warning rather than stopping. Verify by counting how many records carry the annotation before you filter on it:
bcftools query -f '%CHROM\t%POS\t%INFO/SOR\n' sample.snps.vcf.gz | awk '$3=="."' | wc -l
Use --invert-select to keep the complement of an expression, which is the fastest way to inspect exactly what a filter is throwing away. Use --exclude-filtered to drop records that a previous VariantFiltration or VQSR step already marked.
8. Compare against another call set
--concordance keeps sites in your VCF that also appear in a comparison VCF, and --discordance keeps those that do not.
gatk SelectVariants \
-R GRCh38.fa \
-V sample.norm.vcf.gz \
--discordance truth.vcf.gz \
-O sample.novel.vcf.gz
This is a site-and-allele comparison, useful for quick triage. It is not a benchmarking tool. For measured precision and recall against a reference material such as GIAB, use hap.py or vcfeval, which handle equivalent representations of the same indel. Different pipelines applied to the same reads disagree on a meaningful share of calls, and the disagreement concentrates in indels and low-complexity regions 3. Independent comparisons of germline callers on disease cohorts report the same pattern 7.
9. Verify and record what you did
Every subset should end with a count check and a saved command line.
bcftools stats sample.snps.hardfilt.vcf.gz | grep -E '^SN'
bcftools view -h sample.snps.hardfilt.vcf.gz | grep '^##GATKCommandLine' | tail -1
GATK writes its full command line into the output header, which gives you provenance for free. Store the exact GATK version, the reference file name, and the input checksums alongside the output. Variant selection parameters are part of the analysis, and small threshold changes propagate into gene-level conclusions in ways that are hard to reconstruct later 8.
Common problems
A stale index causes silent record loss. If a VCF is edited in place or written out of coordinate order, an existing .tbi or .idx will point at the wrong offsets and SelectVariants will skip records without complaining. The symptom is an output that is missing variants you can see with grep in the input. Fix it by sorting and reindexing: bcftools sort -Oz -o fixed.vcf.gz in.vcf.gz && bcftools index -t fixed.vcf.gz.
Type selection drops multiallelic sites. Covered in step 3, and it is worth repeating because the output looks plausible. If SNP and indel counts do not sum to the input, you skipped normalization.
--remove-unused-alternates changes record types. After removing an alternate allele, a record that was MIXED can become SNP, and a record can lose its only alternate and become NO_VARIATION. Run this flag before type selection, not after, and count the result.
Sample subsetting leaves stale INFO fields. AC, AN, and AF are recalculated. Depth, strand bias, and rank-sum annotations are not. Recompute what you need with bcftools +fill-tags or read the genotype fields directly.
JEXL expressions on missing annotations do not fail loudly. Count annotation presence first. Quoting is the second trap here: use single quotes around expressions that contain double quotes, and remember that the shell will expand $ and backticks inside double quotes.
RNA-seq VCFs need different handling. Calls from RNA come with reference bias at heterozygous sites and with spliced reads that require SplitNCigarReads upstream. The GATK RNA-seq workflow applies a cluster filter with -window 35 -cluster 3 rather than the DNA hard filters, and allele-specific expression means a true heterozygous site can look homozygous 9. Select on RNA VCFs with that in mind, and do not apply DNA thresholds unchanged.
Memory and speed. SelectVariants streams records, so heap is rarely the limit for a single genome. For plain region or sample subsetting on a large cohort VCF, bcftools view is several times faster and we use it there. Reach for SelectVariants when you need type awareness, JEXL expressions, allele-level cleanup, or concordance selection.
Finally, interpretation. Subsetting a VCF tells you which records survived a rule. It does not tell you whether a variant means anything for your health. Take anything that looks consequential to a clinician who can order confirmatory testing.
Footnotes
-
Allison A. Regier, Yossi Farjoun, David E. Larson, et al. Functional equivalence of genome sequencing analysis pipelines enables harmonized variant calling across human genetics projects. Nature Communications, 2018. https://doi.org/10.1038/s41467-018-06159-4 ↩
-
Geraldine A. Van der Auwera, Mauricio O. Carneiro, Christopher Hartl, et al. From FastQ Data to High‐Confidence Variant Calls: The Genome Analysis Toolkit Best Practices Pipeline. Current Protocols in Bioinformatics, 2013. https://doi.org/10.1002/0471250953.bi1110s43 ↩ ↩2
-
Sohyun Hwang, Eiru Kim, Insuk Lee, et al. Systematic comparison of variant calling pipelines using gold standard personal exome variants. Scientific Reports, 2015. https://doi.org/10.1038/srep17875 ↩ ↩2
-
Kenji Nakamichi, Andrew Stacey, Debarshi Mustafi. Targeted long-read sequencing allows for rapid identification of pathogenic disease-causing variants in retinoblastoma. Ophthalmic Genetics, 2022. https://doi.org/10.1080/13816810.2022.2141797 ↩
-
Sabrina Y. Camp, Eric Kofman, Brendan Reardon, et al. Evaluating the molecular diagnostic yield of joint genotyping–based approach for detecting rare germline pathogenic and putative loss-of-function variants. Genetics in Medicine, 2021. https://doi.org/10.1038/s41436-020-01074-w ↩
-
Daniel C. Koboldt. Best practices for variant calling in clinical sequencing. Genome Medicine, 2020. https://doi.org/10.1186/s13073-020-00791-w ↩
-
Qiaofeng Song, Jinglan Zhai, Changshui Chen, et al. Performance comparison of germline variant calling tools in sporadic disease cohorts. Molecular Genetics and Genomics, 2025. https://doi.org/10.1007/s00438-025-02292-0 ↩
-
Mohammed M. Alfayyadh, Neven Maksemous, Heidi G. Sutherland, et al. PathVar: A Customisable NGS Variant Calling Algorithm Implicates Novel Candidate Genes and Pathways in Hemiplegic Migraine. Clinical Genetics, 2024. https://doi.org/10.1111/cge.14625 ↩
-
Jean-Simon Brouard, Nathalie Bissonnette. Variant Calling from RNA-seq Data Using the GATK Joint Genotyping Workflow. Methods in Molecular Biology, 2012. https://doi.org/10.1007/978-1-0716-2293-3_13 ↩
Pothos builds longitudinal molecular profiles of individuals: whole-genome sequencing, single-cell RNA sequencing, and plasma proteomics, delivered as a detailed report, every data file, and stored cells. Build your profile.