For G genes and the K = 4 letters, Pearson's statistic X2 = Σ (O − E)2/E compares the observed letter counts with those expected if all genes shared one composition p. If p is known, X2 is approximately χ2 with G(K − 1) degrees of freedom; if p is estimated from the same table (as it must be for real data) it loses K − 1 of them and is approximately χ2 with (G − 1)(K − 1). Simulate tables in your browser and see which reference fits. The last view computes the exact permutation distribution behind Chargaff's rule.
code/ch02_statistical_modeling.R (staph_null, chf_exact_p). This page reproduces the statistics (70.07533 with the book's p0, 68.65126 with the pooled estimate).