Skip to content

EGenetics · genetics.tdt

Transmission disequilibrium test (TDT)

Do heterozygous parents pass one allele to affected children more often than chance?

A family-based association test. Each heterozygous parent of an affected child transmits one of two alleles; with no association each is passed on half the time. Counting transmissions (b) against non-transmissions (c) of the tested allele gives McNemar's χ² = (b − c)²/(b + c) or an exact binomial test. Comparing within families protects the test from population stratification. Reads complete trios (child, father, mother genotypes) or the two counts directly. Research use only.

Experimental Python and R agree to 10 decimals Also called TDT, transmission disequilibrium test, transmission/disequilibrium test…

A real result

Example “Guide chisq”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Transmission disequilibrium testRecorded · Python and R agreeRecorded 2026-11-17 · 29 values compared
R

TDT χ²(1, N = 48) = 3.00, p = .083, OR = 1.67

Transmissions of tested (b)
30
Transmissions of other (c)
18
χ²
3
p (TDT (McNemar χ²))
.083

Effect size

  • Transmission odds ratio b/c 1.667 95% CI [0.9291, 2.990]
  • Share of transmissions that carry tested 0.6250 95% CI [0.4735, 0.7605]

Assumptions

  • Mendelian transmission — Counts were given directly, so this isn't checkable.
  • Enough informative parents — b + c = 48 informative transmissions.
  • Independent transmissions — Use one affected child per family; extra siblings' transmissions aren't independent.
  • Reliable genotype calls — Calling errors create false transmissions; check Mendelian errors and call rates first.

Transmissions from heterozygous parents

AlleleTransmittedNot transmitted
tested3018
other1830

All the tests of these counts

TestStatisticp
McNemar χ²30.0833
McNemar χ², continuity-corrected2.5210.1124
Exact binomial, two-sided—0.1114
Exact binomial, mid-p—0.0854
Exact, tested over-transmitted—0.0557
Exact, tested under-transmitted—0.9703
  • Research use only: not for clinical or diagnostic decisions. Genotypes are personal data.
  • Only heterozygous parents are informative: homozygous parents transmit the same allele whichever copy they pass on.
  • Within-family comparison protects against population stratification, but not against genotyping error or biased ascertainment.
Python

TDT χ²(1, N = 48) = 3.00, p = .083, OR = 1.67

Transmissions of tested (b)
30
Transmissions of other (c)
18
χ²
3
p (TDT (McNemar χ²))
.083

Effect size

  • Transmission odds ratio b/c 1.667 95% CI [0.9291, 2.990]
  • Share of transmissions that carry tested 0.6250 95% CI [0.4735, 0.7605]

Assumptions

  • Mendelian transmission — Counts were given directly, so this isn't checkable.
  • Enough informative parents — b + c = 48 informative transmissions.
  • Independent transmissions — Use one affected child per family; extra siblings' transmissions aren't independent.
  • Reliable genotype calls — Calling errors create false transmissions; check Mendelian errors and call rates first.

Transmissions from heterozygous parents

AlleleTransmittedNot transmitted
tested3018
other1830

All the tests of these counts

TestStatisticp
McNemar χ²30.0833
McNemar χ², continuity-corrected2.5210.1124
Exact binomial, two-sided—0.1114
Exact binomial, mid-p—0.0854
Exact, tested over-transmitted—0.0557
Exact, tested under-transmitted—0.9703
  • Research use only: not for clinical or diagnostic decisions. Genotypes are personal data.
  • Only heterozygous parents are informative: homozygous parents transmit the same allele whichever copy they pass on.
  • Within-family comparison protects against population stratification, but not against genotyping error or biased ascertainment.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Worked examples in the app

  • Guide chisqge_tdt_counts · transmitted: transmitted · untransmitted: untransmitted
  • Guide exactge_tdt_counts · transmitted: transmitted · untransmitted: untransmitted
  • Guide continuityge_tdt_counts · transmitted: transmitted · untransmitted: untransmitted
  • Even exactge_tdt_counts · transmitted: even_t · untransmitted: even_u
  • Few exact greaterge_tdt_counts · transmitted: few_t · untransmitted: few_u
  • Trios callsge_trios · child: child · father: father · mother: mother
  • Trios doses exactge_trios · child: child_dose · father: father_dose · mother: mother_dose
  • Degenerate all nage_tdt_counts · transmitted: transmitted · untransmitted: untransmitted

