Skip to content

Variant Calling

HaplotypeCaller writes one line for every position where it thinks HG002 differs from the reference, and it attaches a set of annotations to each line that say how it reached the call. This page reads that file field by field, before any filter has touched it. The question is what the caller called and how sure it was.

The file is the raw VCF from the nf-core/sarek run, variant_calling/haplotypecaller/HG002/HG002.haplotypecaller.vcf.gz, and the image keeps a copy under /opt/data/variant_calling/haplotypecaller/. The HaplotypeCaller source calls this output “A raw, unfiltered, highly sensitive callset”. Sarek writes a .filtered copy beside it, and the Filtering page reads that one. The VCF page covers the format in general.

The HG002 inputs come from NIST and the Genome in a Bottle consortium. The preparation on October 29, 2026 selects the chromosome 20 interval, subsets the GIAB v4.2.1 benchmark, and produces fresh analysis outputs. The source and terms notice identifies the original sequencing and benchmark publications, the exact source files, and the changes. It also records the grants for the Broad reference bundle and Ensembl release 99 annotation.

Terminal window
HC=/opt/data/variant_calling/haplotypecaller/HG002.haplotypecaller.vcf.gz
# Header lines start with ##. Every line that does not start with # is a record.
bcftools view --no-version -h "$HC" | grep -c '^##'
bcftools view -H "$HC" | wc -l
27
1807

Most of the header lines define fields, and a few describe the file itself.

Terminal window
bcftools view --no-version -h "$HC" \
| grep -E '^##(fileformat|source|FILTER|contig)='
bcftools view --no-version -h "$HC" | tail -n 1
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##FILTER=<ID=LowQual,Description="Low quality">
##contig=<ID=chr20,length=64444167>
##source=HaplotypeCaller
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT HG002_HG002

The single contig line is chr20, because the reference holds chr20 alone. The header declares PASS and LowQual, but HaplotypeCaller fills in no FILTER value, so every record carries a dot in that column. The last line names the one sample column, HG002_HG002, which sarek builds from the patient and sample columns of the samplesheet.

One header line holds the full HaplotypeCaller command, with every default spelled out. Four of its settings decide what can reach this file.

Terminal window
bcftools view --no-version -h "$HC" \
| grep '^##GATKCommandLine=<ID=HaplotypeCaller' \
| grep -oE \
-e '--pcr-indel-model [^ ]+' \
-e '--standard-min-confidence-threshold-for-calling [^ ]+' \
-e '--sample-ploidy [^ ]+' \
-e '--output-mode [^ ]+'
--pcr-indel-model NONE
--standard-min-confidence-threshold-for-calling 30.0
--sample-ploidy 2
--output-mode EMIT_VARIANTS_ONLY

EMIT_VARIANTS_ONLY means the file holds variant sites and none of the reference blocks that a GVCF would carry. No site with a QUAL below the confidence threshold of 30 is written at all, so a later filter on QUAL < 30 has nothing to remove. The ploidy of 2 is the diploid model.

The polymerase in library PCR slips in homopolymers and short tandem repeats, and the slips reach the reads as indels that are not in the genome. HaplotypeCaller can expect those errors. Its likelihood engine caps the insertion and deletion qualities of each base by the length of the repeat it sits in, so an indel inside a long repeat looks more like an error and counts for less. The CONSERVATIVE level, sarek’s default, “tries to maintain a high true positive rate at the expense of allowing more false positives”. AGGRESSIVE and HOSTILE give up more true positives, and under NONE “no specialized PCR error model will be applied”.

The HG002 reads come from PCR-free libraries. The GIAB library README names the Illumina TruSeq (LT) DNA PCR-Free Sample Prep Kit, FC-121-3001, and the HaplotypeCaller documentation says “When working with PCR-free data, be sure to set -pcr_indel_model NONE”. A PCR model on these reads would discount real indels in repeats to correct for errors that the library never made. The run therefore passes --gatk_pcr_indel_model NONE to sarek, and the command line above shows that it reached HaplotypeCaller. The Experimental design page covers the library side of the same choice.

The INFO column describes the site. These seven annotations are the ones a filter reads.

