Skip to content

The Workflow & the Dataset

A germline analysis turns one person’s reads into a list of the places where that genome differs from the reference, with a genotype at each one. This page lays out the path from FASTQ to an annotated VCF and marks which steps nf-core/sarek runs and which steps the pages of this section run. It then opens the answer key for the sample, the Genome in a Bottle truth set for HG002, and counts what is in it. Those counts are what a perfect call set for this region would contain.

nf-core/sarek, run once on the host pages of this section
─────────────────────────────────── ─────────────────────
paired FASTQ
│ FastQC, fastp ┐ nf-core/sarek and
│ BWA-MEM, samtools sort │ BWA & GATK preprocessing
│ GATK MarkDuplicates │ explain these steps,
│ GATK BaseRecalibrator, ApplyBQSR ┘ reference only
▼
recalibrated CRAM
├── mosdepth, samtools stats ────────────► Coverage & QC
│
│ HaplotypeCaller, DeepVariant,
│ FreeBayes, bcftools mpileup
▼
one VCF per caller ────────────────────────► Variant calling
│ Comparing callers
│ Filtering
│ Benchmarking, with the GIAB truth set
│ Visualization
│ SnpEff
▼
annotated VCF ─────────────────────────────► Annotation

The left column is pipeline work. Sarek ran it once, as a Nextflow run on the host with each process in its own Podman container, and the DNA-seq with nf-core/sarek guide records that run and every file it wrote. The nf-core/sarek and BWA & GATK preprocessing pages explain those steps without running them again, and each one says so in a note.

The right column reads what sarek wrote. The QC reports, the four VCFs, the SnpEff output and the truth set were copied into the dnaseq image under /opt/data, and every gated page reads them from there. No page realigns a read. Each page runs its own code in that image, and its checks fail when a printed number or a figure on the page did not come from that run.

The sample is HG002, also catalogued as NA24385, the son in the Ashkenazi trio that Genome in a Bottle characterizes. GIAB sequenced him to about 300x on a HiSeq 2500, with 2 x 148 bp reads from TruSeq PCR-free libraries and a target insert size of 550 bases, as the GIAB data paper describes. The reads here come from HG002.GRCh38.60x.1.bam, a 60x share of those reads that Novoalign aligned to the GRCh38 analysis set with its decoy sequences, according to the README of the BAM folder.

A fetch script cut one region, chr20:10,000,001-11,000,000, out of that file and wrote the read pairs back out as FASTQ, so sarek starts from reads. The region was the first 1 Mb window from 10 Mb onward that holds at least 1,000 SNVs and 100 indels inside the benchmark regions of the truth set. The reference is chr20 of the GATK GRCh38 FASTA, which is why every coordinate on these pages starts with chr20.

The truth set is the GIAB v4.2.1 benchmark of Wagner et al. 2022. It has two parts. The VCF lists the variants GIAB trusts, and the BED file lists the benchmark regions, where that VCF is complete. Inside those regions, a call that is not in the truth VCF is a false positive, and a truth variant that no caller finds is a false negative. Outside them, nothing can be scored, which is why the GA4GH best practices compute precision and recall inside the benchmark regions only. Both files were cut to the region by the same fetch script.

