Commit 8bf6cf8
Fix nSample parameter bug and enforce exact N-in = N-out row counts
Root cause: the R implementation was using the GWAS sample size (e.g. 5000)
for the nSample parameter, but the original DENTIST binary always uses the
LD reference panel size (ref.N from the .fam file, e.g. 165). This parameter
controls the SVD truncation rank K = min(idx.size(), nSample) * propSVD,
so using the wrong value produces completely different imputation results
(imputed_z correlation of only 0.40 instead of 1.0).
With nSample correctly set to the reference panel size (NULL default in
dentist_from_files), R now matches the binary to machine precision on both
the 2500-variant subset and full 17421-variant toy dataset:
- imputed_z max diff: 5e-6, correlation: 1.0
- rsq max diff: 5e-7, correlation: 1.0
- duplicate detection: 100% agreement
Changes:
- Update nSample docs in dentist(), dentist_single_window(), and
dentist_from_files() to clarify it is the reference panel size, not
the GWAS sample size
- Remove incorrect filter in merge_windows() that dropped variants with
imputed_z == 0 & rsq == 0, which caused output to have fewer rows
than input
- Rewrite unit tests (25 -> 43) with exact row count assertions
(expect_equal(nrow(res), N)) instead of allowing ranges
- Add new tests: windowed mode exact row counts, outlier_stat formula
verification, X matrix input, fill region coverage, column checks,
original_z preservation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0446c35 commit 8bf6cf8
5 files changed
Lines changed: 174 additions & 109 deletions
File tree
- R
- man
- tests/testthat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
157 | | - | |
158 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
531 | 533 | | |
532 | 534 | | |
533 | 535 | | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | 536 | | |
539 | 537 | | |
540 | 538 | | |
| |||
593 | 591 | | |
594 | 592 | | |
595 | 593 | | |
596 | | - | |
597 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments