Coverage & QC
A variant caller can only weigh the reads it is given, so check the alignments before you call anything. This page asks how deep the HG002 alignments are and how even, how many reads are duplicates, and whether the pairs and the bases look like a healthy library. The CRAM files are not in the image, so every number comes from the reports that sarek’s QC steps wrote.
The QC files
Section titled “The QC files”Sarek runs mosdepth and samtools stats twice, on the CRAM that MarkDuplicates wrote, md,
and on the recalibrated CRAM that every caller reads, recal.
File under /opt/data/qc/ |
Tool | What it holds |
|---|---|---|
mosdepth/HG002.md.mosdepth.summary.txt |
mosdepth | the bases counted and the mean depth of chr20 |
mosdepth/HG002.md.mosdepth.global.dist.txt |
mosdepth | the share of chr20 at each depth or more |
mosdepth/HG002.md.regions.bed.gz |
mosdepth | the mean depth of each 500 bp window of chr20 |
markduplicates/HG002.md.cram.metrics |
GATK MarkDuplicates | the duplicate counts of the library |
samtools/HG002.md.cram.stats |
samtools stats | read counts, pairing, insert sizes and mismatches |
Each md file in the table has a recal twin. The task script of the run shows that sarek
started mosdepth with -n --fast-mode --by 500,
which skips the per base output and writes the mean depth of each 500 bp window.
The summary describes all of chr20
Section titled “The summary describes all of chr20”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.
mosdepth=/opt/data/qc/mosdepth
# The summary that mosdepth wrote for the md CRAM.awk '{printf "%-13s %9s %9s %5s %4s %4s\n", $1, $2, $3, $4, $5, $6}' \ "$mosdepth/HG002.md.mosdepth.summary.txt"
# The mean is the bases counted divided by the length of the contig.awk '$1 == "chr20" {printf "mean: %d / %d = %.4f\n", $3, $2, $3 / $2}' \ "$mosdepth/HG002.md.mosdepth.summary.txt"
# The cumulative distribution at 20x and 30x, as mosdepth rounds it.awk '$1 == "total" && ($2 == 20 || $2 == 30) { print "share of chr20 at " $2 "x or more:", $3 }' "$mosdepth/HG002.md.mosdepth.global.dist.txt"chrom length bases mean min maxchr20 64444167 58545277 0.91 0 116chr20_region 64444167 58545277 0.91 0 116total 64444167 58545277 0.91 0 116total_region 64444167 58545277 0.91 0 116mean: 58545277 / 64444167 = 0.9085share of chr20 at 30x or more: 0.02share of chr20 at 20x or more: 0.02The summary gives chr20 a mean depth of 0.91, which is correct arithmetic for the wrong question. mosdepth divided the 58,545,277 bases it counted by all 64,444,167 bases of chr20, and almost all of chr20 outside the region has no reads. The distribution file adds rounding to the same blind spot. Rounded to two decimals of all of chr20, the share for a 1 Mb region can only be 0.00, 0.01 or 0.02, so the 0.02 at 20x and at 30x says almost nothing. Restrict any report computed over the whole reference to the bases you targeted, which here means the windows.
Depth in 500 bp windows
Section titled “Depth in 500 bp windows”Both tabs sort every window of the md and recal files into three zones. A region
window lies inside chr20:10,000,001-11,000,000, an edge window touches one end of the
region from outside, and the rest of chr20 is elsewhere. The tabs then split the
region’s windows by whether they touch a gap in the GIAB benchmark regions.
suppressPackageStartupMessages({ library(dplyr) library(readr) library(GenomicRanges)})
mosdepth_dir <- "/opt/data/qc/mosdepth"bed_path <- paste0( "/opt/data/truth/", "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))}
#' Read a mosdepth window file and label each window by its zone.#'#' @param path Path to a mosdepth regions.bed.gz file.#' @param from The 0-based start of the region, as in its BED file.#' @param to The exclusive end of the region, as in its BED file.#' @return A tibble with one row per window and a zone column: "region"#' inside the region, "edge" for the two windows that touch it, and#' "elsewhere" for the rest of chr20.ReadWindows <- function(path, from, to) { read_tsv( path, col_names = c("chrom", "start", "end", "depth"), show_col_types = FALSE ) |> mutate(zone = case_when( start >= from & end <= to ~ "region", end == from | start == to ~ "edge", .default = "elsewhere" ))}
region <- ReadBed("/opt/data/region/chr20_region.bed")from <- start(region) - 1to <- end(region)windows <- bind_rows( md = ReadWindows( file.path(mosdepth_dir, "HG002.md.regions.bed.gz"), from, to ), recal = ReadWindows( file.path(mosdepth_dir, "HG002.recal.regions.bed.gz"), from, to ), .id = "file")
zone_summary <- windows |> group_by(file, zone) |> summarise( windows = n(), with_reads = sum(depth > 0), mean_depth = round(mean(depth), 3), min_depth = min(depth), max_depth = max(depth), .groups = "drop" )print(as.data.frame(zone_summary))
# The region's windows, split by whether they touch a benchmark gap.gaps <- GenomicRanges::setdiff(region, ReadBed(bed_path))in_region <- filter(windows, file == "md", zone == "region")window_ranges <- GRanges( in_region$chrom, IRanges(in_region$start + 1, in_region$end))in_region$benchmark <- if_else( overlapsAny(window_ranges, gaps), "touches a gap", "fully inside")gap_summary <- in_region |> group_by(benchmark) |> summarise( windows = n(), mean_depth = round(mean(depth), 3), below_30x = sum(depth < 30), below_20x = sum(depth < 20) )print(as.data.frame(gap_summary))
# The windows on both sides of each end of the region.ends <- windows |> filter(file == "md", zone == "edge" | start == from | end == to) |> dplyr::select(start, end, zone, depth)print(as.data.frame(ends))
recal_region <- filter(windows, file == "recal", zone == "region")largest_difference <- max(abs(in_region$depth - recal_region$depth))cat(sprintf("largest md to recal difference in the region: %.2f\n", largest_difference))
# The gate compares these values with the Python tab.parity <- list( region_mean = mean(in_region$depth), below_30x = sum(in_region$depth < 30), gap_windows = sum(in_region$benchmark == "touches a gap"), md_elsewhere_with_reads = sum( windows$depth > 0 & windows$zone == "elsewhere" & windows$file == "md" ), recal_elsewhere_with_reads = sum( windows$depth > 0 & windows$zone == "elsewhere" & windows$file == "recal" ))dir.create("outputs", showWarnings = FALSE)jsonlite::write_json( parity, "outputs/coverage_qc_r.json", auto_unbox = TRUE, digits = NA) file zone windows with_reads mean_depth min_depth max_depth1 md edge 2 1 1.755 0.00 3.512 md elsewhere 126887 113 0.000 0.00 2.753 md region 2000 2000 58.536 22.16 87.114 recal edge 2 1 1.755 0.00 3.515 recal elsewhere 126887 0 0.000 0.00 0.006 recal region 2000 2000 58.536 22.16 87.11 benchmark windows mean_depth below_30x below_20x1 fully inside 1840 59.204 0 02 touches a gap 160 50.852 4 0 start end zone depth1 9999500 10000000 edge 0.002 10000000 10000500 region 35.593 10999500 11000000 region 39.364 11000000 11000500 edge 3.51largest md to recal difference in the region: 0.00import jsonimport pathlib
import numpy as npimport pandas as pd
MOSDEPTH_DIR = pathlib.Path("/opt/data/qc/mosdepth")BED_PATH = ( "/opt/data/truth/hg002_giab_v4_2_1_chr20_region_noinconsistent.bed")
def read_bed(path): """Read a three column BED file.
Args: path: Path to the BED file.
Returns: A DataFrame with chrom, start and end columns. The coordinates stay 0-based and half open, as in the file. """ return pd.read_csv( path, sep="\t", header=None, names=["chrom", "start", "end"] )
def read_windows(path, region_start, region_end): """Read a mosdepth window file and label each window by its zone.
Args: path: Path to a mosdepth regions.bed.gz file. region_start: The 0-based start of the region. region_end: The exclusive end of the region.
Returns: A DataFrame with one row per window and a zone column: "region" inside the region, "edge" for the two windows that touch it, and "elsewhere" for the rest of chr20. """ windows = pd.read_csv( path, sep="\t", header=None, names=["chrom", "start", "end", "depth"] ) inside = (windows["start"] >= region_start) & ( windows["end"] <= region_end ) touches = (windows["end"] == region_start) | ( windows["start"] == region_end ) windows["zone"] = np.select( [inside, touches], ["region", "edge"], default="elsewhere" ) return windows
def benchmark_gaps(benchmark, region_start, region_end): """List the stretches of the region that the benchmark BED leaves out.
Args: benchmark: Sorted, non-overlapping intervals from read_bed. region_start: The 0-based start of the region. region_end: The exclusive end of the region.
Returns: A DataFrame of gaps with 0-based start and exclusive end columns. """ gap_starts = np.concatenate([[region_start], benchmark["end"]]) gap_ends = np.concatenate([benchmark["start"], [region_end]]) keep = gap_ends > gap_starts return pd.DataFrame({"start": gap_starts[keep], "end": gap_ends[keep]})
def touches_any(windows, intervals): """Test each window for an overlap with any of a set of intervals.
Args: windows: A DataFrame with 0-based start and exclusive end columns. intervals: A DataFrame with 0-based start and exclusive end columns.
Returns: A boolean array with one value per window. """ window_starts = windows["start"].to_numpy()[:, np.newaxis] window_ends = windows["end"].to_numpy()[:, np.newaxis] overlaps = (intervals["start"].to_numpy() < window_ends) & ( intervals["end"].to_numpy() > window_starts ) return overlaps.any(axis=1)
region = read_bed("/opt/data/region/chr20_region.bed")region_start = int(region["start"].iloc[0])region_end = int(region["end"].iloc[0])windows = pd.concat( [ read_windows( MOSDEPTH_DIR / f"HG002.{name}.regions.bed.gz", region_start, region_end, ).assign(file=name) for name in ("md", "recal") ], ignore_index=True,)windows["with_reads"] = windows["depth"] > 0
zone_summary = windows.groupby(["file", "zone"], as_index=False).agg( windows=("depth", "size"), with_reads=("with_reads", "sum"), mean_depth=("depth", "mean"), min_depth=("depth", "min"), max_depth=("depth", "max"),)zone_summary["mean_depth"] = zone_summary["mean_depth"].round(3)print(zone_summary.to_string(index=False))
# The region's windows, split by whether they touch a benchmark gap.gaps = benchmark_gaps(read_bed(BED_PATH), region_start, region_end)md_windows = windows[windows["file"] == "md"]in_region = md_windows[md_windows["zone"] == "region"].copy()in_region["benchmark"] = np.where( touches_any(in_region, gaps), "touches a gap", "fully inside")in_region["below_30x"] = in_region["depth"] < 30in_region["below_20x"] = in_region["depth"] < 20gap_summary = in_region.groupby("benchmark", as_index=False).agg( windows=("depth", "size"), mean_depth=("depth", "mean"), below_30x=("below_30x", "sum"), below_20x=("below_20x", "sum"),)gap_summary["mean_depth"] = gap_summary["mean_depth"].round(3)print(gap_summary.to_string(index=False))
# The windows on both sides of each end of the region.ends = md_windows[ (md_windows["zone"] == "edge") | (md_windows["start"] == region_start) | (md_windows["end"] == region_end)]print(ends[["start", "end", "zone", "depth"]].to_string(index=False))
recal_windows = windows[windows["file"] == "recal"]recal_region = recal_windows[recal_windows["zone"] == "region"]largest_difference = np.abs( in_region["depth"].to_numpy() - recal_region["depth"].to_numpy()).max()print( "largest md to recal difference in the region: " f"{largest_difference:.2f}")
# The gate compares these values with the R tab.elsewhere = windows[windows["zone"] == "elsewhere"]with_reads = elsewhere[elsewhere["with_reads"]]parity = { "region_mean": float(in_region["depth"].mean()), "below_30x": int(in_region["below_30x"].sum()), "gap_windows": int((in_region["benchmark"] == "touches a gap").sum()), "md_elsewhere_with_reads": int((with_reads["file"] == "md").sum()), "recal_elsewhere_with_reads": int((with_reads["file"] == "recal").sum()),}pathlib.Path("outputs").mkdir(exist_ok=True)pathlib.Path("outputs/coverage_qc_python.json").write_text( json.dumps(parity, indent=2) + "\n") file zone windows with_reads mean_depth min_depth max_depth md edge 2 1 1.755 0.00 3.51 md elsewhere 126887 113 0.000 0.00 2.75 md region 2000 2000 58.536 22.16 87.11recal edge 2 1 1.755 0.00 3.51recal elsewhere 126887 0 0.000 0.00 0.00recal region 2000 2000 58.536 22.16 87.11 benchmark windows mean_depth below_30x below_20x fully inside 1840 59.204 0 0touches a gap 160 50.852 4 0 start end zone depth 9999500 10000000 edge 0.0010000000 10000500 region 35.5910999500 11000000 region 39.3611000000 11000500 edge 3.51largest md to recal difference in the region: 0.00The two tabs print the same values, and the gate compares the region mean and the window counts between them. The 2,000 windows of the region average 58.536, close to the 60x of the source file. None falls below 20x, four fall below 30x, and the lowest averages 22.16.
Table 3 of Marshall et al. 2020, the quality metrics of the Medical Genome Initiative for clinical WGS, makes a mean depth of at least 30x a pass or fail criterion and monitors the share of bases at 20x or more against 90 percent. The region clears the mean easily. The 20x metric is per base, and a window at 22.16 can still hide single bases below 20x, so the windows only show that no 500 bp stretch averages below it.
The thin windows gather at the gaps in the benchmark regions. The 160 windows that touch a gap average 50.852, against 59.204 for the 1,840 that sit fully inside, and all four windows below 30x touch a gap. Depth and the benchmark flag the same stretches of chr20.
Inside the region the md and recal files agree in every window. The one edge window
with reads starts at 11,000,000 and holds the ends of reads that run past the region. Away
from the region the md file has reads in 113 windows and the recal file has none, for
a reason the last section explains.
The depth profile
Section titled “The depth profile”The figure draws the recal windows, the depth every caller works from, with 5 kb around
each end of the region in the lower panels.
library(ggplot2)library(patchwork)
profile <- filter(windows, file == "recal")region_mean <- mean(profile$depth[profile$zone == "region"])
#' Draw the windows within 5 kb of one end of the region as bars.#'#' @param profile Windows with start, end and depth columns.#' @param boundary The position of the region end, in bases.#' @param region_mean The mean depth of the region, drawn as a line.#' @param label The name of the end, written beside the boundary.#' @param hjust 1 to write the name left of the boundary, 0 for right.#' @return A ggplot object.EdgeView <- function(profile, boundary, region_mean, label, hjust) { near <- filter(profile, start >= boundary - 5000, end <= boundary + 5000) ggplot(near) + geom_rect( aes(xmin = start / 1e6, xmax = end / 1e6, ymin = 0, ymax = depth), fill = "#2a78d6", colour = "white", linewidth = 0.4 ) + geom_hline( yintercept = region_mean, linetype = "dashed", colour = "#52514e" ) + geom_vline( xintercept = boundary / 1e6, linetype = "dotted", colour = "#52514e" ) + annotate( "text", x = boundary / 1e6, y = 85, label = paste0(" ", label, " "), hjust = hjust, size = 3, colour = "#52514e" ) + scale_x_continuous( breaks = seq(boundary - 4000, boundary + 4000, by = 2000) / 1e6, labels = scales::label_number(accuracy = 0.001) ) + scale_y_continuous(limits = c(0, 90)) + labs( title = paste("5 kb on each side of the", label), x = "Position on chr20 (Mb)", y = "Mean depth" ) + theme_minimal(base_size = 10)}
full_view <- ggplot( filter(profile, zone == "region"), aes((start + end) / 2e6, depth)) + geom_line(linewidth = 0.3, colour = "#2a78d6") + geom_hline( yintercept = region_mean, linetype = "dashed", colour = "#52514e" ) + scale_y_continuous(limits = c(0, 90)) + labs( title = sprintf( "The whole region in 500 bp windows, dashed line at the mean of %.1f", region_mean ), x = "Position on chr20 (Mb)", y = "Mean depth" ) + theme_minimal(base_size = 10)
start_view <- EdgeView(profile, from, region_mean, "region start", 1)end_view <- EdgeView(profile, to, region_mean, "region end", 0)figure <- full_view / (start_view | end_view) + plot_annotation( title = "HG002 depth in chr20:10,000,001-11,000,000, recalibrated CRAM" )ggsave( "outputs/coverage-qc_depth_profile_r.png", figure, width = 9, height = 6.5, dpi = 110, bg = "white")
import matplotlib.pyplot as plt
DEPTH_BLUE = "#2a78d6"REFERENCE_GREY = "#52514e"
def draw_edge(axis, profile, boundary, region_mean, label, align): """Draw the windows within 5 kb of one end of the region as bars.
Args: axis: The matplotlib Axes to draw on. profile: Windows with start, end and depth columns. boundary: The position of the region end, in bases. region_mean: The mean depth of the region, drawn as a line. label: The name of the end, written beside the boundary. align: "right" to write the name left of the boundary, "left" to write it on the right. """ near = profile[ (profile["start"] >= boundary - 5000) & (profile["end"] <= boundary + 5000) ] axis.bar( near["start"] / 1e6, near["depth"], width=(near["end"] - near["start"]) / 1e6, align="edge", color=DEPTH_BLUE, edgecolor="white", linewidth=0.6, ) axis.axhline(region_mean, color=REFERENCE_GREY, linestyle="--", lw=0.8) axis.axvline(boundary / 1e6, color=REFERENCE_GREY, linestyle=":", lw=1) axis.text( boundary / 1e6, 85, f" {label} ", ha=align, va="center", fontsize=8, color=REFERENCE_GREY, ) axis.set_ylim(0, 90) axis.set_xticks(np.arange(boundary - 4000, boundary + 4001, 2000) / 1e6) axis.ticklabel_format(axis="x", useOffset=False, style="plain") axis.set_title( f"5 kb on each side of the {label}", loc="left", fontsize=10 ) axis.set_xlabel("Position on chr20 (Mb)") axis.set_ylabel("Mean depth")
profile = recal_windowsregion_mean = profile.loc[profile["zone"] == "region", "depth"].mean()region_profile = profile[profile["zone"] == "region"]
figure = plt.figure(figsize=(9, 6.5), layout="constrained")grid = figure.add_gridspec(2, 2)full_axis = figure.add_subplot(grid[0, :])full_axis.plot( (region_profile["start"] + region_profile["end"]) / 2e6, region_profile["depth"], color=DEPTH_BLUE, lw=0.6,)full_axis.axhline(region_mean, color=REFERENCE_GREY, linestyle="--", lw=0.8)full_axis.set_ylim(0, 90)full_axis.set_title( "The whole region in 500 bp windows, dashed line at the mean of " f"{region_mean:.1f}", loc="left", fontsize=10,)full_axis.set_xlabel("Position on chr20 (Mb)")full_axis.set_ylabel("Mean depth")draw_edge( figure.add_subplot(grid[1, 0]), profile, region_start, region_mean, "region start", "right",)draw_edge( figure.add_subplot(grid[1, 1]), profile, region_end, region_mean, "region end", "left",)for axis in figure.axes: axis.spines[["top", "right"]].set_visible(False) axis.grid(axis="y", color="#e5e4e0", lw=0.6) axis.set_axisbelow(True)figure.suptitle( "HG002 depth in chr20:10,000,001-11,000,000, recalibrated CRAM", x=0.01, ha="left",)figure.savefig("outputs/coverage-qc_depth_profile_python.png", dpi=110)plt.close(figure)
The depth stays level across the region, between the 22.16 and 87.11 of the extreme windows, except at the ends. The first window averages 35.59 and the last 39.36.
The fetch script made that drop, not the library. It kept a pair only when both mates start inside the region, so near the start the reverse reads whose mates start before 10,000,001 are missing, and near the end the forward reads whose mates start after 11,000,000 are missing. With inserts of about 550 bases, the outer few hundred bases at each end keep mostly one strand of reads, and a caller has less evidence there than anywhere else in the region. A whole genome run has no such edge.
Duplicates
Section titled “Duplicates”metrics=/opt/data/qc/markduplicates/HG002.md.cram.metrics
# The metrics row follows the header line after "## METRICS CLASS".awk -F '\t' ' /^## METRICS CLASS/ { getline split($0, names) getline for (i = 1; i <= NF; i++) printf "%-30s %s\n", names[i], $i exit }' "$metrics"
# PERCENT_DUPLICATION counts reads: two for each duplicate pair plus the# unpaired duplicates, over every read examined.awk -F '\t' ' /^## METRICS CLASS/ { getline getline printf "(2 x %d + %d) / (2 x %d + %d) = %.6f\n", $7, $6, $3, $2, (2 * $7 + $6) / (2 * $3 + $2) exit }' "$metrics"LIBRARY HG002UNPAIRED_READS_EXAMINED 0READ_PAIRS_EXAMINED 199845SECONDARY_OR_SUPPLEMENTARY_RDS 220UNMAPPED_READS 0UNPAIRED_READ_DUPLICATES 0READ_PAIR_DUPLICATES 1826READ_PAIR_OPTICAL_DUPLICATES 38PERCENT_DUPLICATION 0.009137ESTIMATED_LIBRARY_SIZE 11097402(2 x 1826 + 0) / (2 x 199845 + 0) = 0.009137MarkDuplicates examined 199,845 pairs and marked 1,826 as copies of another pair, 38 of
them optical duplicates. PERCENT_DUPLICATION counts reads, and the second line rebuilds
its 0.009137 from the other columns. samtools stats agrees in the next section, with 3,652
reads flagged, twice 1,826. The MGI table monitors duplicates at below 10 percent of mapped
sequence, and the PCR-free libraries of HG002 skip the amplification that makes most
copies.
The rate depends on the read groups, because MarkDuplicates compares reads within one
library, the LB tag. GIAB pooled 12 libraries for each reference sample, according to the
library README,
but this run’s samplesheet gives sarek one sample and one lane, so every read lands in one
library. Pairs from different libraries that share both ends by chance are marked too,
which makes 0.009137 an upper bound.
Alignment statistics
Section titled “Alignment statistics”samtools stats writes a summary block of SN lines at the top of its report. The fence
lines up the fields that matter here for the two CRAMs, then derives the share of reads
that are not properly paired and the median insert size.
stats=/opt/data/qc/samtools
# The SN lines are the summary block of samtools stats.grep '^SN' "$stats/HG002.md.cram.stats" | cut -f 2,3 > md_sn.tsvgrep '^SN' "$stats/HG002.recal.cram.stats" | cut -f 2,3 > recal_sn.tsv
# Both files list the same fields in the same order, so paste lines them up.printf '%-32s %12s %12s\n' field md recalpaste md_sn.tsv recal_sn.tsv | awk -F '\t' ' BEGIN { keep = "raw total sequences:,reads mapped:,reads properly paired:" keep = keep ",reads duplicated:,reads MQ0:,supplementary alignments:" keep = keep ",error rate:,average quality:,insert size average:" keep = keep ",insert size standard deviation:" keep = keep ",pairs on different chromosomes:" n = split(keep, fields, ",") for (i = 1; i <= n; i++) wanted[fields[i]] = 1 } $1 in wanted {printf "%-32s %12s %12s\n", $1, $2, $4}'
# Reads that BWA did not flag as part of a proper pair.for name in md recal; do awk -F '\t' -v name="$name" ' $1 == "reads paired:" {paired = $2} $1 == "reads properly paired:" {proper = $2} END { printf "%s: %d of %d reads not properly paired, %.3f%%\n", name, paired - proper, paired, 100 * (paired - proper) / paired }' "${name}_sn.tsv"done
# The IS lines give each insert size and its number of pairs.grep '^IS' "$stats/HG002.md.cram.stats" | cut -f 2,3 | awk ' {size[NR] = $1; pairs[NR] = $2; total += $2} END { for (i = 1; i <= NR; i++) { seen += pairs[i] if (seen >= total / 2) {print "median insert size, md:", size[i]; exit} } }'field md recalraw total sequences: 399690 399676reads mapped: 399690 399676reads properly paired: 399662 399662reads duplicated: 3652 3652reads MQ0: 10 6supplementary alignments: 220 70error rate: 2.846421e-03 2.845006e-03average quality: 36.0 36.8insert size average: 546.3 546.3insert size standard deviation: 141.8 141.8pairs on different chromosomes: 0 0md: 28 of 399690 reads not properly paired, 0.007%recal: 14 of 399676 reads not properly paired, 0.004%median insert size, md: 551Every read mapped, and 28 of the 399,690 reads in the md file are not properly paired.
MGI monitors aligned reads at above 98 percent, but here these numbers say little about the
library, because the fetch script took only primary reads that the source aligner had
placed in the region as proper pairs.
The insert size averages 546.3 bases, with a median of 551. GIAB sheared the DNA for a target of 550 bases, and MGI monitors a median above 300 bp.
The error rate, 2.846421e-03, is the share of aligned bases that differ from the reference
according to the NM tags. Every real variant of HG002 counts as well, so the rate
overstates the sequencing error. BQSR leaves the bases alone and rewrites their
qualities, so the error rate hardly moves in recal while the average quality rises from
36.0 to 36.8, as BWA & GATK preprocessing
explains.
Ten reads in the md file have a mapping quality of 0, which means the aligner found
another place that fits as well. HaplotypeCaller skips reads below 20 by default, as its
engine source
sets, and DeepVariant skips reads below 5 with its WGS model, according to its
FAQ.
Reads that BWA placed elsewhere on chr20
Section titled “Reads that BWA placed elsewhere on chr20”Between the md and recal files, the CRAM lost 14 primary reads, from 399,690 to
399,676, and 150 supplementary alignments, from 220 to 70. The reads that are not properly
paired fell from 28 to 14 while the properly paired count held at 399,662, so the lost
reads all come from those 28. They are mates. For 14 pairs, BWA aligned one read inside the
region and the other elsewhere on chr20. The 150 supplementary alignments are parts of
reads from the region that BWA aligned a second time elsewhere on chr20, the split read
form that BWA & GATK preprocessing describes.
Before BWA realigned them, every one of these reads sat in a proper pair inside the region,
because the fetch script took only proper pairs from a BAM that Novoalign had aligned to
the whole GRCh38 analysis set with its decoy sequences. Against chr20 alone, BWA had no
other chromosome to offer, so every second placement it found landed on chr20. The same
limit silences a usual alarm. The pairs on different chromosomes line reads 0, as it
must with one chromosome, so a chimeric pair shows up only as a pair that is not properly
paired. Counting all 28 reads as chimeric gives 0.007 percent, far under the 1 percent
that MGI monitors.
No caller sees these alignments. The task script shows that sarek passed the region BED
to ApplyBQSR as --intervals, and ApplyBQSR writes only the reads that overlap its
intervals, while every md report still counts them. When a run uses intervals, read the
md and recal reports side by side.
Thresholds on this page
Section titled “Thresholds on this page”The MGI thresholds are written for whole clinical genomes, so on a 1 Mb region they serve as reference points rather than a verdict.
| Check | Threshold | Source | This run |
|---|---|---|---|
| Mean depth | 30x or more, pass or fail | Marshall et al. 2020, Table 3 | 58.536 over the windows of the region |
| Bases at 20x or more | 90 percent or more, monitored | Marshall et al. 2020, Table 3 | no window below 20x; per base depth is not in the fixtures |
| Duplicates | below 10 percent of mapped sequence | Marshall et al. 2020, Table 3 | 0.009137 |
| Chimeric reads | below 1 percent | Marshall et al. 2020, Table 3 | at most 28 reads, 0.007 percent |
| Median insert size | above 300 bp | Marshall et al. 2020, Table 3 | 551 |
| Aligned reads | above 98 percent | Marshall et al. 2020, Table 3 | 399,690 of 399,690, by construction |
| Mapping quality | 20 for HaplotypeCaller, 5 for DeepVariant | GATK source, DeepVariant FAQ | 10 reads at MAPQ 0 in the md file |
Next steps
Section titled “Next steps”The next page, Variant calling, reads the HaplotypeCaller VCF that sarek made from the recalibrated CRAM.
Scientific references
Section titled “Scientific references”Danecek and colleagues, 2021 describe the development and the current features of SAMtools and BCFtools.
Further reading
Section titled “Further reading”The mosdepth documentation explains window summaries and fast-mode behavior. It supports the distinction between whole-contig depth and depth inside the target interval.
The Picard duplication metric implementation defines examined and duplicate read counts. It explains the factors of two in the displayed duplicate-rate calculation.