diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-07 16:21:10 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-07 16:21:10 +0000 |
| commit | b5f5209642f422e87a4d0041471c5654491a8d0c (patch) | |
| tree | 05f6fdaa0c29c5b31b194d48287d6f208ff54fbf /docs | |
| parent | 2fcb57a627ed261b6650522b256cc509ebd65ddd (diff) | |
| download | genenetwork4-b5f5209642f422e87a4d0041471c5654491a8d0c.tar.gz | |
docs: which genotype file is current, and three real mappings measured
The compute endpoints take server-side paths, so callers need to know
the deployment's genotype-file layout and which version is current --
neither of which is discoverable from this repository, and both of which
are spread across GN2 and GN3 (GN2's per-group genotype/<Group>.json
whose `genofile` list is newest-first and is the actual authority -- the
GenoFile table still lists only the classic files; GEMMA fed from
genotype/bimbam/<file>_geno.txt, R/qtl from genotype/<file>.geno; GN3
reading the sample order out of the .geno header; InbredSet.
MappingMethodId deciding which engine a group offers).
Measured on this deployment, with the newest genotypes and values
re-indexed onto each panel's sample order:
BXD BXD.8.geno (WGS Mar2022) GEMMA 17.1s 21055 rows
BXD BXD.8.geno R/qtl 7.5s 21056 markers
HET3-ITP.12 (Apr2023, 6447 individuals) R/qtl 83.1s 893 markers,
lifespan peak LOD 7.95 at 1_24042124 (chr1, 24.04 Mb)
That last run is the shape of what Rob Williams wants: UM-HET3 is a
4-way cross (MappingMethodId=3, R/qtl), and its genotype files are
versioned per cohort with no JSON recording which is current, and no
per-cohort trait split -- 6438 of lifespan's 23879 animal values fall in
the .12 panel, the rest are silently dropped. Recorded as the known
messiness rather than hidden.
* docs/genotypes.md: new. Layout, how GN2/GN3 choose, the alignment
rule, per-group engines, the measurements, what is still messy.
* README.md: pointer.
* docs/www/operator-checklist.md: replace "only the test fixtures exist"
with the real panels, and name the missing alignment step.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/genotypes.md | 119 | ||||
| -rw-r--r-- | docs/www/operator-checklist.md | 25 |
2 files changed, 133 insertions, 11 deletions
diff --git a/docs/genotypes.md b/docs/genotypes.md new file mode 100644 index 0000000..fed2932 --- /dev/null +++ b/docs/genotypes.md @@ -0,0 +1,119 @@ +# Genotype files: where they are, which one is current, how to map with them + +`/compute/rqtl` and `/compute/gemma` take paths that exist on the +server, so whoever calls them has to know two things the API does not +tell them: where the deployment keeps genotype files, and **which** +version of a panel's genotypes is the current one. Both are answered by +long-standing GeneNetwork convention, reproduced here because it is not +discoverable from this repository's code. + +The deployment's copy is `/home/wrk/tmp/ai-root/factory/gn4-data/ +genotype-files`, laid out like GeneNetwork2's own `genotype_files`: + +``` +genotype/<Group>.geno GN genotype format (Chr/Locus/cM/Mb + one column per individual) +genotype/<Group>.json per-group metadata: the list of genotype files, newest first +genotype/bimbam/<file>_geno.txt GEMMA/BIMBAM genotype (0/0.5/1) + <file>_snps.txt + <file>_pheno.txt +genotype/rqtl2/<file>_{geno,gmap,pheno}.csv, <file>.json R/qtl2 bundle +genotype/json/<Group>.json older marker dump (not the version list) +mapping/<Group>.bed|.bim|.fam PLINK, with covariates in mapping/ +``` + +## Which file is current + +GeneNetwork2 (`gn2/base/data_set/datasetgroup.py:get_genofiles`, +`gn2/base/webqtlConfig.py:GENODIR`): read `genotype/<Group>.json` and +take its `genofile` key, which is a **list, newest first**, each entry +`{title, location, sample_list?}`. The mapping UI offers the list and +defaults to the first. With no JSON, it falls back to `<Group>.geno`. +The user's choice rides along in `genofile_string` as +`<file>:<title>` (`display_mapping_results.py`). + +So "the latest version" is `genofile[0]`, not the highest number and not +the newest mtime. For BXD that is: + +```json +{"title": "WGS-based (Mar2022)", "location": "BXD.8.geno", "sample_list": [...235 names...]} +``` + +followed by `BXD.geno` ("Array-based 2017–2021"), `BXD.4.geno` +("Classic 2001-2016") and `BXD.2.geno` ("Test"). Note `BXD.8.geno` is +not even in the `GenoFile` table — that table is older and only ever had +the classic/array files — so the JSON, not MariaDB, is the authority on +which version is current. `GenoFreeze` is one row per group +("BXD Genotypes", 2003), not one per version. + +## How each engine is fed + +- **GEMMA** (GN2 `marker_regression/gemma_mapping.py`): strip `.geno` + from the location and use + `genotype/bimbam/<name>_geno.txt` with `<name>_snps.txt` — for BXD's + current file that is `bimbam/BXD.8_geno.txt` + + `bimbam/BXD.8_snps.txt` (21 056 markers × 235 individuals). The `.geno` + file itself is *not* what GEMMA gets. +- **R/qtl** (GN2 `marker_regression/rqtl_mapping.py`): pass + `genotype/<location>` straight through — `genotype/BXD.8.geno` — and + let `scripts/rqtl_wrapper.R`'s `geno_to_csvr` read the GN format. +- **The sample list** (GN3 `gn3/db/genotypes.py:load_genotype_samples`, + `gn3/db/datasets.py`): the first non-`#`/`@` line of the `.geno` file + is the header; if its fourth column is `Mb`, sample names start at + column 5, otherwise at column 4. That is the only authoritative sample + order, and the only place it is stored. + +## The alignment rule, and what the API does not do yet + +Both engines match values to individuals **by position**: R/qtl's cross +format has no per-sample names, and `write_pheno_file` (src/gemma.rs) +writes bare values. So a request must carry one value per individual in +the genotype file's order, `null`/`NA` where the trait has none. + +The API does **not** do that alignment itself today: the caller has to +expand a trait's values onto the panel (GN3 has `load_genotype_samples` +for exactly this, and it should move into the compute handlers). Until +it does, the `actions` bodies in the values responses are a starting +point, not a finished request — the values have to be re-indexed onto +the genotype file's sample list first. `scripts/rqtl_wrapper.R` now +refuses a count mismatch instead of scanning misassigned values, which +turns a silent wrong answer into a `502`. + +## Which engine a group offers + +`InbredSet.MappingMethodId` (GN2 `get_mapping_methods`): 1 → GEMMA, +QTLReaper and R/qtl; 2 → GEMMA; 3 → R/qtl; 4 → GEMMA and PLINK. On this +database: `BXD` = 1, `HET3-ITP` = 3, `HSNIH-Palmer` = 2, `HS` = NULL. + +`HET3-ITP` is UM-HET3, a 4-way cross (`@type:4-way`, `@mat:AB`, +`@pat:CD` in its `.geno` header), so R/qtl is the right engine even +though `bimbam/HET3-ITP.*` files exist — those are a biallelic +projection of a four-founder panel. + +## Measured runs (2026-11-07, this deployment) + +Values came from `/groups/{group}/traits/{id}/values`, were re-indexed +onto the genotype file's sample list by name with `null` for the rest, +and were posted to the API. + +| panel / genotype file | engine | trait | panel | trait values | time | result | +|---|---|---|---|---|---|---| +| BXD, `BXD.8.geno` (WGS Mar2022) | GEMMA (bimbam) | 10001 cerebellum weight | 235 | 34 | 17.1 s | 21 055 marker rows | +| BXD, `BXD.8.geno` | R/qtl scanone | 10001 | 235 | 34 | 7.5 s | 21 056 markers | +| HET3-ITP, `HET3-ITP.12.geno` (Apr 2023) | R/qtl scanone | 10000 lifespan | 6 447 | 6 438 | 83.1 s | 893 markers, peak LOD 7.95 at `1_24042124` (chr 1, 24.04 Mb) | + +## What is still messy + +`HET3-ITP` has eleven `.geno` versions on disk (`.2` … `.12`) and **no +`genotype/HET3-ITP.json`**, so there is no recorded list and no recorded +"current" — `.12` (6447 individuals, 894 markers, Apr 2023) is the newest by both +numbering and date -- the `rqtl2/` bundles, for what it is worth, only +exist for `.2`, `.3` and `.4`, so they do not mark the current version +either -- but that is inference, not a documented default. Its traits +are per **animal**, not per strain (lifespan: 23 879 values over +several cohorts), so only 6 438 of them fit the `.12` panel; the rest +belong to cohorts that genotype file does not contain. Mapping them +"latest version" therefore silently drops cohorts — correct per the +file, wrong as biology until the version/cohort pairing is recorded. + +The fix on the GN4 side is small and worth doing: align trait values +onto the panel inside the compute handlers (by name, from the `.geno` +header), so a caller passes the values it has and the server does the +re-indexing. That also makes the `actions` bodies directly usable. diff --git a/docs/www/operator-checklist.md b/docs/www/operator-checklist.md index 6d4e18d..333ed68 100644 --- a/docs/www/operator-checklist.md +++ b/docs/www/operator-checklist.md @@ -132,17 +132,20 @@ PATH=$P/bin:$PATH R_LIBS_SITE=$P/site-library/ genenetwork4 …other env… fails with `rqtl_failed` and `there is no package called 'optparse'` — an environment problem, not a token or proxy problem. -What genotype files exist is a deployment question, and today the only -ones on this box are the test fixtures in `tests/test_data/`: -`BXD_geno.txt.gz` (198 BXD individuals × 7 320 markers), `BXD_snps.txt` -(the marker map) and `rqtl_sample1.geno` (a 6-individual cross). They are -fixtures, not a panel-matched dataset: a database trait has its own -strain subset (BXD traits typically ~10–35 of the 198), and both engines -match values to individuals **by position**, so mapping such a trait -against the full 198-individual file is wrong by construction. Until the -deployment ships genotype files subset to a trait's strains (or the team -says which panel file pairs with which trait), real mappings should not -be offered — the fixtures are for smoke tests and for the test suite. +Real panels are served from `/home/wrk/tmp/ai-root/factory/gn4-data/ +genotype-files`, in GeneNetwork2's layout: `genotype/BXD.8.geno` (WGS +Mar2022, 235 individuals × 21 057 markers) with GEMMA's +`genotype/bimbam/BXD.8_geno.txt` + `_snps.txt`, and +`genotype/HET3-ITP.12.geno` (6 447 individuals × 894 markers) for +UM-HET3. `docs/genotypes.md` covers how the current version is chosen, +which engine each group offers, and the measured runs. + +Both engines match values to individuals **by position**, so a request +must expand a trait's values onto the panel's sample order (null for +individuals the trait does not cover) — the API does not do that +re-indexing yet, so whoever prepares the request has to. It is the first +thing to fix: pass the values a caller has, let the server align them +from the `.geno` header. `/compute/gemma/ravanan` additionally needs `ravanan` and `ccwl` on `PATH`, and with `RAVANAN_BATCH_SYSTEM=slurm-api` a reachable slurmrestd |