Terminal window
bcftools view --no-version -h "$HC" \
| grep -E '^##INFO=<ID=(DP|QD|FS|SOR|MQ|MQRankSum|ReadPosRankSum),'
##INFO=<ID=DP,Number=1,Type=Integer,Description="Approximate read depth; some reads may have been filtered">
##INFO=<ID=FS,Number=1,Type=Float,Description="Phred-scaled p-value using Fisher's exact test to detect strand bias">
##INFO=<ID=MQ,Number=1,Type=Float,Description="RMS Mapping Quality">
##INFO=<ID=MQRankSum,Number=1,Type=Float,Description="Z-score From Wilcoxon rank sum test of Alt vs. Ref read mapping qualities">
##INFO=<ID=QD,Number=1,Type=Float,Description="Variant Confidence/Quality by Depth">
##INFO=<ID=ReadPosRankSum,Number=1,Type=Float,Description="Z-score from Wilcoxon rank sum test of Alt vs. Ref read position bias">
##INFO=<ID=SOR,Number=1,Type=Float,Description="Symmetric Odds Ratio of 2x2 contingency table to detect strand bias">
Field What it measures Suspicious when
DP the reads at the site, counted before the caller sets aside reads that do not inform the genotype far above or below the mean depth
QD QUAL divided by the summed allele depths of the sample low: the evidence is weak for the number of reads
FS strand bias as a Phred-scaled Fisher exact test p-value high: the ALT allele comes from one strand
SOR strand bias as a symmetric odds ratio high, for the same reason
MQ the root mean square mapping quality of the reads below 60, the BWA maximum: some reads may belong elsewhere
MQRankSum ALT reads against REF reads, by mapping quality strongly negative: the ALT reads map worse
ReadPosRankSum ALT reads against REF reads, by position in the read strongly negative: the ALT sits near read ends

The FORMAT column holds the genotype of the sample and the evidence for it.

Terminal window
bcftools view --no-version -h "$HC" | grep '^##FORMAT'
##FORMAT=<ID=AD,Number=R,Type=Integer,Description="Allelic depths for the ref and alt alleles in the order listed">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Approximate read depth (reads with MQ=255 or with bad mates are filtered)">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=PL,Number=G,Type=Integer,Description="Normalized, Phred-scaled likelihoods for genotypes as defined in the VCF specification">
Field Meaning
GT the genotype: 0/1 heterozygous, 1/1 homozygous ALT, 1/2 two different ALT alleles
AD reads supporting REF, then each ALT
DP the informative reads behind the genotype
PL Phred-scaled likelihoods of each genotype, shifted so the best one is 0
GQ confidence in the chosen genotype, capped at 99

The first record below is a heterozygous SNV, and the second is a homozygous one just upstream of it.

Terminal window
bcftools view -H -r chr20:10002161 "$HC"
bcftools view -H -r chr20:10002077 "$HC"
chr20 10002161 rs11906973 A T 692.64 . AC=1;AF=0.5;AN=2;BaseQRankSum=1.01;DB;DP=49;ExcessHet=0;FS=11.452;MLEAC=1;MLEAF=0.5;MQ=60;MQRankSum=0;QD=15.06;ReadPosRankSum=-0.455;SOR=2.062 GT:AD:DP:GQ:PL 0/1:26,20:46:99:700,0,883
chr20 10002077 rs6057071 G A 2420.06 . AC=2;AF=1;AN=2;DB;DP=58;ExcessHet=0;FS=0;MLEAC=2;MLEAF=1;MQ=60;QD=25.36;SOR=1.823 GT:AD:DP:GQ:PL 1/1:0,57:57:99:2434,172,0

Read the first line from left to right. The ID rs11906973 comes from the dbSNP file that sarek passes with --dbsnp, and the DB flag says the same thing. QUAL is 692.64, the Phred-scaled confidence that the site carries some ALT allele. The genotype is 0/1, with 26 reads for A and 20 for T, and the PL values 700,0,883 say that 0/1 is the most likely genotype by a wide margin. The next best genotype, 0/0, sits 700 Phred units behind it. GQ is that gap, capped at 99.

The strand annotations disagree a little. FS is 11.452, so the T reads lean toward one strand, while SOR is 2.062. Every read has a mapping quality of 60, so MQ is 60 and MQRankSum is 0. ReadPosRankSum is -0.455, so the T sits in the same part of the reads as the A. Nothing here looks like an artifact.

The second line is a 1/1 call with 57 reads for A and none for G. It has no MQRankSum, BaseQRankSum or ReadPosRankSum, because a rank sum test compares REF reads with ALT reads and this site has no REF reads. Its QD is not QUAL over depth either.

Terminal window
# QD is QUAL over the summed allele depths, until that ratio passes 35
bcftools query -r chr20:10002077,chr20:10002161 \
-f '%POS\t%QUAL\t%INFO/QD\t[%AD]\n' "$HC" \
| awk -F'\t' '{
split($4, ad, ",")
printf "%s QUAL/AD=%.2f QD=%s\n", $1, $2 / (ad[1] + ad[2]), $3
}'
# Records with no MQRankSum, by genotype
bcftools query -i 'INFO/MQRankSum="."' -f '[%GT]\n' "$HC" | sort | uniq -c
10002077 QUAL/AD=42.46 QD=25.36
10002161 QUAL/AD=15.06 QD=15.06
2 0/1
636 1/1
44 1/2

