pangenome_aware_deepvariant

View as Markdown

Run a GPU-accelerated Pangenome-aware DeepVariant algorithm.

Refer to the pangenome_aware_deepvariant Reference section for a detailed listing of all available options.

What is Pangenome-aware DeepVariant?

Pangenome-aware DeepVariant is an enhanced version of Google’s DeepVariant that leverages pangenome reference graphs (GBZ files) to improve variant calling accuracy, particularly in complex and highly variable genomic regions. Traditional variant calling pipelines use a single linear reference genome, which can miss variants in regions that differ significantly from the reference. Pangenome-aware DeepVariant uses pangenome graphs that represent multiple haplotypes and structural variations, enabling more accurate variant detection in diverse populations. Like DeepVariant, Pangenome-aware Deepvariant generates pileup images and uses a CNN to infer genotypes. However, unlike DeepVariant, pileup images are generated for both the input reads and the pangenome haplotypes at potential variant positions. This allows directly using a pangenome for identifying true variants.

Why Pangenome-aware DeepVariant?

Linear genome references have been the standard for reference-based genomic analysis. However, linear references can introduce reference bias where the reference geneome is significantly different from the sample under study. Using a pangenome reference is one way to address this issue, since it includes diverse, non-redundant DNA sequences from multiple individuals. Pangenome-aware Deepvariant leverages the pangenome reference to outperform linear-reference-based DeepVariant by upto 25.5% across various short-read sequencing platforms and read mappers. Researchers from Google have also shown that Element reads with pangenome-aware DeepVariant can achieve 23.6% more accurate variant calling performance compared to existing methods.

Quick Start

1# This command assumes all the inputs are in the current working directory and all the outputs go to the same place.
2docker run --rm --gpus all --volume $(pwd):/workdir --volume $(pwd):/outputdir \
3 --workdir /workdir \
4 nvcr.io/nvidia/clara/clara-parabricks:4.7.1-1 \
5 pbrun pangenome_aware_deepvariant \
6 --ref /workdir/${REFERENCE_FILE} \
7 --pangenome /workdir/${GBZ_FILE} \
8 --in-bam /workdir/${INPUT_BAM} \
9 --out-variants /outputdir/${OUTPUT_VCF}

Roche SBX Mode

Use --sbx when calling variants from Roche SBX-D or SBX-Fast BAMs. Parabricks selects the SBX-trained pangenome-aware model (deepvariant_pangenome_aware_sbx.eng) for the current GPU architecture unless --pb-model-file overrides it, and applies make-examples and postprocess defaults aligned with the Google Roche SBX case study.

When --sbx is set, the following defaults apply:

  • Pileup image width of 301 base pairs.
  • alt_aligned_pileup=single_row pileup layout.
  • multiallelic_mode=product for multiallelic genotype resolution.
  • vsc_min_fraction_indels=0.08 and ws_min_base_quality=25.
  • --create-complex-alleles and --enable-strict-insertion-filter.
  • Insert-size pileup channel disabled by default (pass --channel-insert-size to enable it).

Roche SBX Quick Start

1# This command assumes all the inputs are in the current working directory and all the outputs go to the same place.
2docker run --rm --gpus all --volume $(pwd):/workdir --volume $(pwd):/outputdir \
3 --workdir /workdir \
4 nvcr.io/nvidia/clara/clara-parabricks:4.7.1-1 \
5 pbrun pangenome_aware_deepvariant \
6 --ref /workdir/${REFERENCE_FILE} \
7 --pangenome /workdir/${GBZ_FILE} \
8 --in-bam /workdir/HG002.roche_sbx.chr20.bam \
9 --out-variants /outputdir/HG002.chr20.output.vcf.gz \
10 --sbx \
11 -L chr20

Public case-study inputs (reference, GBZ, BAM, and GIAB truth sets) are available from the Google Roche SBX case study.

Compatible Google Pangenome-aware DeepVariant Command

The command below shows the equivalent Google pangenome-aware DeepVariant command. Note that the Parabricks version provides the same accuracy with significant GPU acceleration.

1sudo docker run \
2--volume <INPUT_DIR>:/input \
3--volume <OUTPUT_DIR>:/output \
4--shm-size 12gb \
5google/pangenome_aware_deepvariant-1.9.0 \
6/opt/deepvariant/bin/run_pangenome_aware_deepvariant \
7--model_type WGS \
8--ref /input/${REFERENCE_FILE} \
9--reads /input/${INPUT_BAM} \
10--pangenome /input/${GBZ_FILE} \
11--output_vcf /output/${OUTPUT_VCF} \
12--num_shards $(nproc) \
13--make_examples_extra_args "ws_use_window_selector_model=true"