In the guides

Tests from the statistics guide this method runs

Where it sits in the decision guides

  • Paired proportions: McNemar · Statistics Guide · E — Compare proportions / frequencies

What you need

Affected child (trios)categorical / numeric · 0–1 column
One row per trio: the affected child's genotype (A/G, AG, 0/1 or a dose).
Father (trios)categorical / numeric · 0–1 column
The father's genotype at the same marker, in the same format.
Mother (trios)categorical / numeric · 0–1 column
The mother's genotype at the same marker, in the same format.
Transmitted (counts)numeric · 0–1 column
Instead of trios: transmissions of the tested allele from heterozygous parents (b), summed over rows.
Not transmitted (counts)numeric · 0–1 column
Non-transmissions of the tested allele (c), summed over rows.

Choices you make

hypothesis

Testdefault chisq

The exact test is valid at any count; McNemar's χ² needs b + c of about 10 or more.

  • McNemar χ²(default) — (b − c)² / (b + c) on 1 df, the classic TDT (Spielman et al. 1993).
  • Exact binomial — b given b + c is Binomial(b + c, ½) under the null; no approximation.
Continuity correctiondefault off

(|b − c| − 1)² / (b + c): closer to the exact test for small counts, more conservative.

Alternative hypothesisdefault two_sided

Decide the direction before looking at the data.

  • Either allele over-transmitted(default) — Two-sided: outcomes no more likely than the observed one.
  • Tested allele over-transmitted — One-sided: b larger than half of b + c.
  • Tested allele under-transmitted — One-sided: b smaller than half of b + c.

statistics

Confidence leveldefault 0.95

For the transmission proportion (Clopper–Pearson) and the transmission odds ratio.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Mendelian transmission

    Each parent passes one allele at random; trios that break this are counted and left out.

  • Enough informative parents

    Only heterozygous parents count; the χ² needs b + c of about 10 or more.

    • If violated → Exact TDT — The exact binomial test doesn't rely on a large number of informative parents.
  • Independent transmissions

    One affected child per family; siblings' transmissions aren't independent as evidence of association.

  • Reliable genotype calls

    Calling errors in parents or children create false transmissions and Mendelian errors.

What it reports

  • Tests: Heterozygous parents transmit either allele half the time
b
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
c
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_informative
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
tdt
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
tdt_cc
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_chisq
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_chisq_cc
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_exact
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_midp
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_exact_greater
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
p_exact_less
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
transmission
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
transmission_low
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
transmission_high
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
odds_ratio
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
or_low
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
or_high
b/c, the odds that a heterozygous parent passes on the tested allele; 1 means no association.
p
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
statistic
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
test
McNemar's χ² = (b − c)²/(b + c) on 1 df, or the exact binomial test of b given b + c with probability one half.
input
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
allele_a
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
allele_b
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_trios
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_used
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_missing
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_mendel
A child's genotype that its parents' genotypes can't produce, such as AA from an AA and a GG parent.
n_uninformative
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.
n_het_parents
A heterozygous parent, whose child shows which of two alleles was passed on. Homozygous parents tell you nothing about association.

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses pandas, numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Python

The exact script CodeSplash ran for example “Guide chisq” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Transmission disequilibrium test (TDT)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method genetics.tdt 1.0.1 · spec ce85b7ea281ecbfc
# Dataset: ge_tdt_counts (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import math

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import genetics as gen  # TDT from trios or counts (Spielman et al. 1993; twins of cs_gen_tdt_*)

# %% Data (no rows dropped here: genotype no-calls and missing values are handled by the analysis)
df = pd.read_parquet("tests/parity/fixtures/ge_tdt_counts.parquet", columns=["transmitted", "untransmitted"])
n_input = len(df)
warnings = []
research_note = "Research use only: not for clinical or diagnostic decisions. Genotypes are personal data."

