`ms_test_presence()` tests, per signature, the hypothesis that the signature is present in the cohort, with Benjamini-Hochberg multiplicity control over the signature family (research/02 section 2; the mSigAct chi^2_1 + BH q semantics). The evidence is the entry-wise presence LRT of [ms_fit()] – which is method-independent by construction: per sample, the full NB-MLE model against the model refit without the signature, `D = 2(ll_with - ll_without)`. Per-sample statistics are pooled across the cohort by summation (independent likelihoods add).
Arguments
- x
An [MsCatalog] (together with `signatures`; the test runs in the Rust kernel) or an existing [MsFit] (the test aggregates the fit's evidence grid; `signatures` must then be NULL).
- signatures
The dictionary for the catalog face: a numeric matrix (channels x signatures) or an [MsSignature], resolved exactly as in [ms_fit()]. Ignored (must stay NULL) on the MsFit face.
- ...
Reserved for future extensions; unused.
- nb_size
Single positive number: the negative-binomial size (mSigAct `nbinom.size`; default 8, the SBS96 anchor). Only used on the catalog face (the MsFit face reuses the fit's evidence).
Details
**Exact pooled null (P0 correction, 2026-10 independent audit).** Under H0 each per-sample statistic follows the Self-Liang boundary law `1/2 * delta_0 + 1/2 * chi^2_1`, so the pooled statistic over n independent samples has the exact null law `sum_m C(n,m)/2^n * chi^2_m` (a Binomial(n, 1/2) mixture of chi-squares); `p_raw` is the strict upper tail of that reference. At n = 1 it is bit-identical to the Self-Liang half-tail `1/2 * pchisq(D, 1, lower.tail = FALSE)`. For n >= 2 the earlier chi^2_1 reference was anti-conservative (the statistic grows with n while the reference does not); this is a correction of the chi-square reference, not a change of estimand. All violations raise `msuiter_error_*` conditions.
**Result.** A data.frame with one row per signature (the dictionary order), columns `signature`, `stat` (pooled LRT statistic), `p_raw` (exact pooled-null p-value, before correction), `p_bh` (Benjamini-Hochberg adjusted p over the k-signature family: sorted p x m/i with the cumulative-minimum fold-back, capped at 1) and `pass_bh` (`p_bh <= 0.05`, the frozen family-wise alpha).
The BH arithmetic is bit-identical between the Rust kernel and the pure-R twin used on the MsFit face (same operation order, stable tie-breaking; pinned by tests).