Every gated page reads its inputs from the files below and from the chr20 reference under /opt/reference. The image checks each file against SHA256SUMS when it is built, and the fence repeats the check.

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
# Every file under /opt/data, with its size in bytes.
find /opt/data -type f -printf '%10s %P\n' | LC_ALL=C sort -k 2
# The chr20 reference and its length.
cut -f 1,2 /opt/reference/chr20.fasta.fai
# Check every file against the checksums written when the fixtures were made.
cd /opt/data
sha256sum --quiet -c SHA256SUMS
echo "$(wc -l < SHA256SUMS) files match SHA256SUMS"
cd - > /dev/null
# The sample name inside each VCF.
for vcf in /opt/data/*/*/*.vcf.gz /opt/data/truth/*.vcf.gz; do
printf '%-12s %s\n' "$(bcftools query -l "$vcf")" "${vcf#/opt/data/}"
done
12940 PROVENANCE.md
4087 SHA256SUMS
117815 annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz
689 annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz.tbi
12042 annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.csv
2434 annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.genes.txt
1135019 qc/bqsr/HG002.recal.table
4219 qc/markduplicates/HG002.md.cram.metrics
2500 qc/mosdepth/HG002.md.mosdepth.global.dist.txt
2248 qc/mosdepth/HG002.md.mosdepth.region.dist.txt
186 qc/mosdepth/HG002.md.mosdepth.summary.txt
553876 qc/mosdepth/HG002.md.regions.bed.gz
217 qc/mosdepth/HG002.md.regions.bed.gz.csi
2500 qc/mosdepth/HG002.recal.mosdepth.global.dist.txt
2248 qc/mosdepth/HG002.recal.mosdepth.region.dist.txt
186 qc/mosdepth/HG002.recal.mosdepth.summary.txt
553331 qc/mosdepth/HG002.recal.regions.bed.gz
217 qc/mosdepth/HG002.recal.regions.bed.gz.csi
2777 qc/multiqc/multiqc_general_stats.txt
104556 qc/samtools/HG002.md.cram.stats
105716 qc/samtools/HG002.recal.cram.stats
24 region/chr20_region.bed
63622 truth/hg002_giab_v4_2_1_chr20_region.vcf.gz
705 truth/hg002_giab_v4_2_1_chr20_region.vcf.gz.tbi
3096 truth/hg002_giab_v4_2_1_chr20_region_noinconsistent.bed
69702 variant_calling/bcftools/HG002.bcftools.vcf.gz
641 variant_calling/bcftools/HG002.bcftools.vcf.gz.tbi
43974 variant_calling/deepvariant/HG002.deepvariant.vcf.gz
684 variant_calling/deepvariant/HG002.deepvariant.vcf.gz.tbi
163809 variant_calling/freebayes/HG002.freebayes.filtered.vcf.gz
685 variant_calling/freebayes/HG002.freebayes.filtered.vcf.gz.tbi
203468 variant_calling/freebayes/HG002.freebayes.vcf.gz
696 variant_calling/freebayes/HG002.freebayes.vcf.gz.tbi
101113 variant_calling/haplotypecaller/HG002.haplotypecaller.filtered.vcf.gz
661 variant_calling/haplotypecaller/HG002.haplotypecaller.filtered.vcf.gz.tbi
92187 variant_calling/haplotypecaller/HG002.haplotypecaller.vcf.gz
661 variant_calling/haplotypecaller/HG002.haplotypecaller.vcf.gz.tbi
chr20 64444167
35 files match SHA256SUMS
HG002_HG002 annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz
HG002 variant_calling/bcftools/HG002.bcftools.vcf.gz
HG002 variant_calling/deepvariant/HG002.deepvariant.vcf.gz
HG002_HG002 variant_calling/freebayes/HG002.freebayes.filtered.vcf.gz
HG002_HG002 variant_calling/freebayes/HG002.freebayes.vcf.gz
HG002_HG002 variant_calling/haplotypecaller/HG002.haplotypecaller.filtered.vcf.gz
HG002_HG002 variant_calling/haplotypecaller/HG002.haplotypecaller.vcf.gz
HG002 truth/hg002_giab_v4_2_1_chr20_region.vcf.gz

Two sample names appear. HaplotypeCaller and FreeBayes take the name from the SM tag of the read group, which sarek builds as <patient>_<sample>, so they write HG002_HG002. Sarek starts DeepVariant with --sample_name HG002, and the bcftools VCF and the truth set also say HG002. A script that selects a sample by name breaks when it moves from one caller’s VCF to the next, so read the first sample column by position when a VCF holds a single sample.

The qc/ folder holds the reports that the Coverage & QC page reads. Each report exists twice, once for the CRAM written after duplicate marking, md, and once for the recalibrated CRAM, recal. The alignment files themselves are not in the image.

bcftools answers the first questions from the command line. The truth BED is in BED coordinates, 0-based and half open, so the length of an interval is its end minus its start. A record counts as inside the benchmark regions when its POS falls inside an interval, which is what bcftools view -T tests by default.

Terminal window
truth=/opt/data/truth
vcf="$truth/hg002_giab_v4_2_1_chr20_region.vcf.gz"
bed="$truth/hg002_giab_v4_2_1_chr20_region_noinconsistent.bed"
# BED intervals are 0-based and half open: the length is end - start.
awk '{n += $3 - $2} END {print "region length:", n}' \
/opt/data/region/chr20_region.bed
awk '{n += $3 - $2} END {print "benchmark bases:", n, "in", NR, "intervals"}' \
"$bed"
echo "truth records in the region: $(bcftools view -H "$vcf" | wc -l)"
# -T keeps the records whose POS falls inside a BED interval.
bcftools view -T "$bed" -Oz -o truth_in_bed.vcf.gz "$vcf"
echo "records inside the BED: $(bcftools view -H truth_in_bed.vcf.gz | wc -l)"
echo "records outside the BED: $(bcftools view -H -T ^"$bed" "$vcf" | wc -l)"
# An SNV has one base in REF and in every ALT. An indel record has at
# least one ALT allele whose length differs from REF.
snvs=$(bcftools view -H -i 'TYPE="snp"' truth_in_bed.vcf.gz | wc -l)
indels=$(bcftools view -H -v indels truth_in_bed.vcf.gz | wc -l)
echo "SNVs: $snvs"
echo "indels: $indels"
# Split each genotype into its two allele indexes, 0 being REF.
bcftools query -f '[%GT]\n' truth_in_bed.vcf.gz \
| awk -F '[/|]' '
$1 == $2 {hom++; next}
$1 == 0 || $2 == 0 {het++; next}
{multi++}
END {
print "het REF/ALT:", het
print "hom ALT/ALT:", hom
print "het ALT/ALT:", multi
}'
region length: 1000000
benchmark bases: 977839 in 129 intervals
truth records in the region: 1625
records inside the BED: 1588
records outside the BED: 37
SNVs: 1354
indels: 234
het REF/ALT: 974
hom ALT/ALT: 595
het ALT/ALT: 19

The R tab reads the same two files with VariantAnnotation and GenomicRanges, and the Python tab reads them with cyvcf2 and pandas. Both also count one case that bcftools does not report, a record whose POS is inside an interval but whose REF allele runs past the interval’s end.

suppressPackageStartupMessages({
library(VariantAnnotation)
library(GenomicRanges)
})
truth_dir <- "/opt/data/truth"
vcf_path <- file.path(truth_dir, "hg002_giab_v4_2_1_chr20_region.vcf.gz")
bed_path <- file.path(
truth_dir, "hg002_giab_v4_2_1_chr20_region_noinconsistent.bed"
)
#' Read a three column BED file as 1-based GRanges.
#'
#' @param path Path to the BED file.
#' @return A GRanges object with one range per line of the file.
ReadBed <- function(path) {
bed <- read.delim(
path, header = FALSE, col.names = c("chrom", "start", "end")
)
# A BED start is 0-based and its end is exclusive, so add 1 to the start.
GRanges(bed$chrom, IRanges(start = bed$start + 1, end = bed$end))
}
region <- ReadBed("/opt/data/region/chr20_region.bed")
benchmark <- ReadBed(bed_path)
cat(sprintf("region length: %d\n", sum(width(region))))
cat(sprintf(
"benchmark bases: %d in %d intervals\n",
sum(width(benchmark)), length(benchmark)
))
# Read the fixed fields and the genotypes, and skip the INFO fields.
param <- ScanVcfParam(info = NA, geno = "GT")
truth <- readVcf(vcf_path, genome = "hg38", param = param)
cat(sprintf("truth records in the region: %d\n", nrow(truth)))
# A record is inside when its POS, the first base of REF, is inside.
first_base <- resize(rowRanges(truth), width = 1, fix = "start")
inside <- truth[overlapsAny(first_base, benchmark)]
is_snv <- nchar(ref(inside)) == 1 & all(nchar(alt(inside)) == 1)
gt <- geno(inside)$GT[, 1]
first_allele <- sub("[/|].*", "", gt)
second_allele <- sub(".*[/|]", "", gt)
is_hom <- first_allele == second_allele
is_het_ref <- !is_hom & (first_allele == "0" | second_allele == "0")
# rowRanges spans the whole REF allele, so "within" tests all of it.
ref_inside <- overlapsAny(rowRanges(inside), benchmark, type = "within")
counts <- list(
records = nrow(truth),
in_bed = nrow(inside),
snvs = sum(is_snv),
indels = sum(!is_snv),
het_ref_alt = sum(is_het_ref),
hom_alt_alt = sum(is_hom),
het_alt_alt = sum(!is_hom & !is_het_ref),
ref_past_end = sum(!ref_inside)
)
cat(sprintf("records inside the BED: %d\n", counts$in_bed))
cat(sprintf("records outside the BED: %d\n", nrow(truth) - nrow(inside)))
cat(sprintf("SNVs: %d\n", counts$snvs))
cat(sprintf("indels: %d\n", counts$indels))
cat(sprintf("het REF/ALT: %d\n", counts$het_ref_alt))
cat(sprintf("hom ALT/ALT: %d\n", counts$hom_alt_alt))
cat(sprintf("het ALT/ALT: %d\n", counts$het_alt_alt))
cat(sprintf("REF runs past its interval: %d\n", counts$ref_past_end))
for (i in which(!ref_inside)) {
record <- rowRanges(inside)[i]
holder <- benchmark[overlapsAny(benchmark, resize(record, 1))]
cat(sprintf(
" POS %d %s>%s, REF ends at %d, interval ends at %d\n",
start(record), as.character(record$REF),
paste(as.character(unlist(record$ALT)), collapse = ","),
end(record), end(holder)
))
}
# The gate compares these counts with the Python tab.
dir.create("outputs", showWarnings = FALSE)
jsonlite::write_json(
counts, "outputs/overview_counts_r.json", auto_unbox = TRUE
)
region length: 1000000
benchmark bases: 977839 in 129 intervals
truth records in the region: 1625
records inside the BED: 1588
records outside the BED: 37
SNVs: 1354
indels: 234
het REF/ALT: 974
hom ALT/ALT: 595
het ALT/ALT: 19
REF runs past its interval: 1
POS 10566231 GTTTTAGTTAAC>G, REF ends at 10566242, interval ends at 10566232

The three fences agree on every count they share, and the gate compares the R and Python counts field by field. The benchmark regions cover 977,839 of the 1,000,000 bases in the region, split into 129 intervals. Of the 1,625 truth records with POS in the region, 1,588 fall inside an interval. The other 37 sit in the gaps between intervals, where the benchmark makes no claim, so no call there can be scored.

Inside the benchmark regions the truth holds 1,354 SNVs and 234 indel records, so a caller that found everything would report 1,588 variants here and nothing else. Of those records, 974 carry one REF and one ALT allele, and 595 carry the ALT allele on both copies. The remaining 19 are multiallelic records, where the two copies carry two different ALT alleles and the genotype reads 1/2. bcftools norm -m- splits each of those into two records with one ALT each, so a count taken after normalization differs from a count taken before it.

The one record that the R and Python tabs flag is an 11 base deletion at POS 10,566,231. Its POS and the first deleted base lie inside an interval that ends at 10,566,232, and the other ten deleted bases lie past that end. A rule that asks for the whole REF allele to sit inside the BED leaves this deletion out, while the POS rule of bcftools view -T keeps it. Neither rule is wrong. Pick one and apply it to the truth set and to the calls alike, or the two counts stop lining up at the edges of the intervals.

  • BED and VCF coordinates differ by one. A BED start is 0-based and a VCF POS is 1-based, so the R tab adds 1 to every BED start and the Python tab compares the BED with the 0-based variant.start of cyvcf2. Skip that step and every interval shifts by one base, which drops an SNV on the first base of an interval and admits one just before it.
  • A call outside the benchmark BED cannot be scored. The truth there is unknown, so the call is neither a true nor a false positive.
  • Sample names differ between the VCFs above. Code that picks the sample by name works on one caller’s file and fails on the next.
  • Counts made before and after normalization do not compare. Splitting the 19 multiallelic records adds one record for each of them.

The next page, nf-core/sarek, covers the pipeline that wrote the QC reports and the VCFs in /opt/data.

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 Sarek 3.11.0 usage guide describes the pipeline inputs and stages that produced the local files. It connects the lesson sequence to the recorded run.

The VCF specification defines records, alternate alleles, genotypes, and reference blocks. These distinctions explain why record counts and benchmark bases answer different questions.