For the heterozygous call QD is exactly QUAL over the 46 reads. For the homozygous one the ratio is 42.46, and GATK’s QualByDepth replaces any value of 35 or more with 30 plus Gaussian noise with a standard deviation of 3, which gives 25.36 here. Missing rank sums are the rule for homozygous calls, as the counts show, so a filter on them never touches most 1/1 records.

The tabs count the records by type and genotype, and summarize QUAL, GQ and the FORMAT DP. A record is an SNV when its REF and every ALT are one base long, an indel when every ALT changes the length, and mixed otherwise. Both tabs ignore the * allele, which marks a deletion that starts upstream and spans the position, and both print the same values.

suppressPackageStartupMessages({
library(VariantAnnotation)
library(ggplot2)
})
hc_path <- file.path(
"/opt/data/variant_calling/haplotypecaller",
"HG002.haplotypecaller.vcf.gz"
)
vcf <- readVcf(hc_path)
#' Summarize a numeric vector as six statistics.
#'
#' @param values A numeric vector with no missing values.
#' @return A character vector with the minimum, first quartile, median, mean,
#' third quartile and maximum, each with two decimals.
SummarizeValues <- function(values) {
stats <- c(
min(values),
quantile(values, 0.25, names = FALSE),
median(values),
mean(values),
quantile(values, 0.75, names = FALSE),
max(values)
)
sprintf("%.2f", stats)
}
#' Return the second lowest value of a vector.
#'
#' @param pl The PL values of one genotype.
#' @return The second lowest PL value.
SecondLowest <- function(pl) {
sort(pl)[2]
}
# VariantAnnotation reads the * allele as an empty string, so drop the
# empty alleles before typing each record.
ref_width <- nchar(ref(vcf))
alt_width <- nchar(alt(vcf))
alt_width <- alt_width[alt_width > 0]
is_snv <- ref_width == 1 & all(alt_width == 1)
is_indel <- all(alt_width != ref_width)
variant_class <- ifelse(is_snv, "SNV", ifelse(is_indel, "indel", "mixed"))
genotype <- geno(vcf)$GT[, 1]
gq <- geno(vcf)$GQ[, 1]
dp <- geno(vcf)$DP[, 1]
pl_second <- vapply(geno(vcf)$PL[, 1], SecondLowest, integer(1))
has_rsid <- grepl("^rs", rownames(vcf))
cat(sprintf("records: %d\n", nrow(vcf)))
for (level in c("SNV", "indel", "mixed")) {
cat(sprintf("%s: %d\n", level, sum(variant_class == level)))
}
for (level in sort(unique(genotype))) {
cat(sprintf("GT %s: %d\n", level, sum(genotype == level)))
}
cat(sprintf("multiallelic: %d\n", sum(lengths(alt(vcf)) > 1)))
cat(sprintf(
"rsID in the ID column: %d (%.1f%%)\n",
sum(has_rsid), 100 * mean(has_rsid)
))
cat(sprintf("GQ at the cap of 99: %d\n", sum(gq == 99)))
cat(sprintf(
"GQ equal to the second lowest PL, capped at 99: %d\n",
sum(gq == pmin(99L, pl_second))
))
cat("\n")
cat(sprintf(
"%-5s%s\n", "field",
paste(sprintf("%9s", c("min", "q1", "median", "mean", "q3", "max")),
collapse = "")
))
fields <- list(QUAL = qual(vcf), GQ = gq, DP = dp)
for (field in names(fields)) {
stats <- SummarizeValues(fields[[field]])
cat(sprintf("%-5s%s\n", field, paste(sprintf("%9s", stats), collapse = "")))
}
# The gate compares these values with the Python tab.
metrics <- list(
records = nrow(vcf),
snv = sum(variant_class == "SNV"),
indel = sum(variant_class == "indel"),
mixed = sum(variant_class == "mixed"),
gt_het = sum(genotype == "0/1"),
gt_hom_alt = sum(genotype == "1/1"),
gt_het_alt = sum(genotype == "1/2"),
multiallelic = sum(lengths(alt(vcf)) > 1),
rsid = sum(has_rsid),
gq_at_cap = sum(gq == 99),
gq_from_pl = sum(gq == pmin(99L, pl_second)),
qual_q1 = quantile(qual(vcf), 0.25, names = FALSE),
qual_median = median(qual(vcf)),
qual_mean = mean(qual(vcf)),
qual_q3 = quantile(qual(vcf), 0.75, names = FALSE),
gq_mean = mean(gq),
dp_median = median(dp),
dp_mean = mean(dp)
)
dir.create("outputs", showWarnings = FALSE, recursive = TRUE)
jsonlite::write_json(
metrics, "outputs/variant-calling_metrics_r.json",
auto_unbox = TRUE, digits = NA
)
records: 1807
SNV: 1450
indel: 351
mixed: 6
GT 0/1: 1097
GT 1/1: 660
GT 1/2: 50
multiallelic: 50
rsID in the ID column: 1713 (94.8%)
GQ at the cap of 99: 1724
GQ equal to the second lowest PL, capped at 99: 1807
field min q1 median mean q3 max
QUAL 40.64 844.62 1154.64 1405.37 1982.56 3665.03
GQ 0.00 99.00 99.00 97.44 99.00 99.00
DP 2.00 45.50 55.00 53.58 64.00 93.00
genotype_labels <- c(
"0/1" = "0/1, heterozygous",
"1/1" = "1/1, homozygous ALT",
"1/2" = "1/2, two different ALT alleles"
)
qual_data <- data.frame(
qual = qual(vcf),
genotype = factor(genotype_labels[genotype], levels = genotype_labels)
)
genotype_colors <- setNames(
c("#2a78d6", "#eb6834", "#1baf7a"), genotype_labels
)
# The dashed line is the calling threshold of 30, below which HaplotypeCaller
# writes nothing.
qual_plot <- ggplot(qual_data, aes(x = qual, fill = genotype)) +
geom_histogram(bins = 40, colour = "white", linewidth = 0.2) +
geom_vline(xintercept = 30, linetype = "dashed", colour = "grey40") +
scale_x_log10(labels = scales::label_comma()) +
scale_fill_manual(values = genotype_colors, guide = "none") +
facet_wrap(~ genotype, ncol = 1, scales = "free_y") +
labs(x = "QUAL, log scale", y = "Records") +
theme_minimal(base_size = 12) +
theme(panel.grid.minor = element_blank())
dir.create("outputs", showWarnings = FALSE, recursive = TRUE)
ggsave(
"outputs/variant-calling_qual_r.png",
plot = qual_plot,
width = 7,
height = 6,
dpi = 150,
bg = "white"
)

