From 2df90559ca597c0d35daf68e8648f8a46c823787 Mon Sep 17 00:00:00 2001 From: Pjotr Date: Tue, 17 Nov 2026 10:25:14 +0000 Subject: impute=hmm runs now: individuals from rownames, and a versioned cache Two more faults, both measured, both in the plumbing rather than the statistics. maxmarg returns individuals x markers, so colnames are *markers*: the individuals file I added last commit listed 1 452 marker names, every trait value aligned to nothing, and the workflow answered "number of analyzed individuals equals 0". It writes rownames now -- 235 names for BXD.8 -- and impute=hmm completes: 200, 11 657 rows, 26 s, single machine, with both notes ("missing calls predicted by R/qtl2's HMM", "trait values aligned by name to the 235 individuals"). The second fault was the cache: the prepared files are keyed on (panel, mode) and not on the code that writes them, so the corrected individuals file was ignored and the run kept failing on the stale one. The key now carries IMPUTE_CACHE_VERSION, bumped when either script changes what it writes. Three modes through the workflow, same trait, same machine: none 200, 21 055 rows mean 200, 21 056 rows hmm 200, 11 657 rows none and mean agree as they should: identical top marker (rs32133186), Spearman rho 1.00000, top-50 50/50, median |d(-log10 p)| 0.00004. hmm disagrees, and that is a real finding rather than a rounding matter: rho -0.07 against both, different top marker, and only 11 657 of the 20 453 markers reported. A rank correlation near zero means the genotypes and the markers are not being paired the way the other two modes pair them, so the next thing to check is the annotation file this path feeds GEMMA (it comes from the cross's physical map, while the genotype rows come from the HMM's marker order) -- not the imputation itself, which the same-genotype comparison already showed to be sound (rho 0.999971 against pangemma on the identical calls). --- src/routes/gemma.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/routes/gemma.rs b/src/routes/gemma.rs index 329158a..e94ca72 100644 --- a/src/routes/gemma.rs +++ b/src/routes/gemma.rs @@ -947,9 +947,15 @@ async fn prepare_genotypes( .file_stem() .map(|name| name.to_string_lossy().into_owned()) .unwrap_or_else(|| "panel".to_string()); + // The cache key carries a version, because it is keyed on the panel and the + // mode and NOT on the code that produces them: a fixed bug in the imputation + // script would otherwise be masked by its own old output (measured: a + // corrected individuals file was ignored and the run kept failing on the + // stale one). Bump this when either script changes what it writes. + const IMPUTE_CACHE_VERSION: &str = "v2"; let prefix = std::path::Path::new(&config.ravanan_cache_dir) .join("imputed") - .join(format!("{stem}-{mode}")); + .join(format!("{stem}-{mode}-{IMPUTE_CACHE_VERSION}")); let prepared_geno = format!("{}.bimbam.txt", prefix.to_string_lossy()); let prepared_snps = format!("{}.snps.txt", prefix.to_string_lossy()); -- cgit 1.4.1