# %% Transmissions
trio_roles = [None, None, None]
count_roles = ["transmitted", "untransmitted"]
test = "chisq"
continuity = False
alternative = "two_sided"
conf = float(0.95)
if all(trio_roles):
    input_kind = "trios"
    t = gen.tdt_trios(df[trio_roles[0]].to_numpy(), df[trio_roles[1]].to_numpy(), df[trio_roles[2]].to_numpy())
    b, c = t["b"], t["c"]
    allele_a, allele_b = t["allele_a"], t["allele_b"]
    if t["n_missing"]:
        warnings.append(f"{t['n_missing']} trios had a no-call and were left out.")
    if t["n_mendel"]:
        warnings.append(f"{t['n_mendel']} trios break Mendelian inheritance (a calling or pedigree error) and were left out.")
elif all(count_roles) and not any(trio_roles):
    input_kind = "counts"
    tb = df[count_roles[0]].to_numpy(dtype=float)
    tc = df[count_roles[1]].to_numpy(dtype=float)
    ok = ~(np.isnan(tb) | np.isnan(tc))
    if (~ok).sum():
        warnings.append(f"{int((~ok).sum())} rows had a missing count and were left out.")
    if not ok.any():
        cs.cs_error("CS_E_NO_ROWS")
    cs.check_finite_columns(df[ok], count_roles)  # infinite values stop the run (registry/errors.yaml)
    b, c = float(tb[ok].sum()), float(tc[ok].sum())
    if b != math.floor(b) or c != math.floor(c) or b < 0 or c < 0:
        raise ValueError("Transmission counts must be whole numbers of at least 0.")
    t = {"n_trios": None, "n_used": None, "n_missing": None, "n_mendel": None, "n_uninformative": None, "n_het_parents": None}
    allele_a, allele_b = "other", "tested"
else:
    raise ValueError("Bind the child, father and mother genotypes (one row per trio), or the transmitted and not-transmitted counts.")

# %% Tests
r = gen.tdt_counts(b, c, conf)
m = r["n_informative"]
if test == "chisq":
    stat = r["tdt_cc"] if continuity else r["tdt"]
    p = r["p_chisq_cc"] if continuity else r["p_chisq"]
    label = "TDT (McNemar χ²" + (", continuity-corrected)" if continuity else ")")
else:
    stat = b
    p = {"two_sided": r["p_exact"], "greater": r["p_exact_greater"], "less": r["p_exact_less"]}[alternative]
    label = "exact TDT" + ("" if alternative == "two_sided" else ", one-sided")

# %% Assumptions
small = m < 10
assumptions = [
    {"key": "mendelian", "label": "Mendelian transmission", "status": ("warn" if t["n_mendel"] else "pass") if input_kind == "trios" else "info",
     "detail": (f"{t['n_mendel']} of {t['n_trios']} trios break Mendelian inheritance and were left out." if t["n_mendel"]
                else "Every complete trio is consistent with Mendelian inheritance.") if input_kind == "trios" else "Counts were given directly, so this isn't checkable."},
    {"key": "informative", "label": "Enough informative parents", "status": ("info" if test == "exact" else "warn") if small else "pass",
     "detail": f"b + c = {int(m)} informative transmissions" + ("; the exact test doesn't need many." if small and test == "exact" else "; use the exact test." if small else ".")},
    {"key": "independence", "label": "Independent transmissions", "status": "info", "detail": "Use one affected child per family; extra siblings' transmissions aren't independent."},
    {"key": "genotype_quality", "label": "Reliable genotype calls", "status": "info", "detail": "Calling errors create false transmissions; check Mendelian errors and call rates first."},
]

# %% Result
summary = (f"Heterozygous parents transmitted {allele_b} {b:g} times and {allele_a} {c:g} times "
           f"(proportion {r['transmission']:.3f}, {conf:.0%} CI {r['transmission_low']:.3f} to {r['transmission_high']:.3f}): {label}, {cs.fmt_p(p)}.")
apa = (f"TDT χ²(1, N = {int(m)}) = {cs.fmt_num(stat)}, {cs.fmt_p(p)}" if test == "chisq" else f"exact TDT, b = {b:g}, c = {c:g}, {cs.fmt_p(p)}") \
    + (f", OR = {cs.fmt_num(r['odds_ratio'])}" if math.isfinite(r["odds_ratio"]) else "")
