You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7bf8438
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(analysis): add two-part count models and occupancy fitter (#196)
## Summary
- Add fixed-effect ZINB and hurdle negative-binomial differential
methods with separate zero/count effects, joint likelihood-ratio tests,
count offsets, BH correction, config/UI support, and a visible
model-caution notice.
- Add a repeated-visit occupancy likelihood API over site × visit ×
taxon histories, with ψ/p estimates, group testing, BH adjustment, and
refusal of single-visit designs.
- Document assumptions and add backend/frontend tests.
Related to #18. This is a partial implementation, not a close of #18:
occupancy remains a lower-level API (not selectable in AnalysisConfig or
the single-sample UI), and detection covariates/formula editors,
Vuong/residual diagnostics, performance benchmarks, and corresponding
schema/provenance work remain outstanding. The issue should stay open
until those acceptance criteria are completed.
## Validation
- npm run build in frontend: passed.
- npm exec --yes --package=bun -- bun test src in frontend: 44 passed.
- Julia/R backend tests could not be run in this sandbox because Julia
and Rscript are not installed; backend simulation tests were added for
CI.
---------
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|`src/analysis/differential.jl` (`fit_two_part_nb`, `differential_abundance`), config enum in `src/server/routes/config.jl` and `frontend/src/components/PipelineStages.tsx`
17
+
|Base R likelihood with zero and count components; the group effect is jointly tested by a 2-df likelihood-ratio test. Count offset is TSS/RLE. BH is applied by the shared result path. Backend Julia/R CI must pass before merge.
18
+
19
+
|Selectable hurdle negative-binomial differential model
20
+
|Same fitter and config/UI path; the positive count likelihood is zero-truncated NB.
21
+
|All observed zeros are assigned to the occurrence process. It does not offer a lognormal or Poisson count component yet.
22
+
23
+
|Model cautions and results
24
+
|`frontend/src/components/DifferentialPanel.tsx`, CSV result types/export, diagnostics in `differential_abundance`
25
+
|The UI surfaces a caution and exposes the zero-process coefficient. The joint LRT is not a model-selection test and does not establish that the chosen zero process is biologically real.
26
+
27
+
|Repeated-visit occupancy estimator
28
+
|`MetaManifold.Differential.fit_occupancy`; tests in `test/unit/test_differential.jl`
29
+
|Accepts sites × visits × taxa Boolean detection histories; estimates group occupancy and common detection probability; refuses fewer than two visits. This is a lower-level API, not the standard analysis method or endpoint.
30
+
31
+
|Scientific limitations
32
+
|`docs/occupancy-models.md`, `README.md`
33
+
|No single-visit occupancy claim. Closure and destructive microbiome sampling limitations are stated. Detection covariates are not implemented.
34
+
|===
35
+
36
+
== Not yet implemented
37
+
38
+
The follow-up issue linked from #18 owns first-class occupancy configuration and
39
+
UI, occupancy/detection formula inputs and covariates, identifiability checks,
40
+
zero-formula/count-distribution options, model diagnostics/comparisons, reference
41
+
parity, scale benchmarks, schema/provenance completion, and a synchronized wiki
42
+
roadmap. Until that work lands, do not describe the occupancy estimator as a
43
+
ready-to-use workflow.
44
+
45
+
== Validation record
46
+
47
+
* Frontend typecheck, production build and frontend unit tests are run locally.
48
+
* Julia/R backend tests are defined in `test/unit/test_differential.jl` and run
49
+
by the repository CI workflow. Their successful CI result is required before
50
+
merge; this sandbox does not have Julia or R installed.
51
+
* CI also contains other workflows; each current failure must be inspected and
52
+
either fixed or shown to be an unrelated, pre-existing non-required lane.
Copy file name to clipboardExpand all lines: README.md
+31-41Lines changed: 31 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ MetaManifold wraps standard amplicon sequencing workflows into a single configur
20
20
21
21
## Overview
22
22
23
-
MetaManifold consists of a Julia backend (pipeline engine + REST API) and a TypeScript/React frontend. The pipeline runs FastQC, MultiQC, cutadapt, DADA2, swarm, vsearch, and cd-hit-est under the hood, and places ASVs on reference trees with MAFFT, trimAl, IQ-TREE, RAxML and gappa; results are stored in per-run DuckDB databases and served to the frontend as interactive Plotly charts and filterable tables. Pipeline configuration is editable in the web UI at every cascade level (see [Configuration](#configuration)).
23
+
MetaManifold consists of a Julia backend (pipeline engine + REST API) and a TypeScript/React frontend. The pipeline runs FastQC, MultiQC, cutadapt, DADA2, swarm, vsearch, and cd-hit-est under the hood, and places ASVs on reference trees with MAFFT, trimAl, IQ-TREE, RAxML and gappa; results are stored in per-run DuckDB databases and served to the frontend as interactive Plotly charts and filterable tables. Pipeline configuration is editable in the web UI at every cascade level (see [Configuration](#configuration)). For analysis-method status and planned work, see [ROADMAP.md](ROADMAP.md); the full occupancy follow-up is tracked in [issue #205](https://github.com/hyperpolymath/MetaManifold-WebUI/issues/205).
24
24
25
25
**Pipeline stages**
26
26
@@ -289,48 +289,38 @@ not exclude samples from this analysis.
289
289
290
290
`analysis.differential.method` chooses the method:
291
291
292
-
- `nb_glm` (default): a negative-binomial GLM per taxon with a library-size
293
-
offset. The effect is log2 fold change; positive values indicate greater
294
-
abundance in the second condition. `offset` selects `tss` (default) or `rle`
295
-
scaling. `dispersion` selects per-taxon maximum likelihood with
296
-
`MASS::glm.nb`(default) or a cross-taxon shrinkage trend from R's
297
-
`glmGamPoi::glm_gp`, followed by fixed-theta NB Wald fits.
292
+
- `nb_glm` (default): a negative-binomial GLM per taxon using `MASS::glm.nb`,
293
+
with a library-size offset. The effect is log2 fold change; positive values
294
+
indicate greater abundance in the second condition. `offset` selects `tss`
295
+
(default) or `rle`; `dispersion` selects maximum-likelihood theta or a
296
+
cross-taxon `glmGamPoi` trend.
297
+
- `zinb`: a zero-inflated negative-binomial model with separate logistic
298
+
zero and count components, a count-component library-size offset, a joint
299
+
2-df likelihood-ratio test, and BH correction.
300
+
- `hurdle_nb`: a logistic occurrence model plus zero-truncated NB counts for
301
+
positive observations. It uses the same joint test and offset convention.
298
302
- `clr_welch`: Welch's t-test on centred log-ratios after zero replacement with
299
303
`zCompositions::cmultRepl`. The effect is a CLR difference, not a fold change.
300
-
`replacement_method`selects `bayesian_multiplicative` (GBM, the default) or
301
-
`multiplicative_replacement`(CZM). `replacement_delta` controls the
302
-
replacement fraction (default 0.65), and optional positive `bayesian_alpha`
303
-
overrides GBM's estimated Dirichlet concentration; `offset` is not used.
304
-
[Zero handling, posterior semantics, warnings and references](docs/statistics/zero-handling.md)
305
-
explain why every replacement is biased and when a count, occupancy or
306
-
zero-inflated model is preferable.
307
-
- `ancom_bc`: ANCOM-BC sampling-fraction bias-corrected log-linear model
0 commit comments