Compatible Google Pangenome-aware DeepVariant Command (Roche SBX)

The command below shows the equivalent Google pangenome-aware DeepVariant Roche SBX command from the Roche SBX case study. Parabricks applies the same SBX defaults when --sbx is set.

1sudo docker run \
2--volume <INPUT_DIR>:/input \
3--volume <OUTPUT_DIR>:/output \
4--volume <REFERENCE_DIR>:/reference \
5--volume <MODEL_DIR>:/model \
6--shm-size 12gb \
7google/deepvariant:pangenome_aware_deepvariant-sbx \
8/opt/deepvariant/bin/run_pangenome_aware_deepvariant \
9--model_type WGS \
10--ref /reference/${REFERENCE_FILE} \
11--reads /input/HG002.roche_sbx.chr20.bam \
12--pangenome /input/${GBZ_FILE} \
13--output_vcf /output/HG002.chr20.output.vcf.gz \
14--num_shards $(nproc) \
15--regions chr20 \
16--customized_model /model/model.ckpt \
17--make_examples_extra_args="alt_aligned_pileup=single_row,create_complex_alleles=true,enable_strict_insertion_filter=true,keep_legacy_allele_counter_behavior=true,keep_only_window_spanning_haplotypes=true,keep_supplementary_alignments=true,min_mapping_quality=0,normalize_reads=true,pileup_image_height_pangenome=100,pileup_image_height_reads=100,pileup_image_width=301,sort_by_haplotypes=true,trim_reads_for_pileup=true,vsc_min_fraction_indels=0.08,ws_min_base_quality=25" \
18--postprocess_variants_extra_args="multiallelic_mode=product"

Source of Mismatches

While Parabricks Pangenome-aware DeepVariant does not lose any accuracy in functionality when compared with Google’s Pangenome-aware DeepVariant, there are several reasons that can result in different output files:

  • CNN Inference

Google DeepVariant uses a CNN (convolutional neural network) to predict the possibilities of each variant candidate. The model is trained, and does inference through, Keras. In Parabricks DeepVariant we convert this Keras model to an engine file with TensorRT to perform accelerated deep learning inferencing on NVIDIA GPUs. Because of the optimizations from TensorRT, there is a small difference in the final possibility scores after inferencing (10^-5), which could cause a few different variants in the final VCF output. Based on current observations, the mismatches only happen to RefCalls with a quality score of zero.

  • Read Sorting Differences

The Google Pangenome-aware DeepVariant implementation uses sort instead of stable_sort for sorting reads based on position, fragment_name, and read_number. Unfortunately, when the keep-supplementary-alignments option is enabled, it is possible to have duplicate reads which are sorted non-deterministically by std::sort. The Parabricks implementation uses stable_sort to resolve this. To obtain identical results with Google’s implementation, users are recommended to update the std::sort in BuildPileupForOneSample pileup_image_native.cc to std::stable_sort.

  • GBZ Reader Caching Mechanism

Google Pangenome-aware DeepVariant’s GBZ reader includes a fast path to speed up queries to the pangenome graph. This fast path introduces non-determinism in the query operation to the pangenome where the result returned by the operation depends on the order of the previous queries to the pangenome. Since, Parabricks relies on multi-threading to achieve high performance, we disable the fast path in the Parabricks implementation. To obtain identical results using Google’s implementation, users should comment out the call to updateCache in the GbzReader::Query() function in deepvariant/third_party/nucleus/io/gbz_reader.cc. Also, the check for whether the requested range is cached or not should be disabled (in the same function). Note that disabling the cache can slow down Google Deepvariant significantly and is not recommended in general. We suggest this approach only for the purposes of comparing output accuracy.

Options

