Repository navigation
Add multivariable PERMANOVA with covariates, strata and PERMDISP - #161
Merged
Merged
Conversation
…DISP (#152) Distance-based linear model in NumPy as in vegan::adonis2: marginal ("margin", default) or sequential ("terms") tests, numeric and categorical terms, and permutations restricted within strata. PERMDISP runs per categorical term (not applicable for numeric terms). CLI: --covariates and --strata with --permanova; --covariates/--categorical/--select are reused. Checked against adonis2 and betadisper outputs saved in tests/reference/.
skennedy8
force-pushed
the
permanova-covariates
branch
from
November 14, 2026 14:47
020ad00 to
a60a284
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #161 +/- ##
==========================================
+ Coverage 91.58% 91.64% +0.06%
==========================================
Files 73 73
Lines 5491 5603 +112
Branches 917 938 +21
==========================================
+ Hits 5029 5135 +106
- Misses 315 318 +3
- Partials 147 150 +3
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Sean · project thread
Description
Adds a multivariable Permutational Multivariate Analysis of Variance (PERMANOVA) as a distance-based linear model in NumPy, following
vegan::adonis2.permanova_model()inmoonstone/analysis/permanova.py: numeric and categorical terms;by="margin"(default, each term after all the others) or"terms"(sequential, Python only);stratarestricts permutations within blocks; same seed,--threads, Benjamini-Hochberg correction and too-few-permutations warning as the existing screen. Results do not depend on sample order or thread count.run_permanova(..., covariates, strata, categorical, by)reuses the taxonomic-level loop. With covariates or strata, the named variables plus covariates form one model and every term is reported (addsterm_typeanddfcolumns). Without them, nothing changes.not applicable. It is one-factor and does not adjust for the other terms (documented). The PERMDISP call is now one shared helper inbeta.py.--covariatesand--stratawith--permanova.--covariatesand--categoricalalready existed for--associateand are reused;--selectand--group_columnnow also work with--permanova(needed for one sample per patient in the example).permanova.rsthas the example files, the screen and model commands, and the quoted numbers.make_examples.pyadds abatchcolumn, drawn last from its own generator so the other example files are unchanged.Changelogs
permanova_model, extendedrun_permanova,--covariates/--stratafor--permanovatests/reference/(permanova_adonis2.R, generated with R 4.3.3 and vegan 2.6-4); CI does not need RIssue(s)
Fixes #152
Tests
adonis2(terms and margin, with and without strata): R2 and pseudo-F agree to 1e-8; p-values within Monte Carlo error.betadisper+permutest: F differs by 0.006 (three groups, F = 0.29) and 0.003 (two groups, F near 0), the scikit-bio negative-eigenvalue difference; recorded in the test and the user guide.test_to_dataframe_odsand_xls, unrelated:odfpy/xlrdare inrequirements-dev, which was not installed). Docs build with-Wclean.Definition of Done