about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/routes/gemma.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/routes/gemma.rs b/src/routes/gemma.rs
index 96a0fb2..232e965 100644
--- a/src/routes/gemma.rs
+++ b/src/routes/gemma.rs
@@ -928,7 +928,21 @@ pub(crate) async fn resolve_inputs(
                         None => keep,
                     };
                     let dropped_empty = (resolved.panel.len() - parents_f1s) - keep.len();
-                    let (aligned, matched) = genotypes::align(&resolved.panel, &keep, &named);
+                    // Pad the phenotype over *the genotype file's* individuals
+                    // instead of narrowing the genotypes to the ones that have
+                    // values.  Both files must describe the same animals in the
+                    // same order, and padding is the side that cannot drift: an
+                    // excluded animal is a row of NA, which GEMMA drops from the
+                    // fit (and from -gk, where `-p` only names who is analysed),
+                    // while a narrowed genotype file has to be written correctly
+                    // for every delimiter a panel might use -- which is how this
+                    // went wrong: write_subset_bimbam splits on ',' and HSNIH's
+                    // BIMBAM is whitespace-separated, so the "subset" was a byte
+                    // copy of all 6147 columns against a 6111-row phenotype, and
+                    // GEMMA failed every marker (6147 != 6111).
+                    let all_individuals: Vec<usize> = (0..resolved.panel.len()).collect();
+                    let (aligned, matched) =
+                        genotypes::align(&resolved.panel, &all_individuals, &named);
                     let kept_names: Vec<String> = keep
                         .iter()
                         .filter_map(|index| resolved.panel.get(*index).cloned())
@@ -937,7 +951,7 @@ pub(crate) async fn resolve_inputs(
                         &directory,
                         &resolved,
                         genotypes::Engine::Gemma,
-                        &keep,
+                        &all_individuals,
                         &cache_dir,
                     )?;
                     Ok::<_, genotypes::GenotypeError>((