Invntr
Source

All instruments

hardy_weinberg

Hardy-Weinberg analysis of genotype counts at one autosomal locus with two or more alleles: allele frequencies with standard errors, expected counts, Pearson chi-square, the Levene-Haldane exact test (full enumeration, or seeded Monte Carlo when too large), observed and expected heterozygosity and the inbreeding coefficient F. Also: allele and carrier frequency from the incidence of a recessive condition (with optional Wright's F), and the chi-square upper tail.

Field
Genomics
Version
0.1.0
Runs as
Compiled (Rust)
Typical run
0.05 s

Compiled from source: run sh packs/install.sh once before admitting it.

Known answers it must pass

Admission replayhardy_weinberg 0.1.0 · files b27d1296926e…32da
  1. r0001MN blood group textbook counts 298/489/213: p = 1085/2000 = 0.5425 exactly, expected M/N = 2Npq = 496.3875, chi-square = N F^2 = 0.221490 (textbook 0.222), df 1 (closed form, rel 1e-9)passed

    p0.5425 ± 5.4e-130.5425lockedunder 0.01 % of the tolerance used
    q0.4575 ± 4.6e-130.4575lockedunder 0.01 % of the tolerance used
    genotype_table.M/N.expected{"value": 496.3875, "rel_tol": 1e-12}
    chi_square0.22149 ± 2.2e-100.22149lockedunder 0.01 % of the tolerance used
    inbreeding_F0.0148825 ± 1.5e-110.0148825lockedunder 0.01 % of the tolerance used
    df11locked
  2. r0002counts exactly p^2 : 2pq : q^2 (36/48/16, p = 0.6): chi-square 0, F 0, chi-square p 1 (exact identity, abs 1e-12)passed

    p0.6 ± 6e-130.6lockedunder 0.01 % of the tolerance used
    chi_square0 ± 1e-120lockedunder 0.01 % of the tolerance used
    inbreeding_F0 ± 1e-120lockedunder 0.01 % of the tolerance used
    chi_square_p1 ± 1e-121lockedunder 0.01 % of the tolerance used
    hwe_ok= truetruelockedexact match
  3. r0003only heterozygotes 0/4/0: F = -1, chi-square = N F^2 = 4, its p = erfc(sqrt 2) = 0.0455003, Levene-Haldane exact p = (3 + 8)/35 and excess p = 8/35 by hand enumeration of 3 tables (rel 1e-9)passed

    inbreeding_F-1 ± 1e-12-1lockedunder 0.01 % of the tolerance used
    chi_square4 ± 4e-124lockedunder 0.01 % of the tolerance used
    chi_square_p0.0455003 ± 4.6e-110.0455003lockedunder 0.01 % of the tolerance used
    exact_p0.314286 ± 3.1e-100.314286lockedunder 0.01 % of the tolerance used
    exact_p_het_excess0.228571 ± 2.3e-100.228571lockedunder 0.01 % of the tolerance used
    exact_tables33locked
  4. r0004three alleles in exact proportions (p = .5/.3/.2, N = 100: 25/30/9/20/12/4): chi-square 0, F 0, df 3, p1 = 0.5 (exact identity)passed

    allele_freq.A1{"value": 0.5, "rel_tol": 1e-12}
    allele_freq.A3{"value": 0.2, "rel_tol": 1e-12}
    chi_square0 ± 1e-120lockedunder 0.01 % of the tolerance used
    inbreeding_F0 ± 1e-120lockedunder 0.01 % of the tolerance used
    df33locked
  5. r0005three alleles, N = 2 (A1/A2 + A3/A3): chi-square 4 and exact p = 1/3 by hand (two possible tables, probabilities 1/3 and 2/3), df 3 (rel 1e-9)passed

    chi_square4 ± 4e-124lockedunder 0.01 % of the tolerance used
    exact_p0.333333 ± 3.3e-100.333333lockedunder 0.01 % of the tolerance used
    exact_tables22locked
    df33locked
  6. r0006recessive incidence 1/2500: q = sqrt(0.0004) = 0.02, carriers 2pq = 0.0392 (textbook), 1 in 25.51 (closed form, rel 1e-12)passed

    q0.02 ± 2e-140.02lockedunder 0.01 % of the tolerance used
    carrier_frequency0.0392 ± 3.9e-140.0392lockedunder 0.01 % of the tolerance used
    carriers_one_in25.5102 ± 2.6e-1125.5102lockedunder 0.01 % of the tolerance used
  7. r0007first-cousin F = 1/16, incidence (1-F)q^2 + Fq = 13/8000 built from q = 0.02: q recovered = 0.02, carriers 2pq(1-F) = 0.03675 (closed form, rel 1e-12)passed

    q0.02 ± 2e-140.02lockedunder 0.01 % of the tolerance used
    carrier_frequency0.03675 ± 3.7e-140.03675lockedunder 0.01 % of the tolerance used
  8. r0008chi-square 1 df at its 0.95 quantile 3.841458820694124: p = erfc(sqrt(x/2)) = 0.05 (closed form, rel 1e-9)passed

    chi_square_p0.05 ± 5e-110.05lockedunder 0.01 % of the tolerance used
  9. r0009chi-square 2 df at 5.991464547107979: p = exp(-x/2) = 0.05 (closed form, rel 1e-9)passed

    chi_square_p0.05 ± 5e-110.05lockedunder 0.01 % of the tolerance used
  10. r0010chi-square 4 df at 10: p = exp(-5)(1 + 5) = 0.0404277 (closed form, rel 1e-9)passed

    chi_square_p0.0404277 ± 4e-110.0404277lockedunder 0.01 % of the tolerance used
10 of 10 cases passed · sandbox macos-seatbeltrecorded from the kernel in a fresh lab

Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.

Inputs

NameUnitDefaultMeaning
modegenotypesgenotypes: test counts for Hardy-Weinberg proportions; carrier: allele and carrier frequency from the incidence of a recessive condition; chi_square_p: upper tail of the chi-square distribution.
counts1Genotype counts in the order A1A1, A1A2, A2A2, A1A3, A2A3, A3A3, ...: k(k+1)/2 numbers for k alleles (2 to 12). Two alleles: [AA, AB, BB]. Give this or 'genotypes'.
genotypesGenotype counts by name, e.g. {"M/M": 298, "M/N": 489, "N/N": 213}. Give this or 'counts'.
allelesAllele names (optional): fixes their order and lets absent alleles be listed.
alpha10.05Significance level for the verdict.
exact_methodautoauto: enumerate every table if it fits the budget, else Monte Carlo; none: chi-square only.
mc_draws120000Random matings of the allele pool for the Monte Carlo exact test.
seed11
incidence1carrier mode: fraction of people affected by the recessive condition (1 in 2500 is 0.0004).
incidence_one_in1carrier mode: the same as 1 / incidence, e.g. 2500.
inbreeding_F10carrier mode: Wright's inbreeding coefficient of the population (0 random mating, 1/16 first-cousin children).
chi_square1chi_square_p mode: the statistic.
df11chi_square_p mode: degrees of freedom.

Readings

NameUnitMeaning
modegenotypes, carrier or chi_square_p
n_individuals1
n_alleles1
allele_freq
p1Frequency of the first allele (two alleles only).
q1Frequency of the second allele (two alleles), or of the recessive allele (carrier mode).
chi_square1
df1
chi_square_p1
exact_p1Levene-Haldane exact test: sum of the probabilities of every genotype table no more probable than the observed one.
exact_p_het_deficit1
exact_p_het_excess1
exact_p_se1
exact_tables1
exact_prob_sum1
exact_mean_het_count1
observed_het1
expected_het1
expected_het_unbiased1
inbreeding_F11 - H_obs / H_exp (genotypes mode); the input F (carrier mode).
min_expected_count1
hwe_p1The p-value the verdict uses: exact when available, else chi-square.
hwe_oktrue when hwe_p is at or above alpha (genotypes mode)
genotype_table
allele_table
incidence1
carrier_frequency12pq(1-F): heterozygote carriers in the whole population.
carriers_one_in1
carrier_frequency_among_unaffected1
carriers_per_affected1

Try the call

Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.

Terminal
MCP call