Comparing callers
Sarek ran four variant callers on the same recalibrated CRAM file. Each one reads the same alignments and decides which genotype HG002 carries at each position, and each decides it with a different model. This page puts the four call sets on one footing, counts where they agree, and compares their genotypes at the sites they share. Which calls are right is a question for the truth set, and the Benchmarking page answers it.
Four models for one question
Section titled “Four models for one question”| Caller | How it decides | Primary source |
|---|---|---|
| GATK HaplotypeCaller | finds active regions, reassembles their reads into candidate haplotypes, scores each read against each haplotype with a pair HMM, then assigns genotypes with Bayes’ rule | Poplin et al. 2017 |
| DeepVariant | encodes the reads around each candidate as a tensor of base, base quality, mapping quality, strand and allele support, and a convolutional network classifies the genotype | Poplin et al. 2018 |
| freebayes | a Bayesian model over the literal read sequences in a window, so it can report MNPs and complex events as one allele | Garrison and Marth 2012 |
| bcftools mpileup and call | genotype likelihoods from the pileup at each position, then the multiallelic caller, call -m |
Li 2011, Danecek et al. 2021 |
The table follows the HaplotypeCaller documentation, the DeepVariant usage guide and the freebayes README. The first two callers rebuild the local sequence before they genotype, and bcftools looks at one position at a time.
The files also leave sarek in different states. The HaplotypeCaller calls pass through
CNNScoreVariants and FilterVariantTranches, which write a FILTER value, and DeepVariant
labels its own rejects RefCall or NoCall. The freebayes file is the one sarek cut at
QUAL > 30, with no FILTER value, and the bcftools file carries no filter. Sarek also
hands DeepVariant the recalibrated CRAM, although the DeepVariant usage guide advises
against BQSR because it lowers accuracy a little.
Put the four call sets on one footing
Section titled “Put the four call sets on one footing”Two call sets can hold the same variant and still disagree on paper. The loop below removes the differences of spelling before any comparison.
reheaderrenames the sample after the caller. HaplotypeCaller and freebayes call itHG002_HG002, the sarek patient and sample joined, and DeepVariant and bcftools call itHG002. A tool that joins files by sample, such asbcftools merge, would treat those as two people.--apply-filters PASS,.keeps the records that passed or were never filtered.--exclude 'ALT="."'drops records with no alternative allele. The bcftools file holds such records with the genotype./., because sarek drops only homozygous reference genotypes, and a missing genotype is not one.norm --multiallelics -anysplits a record with two ALT alleles in two, and--fasta-reflets norm trim shared bases and shift each indel to its leftmost position.- The last
viewkeeps the genotypes that carry the alternative allele inside the region, and it drops the*allele, which only says that an upstream deletion covers the position.
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.
set -o pipefailREF=/opt/reference/chr20.fastaREGION=/opt/data/region/chr20_region.bedCALLS=/opt/data/variant_calling# /work is the page folder. The R and Python tabs read the files from there.OUT=/work/outputs/comparing_callersmkdir -p "$OUT"
callers=(haplotypecaller deepvariant freebayes bcftools)inputs=( "$CALLS/haplotypecaller/HG002.haplotypecaller.filtered.vcf.gz" "$CALLS/deepvariant/HG002.deepvariant.vcf.gz" "$CALLS/freebayes/HG002.freebayes.filtered.vcf.gz" "$CALLS/bcftools/HG002.bcftools.vcf.gz")
printf '%-16s %-12s %7s %6s %s\n' caller sample records no_alt \ "norm total/split/joined/realigned/mismatch/dup/skipped"for i in "${!callers[@]}"; do caller=${callers[$i]} sample=$(bcftools query --list-samples "${inputs[$i]}") records=$(bcftools view --no-header "${inputs[$i]}" | wc -l) no_alt=$(bcftools view --no-header --include 'ALT="."' "${inputs[$i]}" \ | wc -l) # Name the sample after the caller, keep the passing records that carry # an ALT allele, split and left-align, then keep the non-reference # genotypes that are not a spanning deletion (*) inside the region. bcftools reheader --samples-list "$caller" "${inputs[$i]}" \ | bcftools view --apply-filters PASS,. --exclude 'ALT="."' -Ou \ | bcftools norm --multiallelics -any --fasta-ref "$REF" -Ou \ 2> "norm_$caller.log" \ | bcftools view --include 'GT="alt" && ALT!="*"' \ --targets-file "$REGION" \ -Oz --output "$OUT/$caller.vcf.gz" --write-index=tbi printf '%-16s %-12s %7d %6d %s\n' "$caller" "$sample" "$records" \ "$no_alt" "$(grep '^Lines' "norm_$caller.log" | cut -f2)"donecaller sample records no_alt norm total/split/joined/realigned/mismatch/dup/skippedhaplotypecaller HG002_HG002 1807 0 1795/50/0/21/0/0/0deepvariant HG002 2010 0 1788/40/0/20/0/0/0freebayes HG002_HG002 1713 0 1713/57/0/380/0/0/0bcftools HG002 1933 124 1809/31/0/334/0/0/0The no_alt column counts the records the exclude filter removed, and only bcftools has
any, 124 of its 1,933 records. In the norm summary, realigned counts the records whose
alleles norm rewrote. That is 380 freebayes records and 334 bcftools records, against 21
for HaplotypeCaller and 20 for DeepVariant.
Count the calls
Section titled “Count the calls”printf '%-16s %7s %6s %6s %6s\n' caller records snvs indels otherfor caller in "${callers[@]}"; do vcf="$OUT/$caller.vcf.gz" records=$(bcftools view --no-header "$vcf" | wc -l) snvs=$(bcftools view --no-header --types snps "$vcf" | wc -l) indels=$(bcftools view --no-header --types indels "$vcf" | wc -l) printf '%-16s %7d %6d %6d %6d\n' "$caller" "$records" "$snvs" \ "$indels" "$((records - snvs - indels))"donecaller records snvs indels otherhaplotypecaller 1834 1452 382 0deepvariant 1828 1444 384 0freebayes 1770 1378 335 57bcftools 1840 1479 361 0The four sets hold 1,770 to 1,840 records. bcftools calls the most SNVs, 1,479, and
DeepVariant the most indels, 384. Only freebayes has records in the other column, 57
MNPs and complex alleles that norm does not break up, and since no other caller writes
such records, none of the 57 can match another file.
Intersect with bcftools isec
Section titled “Intersect with bcftools isec”bcftools isec --nfiles +1 --collapse none \ "$OUT/haplotypecaller.vcf.gz" "$OUT/deepvariant.vcf.gz" \ "$OUT/freebayes.vcf.gz" "$OUT/bcftools.vcf.gz" \ > "$OUT/isec_sites.tsv"head -n 3 "$OUT/isec_sites.tsv"echo "sites: $(wc -l < "$OUT/isec_sites.tsv")"cut -f5 "$OUT/isec_sites.tsv" | sort | uniq -c | sort -k1,1nr -k2,2
# The spans of the freebayes records that norm left as MNPs or complex# alleles, and the 1101 sites, called by all but freebayes, inside them.bcftools view --exclude-types snps,indels "$OUT/freebayes.vcf.gz" \ | bcftools query --format '%POS0\t%END\n' > freebayes_complex.tsvawk 'NR == FNR {start[NR] = $1; end[NR] = $2; n = NR; next} $5 == "1101" { sites++ for (i = 1; i <= n; i++) { if ($2 > start[i] && $2 <= end[i]) {inside++; break} } } END {print inside " of " sites " sites lie in " n " freebayes records"}' \ freebayes_complex.tsv "$OUT/isec_sites.tsv"chr20 10002077 G A 1111chr20 10002161 A T 1111chr20 10002243 T C 1111sites: 1999 1656 1111 102 1101 67 0010 46 0001 37 1000 28 1100 17 0011 13 0111 11 0100 7 0110 7 1110 4 0101 2 1010 1 1001 1 101177 of 102 sites lie in 57 freebayes records--nfiles +1 lists every site in at least one file, and --collapse none pairs two
records only when POS, REF and ALT all match. The fifth column is a bit string in the
order of the files, HaplotypeCaller, DeepVariant, freebayes and bcftools, so 1101 means
every caller except freebayes.
Of 1,999 sites, 1,656 are in all four call sets. The next group, 1101, holds 102 sites
that only freebayes lacks, and 77 of them lie inside one of its 57 complex records.
freebayes found those alleles and wrote them as part of a longer one. bcftools has 46
private sites, HaplotypeCaller 37 and DeepVariant 11.
The same overlaps in R and Python
Section titled “The same overlaps in R and Python”The R tab reads each normalized file with VariantAnnotation and the Python tab with
cyvcf2. Both build a key from the position and the two alleles, spread the keys into one
column per caller, and count the patterns. Both print the same 15 patterns as
bcftools isec.
suppressPackageStartupMessages({ library(VariantAnnotation) library(dplyr) library(tidyr) library(ggplot2) library(patchwork)})
callers <- c("haplotypecaller", "deepvariant", "freebayes", "bcftools")vcf_dir <- "outputs/comparing_callers"
#' Read one normalized call set as a table of alleles and zygosity.#'#' @param caller Caller name, which is also the sample name in the VCF.#' @param vcf_dir Folder that holds the normalized VCF files.#' @return A tibble with one row per record: caller, key and zygosity.ReadCalls <- function(caller, vcf_dir) { vcf <- readVcf(file.path(vcf_dir, paste0(caller, ".vcf.gz"))) genotype <- geno(vcf)$GT[, caller] tibble( caller = caller, key = paste( start(vcf), as.character(ref(vcf)), as.character(unlist(alt(vcf))), sep = ":" ), zygosity = ifelse(genotype == "1/1", "hom", "het") )}
calls <- bind_rows(lapply(callers, ReadCalls, vcf_dir = vcf_dir))membership <- calls |> mutate(called = 1L) |> select(key, caller, called) |> pivot_wider(names_from = caller, values_from = called, values_fill = 0L)membership$pattern <- do.call(paste0, membership[callers])
pattern_counts <- membership |> count(pattern, name = "sites") |> arrange(desc(sites), pattern)print(as.data.frame(pattern_counts), row.names = FALSE) pattern sites 1111 1656 1101 102 0010 67 0001 46 1000 37 1100 28 0011 17 0111 13 0100 11 0110 7 1110 7 0101 4 1010 2 1001 1 1011 1import jsonimport pathlib
import cyvcf2import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
CALLERS = ["haplotypecaller", "deepvariant", "freebayes", "bcftools"]VCF_DIR = "outputs/comparing_callers"HOM_ALT = 3
def read_calls(caller, vcf_dir): """Read one normalized call set as a table of alleles and zygosity.
Args: caller: Caller name, which is also the sample name in the VCF. vcf_dir: Folder that holds the normalized VCF files.
Returns: A data frame with one row per record: caller, key and zygosity. """ rows = [] for variant in cyvcf2.VCF(f"{vcf_dir}/{caller}.vcf.gz"): key = f"{variant.POS}:{variant.REF}:{variant.ALT[0]}" zygosity = "hom" if variant.gt_types[0] == HOM_ALT else "het" rows.append((caller, key, zygosity)) return pd.DataFrame(rows, columns=["caller", "key", "zygosity"])
calls = pd.concat([read_calls(caller, VCF_DIR) for caller in CALLERS])membership = pd.crosstab(calls["key"], calls["caller"])[CALLERS]membership["pattern"] = membership.astype(str).agg("".join, axis=1)
pattern_counts = ( membership.value_counts("pattern") .rename("sites") .reset_index() .sort_values(["sites", "pattern"], ascending=[False, True]))print(pattern_counts.to_string(index=False))pattern sites 1111 1656 1101 102 0010 67 0001 46 1000 37 1100 28 0011 17 0111 13 0100 11 0110 7 1110 7 0101 4 1010 2 1001 1 1011 1An UpSet chart of the overlaps
Section titled “An UpSet chart of the overlaps”A Venn diagram of four sets has 15 regions and is hard to read. An UpSet chart draws one bar per pattern, and the dot matrix under each bar names its callers.
caller_names <- c( haplotypecaller = "HaplotypeCaller", deepvariant = "DeepVariant", freebayes = "freebayes", bcftools = "bcftools")set_sizes <- table(calls$caller)[callers]row_labels <- sprintf( "%s (%s)", caller_names[callers], format(set_sizes, big.mark = ","))
bar_data <- pattern_counts |> mutate(pattern = factor(pattern, levels = pattern))dot_data <- expand_grid(pattern = bar_data$pattern, row = seq_along(callers))dot_data$called <- substr(dot_data$pattern, dot_data$row, dot_data$row) == "1"dot_data$label <- factor(row_labels[dot_data$row], levels = rev(row_labels))
bars <- ggplot(bar_data, aes(pattern, sites)) + geom_col(fill = "#2a78d6", width = 0.7) + geom_text(aes(label = sites), vjust = -0.5, size = 3, colour = "#52514e") + scale_y_continuous(expand = expansion(mult = c(0, 0.1))) + labs( x = NULL, y = "Sites", title = "Overlap of four call sets, HG002 chr20:10,000,001-11,000,000" ) + theme_minimal(base_size = 11) + theme( axis.text.x = element_blank(), panel.grid.major.x = element_blank(), panel.grid.minor = element_blank() )
dots <- ggplot(dot_data, aes(pattern, label)) + geom_path( data = dot_data[dot_data$called, ], aes(group = pattern), colour = "#0b0b0b", linewidth = 0.8 ) + geom_point(aes(colour = called), size = 3) + scale_colour_manual( values = c(`TRUE` = "#0b0b0b", `FALSE` = "#dcdbd5"), guide = "none" ) + labs(x = "Callers that make the call", y = NULL) + theme_minimal(base_size = 11) + theme(axis.text.x = element_blank(), panel.grid = element_blank())
overlap_plot <- bars / dots + plot_layout(heights = c(3, 1.4))ggsave( "outputs/comparing-callers_overlap_r.png", overlap_plot, width = 9, height = 5.5, dpi = 120, bg = "white")
caller_names = { "haplotypecaller": "HaplotypeCaller", "deepvariant": "DeepVariant", "freebayes": "freebayes", "bcftools": "bcftools",}set_sizes = calls["caller"].value_counts()row_labels = [f"{caller_names[c]} ({set_sizes[c]:,})" for c in CALLERS]
figure, (ax_bars, ax_dots) = plt.subplots( 2, 1, figsize=(9, 5.5), sharex=True, gridspec_kw={"height_ratios": [3, 1.4]},)positions = range(len(pattern_counts))ax_bars.bar(positions, pattern_counts["sites"], width=0.7, color="#2a78d6")for position, sites in zip(positions, pattern_counts["sites"]): ax_bars.text( position, sites, f"{sites}", ha="center", va="bottom", fontsize=8, color="#52514e", )ax_bars.set_ylabel("Sites")ax_bars.set_title( "Overlap of four call sets, HG002 chr20:10,000,001-11,000,000", loc="left",)ax_bars.spines[["top", "right"]].set_visible(False)
for position, pattern in zip(positions, pattern_counts["pattern"]): rows = [row for row, bit in enumerate(pattern) if bit == "1"] ax_dots.scatter([position] * len(CALLERS), range(len(CALLERS)), s=40, color="#dcdbd5") ax_dots.plot([position, position], [min(rows), max(rows)], color="#0b0b0b", linewidth=1.5) ax_dots.scatter([position] * len(rows), rows, s=40, color="#0b0b0b", zorder=3)ax_dots.set_yticks(range(len(CALLERS)), row_labels)ax_dots.invert_yaxis()ax_dots.set_xticks([])ax_dots.tick_params(axis="y", length=0)ax_dots.set_xlabel("Callers that make the call")for spine in ax_dots.spines.values(): spine.set_visible(False)
figure.tight_layout()figure.savefig("outputs/comparing-callers_overlap_python.png", dpi=120)
Most variants in the region are easy, and all four methods find them. The disagreement sits in the short bars, and the second bar comes from how freebayes writes alleles rather than from what it found.
Genotypes at the shared sites
Section titled “Genotypes at the shared sites”A site in all four sets can still get four answers about zygosity. The code takes the 1,656 shared sites, counts the callers that call each one homozygous, and finds the lone caller wherever three agree and one does not.
shared_keys <- membership$key[membership$pattern == "1111"]shared <- calls |> filter(key %in% shared_keys) |> select(key, caller, zygosity) |> pivot_wider(names_from = caller, values_from = zygosity)
# The number of callers that call each shared site homozygous.shared$hom_calls <- rowSums(shared[callers] == "hom")cat(sprintf("shared sites: %d\n", nrow(shared)))cat(sprintf( "same zygosity in all four: %d\n", sum(shared$hom_calls %in% c(0, 4))))cat(sprintf("two against two: %d\n", sum(shared$hom_calls == 2)))
# At a three against one site, the lone caller holds the minority zygosity.lone <- shared |> filter(hom_calls %in% c(1, 3))minority <- ifelse(lone$hom_calls == 1, "hom", "het")is_lone <- lone[callers] == minoritysite_type <- ifelse(grepl("^[0-9]+:[ACGT]:[ACGT]$", lone$key), "snv", "indel")lone_counts <- t(rowsum(is_lone * 1L, site_type))print(lone_counts)
# The gate compares these counts with the Python tab.set_sizes <- table(calls$caller)[callers]parity_metrics <- c( setNames(as.list(as.integer(set_sizes)), paste0("records_", callers)), setNames( as.list(pattern_counts$sites), paste0("pattern_", pattern_counts$pattern) ), list( shared_sites = nrow(shared), same_zygosity = sum(shared$hom_calls %in% c(0, 4)), two_against_two = sum(shared$hom_calls == 2) ), setNames( as.list(as.vector(lone_counts)), paste( "lone", rep(rownames(lone_counts), ncol(lone_counts)), rep(colnames(lone_counts), each = nrow(lone_counts)), sep = "_" ) ))jsonlite::write_json( parity_metrics, "outputs/comparing_callers_metrics_r.json", auto_unbox = TRUE)shared sites: 1656same zygosity in all four: 1629two against two: 3 indel snvhaplotypecaller 0 0deepvariant 0 0freebayes 5 5bcftools 13 1shared_keys = membership.index[membership["pattern"] == "1111"]shared = calls[calls["key"].isin(shared_keys)].pivot( index="key", columns="caller", values="zygosity")[CALLERS]
# The number of callers that call each shared site homozygous.shared["hom_calls"] = (shared[CALLERS] == "hom").sum(axis=1)print("shared sites:", len(shared))print("same zygosity in all four:", shared["hom_calls"].isin([0, 4]).sum())print("two against two:", (shared["hom_calls"] == 2).sum())
# At a three against one site, the lone caller holds the minority zygosity.lone = shared[shared["hom_calls"].isin([1, 3])]minority = pd.Series( np.where(lone["hom_calls"] == 1, "hom", "het"), index=lone.index)is_lone = lone[CALLERS].eq(minority, axis=0)site_type = np.where( lone.index.str.fullmatch(r"\d+:[ACGT]:[ACGT]"), "snv", "indel")lone_counts = is_lone.groupby(site_type).sum().Tprint(lone_counts.to_string())
# The gate compares these counts with the R tab.record_counts = calls["caller"].value_counts()parity_metrics = {f"records_{c}": int(record_counts[c]) for c in CALLERS}for pattern, sites in zip(pattern_counts["pattern"], pattern_counts["sites"]): parity_metrics[f"pattern_{pattern}"] = int(sites)parity_metrics["shared_sites"] = len(shared)parity_metrics["same_zygosity"] = int(shared["hom_calls"].isin([0, 4]).sum())parity_metrics["two_against_two"] = int((shared["hom_calls"] == 2).sum())for caller in CALLERS: for site_class in lone_counts.columns: parity_metrics[f"lone_{caller}_{site_class}"] = int( lone_counts.loc[caller, site_class] )pathlib.Path("outputs/comparing_callers_metrics_python.json").write_text( json.dumps(parity_metrics, indent=2) + "\n")shared sites: 1656same zygosity in all four: 1629two against two: 3 indel snvcallerhaplotypecaller 0 0deepvariant 0 0freebayes 5 5bcftools 13 1All four callers give the same zygosity at 1,629 of the 1,656 shared sites, and 3 sites split two against two. At the others one caller stands alone, and it is always freebayes or bcftools. freebayes stands alone at 5 SNVs and 5 indels, and bcftools at 13 indels and 1 SNV. The Benchmarking page finds most bcftools errors at indels too, often as a false positive and a false negative at one position, which is how a wrong genotype shows up there.
How the comparison fails
Section titled “How the comparison fails”Exact matching punishes spelling. bcftools norm leaves MNPs and complex alleles whole,
and that cost freebayes 77 of the 102 sites it seems to miss. bcftools norm --atomize
splits MNPs into single bases, and the haplotype comparison on the Benchmarking page
avoids the problem.
Counting straight from the sarek files inflates the private calls. The DeepVariant file
holds its RefCall and NoCall records, and the bcftools file holds records with no
alternative allele, so read the FILTER column and the genotypes before you count.
Agreement is not accuracy. Misplaced reads can carry the same false allele into every caller, and a call that one caller makes alone can be the only right one. The overlap shows where to look, and the truth set shows who was right.
The code for this page is in the companion repository under
guides/dnaseq/comparing-callers/.
Scientific references
Section titled “Scientific references”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.
Further reading
Section titled “Further reading”The BCFtools command reference defines normalization and set intersections. Those operations establish what a shared variant representation means.
The VCF specification defines alternate alleles, genotypes, and filter fields. These definitions help distinguish shared sites from shared allele and genotype calls.