tests = [
    {"test": "McNemar χ²", "statistic": r["tdt"], "p": r["p_chisq"]},
    {"test": "McNemar χ², continuity-corrected", "statistic": r["tdt_cc"], "p": r["p_chisq_cc"]},
    {"test": "Exact binomial, two-sided", "statistic": None, "p": r["p_exact"]},
    {"test": "Exact binomial, mid-p", "statistic": None, "p": r["p_midp"]},
    {"test": f"Exact, {allele_b} over-transmitted", "statistic": None, "p": r["p_exact_greater"]},
    {"test": f"Exact, {allele_b} under-transmitted", "statistic": None, "p": r["p_exact_less"]},
]
counts = [{"allele": allele_b, "transmitted": b, "not_transmitted": c}, {"allele": allele_a, "transmitted": c, "not_transmitted": b}]
notes = [research_note, "Only heterozygous parents are informative: homozygous parents transmit the same allele whichever copy they pass on.",
         "Within-family comparison protects against population stratification, but not against genotyping error or biased ascertainment."]
values = {
    **{k: r[k] for k in ("b", "c", "n_informative", "tdt", "tdt_cc", "p_chisq", "p_chisq_cc", "p_exact", "p_midp", "p_exact_greater",
                         "p_exact_less", "transmission", "transmission_low", "transmission_high", "odds_ratio", "or_low", "or_high")},
    "p": p, "statistic": stat, "test": test, "input": input_kind, "allele_a": allele_a, "allele_b": allele_b,
    **{k: t[k] for k in ("n_trios", "n_used", "n_missing", "n_mendel", "n_uninformative", "n_het_parents")},
}
cs.publish({
    "method": "genetics.tdt",
    "methodVersion": "1.0.1",
    "title": "Transmission disequilibrium test",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": int(m),
    "summary": summary,
    "apa": apa,
    "statistics": [
        {"key": "b", "label": f"Transmissions of {allele_b} (b)", "value": b},
        {"key": "c", "label": f"Transmissions of {allele_a} (c)", "value": c},
        {"key": "statistic", "label": "χ²" if test == "chisq" else "b", "value": stat},
        {"key": "p", "label": f"p ({label})", "value": p, "format": "p"},
    ],
    "tables": [
        {"key": "counts", "title": "Transmissions from heterozygous parents",
         "columns": [{"key": "allele", "label": "Allele", "type": "string"}, {"key": "transmitted", "label": "Transmitted", "type": "integer"},
                     {"key": "not_transmitted", "label": "Not transmitted", "type": "integer"}],
         "rows": counts},
        {"key": "tests", "title": "All the tests of these counts",
         "columns": [{"key": "test", "label": "Test", "type": "string"}, {"key": "statistic", "label": "Statistic", "type": "number"}, {"key": "p", "label": "p", "type": "p"}],
         "rows": tests},
    ],
    "effectSizes": [
        {"key": "odds_ratio", "label": "Transmission odds ratio b/c", "value": r["odds_ratio"], "ciLow": r["or_low"], "ciHigh": r["or_high"], "ciLevel": conf, "method": "Wald interval on log(b/c)"},
        {"key": "transmission", "label": f"Share of transmissions that carry {allele_b}", "value": r["transmission"], "ciLow": r["transmission_low"],
         "ciHigh": r["transmission_high"], "ciLevel": conf, "method": "Clopper–Pearson"},
    ],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": notes,
    "charts": [],
    "values": values,
})
R

The exact script CodeSplash ran for example “Guide chisq” · R version 4.5.1 (2025-06-13)

# Transmission disequilibrium test (TDT)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method genetics.tdt 1.0.1 · spec ce85b7ea281ecbfc
# Dataset: ge_tdt_counts (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_gen_tdt_trios, cs_gen_tdt_counts (Spielman et al. 1993; twins of codesplash.stats.genetics)

# %% Data (no rows dropped here: genotype no-calls and missing values are handled by the analysis)
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ge_tdt_counts.parquet", col_select = c("transmitted", "untransmitted")))
n_input <- nrow(df)
warnings <- list()
research_note <- "Research use only: not for clinical or diagnostic decisions. Genotypes are personal data."