QUAL of the 1,807 HaplotypeCaller records on a log scale, one panel per genotype. The heterozygous calls peak below the homozygous ones, the two ALT allele calls sit between them, and no record falls below the dashed calling threshold of 30.

The counts describe an ordinary germline call set for one megabase of one person. Heterozygous calls outnumber homozygous ones, and the 50 multiallelic records are exactly the 50 1/2 calls, where each haplotype carries a different ALT allele.

The rsID share of 94.8 percent says that most of these sites are known, not that the calls are right. The HaplotypeCaller arguments state that “dbSNP is not used in any way for the calculations themselves”, so a false call at a known site still gets its rsID.

QUAL tracks depth and genotype more than correctness. Every read at a homozygous site supports the ALT, so the orange panel sits to the right of the blue one without its calls being any truer. GQ asks which genotype, given a variant, and the run confirms that it equals the second lowest PL, capped at 99, in every record. It sits at the cap for 1,724 of 1,807 records, so at this depth only its low end carries information, and the same holds for QUAL.

Terminal window
# The low tail: records with QUAL below 100, records with GQ below 20, and both
bcftools view -H -i 'QUAL < 100' "$HC" | wc -l
bcftools view -H -i 'FMT/GQ < 20' "$HC" | wc -l
bcftools query -i 'QUAL < 100 || FMT/GQ < 20' \
-f '%POS\t%REF\t%ALT\t%QUAL\t%INFO/QD\t[%GT\t%AD\t%GQ\t%PL]\n' "$HC"
32
7
10043652 CT C 72.6 14.52 0/1 2,3 49 80,0,49
10118061 TTA T 70.86 31.73 0/1 0,2 2 78,0,2
10118081 T TATA 151.02 31.55 0/1 0,4 0 158,0,0
10145655 GA G 544.94 24.77 1/1 2,20 5 556,5,0
10147102 A C 57.64 1.7 0/1 28,6 65 65,0,913
10224292 TGCAG T 55.6 6.18 0/1 7,2 63 63,0,288
10224298 C T 52.64 5.26 0/1 8,2 60 60,0,330
10224303 C T 52.64 5.26 0/1 8,2 60 60,0,330
10224304 C T 52.64 5.26 0/1 8,2 60 60,0,330
10308257 C CT 99.6 14.23 0/1 3,4 76 107,0,76
10327064 C CTT 56.6 9.43 0/1 4,2 64 64,0,134
10333494 T C 80.64 2.44 0/1 28,5 88 88,0,1108
10333498 T C 77.64 2.28 0/1 29,5 85 85,0,1164
10333502 A C 77.64 2.28 0/1 29,5 85 85,0,1159
10333506 T C 48.64 1.47 0/1 29,4 56 56,0,1157
10381822 C CTT 93.6 11.7 0/1 5,3 99 101,0,158
10392438 C CT 78.03 26.01 1/1 0,3 9 73,9,0
10394171 C T 66.64 2.02 0/1 26,7 74 74,0,840
10400813 C CAAA 61.6 8.8 0/1 3,4 43 69,0,43
10432789 C CA 58.6 7.33 0/1 4,4 66 66,0,80
10445311 CT C 92.6 9.26 0/1 6,4 99 100,0,139
10493859 C CTTT 262.61 29.18 0/1 1,8 18 270,0,18
10558341 CA C 80.6 4.74 0/1 12,5 88 88,0,381
10579666 T C 80.64 2.02 0/1 30,10 88 88,0,1158
10579669 A C 80.64 2.02 0/1 30,10 88 88,0,1158
10626190 A AT 50.27 25.13 1/1 0,2 6 62,6,0
10668092 TAAA T 274.77 34.35 0/1 1,7 4 282,0,4
10899557 TTTC T 73.6 4.6 0/1 13,3 81 81,0,531
10915545 G A 86.64 4.33 0/1 16,4 94 94,0,660
10915549 G A 86.64 4.33 0/1 16,4 94 94,0,660
10915553 G A 61.64 2.8 0/1 19,3 69 69,0,789
10915559 G A 52.64 2.11 0/1 22,3 60 60,0,915
10915564 G A 46.64 1.73 0/1 24,3 54 54,0,994
10915568 G A 40.64 1.4 0/1 26,3 48 48,0,1066
10933319 T G 59.64 1.99 0/1 22,8 67 67,0,542
10938840 A C 93.64 2.4 0/1 27,12 99 101,0,796

