{#
Reusable section fragments shared by the single-sample (report.html) and
longitudinal (timeline.html) reports. Each macro only places already-formatted,
HTML-safe values from the render context (see allomix.html.context); the number
formatting comes from the registered Jinja filters/globals (pct, pval, ci,
count, badge, ...). No analysis happens here.
A lab can override this file via --template to restructure or reword any
section while keeping the rest of the built-in report.
#}
{# A small, collapsed "how this works" disclosure. Body supplied by the caller. #}
{% macro help(summary) %}
{{ summary }}
The donor fraction is a maximum-likelihood estimate from the alternate and reference read depths at informative markers (loci where the host and donor genotypes differ), following Crysup and Woerner (2022). The host (recipient) fraction is the remainder. The 95% confidence interval reflects sampling at the sequenced depth.
Limit of blank is the highest donor fraction expected from a true-zero sample at this sample's depth and marker set; limit of detection is the lowest fraction reliably distinguished from blank. Both are specific to this sample.
{% endcall %} {% endmacro %} {% macro help_host_presence() %} {% call help("How host-presence detection works") %}At markers where every donor is homozygous for the same allele and the host carries the other allele, that donor-absent allele appears only at the sequencing-error background in a pure-donor sample. A one-sided test (a likelihood ratio, with a pooled-Poisson cross-check) asks whether the observed donor-absent reads exceed that background, that is, whether any host signal is present.
This answers "is the host detectable?" directly, separately from the size of the donor fraction estimated above, and is most informative near the detection limit.
{% endcall %} {% endmacro %} {% macro help_qc() %} {% call help("How the quality-control checks work") %}Goodness-of-fit compares the observed allele depths to those predicted by the fitted fraction; a low p-value means the single-fraction model fits poorly (an unexpected marker, an extra contributor, or a genotyping error).
Contamination measures third-party DNA at markers where the host and every donor share the same homozygote: minor-allele reads there cannot come from either contributor, so their excess over the sequencing-error floor estimates contamination (for example index hopping or cross-contamination).
Sample-swap counts those same shared-homozygote sites where the minor allele is individually significant; many such sites indicate a whole extra genome (a swap or wrong-patient VCF).
Shared-het balance checks the admixture allele fraction at markers heterozygous in the host and every donor, where it should sit near 50% whatever the mixing fraction. Many sites skewed away from balance point to contamination, copy-number or allelic imbalance, or a sample mix-up.
Relatedness is a kinship coefficient between the reference samples, compared against the declared relationship to catch mislabelled or unexpectedly related inputs.
The robust refit re-fits after dropping markers whose residuals are large outliers; dropping a large fraction is itself flagged, since it points at host copy-number change or a genotyping problem.
{% endcall %} {% endmacro %} {# Collapsed "run command" provenance block. Single-sourced so the HTML footer and the PDF appendix render it identically. #} {% macro run_command(params) %} {% if params.command %}{{ params.command }}| Check | Value | Reference |
|---|---|---|
| {{ label }} | {{ value }} | {{ ref }} |
{{ ctx.marker_accounting }}
{{ ctx.flag_summary }}
| Check | Value | Reference |
|---|---|---|
| Total markers (input) | {{ a.n_total_markers | count }} | |
| Shared across samples | {{ a.n_shared_markers | count }} | |
| Informative | {{ a.n_informative | count }} | |
| Used in fit | {{ a.n_used | count }} | |
| Informative per donor | {% for n in a.per_donor_n_informative %}donor {{ loop.index }}: {{ n }}{{ ", " if not loop.last else "" }}{% endfor %} | |
| Excluded: low depth | {{ a.n_excluded_depth | count }} | |
| Excluded: quality | {{ a.n_excluded_quality | count }} | |
| Excluded: outlier | {{ a.n_excluded_outlier | count }} | |
| Robust refit dropped | {{ (a.robust_drop_fraction or 0.0) | pct(0) }} | {{ refs.robust }} |
| Check | Value | Reference |
|---|---|---|
| Mean depth | {{ a.mean_depth | num(0) }}x | {{ refs.depth }} |
| Median depth | {{ a.median_depth | num(0) }}x | |
| Minimum depth | {{ a.min_depth | count }}x |
| Check | Value | Reference |
|---|---|---|
| Goodness-of-fit p | {{ a.gof_pval | pval }} | {{ refs.gof }} |
| Goodness-of-fit p (pre-trim) | {{ a.gof_pval_pretrim | pval }} |
| Check | Value | Reference |
|---|---|---|
| Contamination | not assessed | |
| Contamination fraction | {{ a.contamination.contamination_fraction | pct(3) }} | {{ refs.contamination }} |
| Contamination p | {{ a.contamination.p_value | pval }} | |
| Contamination markers | {{ a.contamination.n_markers | count }} |
| Check | Value | Reference |
|---|---|---|
| Sample-swap check | not assessed | |
| Swap discordant fraction | {{ a.admix_consistency.discordant_fraction | pct(2) }} | |
| Swap p | {{ a.admix_consistency.swap_pval | pval }} | {{ refs.swap }} |
| Consensus-homozygous markers | {{ a.admix_consistency.n_consensus_hom | count }} |
| Check | Value | Reference |
|---|---|---|
| Shared-het balance | not assessed | |
| Imbalanced fraction | {{ a.shared_het_balance.imbalanced_fraction | pct(1) }} | {{ refs.shared_het }} |
| Pooled VAF | {{ a.shared_het_balance.pooled_vaf | num(3) }} | |
| Shared-het markers | {{ a.shared_het_balance.n_shared_het | count }} |
| Check | Value | Reference |
|---|---|---|
| Run unit | {{ a.run_unit.run_unit if a.run_unit.run_unit else NA }} | |
| Run-unit source | {{ a.run_unit.source if a.run_unit.source else NA }} | |
| Shares run with host | {{ NA if shares is none else ("yes" if shares else "no") }} | index-hopping risk if yes |
| Pair | Coefficient | 95% CI | Relationship | Confidence | Markers |
|---|---|---|---|---|---|
| {{ r.a_name }} vs {{ r.b_name }} | {{ r.coefficient | num(3) }} | {{ ci(r.ci_low, r.ci_high, 3, as_pct=False) }} | {{ r.relationship }} | {{ r.confidence }} | {{ r.n_sites | count }} |
No QC warnings raised.
{% endif %}