RULES_rederive.txt -- pre-registered 2026-11-20, before any data file of the Dryad deposit was available Page: planthopper-magnetic-genes (Xie et al. 2026; Dryad doi:10.5061/dryad.r4xgxd2vx, version 7, CC0) Written by agent P before the data were downloaded (Dryad's API refused the zip, HTTP 401). Inputs and integrity checks: section 1 of RULES_deg_recount.txt. Any later change is added at the end as a dated amendment with its reason; both results are reported. PURPOSE Re-derive differential expression independently from the authors' raw count matrix with simpler methods we write ourselves, and say how close the DEG counts come to the authors' DESeq2 counts (244 for GMF50 vs GMF45; 2753 and 3258 for the two NZMF comparisons, per the abstract). It will not match DESeq2 exactly; the question is the order of magnitude. INPUT "Raw_data_for_RNAseq_count_matrix.csv": Gene_Symbol plus sample columns GMF45_1-3, GMF50_1-3, NZMF_1-3. If a value is not a non-negative integer, report how many and round to the nearest integer. Duplicate Gene_Symbol rows: report; keep all rows (each row is a gene record). SAMPLES AND FILTER (as the authors' README states them) - Primary: eight samples, GMF45_1-3, GMF50_1-3, NZMF_1-2 (NZMF_3 excluded, as the authors did for quality control). Genes kept if their total count over the eight samples is >= 6. - Sensitivity (reported separately, labelled as such): NZMF_3 kept (nine samples, filter >= 6 over nine). The authors excluded it on quality grounds; this only shows how much the NZMF counts depend on n = 2. METHOD A (primary): negative-binomial Wald test with a shared dispersion trend A1 Size factors: median-of-ratios over genes with all retained counts > 0: s_j = exp(median_i(ln K_ij - mean_j ln K_ij)). A2 Normalized counts q_ij = K_ij / s_j; baseMean_i = mean over the retained samples of q_ij. A3 Gene-wise dispersion by moments, pooled within groups: m_ig = group mean of q; v_i = sum over groups and samples of (q_ij - m_ig)^2 / (N - G); alpha_hat_i = [v_i - mean_j(m_i,g(j) / s_j)] / mean_j(m_i,g(j)^2). A4 Trend alpha_tr(mu) = a0 + a1/mu (DESeq2's parametric form), fitted to genes with alpha_hat > 1e-8 by a gamma GLM with identity link (IRLS, weights 1/fitted^2), dropping genes with alpha_hat/alpha_tr outside (1e-4, 15) and refitting until the summed absolute change in log coefficients is < 1e-6 (at most 10 rounds). Fallback if a0 <= 0 or a1 <= 0: median alpha_hat in 20 equal-count bins of baseMean, linearly interpolated in log baseMean and held constant beyond the end bins. A5 Dispersion used: primary alpha_i = alpha_tr(baseMean_i). Conservative variant (reported separately): alpha_i = max(alpha_hat_i, alpha_tr(baseMean_i)). A6 For each comparison (numerator vs reference, as the authors' sheets: GMF50 vs GMF45, NZMF vs GMF45, NZMF vs GMF50), group means by negative-binomial maximum likelihood with the size factors as offsets (Fisher scoring on log mu from the Poisson estimate sum K / sum s; tolerance 1e-10; at most 50 steps). A group with zero total count gets mu = 0.5 / sum s (half-count rule). If both groups are all zero the gene gets log2FC = 0 and p = 1. A7 log2FC = (ln mu_num - ln mu_ref) / ln 2; SE = sqrt(1/I_num + 1/I_ref) / ln 2 with I_g = sum_{j in g} s_j mu_g / (1 + alpha s_j mu_g); z = log2FC / SE; p = 2 * Phi(-|z|). A8 Benjamini-Hochberg over all genes passing the filter (no independent filtering). Variant (reported separately): DESeq2-like independent filtering -- for theta in 0, 0.05, ..., 0.95 drop genes with baseMean below the theta quantile, apply BH to the rest, count rejections at 0.05 (no fold-change threshold); use the theta with the most rejections (smallest theta on ties). A9 DEG: BH-adjusted p < 0.05 and |log2FC| > 0.25 (the authors' thresholds). Scopes: primary "one model": filter, size factors and dispersions from all eight retained samples, as a single DESeq2 model would pool them; secondary "per comparison": filter (>= 6 over the comparison's samples), size factors and dispersions from the two groups' samples only (pooled within the two groups, N - 2 df). METHOD B (secondary): moderated t-test on log normalized counts (limma-style empirical Bayes, global prior) B1 y_ij = log2(K_ij + 0.5) - log2(s_j), same genes and size factors as method A (per scope). B2 Per comparison: d_i = mean_num(y) - mean_ref(y) (the log2 fold change); pooled variance s2_i with d = n_num + n_ref - 2 df. B3 Prior (Smyth 2004, method of moments on log s2, genes with s2 > 0): e_i = ln s2_i - digamma(d/2) + ln(d/2); if mean((e - mean e)^2) * G/(G-1) - trigamma(d/2) > 0, d0 = 2 * trigammaInverse(that value) and s0^2 = exp(mean e + digamma(d0/2) - ln(d0/2)); otherwise d0 = infinity, s0^2 = exp(mean e). B4 Moderated variance (d0 s0^2 + d s2_i)/(d0 + d); t = d_i / sqrt(that * (1/n_num + 1/n_ref)), df = d + d0 (normal if d0 is infinite); two-sided p; BH; DEG if BH < 0.05 and |d_i| > 0.25. OUTCOMES (per method, variant and scope, per comparison) - DEG counts: total, up, down. - Against the authors' DESeq2 file (same comparison, primary rule of RULES_deg_recount.txt): DEGs in common, the share of the authors' DEGs we also call, Jaccard index; Spearman correlation of our log2FC with their log2FoldChange and of our -log10 p with theirs (genes present in both). - Labels fixed now: "close" if our primary count is within +/-25% of the authors' count; "same order of magnitude" if within a factor of 3; otherwise "different order of magnitude". These labels describe how method-dependent the counts are; they are not a test of the authors' analysis. DESCRIPTIVE CHECKS (no decision attached) - Library size (column sum) and number of detected genes (count > 0) for all nine samples. - Pearson correlations between samples of log2(q + 1) over genes with total >= 6 across nine samples (size factors from nine), and the first two principal components of the 500 genes with the largest variance of log2(q + 1): where NZMF_3 and each group lie. OUTPUT code/out/rederive.json, code/out/rederive_genes_.csv (our per-gene results), and a table in report.md.