Select a subset of variants from a VCF file
Category Variant Manipulation
Overview
Select a subset of variants from a VCF fileThis tool makes it possible to select a subset of variants based on various criteria in order to facilitate certain analyses. Examples of such analyses include comparing and contrasting cases vs. controls, extracting variant or non-variant loci that meet certain requirements, or troubleshooting some unexpected results, to name a few.
There are many different options for selecting subsets of variants from a larger callset:
- Extract one or more samples from a callset based on either a complete sample name or a pattern match.
- Specify criteria for inclusion that place thresholds on annotation values, e.g. "DP > 1000" (depth of coverage greater than 1000x), "AF < 0.25" (sites with allele frequency less than 0.25). These criteria are written as "JEXL expressions", which are documented in the article about using JEXL expressions.
- Provide concordance or discordance tracks in order to include or exclude variants that are also present in other given callsets.
- Select variants based on criteria like their type (e.g. INDELs only), evidence of mendelian violation, filtering status, allelicity, etc.
There are also several options for recording the original values of certain annotations which are recalculated when one subsets the new callset, trims alleles, etc.
Input
A variant call set in VCF format from which a subset can be selected.
Output
A new VCF file containing the selected subset of variants.
*Usage examples
Select SNPs
gatk SelectVariants \ -R Homo_sapiens_assembly38.fasta \ -V input.vcf \ --select-type-to-include SNP \ -O output.vcf
Query Chromosome 20 Variants from a GenomicsDB
gatk SelectVariants \ -R Homo_sapiens_assembly38.fasta \ -V gendb://genomicsDB \ -L 20 \ -O output.chr20.vcf
SelectVariants specific arguments
This table summarizes the command-line arguments that are specific to this tool. For more details on each argument, see the list further down below the table or click on an argument name to jump directly to that entry in the list.
Argument name(s) | Default value | Summary | |
---|---|---|---|
Required Arguments | |||
--output -O |
null | File to which variants should be written | |
--variant -V |
null | A VCF file containing variants | |
Optional Tool Arguments | |||
--arguments_file |
[] | read one or more arguments files and add them to the command line | |
--cloud-index-prefetch-buffer -CIPB |
-1 | Size of the cloud-only prefetch buffer (in MB; 0 to disable). Defaults to cloudPrefetchBuffer if unset. | |
--cloud-prefetch-buffer -CPB |
40 | Size of the cloud-only prefetch buffer (in MB; 0 to disable). | |
--concordance -conc |
null | Output variants also called in this comparison track | |
--disable-bam-index-caching -DBIC |
false | If true, don't cache bam indexes, this will reduce memory requirements but may harm performance if many intervals are specified. Caching is automatically disabled if there are no intervals specified. | |
--disable-sequence-dictionary-validation |
false | If specified, do not check the sequence dictionaries from our inputs for compatibility. Use at your own risk! | |
--discordance -disc |
null | Output variants not called in this comparison track | |
--exclude-filtered |
false | Don't include filtered sites | |
--exclude-ids -xl-ids |
[] | List of variant rsIDs to exclude | |
--exclude-non-variants |
false | Don't include non-variant sites | |
--exclude-sample-expressions -xl-se |
[] | List of sample expressions to exclude | |
--exclude-sample-name -xl-sn |
[] | Exclude genotypes from this sample | |
--gcs-max-retries -gcs-retries |
20 | If the GCS bucket channel errors out, how many times it will attempt to re-initiate the connection | |
--gcs-project-for-requester-pays |
"" | Project to bill when accessing "requester pays" buckets. If unset, these buckets cannot be accessed. | |
--help -h |
false | display the help message | |
--interval-merging-rule -imr |
ALL | Interval merging rule for abutting intervals | |
--intervals -L |
[] | One or more genomic intervals over which to operate | |
--invert-mendelian-violation |
false | Output non-mendelian violation sites only | |
--invertSelect -invert-select |
false | Invert the selection criteria for -select | |
--keep-ids -ids |
[] | List of variant rsIDs to select | |
--keep-original-ac |
false | Store the original AC, AF, and AN values after subsetting | |
--keep-original-dp |
false | Store the original DP value after subsetting | |
--max-filtered-genotypes |
2147483647 | Maximum number of samples filtered at the genotype level | |
--max-fraction-filtered-genotypes |
1.0 | Maximum fraction of samples filtered at the genotype level | |
--max-indel-size |
2147483647 | Maximum size of indels to include | |
--max-nocall-fraction |
1.0 | Maximum fraction of samples with no-call genotypes | |
--max-nocall-number |
2147483647 | Maximum number of samples with no-call genotypes | |
--mendelian-violation |
false | Output mendelian violation sites only | |
--mendelian-violation-qual-threshold |
0.0 | Minimum GQ score for each trio member to accept a site as a violation | |
--min-filtered-genotypes |
0 | Minimum number of samples filtered at the genotype level | |
--min-fraction-filtered-genotypes |
0.0 | Maximum fraction of samples filtered at the genotype level | |
--min-indel-size |
0 | Minimum size of indels to include | |
--pedigree -ped |
null | Pedigree file | |
--preserve-alleles |
false | Preserve original alleles, do not trim | |
--reference -R |
null | Reference sequence | |
--remove-fraction-genotypes |
0.0 | Select a fraction of genotypes at random from the input and sets them to no-call | |
--remove-unused-alternates |
false | Remove alternate alleles not present in any genotypes | |
--restrict-alleles-to |
ALL | Select only variants of a particular allelicity | |
--sample-expressions -se |
[] | Regular expression to select multiple samples | |
--sample-name -sn |
[] | Include genotypes from this sample | |
--select-random-fraction -fraction |
0.0 | Select a fraction of variants at random from the input | |
--select-type-to-exclude -xl-select-type |
[] | Do not select certain type of variants from the input file | |
--select-type-to-include -select-type |
[] | Select only a certain type of variants from the input file | |
--selectExpressions -select |
[] | One or more criteria to use when selecting the data | |
--set-filtered-gt-to-nocall |
false | Set filtered genotypes to no-call | |
--sites-only-vcf-output |
false | If true, don't emit genotype fields when writing vcf file output. | |
--version |
false | display the version number for this tool | |
Optional Common Arguments | |||
--add-output-sam-program-record |
true | If true, adds a PG tag to created SAM/BAM/CRAM files. | |
--add-output-vcf-command-line |
true | If true, adds a command line header line to created VCF files. | |
--create-output-bam-index -OBI |
true | If true, create a BAM/CRAM index when writing a coordinate-sorted BAM/CRAM file. | |
--create-output-bam-md5 -OBM |
false | If true, create a MD5 digest for any BAM/SAM/CRAM file created | |
--create-output-variant-index -OVI |
true | If true, create a VCF index when writing a coordinate-sorted VCF file. | |
--create-output-variant-md5 -OVM |
false | If true, create a a MD5 digest any VCF file created. | |
--disable-read-filter -DF |
[] | Read filters to be disabled before analysis | |
--disable-tool-default-read-filters |
false | Disable all tool default read filters (WARNING: many tools will not function correctly without their default read filters on) | |
--exclude-intervals -XL |
[] | One or more genomic intervals to exclude from processing | |
--gatk-config-file |
null | A configuration file to use with the GATK. | |
--input -I |
[] | BAM/SAM/CRAM file containing reads | |
--interval-exclusion-padding -ixp |
0 | Amount of padding (in bp) to add to each interval you are excluding. | |
--interval-padding -ip |
0 | Amount of padding (in bp) to add to each interval you are including. | |
--interval-set-rule -isr |
UNION | Set merging approach to use for combining interval inputs | |
--lenient -LE |
false | Lenient processing of VCF files | |
--QUIET |
false | Whether to suppress job-summary info on System.err. | |
--read-filter -RF |
[] | Read filters to be applied before analysis | |
--read-index |
[] | Indices to use for the read inputs. If specified, an index must be provided for every read input and in the same order as the read inputs. If this argument is not specified, the path to the index for each input will be inferred automatically. | |
--read-validation-stringency -VS |
SILENT | Validation stringency for all SAM/BAM/CRAM/SRA files read by this program. The default stringency value SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded. | |
--seconds-between-progress-updates |
10.0 | Output traversal statistics every time this many seconds elapse | |
--sequence-dictionary |
null | Use the given sequence dictionary as the master/canonical sequence dictionary. Must be a .dict file. | |
--tmp-dir |
null | Temp directory to use. | |
--use-jdk-deflater -jdk-deflater |
false | Whether to use the JdkDeflater (as opposed to IntelDeflater) | |
--use-jdk-inflater -jdk-inflater |
false | Whether to use the JdkInflater (as opposed to IntelInflater) | |
--verbosity |
INFO | Control verbosity of logging. | |
Advanced Arguments | |||
--showHidden |
false | display hidden arguments |
Argument details
Arguments in this list are specific to this tool. Keep in mind that other arguments are available that are shared with other tools (e.g. command-line GATK arguments); see Inherited arguments above.
--add-output-sam-program-record / -add-output-sam-program-record
If true, adds a PG tag to created SAM/BAM/CRAM files.
boolean true
--add-output-vcf-command-line / -add-output-vcf-command-line
If true, adds a command line header line to created VCF files.
boolean true
--arguments_file / NA
read one or more arguments files and add them to the command line
List[File] []
--cloud-index-prefetch-buffer / -CIPB
Size of the cloud-only prefetch buffer (in MB; 0 to disable). Defaults to cloudPrefetchBuffer if unset.
int -1 [ [ -∞ ∞ ] ]
--cloud-prefetch-buffer / -CPB
Size of the cloud-only prefetch buffer (in MB; 0 to disable).
int 40 [ [ -∞ ∞ ] ]
--concordance / -conc
Output variants also called in this comparison track
A site is considered concordant if (1) we are not looking for specific samples and there is a variant called
in both the variant and concordance tracks or (2) every sample present in the variant track is present in the
concordance track and they have the sample genotype call.
FeatureInput[VariantContext] null
--create-output-bam-index / -OBI
If true, create a BAM/CRAM index when writing a coordinate-sorted BAM/CRAM file.
boolean true
--create-output-bam-md5 / -OBM
If true, create a MD5 digest for any BAM/SAM/CRAM file created
boolean false
--create-output-variant-index / -OVI
If true, create a VCF index when writing a coordinate-sorted VCF file.
boolean true
--create-output-variant-md5 / -OVM
If true, create a a MD5 digest any VCF file created.
boolean false
--disable-bam-index-caching / -DBIC
If true, don't cache bam indexes, this will reduce memory requirements but may harm performance if many intervals are specified. Caching is automatically disabled if there are no intervals specified.
boolean false
--disable-read-filter / -DF
Read filters to be disabled before analysis
List[String] []
--disable-sequence-dictionary-validation / -disable-sequence-dictionary-validation
If specified, do not check the sequence dictionaries from our inputs for compatibility. Use at your own risk!
boolean false
--disable-tool-default-read-filters / -disable-tool-default-read-filters
Disable all tool default read filters (WARNING: many tools will not function correctly without their default read filters on)
boolean false
--discordance / -disc
Output variants not called in this comparison track
A site is considered discordant if there exists some sample in the variant track that has a non-reference
genotype and either the site isn't present in this track, the sample isn't present in this track, or the
sample is called reference in this track.
FeatureInput[VariantContext] null
--exclude-filtered / NA
Don't include filtered sites
If this flag is enabled, sites that have been marked as filtered (i.e. have anything other than `.` or `PASS`
in the FILTER field) will be excluded from the output.
boolean false
--exclude-ids / -xl-ids
List of variant rsIDs to exclude
List of IDs (or a .list file containing ids) to exclude. The tool will exclude variants whose ID
field is present in this list of IDs. The matching is done by exact string matching. If a file, the
file name must end in ".list", and the expected file format is simply plain text with one ID per line.
Set[String] []
--exclude-intervals / -XL
One or more genomic intervals to exclude from processing
Use this argument to exclude certain parts of the genome from the analysis (like -L, but the opposite).
This argument can be specified multiple times. You can use samtools-style intervals either explicitly on the
command line (e.g. -XL 1 or -XL 1:100-200) or by loading in a file containing a list of intervals
(e.g. -XL myFile.intervals).
List[String] []
--exclude-non-variants / NA
Don't include non-variant sites
boolean false
--exclude-sample-expressions / -xl-se
List of sample expressions to exclude
Using a regular expression allows you to match multiple sample names that have that pattern in common. Note that
sample exclusion takes precedence over inclusion, so that if a sample is in both lists it will be excluded. This
argument can be specified multiple times in order to use multiple different matching patterns.
Set[String] []
--exclude-sample-name / -xl-sn
Exclude genotypes from this sample
Note that sample exclusion takes precedence over inclusion, so that if a sample is in both lists it will be
excluded. This argument can be specified multiple times in order to provide multiple sample names, or to
specify the name of one or more files containing sample names. File names must use the extension ".args",
and the expected file format is simply plain text with one sample name per line.
Set[String] []
--gatk-config-file / NA
A configuration file to use with the GATK.
String null
--gcs-max-retries / -gcs-retries
If the GCS bucket channel errors out, how many times it will attempt to re-initiate the connection
int 20 [ [ -∞ ∞ ] ]
--gcs-project-for-requester-pays / NA
Project to bill when accessing "requester pays" buckets. If unset, these buckets cannot be accessed.
String ""
--help / -h
display the help message
boolean false
--input / -I
BAM/SAM/CRAM file containing reads
List[String] []
--interval-exclusion-padding / -ixp
Amount of padding (in bp) to add to each interval you are excluding.
Use this to add padding to the intervals specified using -XL. For example, '-XL 1:100' with a
padding value of 20 would turn into '-XL 1:80-120'. This is typically used to add padding around targets when
analyzing exomes.
int 0 [ [ -∞ ∞ ] ]
--interval-merging-rule / -imr
Interval merging rule for abutting intervals
By default, the program merges abutting intervals (i.e. intervals that are directly side-by-side but do not
actually overlap) into a single continuous interval. However you can change this behavior if you want them to be
treated as separate intervals instead.
The --interval-merging-rule argument is an enumerated type (IntervalMergingRule), which can have one of the following values:
- ALL
- OVERLAPPING_ONLY
IntervalMergingRule ALL
--interval-padding / -ip
Amount of padding (in bp) to add to each interval you are including.
Use this to add padding to the intervals specified using -L. For example, '-L 1:100' with a
padding value of 20 would turn into '-L 1:80-120'. This is typically used to add padding around targets when
analyzing exomes.
int 0 [ [ -∞ ∞ ] ]
--interval-set-rule / -isr
Set merging approach to use for combining interval inputs
By default, the program will take the UNION of all intervals specified using -L and/or -XL. However, you can
change this setting for -L, for example if you want to take the INTERSECTION of the sets instead. E.g. to
perform the analysis only on chromosome 1 exomes, you could specify -L exomes.intervals -L 1 --interval-set-rule
INTERSECTION. However, it is not possible to modify the merging approach for intervals passed using -XL (they will
always be merged using UNION).
Note that if you specify both -L and -XL, the -XL interval set will be subtracted from the -L interval set.
The --interval-set-rule argument is an enumerated type (IntervalSetRule), which can have one of the following values:
- UNION
- Take the union of all intervals
- INTERSECTION
- Take the intersection of intervals (the subset that overlaps all intervals specified)
IntervalSetRule UNION
--intervals / -L
One or more genomic intervals over which to operate
List[String] []
--invert-mendelian-violation / NA
Output non-mendelian violation sites only
If this flag is enabled, this tool will select only variants that do not correspond to a mendelian violation as
determined on the basis of family structure. Requires passing a pedigree file using the engine-level
`-ped` argument.
Boolean false
--invertSelect / -invert-select
Invert the selection criteria for -select
Invert the selection criteria for -select.
boolean false
--keep-ids / -ids
List of variant rsIDs to select
List of IDs (or a .list file containing ids) to select. The tool will only select variants whose ID
field is present in this list of IDs. The matching is done by exact string matching. If a file, the file
name must end in ".list", and the expected file format is simply plain text with one ID per line.
Set[String] []
--keep-original-ac / NA
Store the original AC, AF, and AN values after subsetting
When subsetting a callset, this tool recalculates the AC, AF, and AN values corresponding to the contents of the
subset. If this flag is enabled, the original values of those annotations will be stored in new annotations called
AC_Orig, AF_Orig, and AN_Orig.
boolean false
--keep-original-dp / NA
Store the original DP value after subsetting
When subsetting a callset, this tool recalculates the site-level (INFO field) DP value corresponding to the
contents of the subset. If this flag is enabled, the original value of the DP annotation will be stored in
a new annotation called DP_Orig.
boolean false
--lenient / -LE
Lenient processing of VCF files
boolean false
--max-filtered-genotypes / NA
Maximum number of samples filtered at the genotype level
If this argument is provided, select sites where at most a maximum number of samples are filtered at the genotype level.
int 2147483647 [ [ -∞ ∞ ] ]
--max-fraction-filtered-genotypes / NA
Maximum fraction of samples filtered at the genotype level
If this argument is provided, select sites where a fraction or less of the samples are filtered at
the genotype level.
double 1.0 [ [ -∞ ∞ ] ]
--max-indel-size / NA
Maximum size of indels to include
If this argument is provided, indels that are larger than the specified size will be excluded.
int 2147483647 [ [ -∞ ∞ ] ]
--max-nocall-fraction / NA
Maximum fraction of samples with no-call genotypes
If this argument is provided, select sites where at most the given fraction of samples have no-call genotypes.
double 1.0 [ [ -∞ ∞ ] ]
--max-nocall-number / NA
Maximum number of samples with no-call genotypes
If this argument is provided, select sites where at most the given number of samples have no-call genotypes.
int 2147483647 [ [ -∞ ∞ ] ]
--mendelian-violation / NA
Output mendelian violation sites only
If this flag is enabled, this tool will select only variants that correspond to a mendelian violation as
determined on the basis of family structure. Requires passing a pedigree file using the engine-level
`-ped` argument.
Boolean false
--mendelian-violation-qual-threshold / NA
Minimum GQ score for each trio member to accept a site as a violation
This argument specifies the genotype quality (GQ) threshold that all members of a trio must have in order
for a site to be accepted as a mendelian violation. Note that the `-mv` flag must be set for this argument
to have an effect.
double 0.0 [ [ -∞ ∞ ] ]
--min-filtered-genotypes / NA
Minimum number of samples filtered at the genotype level
If this argument is provided, select sites where at least a minimum number of samples are filtered at
the genotype level.
int 0 [ [ -∞ ∞ ] ]
--min-fraction-filtered-genotypes / NA
Maximum fraction of samples filtered at the genotype level
If this argument is provided, select sites where a fraction or more of the samples are filtered at
the genotype level.
double 0.0 [ [ -∞ ∞ ] ]
--min-indel-size / NA
Minimum size of indels to include
If this argument is provided, indels that are smaller than the specified size will be excluded.
int 0 [ [ -∞ ∞ ] ]
--output / -O
File to which variants should be written
R File null
--pedigree / -ped
Pedigree file
File null
--preserve-alleles / NA
Preserve original alleles, do not trim
The default behavior of this tool is to remove bases common to all remaining alleles after subsetting
operations have been completed, leaving only their minimal representation. If this flag is enabled, the original
alleles will be preserved as recorded in the input VCF.
boolean false
--QUIET / NA
Whether to suppress job-summary info on System.err.
Boolean false
--read-filter / -RF
Read filters to be applied before analysis
List[String] []
--read-index / -read-index
Indices to use for the read inputs. If specified, an index must be provided for every read input and in the same order as the read inputs. If this argument is not specified, the path to the index for each input will be inferred automatically.
List[String] []
--read-validation-stringency / -VS
Validation stringency for all SAM/BAM/CRAM/SRA files read by this program. The default stringency value SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded.
The --read-validation-stringency argument is an enumerated type (ValidationStringency), which can have one of the following values:
- STRICT
- LENIENT
- SILENT
ValidationStringency SILENT
--reference / -R
Reference sequence
String null
--remove-fraction-genotypes / NA
Select a fraction of genotypes at random from the input and sets them to no-call
The value of this argument should be a number between 0 and 1 specifying the fraction of total variants to be
randomly selected from the input callset and set to no-call (./). Note that this is done using a probabilistic
function, so the final result is not guaranteed to carry the exact fraction requested. Can be used for large fractions.
double 0.0 [ [ -∞ ∞ ] ]
--remove-unused-alternates / NA
Remove alternate alleles not present in any genotypes
When this flag is enabled, all alternate alleles that are not present in the (output) samples will be removed.
Note that this even extends to biallelic SNPs - if the alternate allele is not present in any sample, it will be
removed and the record will contain a '.' in the ALT column. Note also that sites-only VCFs, by definition, do
not include the alternate allele in any genotype calls.
boolean false
--restrict-alleles-to / NA
Select only variants of a particular allelicity
When this argument is used, we can choose to include only multiallelic or biallelic sites, depending on how many
alleles are listed in the ALT column of a VCF. For example, a multiallelic record such as:
1 100 . A AAA,AAAAA
will be excluded if `-restrict-alleles-to BIALLELIC` is used, because there are two alternate alleles, whereas a
record such as:
1 100 . A T
will be included in that case, but would be excluded if `-restrict-alleles-to MULTIALLELIC` is used.
Valid options are ALL (default), MULTIALLELIC or BIALLELIC.
The --restrict-alleles-to argument is an enumerated type (NumberAlleleRestriction), which can have one of the following values:
- ALL
- BIALLELIC
- MULTIALLELIC
NumberAlleleRestriction ALL
--sample-expressions / -se
Regular expression to select multiple samples
Using a regular expression allows you to match multiple sample names that have that pattern in common. This
argument can be specified multiple times in order to use multiple different matching patterns.
Set[String] []
--sample-name / -sn
Include genotypes from this sample
This argument can be specified multiple times in order to provide multiple sample names, or to specify
the name of one or more files containing sample names. File names must use the extension ".args", and the
expected file format is simply plain text with one sample name per line. Note that sample exclusion takes
precedence over inclusion, so that if a sample is in both lists it will be excluded.
Set[String] []
--seconds-between-progress-updates / -seconds-between-progress-updates
Output traversal statistics every time this many seconds elapse
double 10.0 [ [ -∞ ∞ ] ]
--select-random-fraction / -fraction
Select a fraction of variants at random from the input
The value of this argument should be a number between 0 and 1 specifying the fraction of total variants to be
randomly selected from the input callset. Note that this is done using a probabilistic function, so the final
result is not guaranteed to carry the exact fraction requested. Can be used for large fractions.
double 0.0 [ [ -∞ ∞ ] ]
--select-type-to-exclude / -xl-select-type
Do not select certain type of variants from the input file
This argument excludes particular kinds of variants out of a list. If left empty, there is no type selection
and all variant types are considered for other selection criteria. Valid types are INDEL, SNP, MIXED, MNP,
SYMBOLIC, NO_VARIATION. Can be specified multiple times.
List[Type] []
--select-type-to-include / -select-type
Select only a certain type of variants from the input file
This argument selects particular kinds of variants out of a list. If left empty, there is no type selection
and all variant types are considered for other selection criteria. Valid types are INDEL, SNP, MIXED, MNP,
SYMBOLIC, NO_VARIATION. Can be specified multiple times.
List[Type] []
--selectExpressions / -select
One or more criteria to use when selecting the data
See example commands above for detailed usage examples. Note that these expressions are evaluated *after* the
specified samples are extracted and the INFO field annotations are updated.
ArrayList[String] []
--sequence-dictionary / -sequence-dictionary
Use the given sequence dictionary as the master/canonical sequence dictionary. Must be a .dict file.
String null
--set-filtered-gt-to-nocall / NA
Set filtered genotypes to no-call
If this argument is provided, set filtered genotypes to no-call (./.).
boolean false
--showHidden / -showHidden
display hidden arguments
boolean false
--sites-only-vcf-output / NA
If true, don't emit genotype fields when writing vcf file output.
boolean false
--tmp-dir / NA
Temp directory to use.
String null
--use-jdk-deflater / -jdk-deflater
Whether to use the JdkDeflater (as opposed to IntelDeflater)
boolean false
--use-jdk-inflater / -jdk-inflater
Whether to use the JdkInflater (as opposed to IntelInflater)
boolean false
--variant / -V
A VCF file containing variants
R String null
--verbosity / -verbosity
Control verbosity of logging.
The --verbosity argument is an enumerated type (LogLevel), which can have one of the following values:
- ERROR
- WARNING
- INFO
- DEBUG
LogLevel INFO
--version / NA
display the version number for this tool
boolean false
GATK version 4.0.9.0 built at 25-11-2019 01:11:10.
0 comments
Please sign in to leave a comment.