# %% Transmissions
trio_roles <- c(NULL, NULL, NULL)
count_roles <- c("transmitted", "untransmitted")
test <- "chisq"
continuity <- FALSE
alternative <- "two_sided"
conf <- 0.95
if (length(trio_roles) == 3) {
  input_kind <- "trios"
  t <- cs_gen_tdt_trios(df[[trio_roles[1]]], df[[trio_roles[2]]], df[[trio_roles[3]]])
  b <- t$b
  c <- t$c
  allele_a <- t$allele_a
  allele_b <- t$allele_b
  if (t$n_missing > 0) warnings <- c(warnings, sprintf("%d trios had a no-call and were left out.", as.integer(t$n_missing)))
  if (t$n_mendel > 0) warnings <- c(warnings, sprintf("%d trios break Mendelian inheritance (a calling or pedigree error) and were left out.", as.integer(t$n_mendel)))
} else if (length(count_roles) == 2 && length(trio_roles) == 0) {
  input_kind <- "counts"
  tb <- as.numeric(df[[count_roles[1]]])
  tc <- as.numeric(df[[count_roles[2]]])
  ok <- !(is.na(tb) | is.na(tc))
  if (sum(!ok) > 0) warnings <- c(warnings, sprintf("%d rows had a missing count and were left out.", sum(!ok)))
  if (!any(ok)) cs_error("CS_E_NO_ROWS")
  cs_check_finite_columns(df[ok, , drop = FALSE], count_roles)  # infinite values stop the run (registry/errors.yaml)
  b <- sum(tb[ok])
  c <- sum(tc[ok])
  if (b != floor(b) || c != floor(c) || b < 0 || c < 0) stop("Transmission counts must be whole numbers of at least 0.", call. = FALSE)
  t <- list(n_trios = NA, n_used = NA, n_missing = NA, n_mendel = NA, n_uninformative = NA, n_het_parents = NA)
  allele_a <- "other"
  allele_b <- "tested"
} else {
  stop("Bind the child, father and mother genotypes (one row per trio), or the transmitted and not-transmitted counts.", call. = FALSE)
}

# %% Tests
r <- cs_gen_tdt_counts(b, c, conf)
m <- r$n_informative
if (test == "chisq") {
  stat <- if (continuity) r$tdt_cc else r$tdt
  p <- if (continuity) r$p_chisq_cc else r$p_chisq
  label <- paste0("TDT (McNemar χ²", if (continuity) ", continuity-corrected)" else ")")
} else {
  stat <- b
  p <- switch(alternative, two_sided = r$p_exact, greater = r$p_exact_greater, less = r$p_exact_less)
  label <- paste0("exact TDT", if (alternative == "two_sided") "" else ", one-sided")
}

# %% Assumptions
small <- m < 10
mendel_status <- if (input_kind == "trios") (if (t$n_mendel > 0) "warn" else "pass") else "info"
mendel_detail <- if (input_kind == "trios") {
  if (t$n_mendel > 0) sprintf("%d of %d trios break Mendelian inheritance and were left out.", as.integer(t$n_mendel), as.integer(t$n_trios)) else
    "Every complete trio is consistent with Mendelian inheritance."
} else "Counts were given directly, so this isn't checkable."
assumptions <- list(
  list(key = "mendelian", label = "Mendelian transmission", status = mendel_status, detail = mendel_detail),
  list(key = "informative", label = "Enough informative parents", status = if (small) (if (test == "exact") "info" else "warn") else "pass",
       detail = paste0(sprintf("b + c = %d informative transmissions", as.integer(m)),
                       if (small && test == "exact") "; the exact test doesn't need many." else if (small) "; use the exact test." else ".")),
  list(key = "independence", label = "Independent transmissions", status = "info", detail = "Use one affected child per family; extra siblings' transmissions aren't independent."),
  list(key = "genotype_quality", label = "Reliable genotype calls", status = "info", detail = "Calling errors create false transmissions; check Mendelian errors and call rates first.")
)

# %% Result
summary <- sprintf("Heterozygous parents transmitted %s %s times and %s %s times (proportion %.3f, %.0f%% CI %.3f to %.3f): %s, %s.",
                   allele_b, format(b), allele_a, format(c), r$transmission, 100 * conf, r$transmission_low, r$transmission_high, label, cs_fmt_p(p))
