#!/usr/bin/env python3 """Values READ OFF the bars of Figures 1B, 2A-E, 3A-D and 5A-C of Mannino et al. (2026), by pixels. The paper gives most of these only in its supplement (Tables S2-S4, Data Set S1), which we had not got when this was written; its tables replaced these readings where they overlap. Every value here is a reading of the PDF's embedded raster image, good to about +/- 2 pixels; the "resolution" field gives what 1 pixel is worth in the axis's units. Geometry below comes from scanning pixel rows and columns for tick marks and bar edges. Outlined bars are read at the middle of the outline; a bar's error is the distance to the far edge of its error bar, less half the cap's thickness. Run with `python3 -I`. Usage: python3 -I figure_values.py """ import json import sys from pathlib import Path from PIL import Image folder = Path(sys.argv[1]) WHITE = 235 def read_bar(px, x0, x1, y_base, direction, y_limit, half_outline=1.5, half_cap=1.0): """direction -1: bar grows toward smaller y; +1: toward larger y. Returns (y_end, y_cap).""" xc = (x0 + x1) // 2 sample = [x0 + 6, x0 + 10, x1 - 10, x1 - 6] ends = [] for x in sample: y = y_base + direction * 4 while (y_limit - y) * direction > 0 and px[x, y] < WHITE: y += direction ends.append(y - direction) end_outer = sorted(ends)[len(ends) // 2] y = end_outer + direction # walk along the central column through the error bar last = end_outer gap = 0 while (y_limit - y) * direction > 0 and gap <= 1: if any(px[xc + k, y] < 170 for k in range(-4, 5)): last = y gap = 0 else: gap += 1 y += direction y_end = end_outer - direction * half_outline y_cap = last - direction * half_cap if last != end_outer else y_end return y_end, y_cap def to_value(y, y0, v0, y1, v1): return v0 + (y - y0) * (v1 - v0) / (y1 - y0) def panel(px, ticks, bars, direction=-1, limit=None, half_outline=1.5): (y_a, v_a), (y_b, v_b) = ticks res = {"resolution_per_px": round(abs((v_b - v_a) / (y_b - y_a)), 5), "bars": {}} y_zero = to_value(0.0, v_a, y_a, v_b, y_b) for label, x0, x1, *rest in bars: d = rest[0] if rest else direction y_lim = limit if limit is not None else (0 if d < 0 else 10 ** 6) ye, yc = read_bar(px, x0, x1, int(round(y_zero)), d, y_lim, half_outline=half_outline) v, c = to_value(ye, y_a, v_a, y_b, v_b), to_value(yc, y_a, v_a, y_b, v_b) res["bars"][label] = {"value": round(v, 3), "spread": round(abs(c - v), 3)} return res def px_of(name): im = Image.open(folder / name).convert("L") return im.load() out = {"note": "Read off the figures of Mannino et al. (2026), not from a table; good to about +/- 2 pixels. Spread is the error bar as drawn, which the captions call SD."} p1 = px_of("img000_1900x1412.png") out["Fig1B_log2FC"] = panel(p1, ((905.5, 0.0), (1294.5, -3.0)), [ ("IspD", 228, 361), ("IspE", 415, 548), ("IspF", 601, 734), ("IspG", 788, 921), ("IspH", 975, 1108), ("GDPS", 1161, 1295), ("LS", 1348, 1481), ("CYP71D18", 1535, 1668), ("CDH", 1722, 1855)], direction=1, limit=1400, half_outline=0.0) p2 = px_of("img001_1900x1754.png") t_chl = ((654.0, 0.0), (252.0, 6.0)) out["Fig2A_Chl_a_mg_g"] = panel(p2, t_chl, [("GMF", 207, 275), ("NNMF", 280, 348)], limit=230) out["Fig2B_Chl_b_mg_g"] = panel(p2, t_chl, [("GMF", 550, 618), ("NNMF", 623, 691)], limit=230) out["Fig2C_total_Chl_mg_g"] = panel(p2, ((654.0, 0.0), (252.0, 10.0)), [("GMF", 906, 975), ("NNMF", 980, 1049)], limit=230) out["Fig2D_total_Car_mg_g"] = panel(p2, ((653.0, 0.0), (350.0, 0.3)), [("GMF", 1261, 1329), ("NNMF", 1334, 1402)], limit=230) out["Fig2E_ratio_as_labelled_TCarC_TChlC"] = panel(p2, ((651.0, 0.0), (349.0, 30.0)), [("GMF", 1597, 1668), ("NNMF", 1673, 1744)], limit=230) p3 = px_of("img002_1800x2334.png") t3 = ((755.0, 0.0), (287.0, 200.0)) out["Fig3A_TPC_mg_GAE_g"] = panel(p3, t3, [("root_GMF", 142, 202), ("root_NNMF", 206, 266), ("shoot_GMF", 293, 352), ("shoot_NNMF", 356, 416)], limit=280) out["Fig3B_TFC_mg_RE_g"] = panel(p3, t3, [("root_GMF", 582, 642), ("root_NNMF", 646, 706), ("shoot_GMF", 733, 792), ("shoot_NNMF", 796, 856)], limit=280) out["Fig3C_TFC_TPC_ratio"] = panel(p3, ((755.0, 0.0), (287.0, 5.0)), [("root_GMF", 1015, 1076), ("root_NNMF", 1080, 1141), ("shoot_GMF", 1169, 1230), ("shoot_NNMF", 1234, 1295)], limit=280) out["Fig3D_CHI_log2FC"] = panel(p3, ((368.0, 0.0), (744.0, -0.6)), [("root", 1463, 1534, -1), ("shoot", 1617, 1722, 1)], limit=None, half_outline=1.5) p5 = px_of("img004_1000x1393.png") out["Fig5A_protein_mg_g"] = panel(p5, ((708.0, 0.0), (211.0, 40.0)), [("root_GMF", 137, 207), ("root_NNMF", 212, 283), ("shoot_GMF", 314, 385), ("shoot_NNMF", 389, 459)], limit=190) out["Fig5B_H2O2"] = panel(p5, ((708.0, 0.0), (211.0, 24.0)), [("root_GMF", 657, 727), ("root_NNMF", 732, 802), ("shoot_GMF", 834, 905), ("shoot_NNMF", 909, 979)], limit=190) out["Fig5C_log2FC"] = panel(p5, ((1206.5, 0.0), (947.5, 1.2)), [ ("rbohD_shoot", 264, 345, 1), ("sod_root", 384, 467, 1), ("sod_shoot", 473, 555, -1), ("cat_root", 594, 677, 1), ("cat_shoot", 684, 765, 1), ("apx_root", 805, 887, 1), ("apx_shoot", 894, 976, 1)], limit=None, half_outline=1.5) def pct(new, old): return round(100.0 * (new - old) / old, 1) d = out summary = { "Chl a change %": pct(d["Fig2A_Chl_a_mg_g"]["bars"]["NNMF"]["value"], d["Fig2A_Chl_a_mg_g"]["bars"]["GMF"]["value"]), "Chl b change %": pct(d["Fig2B_Chl_b_mg_g"]["bars"]["NNMF"]["value"], d["Fig2B_Chl_b_mg_g"]["bars"]["GMF"]["value"]), "total Chl change %": pct(d["Fig2C_total_Chl_mg_g"]["bars"]["NNMF"]["value"], d["Fig2C_total_Chl_mg_g"]["bars"]["GMF"]["value"]), "Car change %": pct(d["Fig2D_total_Car_mg_g"]["bars"]["NNMF"]["value"], d["Fig2D_total_Car_mg_g"]["bars"]["GMF"]["value"]), "Chl a/b GMF": round(d["Fig2A_Chl_a_mg_g"]["bars"]["GMF"]["value"] / d["Fig2B_Chl_b_mg_g"]["bars"]["GMF"]["value"], 2), "Chl a/b NNMF": round(d["Fig2A_Chl_a_mg_g"]["bars"]["NNMF"]["value"] / d["Fig2B_Chl_b_mg_g"]["bars"]["NNMF"]["value"], 2), "total Chl / Car GMF": round(d["Fig2C_total_Chl_mg_g"]["bars"]["GMF"]["value"] / d["Fig2D_total_Car_mg_g"]["bars"]["GMF"]["value"], 1), "total Chl / Car NNMF": round(d["Fig2C_total_Chl_mg_g"]["bars"]["NNMF"]["value"] / d["Fig2D_total_Car_mg_g"]["bars"]["NNMF"]["value"], 1), "TPC root %": pct(d["Fig3A_TPC_mg_GAE_g"]["bars"]["root_NNMF"]["value"], d["Fig3A_TPC_mg_GAE_g"]["bars"]["root_GMF"]["value"]), "TPC shoot %": pct(d["Fig3A_TPC_mg_GAE_g"]["bars"]["shoot_NNMF"]["value"], d["Fig3A_TPC_mg_GAE_g"]["bars"]["shoot_GMF"]["value"]), "TFC root %": pct(d["Fig3B_TFC_mg_RE_g"]["bars"]["root_NNMF"]["value"], d["Fig3B_TFC_mg_RE_g"]["bars"]["root_GMF"]["value"]), "TFC shoot %": pct(d["Fig3B_TFC_mg_RE_g"]["bars"]["shoot_NNMF"]["value"], d["Fig3B_TFC_mg_RE_g"]["bars"]["shoot_GMF"]["value"]), "protein root %": pct(d["Fig5A_protein_mg_g"]["bars"]["root_NNMF"]["value"], d["Fig5A_protein_mg_g"]["bars"]["root_GMF"]["value"]), "protein shoot %": pct(d["Fig5A_protein_mg_g"]["bars"]["shoot_NNMF"]["value"], d["Fig5A_protein_mg_g"]["bars"]["shoot_GMF"]["value"]), "H2O2 root %": pct(d["Fig5B_H2O2"]["bars"]["root_NNMF"]["value"], d["Fig5B_H2O2"]["bars"]["root_GMF"]["value"]), "H2O2 shoot %": pct(d["Fig5B_H2O2"]["bars"]["shoot_NNMF"]["value"], d["Fig5B_H2O2"]["bars"]["shoot_GMF"]["value"]), } for name in ("Fig1B_log2FC", "Fig3D_CHI_log2FC", "Fig5C_log2FC"): for k, v in d[name]["bars"].items(): summary[f"{name} {k} as fold change"] = round(2 ** v["value"], 2) out["summary"] = summary Path(sys.argv[2]).parent.mkdir(parents=True, exist_ok=True) with open(sys.argv[2], "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1) sys.stdout.reconfigure(encoding="utf-8") for k, v in out.items(): if k not in ("note", "summary"): print(k, "res", v["resolution_per_px"], {b: (x["value"], x["spread"]) for b, x in v["bars"].items()}) print(json.dumps(summary, indent=0))