Skip to content

Commit c844d78

Browse files
authored
Add genotype filtering Terra workflow configs and documentation (#695)
1 parent 29910b4 commit c844d78

File tree

9 files changed

+225
-42
lines changed

9 files changed

+225
-42
lines changed

README.md

+120-16
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ A structural variation discovery pipeline for Illumina short-read whole-genome s
2424
* [GenotypeBatch](#genotype-batch) - Genotyping
2525
* [RegenotypeCNVs](#regenotype-cnvs) - Genotype refinement (optional)
2626
* [MakeCohortVcf](#make-cohort-vcf) - Cross-batch integration, complex event resolution, and VCF cleanup
27-
* [Module 07](#module07) - Downstream Filtering
28-
* [AnnotateVcf](#annotate-vcf) - Annotation
27+
* [JoinRawCalls](#join-raw-calls) - Merges unfiltered calls across batches
28+
* [SVConcordance](#svconcordance) - Calculates genotype concordance with raw calls
29+
* [FilterGenotypes](#filter-genotypes) - Performs genotype filtering
30+
* [AnnotateVcf](#annotate-vcf) - Functional and allele frequency annotation
2931
* [Module 09](#module09) - QC and Visualization
3032
* Additional modules - Mosaic and de novo
3133
* [CI/CD](#cicd)
@@ -159,8 +161,10 @@ The pipeline consists of a series of modules that perform the following:
159161
* [FilterBatch](#filter-batch): Variant filtering; outlier exclusion
160162
* [GenotypeBatch](#genotype-batch): Genotyping
161163
* [MakeCohortVcf](#make-cohort-vcf): Cross-batch integration; complex variant resolution and re-genotyping; vcf cleanup
162-
* [Module 07](#module07): Downstream filtering, including minGQ, batch effect check, outlier samples removal and final recalibration;
163-
* [AnnotateVcf](#annotate-vcf): Annotations, including functional annotation, allele frequency (AF) annotation and AF annotation with external population callsets;
164+
* [JoinRawCalls](#join-raw-calls): Merges unfiltered calls across batches
165+
* [SVConcordance](#svconcordance): Calculates genotype concordance with raw calls
166+
* [FilterGenotypes](#filter-genotypes): Performs genotype filtering
167+
* [AnnotateVcf](#annotate-vcf): Annotations, including functional annotation, allele frequency (AF) annotation and AF annotation with external population callsets
164168
* [Module 09](#module09): Visualization, including scripts that generates IGV screenshots and rd plots.
165169
* Additional modules to be added: de novo and mosaic scripts
166170

@@ -471,23 +475,123 @@ Combines variants across multiple batches, resolves complex variants, re-genotyp
471475
#### Outputs:
472476
* Finalized "cleaned" VCF and QC plots
473477

474-
## <a name="module07">Module 07</a> (in development)
475-
Apply downstream filtering steps to the cleaned VCF to further control the false discovery rate; all steps are optional and users should decide based on the specific purpose of their projects.
478+
## <a name="join-raw-calls">JoinRawCalls</a>
476479

477-
Filtering methods include:
478-
* minGQ - remove variants based on the genotype quality across populations.
479-
Note: Trio families are required to build the minGQ filtering model in this step. We provide tables pre-trained with the 1000 genomes samples at different FDR thresholds for projects that lack family structures, and they can be found at the paths below. These tables assume that GQ has a scale of [0,999], so they will not work with newer VCFs where GQ has a scale of [0,99].
480+
Merges raw unfiltered calls across batches. Concordance between these genotypes and the joint call set usually can be indicative of variant quality and is used downstream for genotype filtering.
481+
482+
#### Prerequisites:
483+
* [ClusterBatch](#cluster-batch)
484+
485+
#### Inputs:
486+
* Clustered Manta, Wham, depth, Scramble, and/or MELT VCF URIs ([ClusterBatch](#cluster-batch))
487+
* PED file
488+
* Reference sequence
489+
490+
#### Outputs:
491+
* VCF of clustered raw calls
492+
* Ploidy table
493+
494+
## <a name="svconcordance">SVConcordance</a>
495+
496+
Computes genotype concordance metrics between all variants in the joint call set and raw calls.
497+
498+
#### Prerequisites:
499+
* [MakeCohortVcf](#make-cohort-vcf)
500+
* [JoinRawCalls](#join-raw-calls)
501+
502+
#### Inputs:
503+
* Cleaned ("eval") VCF URI ([MakeCohortVcf](#make-cohort-vcf))
504+
* Joined raw call ("truth") VCF URI ([JoinRawCalls](#join-raw-calls))
505+
* Reference dictionary URI
506+
507+
#### Outputs:
508+
* VCF with concordance annotations
509+
510+
## <a name="filter-genotypes">FilterGenotypes</a>
511+
512+
Performs genotype quality recalibration using a machine learning model based on [xgboost](https://github.com/dmlc/xgboost), and filters genotypes.
513+
514+
The ML model uses the following features:
515+
516+
* Genotype properties:
517+
* Non-reference and no-call allele counts
518+
* Genotype quality (GQ)
519+
* Supporting evidence types (EV) and respective genotype qualities (PE_GQ, SR_GQ, RD_GQ)
520+
* Raw call concordance (CONC_ST)
521+
* Variant properties:
522+
* Variant type (SVTYPE) and size (SVLEN)
523+
* FILTER status
524+
* Calling algorithms (ALGORITHMS)
525+
* Supporting evidence types (EVIDENCE)
526+
* Two-sided SR support flag (BOTHSIDES_SUPPORT)
527+
* Evidence overdispersion flag (PESR_GT_OVERDISPERSION)
528+
* SR noise flag (HIGH_SR_BACKGROUND)
529+
* Raw call concordance (STATUS, NON_REF_GENOTYPE_CONCORDANCE, VAR_PPV, VAR_SENSITIVITY, TRUTH_AF)
530+
* Reference context with respect to UCSC Genome Browser tracks:
531+
* RepeatMasker
532+
* Segmental duplications
533+
* Simple repeats
534+
* K-mer mappability (umap_s100 and umap_s24)
535+
536+
For ease of use, we provide a model pre-trained on high-quality data with truth data derived from long-read calls:
480537
```
481-
gs://gatk-sv-resources-public/hg38/v0/sv-resources/ref-panel/1KG/v2/mingq/1KGP_2504_and_698_with_GIAB.10perc_fdr.PCRMINUS.minGQ.filter_lookup_table.txt
482-
gs://gatk-sv-resources-public/hg38/v0/sv-resources/ref-panel/1KG/v2/mingq/1KGP_2504_and_698_with_GIAB.1perc_fdr.PCRMINUS.minGQ.filter_lookup_table.txt
483-
gs://gatk-sv-resources-public/hg38/v0/sv-resources/ref-panel/1KG/v2/mingq/1KGP_2504_and_698_with_GIAB.5perc_fdr.PCRMINUS.minGQ.filter_lookup_table.txt
538+
gs://gatk-sv-resources-public/hg38/v0/sv-resources/resources/v1/gatk-sv-recalibrator.aou_phase_1.v1.model
484539
```
540+
See the SV "Genotype Filter" section on page 34 of the [All of Us Genomic Quality Report C2022Q4R9 CDR v7](https://support.researchallofus.org/hc/en-us/articles/4617899955092-All-of-Us-Genomic-Quality-Report-ARCHIVED-C2022Q4R9-CDR-v7) for further details on model training.
541+
542+
All valid genotypes are annotated with a "scaled logit" (SL) score, which is rescaled to non-negative adjusted GQs on [1, 99]. Note that the rescaled GQs should *not* be interpreted as probabilities. Original genotype qualities are retained in the OGQ field.
543+
544+
A more positive SL score indicates higher probability that the given genotype is not homozygous for the reference allele. Genotypes are therefore filtered using SL thresholds that depend on SV type and size. This workflow also generates QC plots using the [MainVcfQc](https://github.com/broadinstitute/gatk-sv/blob/main/wdl/MainVcfQc.wdl) workflow to review call set quality (see below for recommended practices).
545+
546+
This workflow can be run in one of two modes:
547+
548+
1. (Recommended) The user explicitly provides a set of SL cutoffs through the `sl_filter_args` parameter, e.g.
549+
```
550+
"--small-del-threshold 93 --medium-del-threshold 150 --small-dup-threshold -51 --medium-dup-threshold -4 --ins-threshold -13 --inv-threshold -19"
551+
```
552+
Genotypes with SL scores less than the cutoffs are set to no-call (`./.`). The above values were taken directly from Appendix N of the [All of Us Genomic Quality Report C2022Q4R9 CDR v7 ](https://support.researchallofus.org/hc/en-us/articles/4617899955092-All-of-Us-Genomic-Quality-Report-ARCHIVED-C2022Q4R9-CDR-v7). Users should adjust the thresholds depending on data quality and desired accuracy. Please see the arguments in [this script](https://github.com/broadinstitute/gatk-sv/blob/main/src/sv-pipeline/scripts/apply_sl_filter.py) for all available options.
553+
554+
2. (Advanced) The user provides truth labels for a subset of non-reference calls, and SL cutoffs are automatically optimized. These truth labels should be provided as a json file in the following format:
555+
```
556+
{
557+
"sample_1": {
558+
"good_variant_ids": ["variant_1", "variant_3"],
559+
"bad_variant_ids": ["variant_5", "variant_10"]
560+
},
561+
"sample_2": {
562+
"good_variant_ids": ["variant_2", "variant_13"],
563+
"bad_variant_ids": ["variant_8", "variant_11"]
564+
}
565+
}
566+
```
567+
where "good_variant_ids" and "bad_variant_ids" are lists of variant IDs corresponding to non-reference (i.e. het or hom-var) sample genotypes that are true positives and false positives, respectively. SL cutoffs are optimized by maximizing the [F-score](https://en.wikipedia.org/wiki/F-score) with "beta" parameter `fmax_beta`, which modulates the weight given to precision over recall (lower values give higher precision).
568+
569+
In both modes, the workflow additionally filters variants based on the "no-call rate", the proportion of genotypes that were filtered in a given variant. Variants exceeding the `no_call_rate_cutoff` are assigned a `HIGH_NCR` filter status.
570+
571+
We recommend users observe the following basic criteria to assess the overall quality of the filtered call set:
485572
486-
* BatchEffect - remove variants that show significant discrepancies in allele frequencies across batches
487-
* FilterOutlierSamplesPostMinGQ - remove outlier samples with unusually high or low number of SVs
488-
* FilterCleanupQualRecalibration - sanitize filter columns and recalibrate variant QUAL scores for easier interpretation
573+
* Number of PASS variants (excluding BND) between 7,000 and 11,000.
574+
* At least 75% of variants in Hardy-Weinberg equilibrium (HWE). Note that this could be lower, depending on how how closely the cohort adheres to the assumptions of the Hardy-Weinberg model. However, HWE is expected to at least improve after filtering.
575+
* Low *de novo* inheritance rate (if applicable), typically 5-10%.
576+
577+
These criteria can be assessed from the plots in the `main_vcf_qc_tarball` output, which is generated by default.
578+
579+
#### Prerequisites:
580+
* [SVConcordance](#svconcordance)
581+
582+
#### Inputs:
583+
* VCF with genotype concordance annotations URI ([SVConcordance](#svconcordance))
584+
* Ploidy table URI ([JoinRawCalls](#join-raw-calls))
585+
* GQRecalibrator model URI
586+
* Either a set of SL cutoffs or truth labels
587+
588+
#### Outputs:
589+
* Filtered VCF
590+
* Call set QC plots (optional)
591+
* Optimized SL cutoffs with filtering QC plots and data tables (if running mode [2] with truth labels)
592+
* VCF with only SL annotation and GQ recalibration (before filtering)
489593
490-
## <a name="annotate-vcf">AnnotateVcf</a> (in development)
594+
## <a name="annotate-vcf">AnnotateVcf</a>
491595
*Formerly Module08Annotation*
492596
493597
Add annotations, such as the inferred function and allele frequencies of variants, to final VCF.

inputs/templates/terra_workspaces/cohort_mode/cohort_mode_workspace_dashboard.md.tmpl

+10-7
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ The following workflows are included in this workspace, to be executed in this o
6161
13. `13-ResolveComplexVariants`: Complex variant resolution
6262
14. `14-GenotypeComplexVariants`: Complex variant re-genotyping
6363
15. `15-CleanVcf`: VCF cleanup
64-
16. `16-MainVcfQc`: Generates VCF QC reports
65-
17. `17-AnnotateVcf`: Cohort VCF annotations, including functional annotation, allele frequency (AF) annotation, and AF annotation with external population callsets
64+
16. `16-JoinRawCalls`: Combines unfiltered calls (from step 5) across batches
65+
17. `17-SVConcordance`: Annotates variants with genotype concordance against raw calls
66+
18. `18-FilterGenotypes`: Performs genotype filtering to improve precision and generates QC plots
67+
19. `19-AnnotateVcf`: Cohort VCF annotations, including functional annotation, allele frequency (AF) annotation, and AF annotation with external population callsets
6668

67-
Additional downstream modules, such as those for filtering and visualization, are under development. They are not included in this workspace at this time, but the source code can be found in the [GATK-SV GitHub repository](https://github.com/broadinstitute/gatk-sv). See **Downstream steps** towards the bottom of this page for more information.
69+
Additional downstream modules, such as those for visualization, are under development. They are not included in this workspace at this time, but the source code can be found in the [GATK-SV GitHub repository](https://github.com/broadinstitute/gatk-sv). See **Downstream steps** towards the bottom of this page for more information.
6870

6971
Extra workflows (Not part of canonical pipeline, but included for your convenience. May require manual configuration):
70-
* `PlotSVCountsPerSample: Plot SV counts per sample per SV type
72+
* `MainVcfQc`: Generates VCF QC reports (is run during 18-FilterGenotypes by default)
73+
* `PlotSVCountsPerSample`: Plot SV counts per sample per SV type
7174
* `FilterOutlierSamples`: Filter outlier samples (in terms of SV counts) from a single VCF. Recommended to run `PlotSVCountsPerSample` beforehand (configured with the single VCF you want to filter) to enable IQR cutoff choice.
7275

7376
For detailed instructions on running the pipeline in Terra, see **Step-by-step instructions** below.
@@ -202,11 +205,11 @@ Read the full MergeBatchSites documentation [here](https://github.com/broadinsti
202205
Read the full GenotypeBatch documentation [here](https://github.com/broadinstitute/gatk-sv#genotype-batch).
203206
* Use the same `sample_set` definitions you used for `03-TrainGCNV` through `08-FilterBatchSamples`.
204207

205-
#### 11-RegenotypeCNVs, 12-CombineBatches, 13-ResolveComplexVariants, 14-GenotypeComplexVariants, 15-CleanVcf, 16-MainVcfQc, and 17-AnnotateVcf
208+
#### 11-RegenotypeCNVs, 12-CombineBatches, 13-ResolveComplexVariants, 14-GenotypeComplexVariants, 15-CleanVcf, 16-JoinRawCalls, 17-SVConcordance, 18-FilterGenotypes, and 19-AnnotateVcf
206209

207-
Read the full documentation for [RegenotypeCNVs](https://github.com/broadinstitute/gatk-sv#regenotype-cnvs), [MakeCohortVcf](https://github.com/broadinstitute/gatk-sv#make-cohort-vcf) (which includes `CombineBatches`, `ResolveComplexVariants`, `GenotypeComplexVariants`, `CleanVcf`, `MainVcfQc`), and [AnnotateVcf](https://github.com/broadinstitute/gatk-sv#annotate-vcf) on the README.
210+
Read the full documentation for [RegenotypeCNVs](https://github.com/broadinstitute/gatk-sv#regenotype-cnvs), [MakeCohortVcf](https://github.com/broadinstitute/gatk-sv#make-cohort-vcf) (which includes `CombineBatches`, `ResolveComplexVariants`, `GenotypeComplexVariants`, `CleanVcf`), [`JoinRawCalls`](https://github.com/broadinstitute/gatk-sv#join-raw-calls), [`SVConcordance`](https://github.com/broadinstitute/gatk-sv#svconcordance), [`FilterGenotypes`](https://github.com/broadinstitute/gatk-sv#filter-genotypes), and [AnnotateVcf](https://github.com/broadinstitute/gatk-sv#annotate-vcf) on the README.
208211
* Use the same cohort `sample_set_set` you created and used for `09-MergeBatchSites`.
209212

210213
#### Downstream steps
211214

212-
Additional downstream steps are under development. Read about some of them on the README [here](https://github.com/broadinstitute/gatk-sv#module07). Please note that the VCF produced by `15-CleanVcf` (and annotated by `17-AnnotateVcf`) prioritizes sensitivity, but additional downstream filtration is recommended to improve specificity. Filtration methods are under active development by the GATK-SV team; stay tuned for updates.
215+
Additional downstream steps are under development.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"FilterGenotypes.vcf": "${this.concordance_vcf}",
3+
"FilterGenotypes.output_prefix": "${this.sample_set_set_id}",
4+
"FilterGenotypes.ploidy_table": "${this.ploidy_table}",
5+
"FilterGenotypes.gq_recalibrator_model_file": "${workspace.recalibrate_gq_model_file}",
6+
"FilterGenotypes.sl_filter_args": "--small-del-threshold 93 --medium-del-threshold 150 --small-dup-threshold -51 --medium-dup-threshold -4 --ins-threshold -13 --inv-threshold -19",
7+
8+
"FilterGenotypes.genome_tracks": "${workspace.recalibrate_gq_genome_tracks}",
9+
"FilterGenotypes.genome_tracks": [
10+
{{ reference_resources.recalibrate_gq_genome_track_repeatmasker | tojson }},
11+
{{ reference_resources.recalibrate_gq_genome_track_segdup | tojson }},
12+
{{ reference_resources.recalibrate_gq_genome_track_simple_repeats | tojson }},
13+
{{ reference_resources.recalibrate_gq_genome_track_umap100 | tojson }},
14+
{{ reference_resources.recalibrate_gq_genome_track_umap24 | tojson }}
15+
],
16+
"FilterGenotypes.recalibrate_gq_args": [
17+
"--keep-homvar false",
18+
"--keep-homref true",
19+
"--keep-multiallelic true",
20+
"--skip-genotype-filtering true",
21+
"--min-samples-to-estimate-allele-frequency -1"
22+
],
23+
24+
"FilterGenotypes.ped_file": "${workspace.cohort_ped_file}",
25+
"FilterGenotypes.primary_contigs_fai": "${workspace.primary_contigs_fai}",
26+
"FilterGenotypes.site_level_comparison_datasets": [
27+
{{ reference_resources.ccdg_abel_site_level_benchmarking_dataset | tojson }},
28+
{{ reference_resources.gnomad_v2_collins_site_level_benchmarking_dataset | tojson }},
29+
{{ reference_resources.hgsv_byrska_bishop_site_level_benchmarking_dataset | tojson }},
30+
{{ reference_resources.thousand_genomes_site_level_benchmarking_dataset | tojson }}
31+
],
32+
"FilterGenotypes.runtime_override_plot_qc_per_family": {
33+
"mem_gb": 15,
34+
"disk_gb": 100
35+
},
36+
37+
"FilterGenotypes.linux_docker": "${workspace.linux_docker}",
38+
"FilterGenotypes.gatk_docker": "${workspace.gq_recalibrator_docker}",
39+
"FilterGenotypes.sv_base_mini_docker": "${workspace.sv_base_mini_docker}",
40+
"FilterGenotypes.sv_pipeline_docker": "${workspace.sv_pipeline_docker}"
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"JoinRawCalls.gatk_docker": "${workspace.gatk_docker}",
3+
"JoinRawCalls.sv_base_mini_docker": "${workspace.sv_base_mini_docker}",
4+
"JoinRawCalls.sv_pipeline_docker": "${workspace.sv_pipeline_docker}",
5+
6+
"JoinRawCalls.clustered_depth_vcfs" : "${this.sample_sets.clustered_depth_vcf}",
7+
"JoinRawCalls.clustered_depth_vcf_indexes" : "${this.sample_sets.clustered_depth_vcf_index}",
8+
9+
"JoinRawCalls.clustered_manta_vcfs" : "${this.sample_sets.clustered_manta_vcf}",
10+
"JoinRawCalls.clustered_manta_vcf_indexes" : "${this.sample_sets.clustered_manta_vcf_index}",
11+
12+
"JoinRawCalls.clustered_wham_vcfs" : "${this.sample_sets.clustered_wham_vcf}",
13+
"JoinRawCalls.clustered_wham_vcf_indexes" : "${this.sample_sets.clustered_wham_vcf_index}",
14+
15+
"JoinRawCalls.clustered_scramble_vcfs" : "${this.sample_sets.clustered_scramble_vcf}",
16+
"JoinRawCalls.clustered_scramble_vcf_indexes" : "${this.sample_sets.clustered_scramble_vcf_index}",
17+
18+
"JoinRawCalls.FormatVcfForGatk.formatter_args": "--fix-end",
19+
20+
"JoinRawCalls.ped_file": "${workspace.cohort_ped_file}",
21+
22+
"JoinRawCalls.contig_list": "${workspace.primary_contigs_list}",
23+
"JoinRawCalls.reference_fasta": "${workspace.reference_fasta}",
24+
"JoinRawCalls.reference_fasta_fai": "${workspace.reference_index}",
25+
"JoinRawCalls.reference_dict": "${workspace.reference_dict}",
26+
27+
"JoinRawCalls.prefix": "${this.sample_set_set_id}"
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"SVConcordance.gatk_docker": "${workspace.gatk_docker}",
3+
"SVConcordance.sv_base_mini_docker": "${workspace.sv_base_mini_docker}",
4+
5+
"SVConcordance.eval_vcf" : "${this.cleaned_vcf}",
6+
"SVConcordance.truth_vcf" : "${this.joined_raw_calls_vcf}",
7+
8+
"SVConcordance.output_prefix": "${this.sample_set_set_id}",
9+
10+
"SVConcordance.contig_list": "${workspace.primary_contigs_list}",
11+
"SVConcordance.reference_dict": "${workspace.reference_dict}"
12+
}

inputs/templates/terra_workspaces/cohort_mode/workspace.tsv.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gatk_docker {{ dockers.gatk_docker }}
55
gatk_docker_pesr_override {{ dockers.gatk_docker_pesr_override }}
66
gcnv_gatk_docker {{ dockers.gatk_docker }}
77
genomes_in_the_cloud_docker {{ dockers.genomes_in_the_cloud_docker }}
8+
gq_recalibrator_docker {{ dockers.gq_recalibrator_docker }}
89
linux_docker {{ dockers.linux_docker }}
910
manta_docker {{ dockers.manta_docker }}
1011
samtools_cloud_docker {{ dockers.samtools_cloud_docker }}
@@ -39,6 +40,7 @@ preprocessed_intervals {{ reference_resources.preprocessed_intervals }}
3940
primary_contigs_fai {{ reference_resources.primary_contigs_fai }}
4041
primary_contigs_list {{ reference_resources.primary_contigs_list }}
4142
protein_coding_gtf {{ reference_resources.protein_coding_gtf }}
43+
recalibrate_gq_model_file {{ reference_resources.aou_recalibrate_gq_model_file }}
4244
reference_build {{ reference_resources.reference_build }}
4345
reference_dict {{ reference_resources.reference_dict }}
4446
reference_fasta {{ reference_resources.reference_fasta }}

0 commit comments

Comments
 (0)