apa <- paste0(if (test == "chisq") sprintf("TDT χ²(1, N = %d) = %s, %s", as.integer(m), cs_fmt_num(stat), cs_fmt_p(p)) else
  sprintf("exact TDT, b = %s, c = %s, %s", format(b), format(c), cs_fmt_p(p)),
  if (is.finite(r$odds_ratio)) sprintf(", OR = %s", cs_fmt_num(r$odds_ratio)) else "")
tests <- list(
  list(test = "McNemar χ²", statistic = r$tdt, p = r$p_chisq),
  list(test = "McNemar χ², continuity-corrected", statistic = r$tdt_cc, p = r$p_chisq_cc),
  list(test = "Exact binomial, two-sided", statistic = NA, p = r$p_exact),
  list(test = "Exact binomial, mid-p", statistic = NA, p = r$p_midp),
  list(test = sprintf("Exact, %s over-transmitted", allele_b), statistic = NA, p = r$p_exact_greater),
  list(test = sprintf("Exact, %s under-transmitted", allele_b), statistic = NA, p = r$p_exact_less)
)
counts <- list(list(allele = allele_b, transmitted = b, not_transmitted = c), list(allele = allele_a, transmitted = c, not_transmitted = b))
notes <- list(research_note, "Only heterozygous parents are informative: homozygous parents transmit the same allele whichever copy they pass on.",
              "Within-family comparison protects against population stratification, but not against genotyping error or biased ascertainment.")
result_values <- c(
  r[c("b", "c", "n_informative", "tdt", "tdt_cc", "p_chisq", "p_chisq_cc", "p_exact", "p_midp", "p_exact_greater",
      "p_exact_less", "transmission", "transmission_low", "transmission_high", "odds_ratio", "or_low", "or_high")],
  list(p = p, statistic = stat, test = test, input = input_kind, allele_a = allele_a, allele_b = allele_b),
  t[c("n_trios", "n_used", "n_missing", "n_mendel", "n_uninformative", "n_het_parents")]
)
cs_publish(list(
  method = "genetics.tdt",
  methodVersion = "1.0.1",
  title = "Transmission disequilibrium test",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = m,
  summary = summary,
  apa = apa,
  statistics = list(
    list(key = "b", label = sprintf("Transmissions of %s (b)", allele_b), value = b),
    list(key = "c", label = sprintf("Transmissions of %s (c)", allele_a), value = c),
    list(key = "statistic", label = if (test == "chisq") "χ²" else "b", value = stat),
    list(key = "p", label = sprintf("p (%s)", label), value = p, format = "p")
  ),
  tables = list(
    list(key = "counts", title = "Transmissions from heterozygous parents",
         columns = list(list(key = "allele", label = "Allele", type = "string"), list(key = "transmitted", label = "Transmitted", type = "integer"),
                        list(key = "not_transmitted", label = "Not transmitted", type = "integer")),
         rows = counts),
    list(key = "tests", title = "All the tests of these counts",
         columns = list(list(key = "test", label = "Test", type = "string"), list(key = "statistic", label = "Statistic", type = "number"), list(key = "p", label = "p", type = "p")),
         rows = tests)
  ),
  effectSizes = list(
    list(key = "odds_ratio", label = "Transmission odds ratio b/c", value = r$odds_ratio, ciLow = r$or_low, ciHigh = r$or_high, ciLevel = conf, method = "Wald interval on log(b/c)"),
    list(key = "transmission", label = sprintf("Share of transmissions that carry %s", allele_b), value = r$transmission, ciLow = r$transmission_low,
         ciHigh = r$transmission_high, ciLevel = conf, method = "Clopper–Pearson")
  ),
  assumptions = assumptions,
  warnings = warnings,
  notes = notes,
  charts = list(),
  values = result_values
))

Sources

  • Spielman, R. S., McGinnis, R. E., & Ewens, W. J. (1993). Transmission test for linkage disequilibrium: the insulin gene region and insulin-dependent diabetes mellitus (IDDM). American Journal of Human Genetics, 52, 506–516.
  • Ewens, W. J., & Spielman, R. S. (1995). The transmission/disequilibrium test: history, subdivision, and admixture. American Journal of Human Genetics, 57, 455–464.
  • Clopper, C. J., & Pearson, E. S. (1934). The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika, 26, 404–413.

From the CodeSplash method registry · genetics.tdt v1.0.1.