#!/usr/bin/env python3 """Check the mint paper's printed statistics against its own printed means and spreads. RULES, fixed before the first run (2026-11-04): 1. Table 1 (n = 3 per group, its heading says so): for each row, Student's two-sample t on the printed means and SDs (with two groups, the paper's one-way ANOVA is the same test) and Welch's t. Compare with the printed P. A row "reproduces" if printed and recomputed P agree to within a factor of 1.5 or to within 0.03, allowing for the rounding of printed means and SDs. 2. Multiplicity: Benjamini-Hochberg at q = 0.05 and Holm at 0.05 on the printed P values, over (a) all 24 rows, (b) the 22 single compounds. Rows are not independent (one pathway; the totals contain the compounds), so this is a rough screen; BH remains valid under positive dependence. 3. The fluorescence comparisons in the Results give means, SDs and P values but no n, and a pooled sample cannot be measured on an intact leaf. For each, find the n per group (2-12) whose Student or Welch P is closest to the printed P, to show what the numbers imply. This is an inference. Superseded after the supplement arrived: the raw-count means in Tables S2 and S3 come in quarters and in sevenths or sixths, which fits 4 control readings against 7 and 6 coil readings (recheck_tables.py). This rule assumes equal groups, so its "5-6 per group" is kept below only as a record. 4. Changes in percent, from the printed means. 5. A tally of the comparisons the paper shows, counted by eye from its table and figures; the JIP-test table (S2) and Data Set S1 are in the supplement, which we have not got, so this is a floor. Updated after the supplement arrived; see the note above TALLY. Still our count. 6. Added after a fresh review of the page (RULES_review_addendum.txt, R2, R3), not before the first run. Fig. 3K has 8 asterisks, not 7, so the tally is one higher. Report the tally without Fig. 3H-K as well. And a post hoc reading of Table 1: Holm on total oil and carvone alone, the two outcomes the abstract names. Pure Python; run with `python3 -I`. Usage: python3 -I recheck_stats.py """ import json import math import sys from pathlib import Path TABLE1 = [ ("alpha-Pinene", 2.42, 0.04, 2.31, 0.34, 0.564), ("alpha-Thujene", 0.99, 0.25, 1.22, 0.09, 0.317), ("Sabinene", 2.90, 0.07, 2.68, 0.43, 0.435), ("beta-Pinene", 3.87, 0.08, 3.39, 0.52, 0.189), ("beta-Myrcene", 3.76, 0.30, 3.24, 0.12, 0.051), ("alpha-Phellandrene", 6.43, 0.51, 5.28, 3.79, 0.713), ("p-Cymene", 3.38, 0.08, 3.05, 0.39, 0.230), ("Limonene", 35.65, 1.99, 24.32, 3.65, 0.009), ("1,8-Cineole", 72.15, 4.10, 60.39, 3.80, 0.022), ("gamma-Terpinene", 3.53, 0.04, 3.59, 1.65, 0.953), ("Trans-sabinene hydrate", 32.08, 2.61, 27.43, 0.70, 0.041), ("Terpinolene", 0.98, 0.03, 0.97, 0.01, 0.760), ("Dihydrocarveol", 4.36, 0.21, 4.12, 0.59, 0.531), ("Myrtenol", 1.35, 0.09, 1.25, 0.06, 0.159), ("Trans-carveol", 2.11, 0.22, 1.29, 0.11, 0.010), ("Cis-carveol", 19.89, 1.36, 32.24, 3.29, 0.009), ("Carvone", 447.19, 35.31, 353.36, 4.14, 0.010), ("Eugenol", 1.17, 0.12, 1.02, 0.18, 0.287), ("Cis-jasmone", 2.44, 0.15, 2.20, 0.07, 0.063), ("beta-Caryophyllene", 7.15, 0.51, 6.94, 1.10, 0.780), ("Germacrene-D", 24.09, 1.20, 22.16, 3.40, 0.407), ("Cubenol", 1.40, 0.16, 1.22, 0.15, 0.236), ("Total identified", 684.66, 46.83, 569.56, 23.95, 0.015), ("Total all GC-FID", 1002.22, 97.26, 811.72, 25.38, 0.030), ] # name, control mean, control SD, NNMF mean, NNMF SD, printed P (Results, pp. 5) FLUORESCENCE = [ ("Ss", 0.54, 0.02, 0.51, 0.02, 0.027), ("ETo/RC", 1.06, 0.06, 1.13, 0.04, 0.042), ("QP Lss", 0.49, 0.07, 0.39, 0.04, 0.024), ("NPQ D2", 0.37, 0.06, 0.49, 0.08, 0.028), ("NPQ D3", 0.21, 0.03, 0.31, 0.06, 0.017), ("QY D2", 0.74, 0.01, 0.71, 0.02, 0.025), ("QY D3", 0.77, 0.01, 0.74, 0.02, 0.025), ("NPQ E", 1.09, 0.15, 0.84, 0.13, 0.012), ] # panel: (comparisons shown, comparisons flagged significant). Tables are counted from their printed P values or asterisks; figure panels by eye. # Updated 2026-11-04 after the supplement arrived: Table S2, Table S3 and Table S4 replace the radar panels of Figs. 2G-J and 4C-D and the # two values quoted on p. 5. The first count, before the supplement, was 96 of 149. Per-compound tests on Data Set S1 are not in the tally: # the paper reports none. TALLY = { "Table 1 (essential-oil rows)": (24, 8), "Fig. 1B (MEP and monoterpene genes)": (9, 9), "Fig. 2A-E (pigments)": (5, 3), "Table S2 (OJIP parameters)": (26, 2), "Table S3 (PAM parameters)": (39, 26), "Fig. 3A-D (TPC, TFC, ratio, CHI; root and shoot)": (8, 6), "Fig. 3H (root sugar groups)": (9, 4), "Fig. 3I (root aglycones)": (10, 5), "Fig. 3J (shoot sugar groups)": (9, 6), "Fig. 3K (shoot aglycones)": (10, 8), "Table S4 (hormones, root and shoot)": (18, 12), "Fig. 5A-B (protein, H2O2; root and shoot)": (4, 3), "Fig. 5C (ROS genes; rbohD root not detected)": (7, 7), } def betacf(a, b, x): m_max, eps, fpmin = 400, 3e-14, 1e-300 qab, qap, qam = a + b, a + 1.0, a - 1.0 c, d = 1.0, 1.0 - qab * x / qap d = fpmin if abs(d) < fpmin else d d = 1.0 / d h = d for m in range(1, m_max + 1): m2 = 2 * m aa = m * (b - m) * x / ((qam + m2) * (a + m2)) d = 1.0 + aa * d d = fpmin if abs(d) < fpmin else d c = 1.0 + aa / c c = fpmin if abs(c) < fpmin else c d = 1.0 / d h *= d * c aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2)) d = 1.0 + aa * d d = fpmin if abs(d) < fpmin else d c = 1.0 + aa / c c = fpmin if abs(c) < fpmin else c d = 1.0 / d de = d * c h *= de if abs(de - 1.0) < eps: break return h def betai(a, b, x): if x <= 0.0: return 0.0 if x >= 1.0: return 1.0 bt = math.exp(math.lgamma(a + b) - math.lgamma(a) - math.lgamma(b) + a * math.log(x) + b * math.log(1.0 - x)) if x < (a + 1.0) / (a + b + 2.0): return bt * betacf(a, b, x) / a return 1.0 - bt * betacf(b, a, 1.0 - x) / b def t_p(t, df): return betai(df / 2.0, 0.5, df / (df + t * t)) def student(m1, s1, m2, s2, n): se = math.sqrt((s1 * s1 + s2 * s2) / n) t = abs(m1 - m2) / se return t, t_p(t, 2 * n - 2) def welch(m1, s1, m2, s2, n): v1, v2 = s1 * s1 / n, s2 * s2 / n t = abs(m1 - m2) / math.sqrt(v1 + v2) df = (v1 + v2) ** 2 / (v1 * v1 / (n - 1) + v2 * v2 / (n - 1)) return t, df, t_p(t, df) def bh(ps, q=0.05): order = sorted(range(len(ps)), key=lambda i: ps[i]) m = len(ps) k_max = 0 for rank, i in enumerate(order, 1): if ps[i] <= q * rank / m: k_max = rank return [order[j] for j in range(k_max)], [(rank, ps[i], q * rank / m) for rank, i in enumerate(order, 1)][:9] def holm(ps, alpha=0.05): order = sorted(range(len(ps)), key=lambda i: ps[i]) keep = [] for rank, i in enumerate(order): if ps[i] <= alpha / (len(ps) - rank): keep.append(i) else: break return keep sys.stdout.reconfigure(encoding="utf-8") res = {"rules": "see the script's docstring"} rows = [] for name, m1, s1, m2, s2, p in TABLE1: t, ps = student(m1, s1, m2, s2, 3) _, df, pw = welch(m1, s1, m2, s2, 3) ok = (max(p, ps) / max(min(p, ps), 1e-12) <= 1.5) or abs(p - ps) <= 0.03 rows.append({"row": name, "GMF": m1, "NNMF": m2, "change_pct": round(100 * (m2 - m1) / m1, 1), "t": round(t, 2), "P_printed": p, "P_student_n3": round(ps, 4), "P_welch_n3": round(pw, 4), "reproduces": ok}) res["table1"] = rows print("Table 1: printed P vs Student (n=3) vs Welch") for r in rows: flag = "" if r["reproduces"] else " <-- differs" print(f" {r['row']:<24} {r['GMF']:>8} {r['NNMF']:>8} {r['change_pct']:>7}% printed {r['P_printed']:<6} student {r['P_student_n3']:<7} welch {r['P_welch_n3']:<7}{flag}") print(" rows reproducing:", sum(r["reproduces"] for r in rows), "of", len(rows)) print(" rows with printed P < 0.05:", sum(r["P_printed"] < 0.05 for r in rows)) for label, subset in (("all 24 rows", rows), ("22 single compounds", rows[:22])): ps = [r["P_printed"] for r in subset] keep, ladder = bh(ps) h = holm(ps) res["multiplicity_" + label.replace(" ", "_")] = {"BH_survivors": [subset[i]["row"] for i in keep], "Holm_survivors": [subset[i]["row"] for i in h], "BH_ladder_rank_p_threshold": [[a, b, round(c, 5)] for a, b, c in ladder]} print(f" {label}: BH q=0.05 survivors {[subset[i]['row'] for i in keep]}; Holm survivors {[subset[i]['row'] for i in h]}; smallest P {min(ps)} against first threshold {0.05 / len(ps):.5f}") print("\nFluorescence: what n per group do the printed means, SDs and P imply?") res["fluorescence_implied_n"] = [] for name, m1, s1, m2, s2, p in FLUORESCENCE: best_s = min(range(2, 13), key=lambda n: abs(math.log(student(m1, s1, m2, s2, n)[1] / p))) best_w = min(range(2, 13), key=lambda n: abs(math.log(welch(m1, s1, m2, s2, n)[2] / p))) p3 = student(m1, s1, m2, s2, 3)[1] res["fluorescence_implied_n"].append({"name": name, "P_printed": p, "best_n_student": best_s, "P_at_best_student": round(student(m1, s1, m2, s2, best_s)[1], 4), "best_n_welch": best_w, "P_at_best_welch": round(welch(m1, s1, m2, s2, best_w)[2], 4), "P_if_n3_student": round(p3, 3)}) print(f" {name:<8} printed {p:<6} n(student)={best_s} P={student(m1, s1, m2, s2, best_s)[1]:.4f}; n(welch)={best_w} P={welch(m1, s1, m2, s2, best_w)[2]:.4f}; if n=3, P={p3:.3f}") shown = sum(v[0] for v in TALLY.values()) flagged = sum(v[1] for v in TALLY.values()) res["tally"] = {"panels": TALLY, "comparisons_shown": shown, "flagged_significant": flagged, "expected_false_positives_at_0.05_if_no_real_differences": round(0.05 * shown, 1)} hk = [k for k in TALLY if k.startswith(("Fig. 3H", "Fig. 3I", "Fig. 3J", "Fig. 3K"))] hk_shown, hk_flagged = sum(TALLY[k][0] for k in hk), sum(TALLY[k][1] for k in hk) res["tally_without_Fig_3H_K"] = {"Fig_3H_K_comparisons": hk_shown, "Fig_3H_K_flagged": hk_flagged, "comparisons_shown": shown - hk_shown, "flagged_significant": flagged - hk_flagged, "expected_false_positives_at_0.05_if_no_real_differences": round(0.05 * (shown - hk_shown), 1)} named = [r for r in res["table1"] if r["row"] in ("Carvone", "Total all GC-FID")] def holm_adjusted(ps): a, b = sorted(ps) return [round(min(1.0, 2 * a), 3), round(max(min(1.0, 2 * a), b), 3)] res["two_named_outcomes_post_hoc"] = {"rows": [r["row"] for r in named], "Holm_adjusted_student_printed_P": holm_adjusted([r["P_printed"] for r in named]), "Holm_adjusted_welch": holm_adjusted([r["P_welch_n3"] for r in named]), "note": "Post hoc: the two outcomes the abstract names. It does not replace the correction over 24 rows."} print(f"\nTally by eye: {shown} comparisons shown, {flagged} flagged significant, {0.05 * shown:.1f} expected by chance at 0.05 if nothing differed.") with open(sys.argv[1], "w", encoding="utf-8", newline="\n") as fh: json.dump(res, fh, indent=1)