# Pre-estimation analysis rules
Published before microbial association estimation. Seed: 20261008. Source: biocore/American-Gut commit 68fd6d4b2fa6aeb5b4f5272c6f1006defe5b160e, AG_100nt.biom and AG_100nt.txt. Historical QIIME 1.9.0 table created 2015-03-28; repository warns of earlier survey.

## Cohort and features
Match #SampleID to BIOM sample IDs (4827/4827). BODY_SITE must equal UBERON:feces; AGE >=18 with AGE_UNIT=years. HOST_SUBJECT_ID must be numeric, optionally preceded by a numeric study prefix and colon. Use the numeric suffix as participant identity across prefix formats, conservatively collapsing matching suffixes. Retain finite nonnegative profiles with >=1000 reads; select highest-depth sample per participant, breaking ties lexicographically by sample ID. No microbiome or exposure-based selection.
Flow: matched 4827; stool 3679; adult 3304; valid identifiers 3304; depth threshold 3061; unique participants 2719. Select 600 with seed 20261008 using country-proportional largest-remainder allocation and random sampling within sorted country strata. Retain missing-country stratum.
Use all 9089 features nonzero in this cohort (22742 original features), no prevalence filtering or rarefaction; convert each row to relative abundance. Apply this same feature set throughout.
Exposure is TYPES_OF_PLANTS with exact categorical labels: Less than 5, 6 to 10, 11 to 20, 21 to 30, More than 30. Do not replace labels by midpoints or reinterpret Less than 5 as <=5. Numeric 28 and all other codes are unvalidated/missing. PLANT_PER is not the exposure. These are reported plant-type categories; exact historical survey wording/recall interval is not established by the downloaded documentation.
Missing codes: blank, no_data, unknown, not provided, unspecified, nan, none (case insensitive). COUNTRY removes GAZ: prefix; STATE uses recorded state code. Sex accepts female/male/other; BMI numeric positive finite; antibiotic accepts the five named time-since-use categories. No imputation.

## Support and subsets
At least 20 observations per exposure category, at least two supported categories, and >=20 residual degrees of freedom are required for inference. Drop unsupported categories for that contrast and document counts; never merge based on outcomes. Country subgroup requires >=60 respondents and >=2 categories with >=20 each. Regional model requires >=2 states with >=20 respondents each, connected state-exposure support, and full design rank.
600-person cohort: US 571, Canada 10, UK 5, Australia 3, Germany 2, Thailand 2, country missing 2, Japan/France/China/Switzerland/Belgium 1 each.
Plant missing/unvalidated 34; country missing 2; sex missing 51; BMI missing 56; antibiotic missing 7; state missing 10.
Main matched comparison: 564 exposure-observed, country-known participants. All five categories supported. Complete-case comparison: 479 (category counts 30,105,158,96,90 in exposure order). US subgroup: 540 respondents; other countries lack support.
Regional subset: 300 respondents in CA, CO, IL, MA, NY, TX, VA, WA. All five exposure groups have >=20 overall in this subset; all states connect through shared categories. Compare unadjusted and state-adjusted models on this identical subset. No per-state exposure inference.
Nonresponse analysis uses country-known cohort, contrasting validated exposure respondents versus missing/unvalidated exposure; 34 nonrespondents support this binary contrast.

## Geometry and inference
Compute Bray-Curtis from relative abundance across all 600 participants. Let B=-0.5 J D^2 J and c=max(0,-lambda_min(B)). Lingoes-correct off-diagonal squared distances by adding 2c; keep diagonal zero. Eigendecompose corrected B and retain every eigenvalue >1e-10 times max(1, largest eigenvalue). Use the resulting full coordinate matrix for ALL models, subgroups, centroid dispersion tests and reconstructed distances. Record negative spectrum, c, retained dimensions and reconstruction error. The first two axes serve visualization only.
Multivariate least squares nested models: full=intercept+nuisance+plant, reduced=intercept+nuisance. Incremental R2=extra SS / centered total SS; partial R2=extra SS / reduced residual SS; pseudo-F=(extra SS / added df)/(full residual SS / residual df).
Use 999 Freedman-Lane reduced-model residual permutations and p=(1+number Fperm>=Fobs)/1000. Country-adjusted tests permute within country; state-adjusted within state; other tests unrestricted. Adjusted complete-case nuisance: country, age, sex, BMI, antibiotic category. Categorical dummy variables use a deterministic reference; continuous nuisance columns standardized for conditioning. Check full rank and connected support. This assumes exchangeable residuals within permitted strata; heterogeneous dispersion can undermine location interpretation.
Dispersion diagnostic: Euclidean distances to plant-group centroids in the FULL corrected space, bias adjusted by sqrt(n_group/(n_group-1)); one-way F assessed by 999 label permutations of scalar distances. This is a diagnostic of mean centroid distance, with permutation exchangeability limitations, not proof of equal multivariate distributions.
Compare unadjusted vs country-adjusted on main subset; same pair on complete cases and add clinical/demographic covariates; US-only and matched regional pair. Compare exposure response groups unadjusted and country-adjusted. Holm-adjust subgroup sensitivity tests together and nonresponse tests together; primary adjusted plant test is prespecified, other estimates contextual.
Report all planned estimates regardless of significance. Do not claim causation, geographic generalizability, or missing-at-random. Preserve original bytes and report all omissions.