Three failure patterns run through that list, and the reference sequence around three of its records shows where they come from.

Terminal window
samtools faidx /opt/reference/chr20.fasta \
chr20:10915540-10915575 chr20:10118055-10118095 chr20:10432780-10432825
>chr20:10915540-10915575
AAAAAGAAAGAAAGAAAAAGAAAAGAAAGAAAAAAA
>chr20:10118055-10118095
TATATATTATATATATAATGTGTATATATATATATATTATA
>chr20:10432780-10432825
ACTCTTTGTCAAAAAAAAAAAAAAAAAAAAAAAAAATCGTGTAGTT

The first is a run of heterozygous SNVs a few bases apart. The six G to A calls from 10,915,545 to 10,915,568 sit in an AAAG repeat, each with 3 or 4 ALT reads against 16 to 26 REF reads and a QD from 1.4 to 4.33. A real heterozygous SNV draws about half the reads. A cluster at a low allele fraction points to reads placed where they do not belong, from a similar sequence elsewhere in the genome or from a different repeat length aligned with mismatches. With chr20 as the whole reference, reads from other chromosomes have nowhere else to go, and the Benchmarking page checks calls like these against the truth set.

The second is a genotype built on almost no reads, inside a TA repeat. The deletion at 10,118,061 is called 0/1 from two reads that both support the deletion, with a GQ of 2. The insertion at 10,118,081 has PL 158,0,0, a tie between 0/1 and 1/1, so its GQ is 0. The site is probably variant, and the genotype is a guess.

The third is a homopolymer. The C to CA insertion at 10,432,789 lengthens a long run of A bases, with 4 reads for each allele, and every base of such a run is a chance for the sequencer or the aligner to gain or lose one.

None of these records carries a FILTER value. The Filtering page turns QD, the strand annotations and the rest into filters and counts what each one removes.

The next page, Comparing callers, puts this file next to the DeepVariant, freebayes and bcftools calls on the same reads.

Danecek and colleagues, 2021 describe the development and the current features of SAMtools and BCFtools.

Obenchain and colleagues, 2014 describe VariantAnnotation, the Bioconductor package for the exploration and annotation of genetic variants.

The GATK HaplotypeCaller reference describes local assembly and the initial call set. Its output still needs the filtering discussed in the next lesson.

The VCF specification defines QUAL, FILTER, and genotype fields. These definitions separate site-level annotations from per-sample evidence.