TypeNameRequired?Description
I/O--ref REFYesPath to the reference file.
I/O--pangenome PANGENOMEYesPath to the pangenome gbz file.
I/O--in-bam IN_BAMYesPath to the input BAM/CRAM file for variant calling.
I/O--interval-file INTERVAL_FILENoPath to a BED file (.bed) for selective access. This option can be used multiple times.
I/O--out-variants OUT_VARIANTSYesPath of the vcf/vcf.gz/g.vcf/g.vcf.gz file after variant calling.
I/O--pb-model-file PB_MODEL_FILENoPath to a Parabricks TensorRT model (.eng) for pangenome_aware_deepvariant. Optional; if omitted, uses deepvariant_pangenome_aware.eng or deepvariant_pangenome_aware_sbx.eng when --sbx is set.
Tool--sbxNoRoche SBX mode. Uses the shipped deepvariant_pangenome_aware_sbx.eng for the current GPU tier unless --pb-model-file overrides it.
Tool--disable-use-window-selector-modelNoChange the window selector model from Allele Count Linear to Variant Reads. This option will increase the accuracy and runtime.
Tool--norealign-readsNoDo not locally realign reads before calling variants. Reads longer than 500 bp are never realigned.
Tool--vsc-min-fraction-indels VSC_MIN_FRACTION_INDELSNoIndel alleles occurring at least this fraction of all counts in our AlleleCount will be advanced as candidates.
Tool--ws-min-base-quality WS_MIN_BASE_QUALITYNoMinimum base quality to consider in calling a reference position for local assembly.
Tool--min-mapping-quality MIN_MAPPING_QUALITYNoBy default, reads with any mapping quality are kept. Setting this field to a positive integer i will only keep reads that have a MAPQ >= i. Note this only applies to aligned reads.
Tool--mode MODENoValue can be one of [shortread]. By default, it is shortread. (default: shortread)
Tool--pileup-image-width PILEUP_IMAGE_WIDTHNoPileup image width. Only change this if you know your model supports this width.
Tool--channel-insert-sizeNoEnable the insert_size pileup channel. Without --sbx it is on by default. With --sbx it is off by default; pass this flag to enable it.
Tool--no-channel-insert-sizeNoDisable the insert_size pileup channel. Without --sbx the channel is on by default; use this to turn it off. With --sbx the channel is already off unless --channel-insert-size is set. If both this flag and --channel-insert-size are set, the channel stays off. (default: False)
Tool--create-complex-allelesNoCreate complex alleles during calling.
Tool--enable-strict-insertion-filterNoIf True, add stricter filter for insertion in window selector. (experimental)
Tool--multiallelic-mode MULTIALLELIC_MODENoIf True, use a specialized model for genotype resolution of multiallelic cases with two alts.
Tool--sample-name-pangenome SAMPLE_NAME_PANGENOMENoSample name to use for pangenome data. Default is 'pangenome'. (default: pangenome)
Tool--ref-name-pangenome REF_NAME_PANGENOMENoReference genome name for pangenome data. Default is 'GRCh38'. (default: GRCh38)
Tool-L INTERVAL, --interval INTERVALNoInterval within which to call the variants from the BAM/CRAM file. Overlapping intervals will be combined. Interval files should be passed using the --interval-file option. This option can be used multiple times (e.g. "-L chr1 -L chr2:10000 -L chr3:20000+ -L chr4:10000-20000").
Performance--num-cpu-threads-per-stream NUM_CPU_THREADS_PER_STREAMNoNumber of CPU threads to use per stream. (default: 6)
Performance--num-streams-per-gpu NUM_STREAMS_PER_GPUNoNumber of streams to use per GPU. Default is 'auto' which will try to use an optimal amount of streams based on the GPU. (default: auto)
Performance--run-partitionNoDivide the whole genome into multiple partitions and run multiple processes at the same time, each on one partition.
Performance--gpu-num-per-partition GPU_NUM_PER_PARTITIONNoNumber of GPUs to use per partition.
Runtime--verboseNoEnable verbose output.
Runtime--x3NoShow full command line arguments.
Runtime--logfile LOGFILENoPath to the log file. If not specified, messages will only be written to the standard error output.
Runtime--tmp-dir TMP_DIRNoFull path to the directory where temporary files will be stored. (default: .)
Runtime--with-petagene-dir WITH_PETAGENE_DIRNoFull path to the PetaGene installation directory. By default, this should have been installed at /opt/petagene. Use of this option also requires that the PetaLink library has been preloaded by setting the LD_PRELOAD environment variable. Optionally set the PETASUITE_REFPATH and PGCLOUD_CREDPATH environment variables that are used for data and credentials. Optionally set the PetaLinkMode environment variable that is used to further configure PetaLink, notably setting it to "+write" to enable outputting compressed BAM and .fastq files.
Runtime--keep-tmpNoDo not delete the directory storing temporary files after completion.
Runtime--no-seccomp-overrideNoDo not override seccomp options for docker.
Runtime--versionNoView compatible software versions.
Runtime--preserve-file-symlinksNoOverride default behavior to keep file symlinks intact and *not* resolve the symlink.
Runtime--num-gpus NUM_GPUSNoNumber of GPUs to use for a run. (default: 1)