feat: repeated permutation null for get_pseudo_correlation (v2.3.2)#28
Merged
Merged
Conversation
Add permutation_count (default 100) and permutation_seed arguments to get_pseudo_correlation() and SplikitObject$getPseudoCorrelation(). The null model is now built from permutation_count cell-permutations of ZDB_matrix, yielding a per-event empirical null with the new columns null_sd, n_perm_valid, emp_pvalue (two-sided, (b+1)/(m+1) corrected) and emp_padj (Benjamini-Hochberg). The full per-event draws are attached as attr(result, "null_draws"). permutation_seed seeds the permutations reproducibly and saves/restores the caller's global RNG stream, so it does not perturb downstream randomness. null_distribution is now the mean of the per-event null draws (equal to the single draw when permutation_count = 1, preserving backward compatibility); the observed pseudo_correlation is unchanged. Bump to 2.3.2; update NEWS.md, RELEASENOTES.md logbook, regenerated docs, vignettes, and add a dedicated permutation test (validity, seed reproducibility, global-RNG isolation, count=1 equivalence, input validation).
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.
Summary
Adds repeated-permutation null support to
get_pseudo_correlation()and the R6 methodSplikitObject$getPseudoCorrelation(), controlled by two new arguments:permutation_count(default100L) — number of times the cells (columns) ofZDB_matrixare permuted and the pseudo correlation recomputed. Each permutation yields one null value per event, forming a per-event empirical null.permutation_count = 1reproduces the original single-permutation behaviour.permutation_seed(defaultNULL) — seeds the permutations for reproducible nulls/empirical p-values. The caller's global RNG stream is saved and restored, so a seed here does not perturb downstream randomness.The observed correlation is computed once; only the null pass scales with
permutation_count.Output changes
null_distributionis now the mean of the per-event null draws (equal to the single draw whenpermutation_count = 1→ backward compatible). New columns:null_sdNAif < 2 valid draws)n_perm_validNAnull for the eventemp_pvalue(b + 1) / (n_perm_valid + 1)emp_padjemp_pvalueThe full per-event draws (events ×
permutation_count) are attached asattr(result, "null_draws").pseudo_correlationis unchanged.Design notes
compute_kernel()closure); the kernel is not row-parallelised, so a C++ loop would buy nothing while creating an OpenMP RNG-determinism trap.(b+1)/(m+1)Phipson–Smyth correction with the denominator counting only valid (non-NA) draws.Validation
R CMD check --as-cran: no ERRORs/WARNINGs; only the 4 pre-existing local-environment NOTEs (cluster-marchflag,.sosize, network-time, CRAN-incoming) — none introduced by this change. No "no visible binding" / undocumented-args / code-doc-mismatch notes.devtools::test(): 113 passed, 0 failed. New dedicated test covers empirical-p validity, seed reproducibility, global-RNG isolation,permutation_count = 1equivalence, and input validation.permutation_count; the\donttestexample subsets cells (runs in ~0.2s).Version
Bumped to 2.3.2;
NEWS.mdand theRELEASENOTES.mdlogbook updated; docs/vignettes regenerated.