| Age | Commit message (Collapse) | Author |
|
Fills in the usage slot for gemma (all three routes, through one
record_usage helper), qtl2, rqtl, fitqtl, bulklmm, bnw and bnw_features:
dataset, group, source (group|upload|file|basket), trait, engine, and the
run id where the endpoint has one -- the id a later result fetch carries
in its path, which is what makes "computed and never fetched" measurable.
The call goes in before validation on purpose: a 422 still records what
was asked for, and a failed compute is as interesting as a working one.
/search gets q, type, engine and hits. It is the only place a query
string is written: the access log drops query strings because one can
carry a credential, so ?q= was otherwise invisible, and "what people
search for" is the most useful behavioural signal this API has.
|
|
`genotype_file` + `samples` (or a basket) against a **BIMBAM** file could not
work: a BIMBAM has no individual names, so `align_to_file` read it as if it were
a `.geno`, found no header, and dropped every value -- the request then failed
with "ravanan needs a genotype file and a SNP map ... and at least one trait
value", which named nothing that was actually wrong (measured on At-Serin:
R/qtl accepted the basket, GEMMA refused it).
The deployment keeps the two files under one stem
(`genotype/<stem>.geno`, `genotype/bimbam/<stem>_geno.txt`) and the BIMBAM is
generated from the `.geno`, so the sibling is the name source: a named request
for a bimabm file now aligns onto the `.geno` beside it and places the values in
the BIMBAM's column order. The reply's note says which happened, so a caller
can tell an alignment from positional values.
|
|
the file
The phenotype and the genotype file must describe the same animals in the same
order, and this route was making that true by *narrowing the genotype file* to
the animals with values. That is the side that can drift: `write_subset_bimbam`
splits a line on ',' alone, while HSNIH-Palmer_true's BIMBAM is
whitespace-separated, so every line fell into its "fewer than four fields"
branch and was copied unchanged -- a "subset" byte-identical to the 3.9 GB
original, 6,147 columns, against a 6,111-row phenotype. GEMMA then failed
every one of the 134,918 markers with "6147 != 6111", printing the offending
marker line each time: 3.9 GB of stderr per job, ~204 GB of store logs, and the
filesystem at 100 %.
Now the alignment covers the whole panel and excluded animals are NA rows,
which GEMMA drops from the fit (and from -gk, where -p only names who is
analysed). One invariant instead of two writers, and no 3.9 GB copy per
request either.
Measured: HSNIH-Palmer_true trait 10404, engine pangemma, from a fully deleted
ravanan store: 14 m 48 s cold, 133,116 rows, no per-marker errors. The peak is
**chr1 247.86 Mb, LOD 4.78** -- and the previously reported chr5 24.6 Mb / 5.73
was computed with a scrambled phenotype (6,111 keep-order rows paired against
the first 6,111 store samples), so that number is withdrawn. R/qtl (HK) on the
same trait gives chr3 150.58 Mb, LOD 6.25, so an LMM-vs-HK difference remains to
be explained; the alignment bug is not it any more.
The store's sample order was verified equal to the .geno header order (first
marker 6147/6147, 136 markers spread across the genome with no positional
mismatch), which is what makes a positional phenotype against an lmdb store
sound at all.
|
|
The converter became an Odin binary in gemma-wrapper e244f99 and is packaged in
guix-bioinformatics (built in the package, installed as bin/geno2mdb). This
switches the store workflow to it: no interpreter, no python-lmdb, no
PYTHONPATH in the job, which is what the python version cost this deployment
twice -- a hand-exported PYTHONPATH on the API host and three python packages
in the artifact manifest.
Three things had to change, each of them measured:
- `store.scm` runs `#:run "geno2mdb"` and no longer takes the script as a File
input. ccwl appends every declared input to the command line, so a staged copy
of the binary arrived as argv[1] and geno2mdb read its own ELF header as the
BIMBAM file ("16 genotypes, expected 14, line 1").
- the server stops supplying `store_script`; the pre-flight input check named
the disagreement, as designed.
- artifact runs keep GUIX_PACKAGE_PATH set. Clearing it saved ~4 s of Guile per
run, but the artifact manifest now names gemma-wrapper, which only exists in
the channel: cleared, the job died with "gemma-wrapper: unknown package"
before reading a marker. Correctness over four seconds, and the artifact memo
means most requests never pay it.
Verified on a cold artifact path (BXD.8, impute=mean, engine=pangemma):
artifacts built in 19,263 ms, 41 cluster jobs (prepare + store + 19 kinship + 20
gwa), workflow 14,793 ms, 21,056 rows. The packaged binary was earlier checked
to produce a store identical to bin/geno2mdb.py's, on BXD.8 and on the 3.9 GB
HSNIH-Palmer_true panel.
|
|
Two gaps, both found by measuring a request that dwarfs the mapping itself.
**The genotypes phase.** `resolve_inputs` opens the panel, works out which
individuals have genotypes and writes the prepared subset; on
HSNIH-Palmer_true (134,918 markers, 6,147 individuals) that is 20.5 s of a
29.5 s request -- 70 % of it, and until now reported nowhere. The phases now
start with it, and on that panel they sum to 97 % of `took_ms` (genotypes
20,522 ms, artifacts reused 3 ms, workflow 8,013 ms, parse 152 ms, of 29,529).
**Cached kinship steps.** `steps` listed only GWA entries: `kinship_log` is not
a workflow output (ccwl's `pipe` publishes the last step's outputs only), and a
cached step submits no job to trace it by. But GEMMA prints the command line it
ran, and the GWA job's `-k` names the K file ravanan staged from the kinship
step's own store directory -- so the path carries both the step key
("<key>-kinship") and the chromosome ("<chr>-kin.cXX.txt"). Reading the log
beside it gives the cached figure: 40 steps on both panels now, kinship
included (HSNIH chr1 1,769,670 ms, chr10 1,315,176 ms).
**And a parsing bug that fix exposed:** GEMMA's `## total computation time` is
0 for `-gk` while its breakdown says `time on calculating relatedness matrix =
0.0783561 min`. The parts are summed as well and the larger of the two wins; a
figure of exactly zero becomes absent rather than a false "instant".
Worth reading off the result: on this panel the engine reports ~19 h of step
time (68.8 M ms across 20 kinship + 20 GWA), while Slurm's records show the 20
GWA jobs overlapping into a 21-minute wall -- job time and wall time differ by
more than an order of magnitude here, which is why both are labelled.
|
|
A cold LOCO scan of a large panel is ~21 minutes of wall clock (measured from
Slurm's own records: 20 GWA jobs, all started 17:40:01, 18-21 min each, last
ended 18:01:27). A client cutoff at 300 s could never have returned one, and
the connection closing took the answer with it -- the work already survived, as
a tokio task under the compute gate, but nothing kept its result.
POST /compute/gemma/async?id=<name> -> 202 at once (0.0 s measured) with
{id, state: running, status: url}
GET /compute/gemma/result/<id> -> progress while running, the finished
reply afterwards, the error if it failed
The blocking endpoints are unchanged, so nothing that fits a client's patience
switches to polling. Progress is what can be measured from outside the run: the
process's clock, plus the cluster's job counts for this request's window (the
same query meta.timing uses). The reply bodies are envelopes, like every other
success response -- the openapi check in the build's check phase is what caught
the first draft returning bare JSON, which is the contract doing its job.
Measured on HSNIH-Palmer_true trait 10404 (warm): POST 202 in 0.0 s, polls
showing state=running with growing elapsed_ms, then the finished envelope:
133,217 rows, engine pangemma, phases artifacts built 8,717 ms (a rebuild
because the stale half-pair had been removed), workflow 7,894 ms, parse 146 ms,
steps 20 cached, took_ms 45,932.
|
|
`meta.took_ms` is one number and it has misled twice: a warm re-request reports
the cache's speed, not the engine's, and a client cutoff looks like a failure.
A compute reply now carries `meta.timing` beside it:
engine gemma | pangemma
phases[] artifacts (state: built|reused|none), workflow, parse
cluster {jobs_submitted, run_ms_sum, run_ms_max, queue_ms_sum}
steps[] one per CWL step instance: step, chr, compute_ms, state
steps_summary n, compute_ms_sum, compute_ms_max, cached
Three decisions worth their words:
- **states, not just durations.** A cached step's log is still in ravanan's
store with the figure from when it ran, so every number carries `ran` or
`cached`: a warm answer's step times are the original run's, not this
request's work. The state comes from the log's mtime against the request's
start, which is per step and needs no cooperation from ravanan.
- **`jobs_submitted: 0` is the warm claim.** Slurm is asked once, after the
run, for the jobs it accepted since the request began. It is a count rather
than a boolean because a request can be half warm: a new trait over a known
panel re-uses every kinship matrix and runs only the GWA steps (measured:
20 of 40). Slurm's clock is one-second granular, so a sub-second job reports
0 run ms; the queue sum still shows the dispatch tick.
- **per-step figures come from the engines' own logs** (`## total computation
time`), which the workflow already returns for GWA and `-pve`. A scattered
step whose log is *not* a workflow output (kinship's) is located through the
job that ran it -- which is why ravanan now names jobs after the step's store
basename (separate commit, 1542662).
Measured on BXD.8 trait 10001, engine=pangemma:
warm: took_ms 4704, artifacts reused, 0 jobs, 20 steps all `cached`
(compute_ms_sum 16067 -- historical, as labelled), workflow 3687
cold: took_ms 10012, 20 jobs (kinship re-used, GWA ran), 20 steps `ran`,
compute_ms_sum 15872, workflow 9043
bin/monitor-gn4 reads `meta.timing.engine` instead of parsing note text, and
reports the cache state with it ("engine: gemma, warm").
|
|
Measured where a warm request's time actually goes, because it was easy to
blame the scheduler. It is not the scheduler: over 683 jobs slurmrestd reports
a queue delay of 0 s (median; p90 1 s, max 1 s) and run times of 1-4 s, with
the container's tuned 5 s interval already invisible to backfill. What cost
time was ravanan's own overhead, paid once per invocation:
- ~4 s per invocation just to evaluate a manifest: leaving GUIX_PACKAGE_PATH
set makes guix autoload guix-bioinformatics' whole module tree (one ABI
mismatch warning per module). The artifact workflows' manifests name only
`(gnu packages)` specs, so run_artifact now clears the variable for its
child: 12.0 s -> 7.9 s for the same cached run.
- ~7 s to walk a fully cached 40-step workflow (no jobs at all).
- pangemma ran *two* invocations per request (store, then mapping) even when
both were cached, so it paid all of that twice.
So the artifacts are memoized: a small pointer file under
<ravanan cache>/artifacts/ records where a workflow left its outputs, keyed on
the inputs' path, size and mtime (a regenerated panel file misses; a stale
pointer whose files are gone is ignored and rebuilt). Ravanan's store remains
the data cache and the mapping workflow's own key is unchanged -- this only
avoids asking ravanan to tell us something we already know.
Warm BXD.8 trait 10001, before -> after:
gemma 8.3 s -> 4.2 s
pangemma 21.1 s -> 4.1 s
and a request for a new trait is now the same for both engines (9.5 s: the 20
GWA jobs, cached K), where gemma's was 13.5 s.
Still on the table, not done here: merging the kinship and GWA steps into one
job per chromosome (20 steps instead of 40, halving the walk) at the cost of
the K-sharing across traits, a Slurm sched_interval of 1 s in the container,
and pruning ravanan's store -- 87 GB now, of which 72 GB is per-step logs.
|
|
Both used to run on the API host before ravanan was invoked, cached by two
hand-rolled file keys -- one of which (the treatment) carried a version
constant that had to be bumped whenever the script changed what it wrote, and
the other (the store) keyed on a genotype file's path, size and mtime. As
workflow jobs they are scheduled on the cluster and cached by ravanan on
(script, inputs) like every other step, and both caches go away.
They are *separate* workflows, not steps inside the mapping one, because
ccwl's `pipe` is strictly linear: a step sees only the immediately preceding
step's unconsumed outputs, and GWA needs the prepared genotypes *and* the
kinship matrix -- a diamond ccwl cannot express (verified with a three-step
probe; ravanan implements no CWL `when` either, so an optional step is not an
option). So:
cwl/gemma/prepare.scm mode + BIMBAM pair (+ cross, individuals) -> pair
cwl/gemma/store.scm BIMBAM pair -> pangemma's lmdb store
cwl/gemma/manifest-artifacts.scm bash, coreutils, gawk, r-minimal,
r-qtl2, python, python-numpy, python-lmdb
and the server chains them: prepare when `impute` is not `none`, store when
the engine is pangemma, then the mapping workflow with the resulting paths.
Ravanan sets the manifest profile's search paths inside the job, so python3
there finds numpy and lmdb without the PYTHONPATH the API host needs.
Measured warm on BXD.8 trait 10001 (gemma / pangemma, rows):
none 21055 3.9 s / 10.3 s mean 21056 10.5 s / 16.5 s
hmm 20453 10.2 s / 16.5 s
Against 26.8 s for hmm through the host-side path before this.
Three things had to be right that were not:
- A step input cannot be optional here, so `cross` and `individuals_file` are
always passed -- an empty directory and an empty file for the modes that
ignore them.
- `cross` is a *path*, not a CWL Directory: ravanan's slurm-api backend does
not stage a Directory input (the staged path reached the job and R's setwd
failed; the same workflow under single-machine succeeded), so the server
copies the cross under its cache directory, which the nodes can see.
- `scripts/prepare-genotypes.sh --out` is now absolutized before use, because
qtl2-impute-bimbam.R does setwd(cross_dir) and writes <prefix>.* from there:
a relative prefix put the outputs inside the cross directory and the job's
output globs matched nothing. It also grew --impute-script (a staged script
is not beside its companion) and always writes <out>.individuals.txt, since
the caller needs the HMM's individual order to align trait values.
Also: a request that asked for a treatment no longer falls back to the
in-process wrapper when the Slurm route fails. The wrapper reads genotypes as
they stand, so falling back on `impute: hmm` answered 21,055 rows where the
request meant 20,453 -- a wrong answer under a "degraded" note. Treated
requests (and pangemma ones) now fail instead.
And ravanan's output may be one File or an array of them: a scattered step
reports an array, a single-step workflow one File, which is what "no store
array in ravanan's output" was.
Deployed and verified on the production instance: all six engine x mode
combinations answer 200 with the expected row counts, and
bin/monitor-gn4 --tier all is 50 ok / 0 failed.
|
|
Two places still said pangemma "cannot represent a gap at all" and that its
store builder refuses impute=none -- written against an older pangemma. The
store keeps them (NaN for Gf, 255 for Gb) and pangemma mean-substitutes per
marker as GEMMA does: measured, impute=none through the pangemma engine
answers 21,055 rows with `af` identical to GEMMA's on the same panel.
What `impute` does change is which markers and individuals map, and it does so
before the store is built, so each mode has its own store (they are different
genotype files). Measured warm on BXD.8 trait 10001:
none 21,055 rows, 20 chromosomes gemma 4.0 s pangemma 3.9 s
hmm 20,453 rows, 19 chromosomes gemma 26.8 s pangemma 15.8 s
mean 21,056 rows, 20 chromosomes gemma 16.3 s pangemma 16.0 s
The hmm figures include the R/qtl2 imputation the first time and reuse it from
RAVANAN_CACHE_DIR/imputed/ afterwards; mean maps one marker that complete-case
treatment drops, which is why the three are not interchangeable answers.
|
|
The pangemma workflow (cwl/gemma/gemma-loco-mdb.scm, committed but until now
unreachable: nothing pointed at it) is now selected per request. It differs
from its gemma twin in the genotype input only -- pangemma reads the
chromosome from the store's key, so it needs neither `-g` BIMBAM nor the `-a`
annotation -- so the two run the same kinship-then-GWA scatter and answer the
same question:
gemma 21,055 rows in 4.1 s af and l_mle identical to pangemma
pangemma 21,055 rows in 3.9 s beta/se/p_lrt median |d| 2.6e-4/3.6e-5/1.3e-4,
max 1.2e-3/5.4e-4/6.2e-4
(trait 10001, BXD.8, lmm 9, warm; pangemma builds its GRM in float32, which is
where that third decimal goes -- verified against the store itself: Gf,
198 samples, 21,056 markers, 21,056 geno records.) At BXD.8 size there is
nothing to win; on HLC the same 23 chromosomes cost 141 s of cluster job time
against 958 s for gemma on BIMBAM, which is the point of the engine.
Selection is a request field, defaulting to gemma, so no existing caller
changes:
- GemmaEngine::{Gemma,Pangemma} carries the workflow's input list and the
compiled-CWL suffix as well as the parse aliases (gemma-gn2, pangemma-lmdb);
an unknown value is 422 invalid_engine, not a silent gemma.
- check_workflow_inputs now takes the engine's own list, so a stale workflow
is still refused by name -- the mdb workflow declares `store` where the
gemma one declares `genotype_file` and `snps_file`, and handing it the
wrong one fails deep inside cwltool as "expected File but got null".
- The store is built once per genotype file, not per trait, by geno2mdb.py
(GENO2MDB_CMD) into GEMMA_LMDB_CACHE_DIR, keyed on the genotype file's
path, size and mtime plus the annotation's contents. Gf always: exact for
a mean-genotype panel, where Gb is exact only for integer calls. Written
aside and renamed, so a concurrent identical request sees no store or a
complete one; two first-runs both build it, which the rename makes
harmless rather than wrong. Measured: 22.3 s cold (store built), 3.9 s
warm, and a second trait on the same panel reuses the store.
- There is no fallback for this engine. The in-process runner is
gemma-wrapper on BIMBAM, so falling back would answer a different question
under the requested engine's name: pangemma forces the ravanan route even
when GEMMA_ENGINE=local, and its failures are returned as they are.
Also fixed on the way: GemmaError::CommandFailed said "gemma-wrapper (<step>)
failed" for every step, which blamed the wrapper for geno2mdb and ccwl
compile; the step now names its own tool ("gemma-wrapper gwa failed",
"geno2mdb failed").
Deployment knobs (README and docs/ravanan-slurm.md updated):
GEMMA_RAVANAN_WORKFLOW_MDB, GEMMA_RAVANAN_MANIFEST_MDB (a manifest naming
pangemma-git -- a manifest change needs a cold run, since ravanan keys a step
on (script, inputs)), GENO2MDB_CMD and GEMMA_LMDB_CACHE_DIR.
Deployed and verified on the production instance: both engines answer 200 on
the same request through ravanan on Slurm, and bin/monitor-gn4 --tier all is
50 ok / 0 failed. One deployment detail worth recording: geno2mdb.py needs
numpy and python-lmdb, which the store script's own shebang interpreter does
not have, so the server now runs with PYTHONPATH pointing at the profile's
site-packages -- without it the engine answers 502 "No module named 'numpy'".
|
|
Slurm is now the default engine (GEMMA_ENGINE=slurm) because a ravanan step
is keyed on (script, inputs) and the K matrix is one of those inputs, while
gemma-wrapper keys its GWA cache on the phenotype file and the chromosome
alone. Measured on BXD.8 (198 strains, lmm 9, synthetic trait 4242): with a
stale chr1 LOCO K left in the wrapper's cache, 2060 of 21055 rows disagreed
with both Slurm routes -- gemma through ravanan and pangemma on lmdb -- and
clearing that GWA entry made all three agree cell for cell. A rebuilt K can
therefore leave stale association rows behind on the wrapper path, and
cannot on the Slurm one.
compute_gemma_ravanan's body moved into gemma_via_ravanan(...),
parameterised by the endpoint name it reports in errors and claims, so
/compute/gemma calls it first and keeps its own body as the fallback. Only a
5xx falls back: Slurm or ravanan unreachable, or the engine exiting
non-zero. A 4xx is the caller's error and is returned as such, and a
numerical disagreement never falls back, because that would hide a
regression behind an answer from the other engine. The fallback takes a
fresh light claim -- the first went with the Slurm attempt -- and adds an
"Engine: the Slurm route was unavailable (<status> <code>), so this answer
comes from the local gemma-wrapper run instead" note, so a reply says which
engine produced it.
Clone derives on ComputeGemmaParams, GemmaRequest and GemmaSample, and a
Clone impl for Ctx: a request id and a start instant, so a clone is another
handle on the same request.
Validated on two scratch instances of the built tree against the live
database: :3002 answers warm from ravanan in 3.79 s, and :3003 with
RAVANAN_SLURM_API_ENDPOINT pointed at a dead port answers 200 in 21.38 s
from the local wrapper, with the note naming "502 gemma_failed", on 21055
rows identical to the Slurm answer.
|
|
The note still told callers that hmm collapses to one allele and to
prefer none or mean. That was true with the allele coded 3; with the
codes fixed the path keeps all 20453 autosomal markers polymorphic and
puts its top at rsm10000005700, p 6.6e-07 -- the locus /compute/qtl2
(3.8916 LOD) and plain GEMMA (5.90e-07) both name. Before the fix it
was 11912 markers peaking on chromosome 5.
The warning that survives is the honest one: this mode can still fail
quietly if the HMM has nothing to go on, so a surprising scan is worth
checking rather than trusting.
|
|
The conversion wrote qtl2's control file and CSVs by hand in Rust. Its
output is an R/qtl2 cross, so the script does it and write_control_file
describes it: one implementation of the format, qtl2's. What Rust keeps
is the endpoint's own limit -- a .geno panel carries no founder
genotypes, so a multiparent crosstype is a 422 with a reason, and the
cross type follows @type and the heterozygous policy.
prepare_cross now runs
Rscript scripts/qtl2-convert-geno.R --geno GROUP.geno --out DIR
--het drop|keep --crosstype riself|f2
writes the cross into the same versioned cache directory (now v6: the
files it writes are qtl2's own layout), and reads back the report the
script leaves beside it -- markers, non-autosomal, individuals,
het_dropped, cells -- instead of counting them itself. A failed
conversion reports R's own complaint. New configuration key
QTL2_CONVERT_SCRIPT (default scripts/qtl2-convert-geno.R).
The Rust writer's 250 lines are deleted, along with count_calls and
metadata_het.
Measured, BXD trait 10001 on the same request:
before (Rust, alleles 1/3) top rsm10000005730 chr8 LOD 3.685
after (R/qtl2, alleles 1/2) top rs32579649 chr8 LOD 3.8917,
rsm10000005700 3.8916
GEMMA LMM, same trait rsm10000005700 p 5.90e-07
so the wrong allele code was flattening this endpoint's own scan too: it
still found chromosome 8, at a neighbouring marker and 0.21 LOD lower,
with the marker GEMMA picks not in its top three. The two engines now
agree on the locus. Cost: 38.3 s cold for 20453 autosomal markers (the
R conversion is ~35 s of it), 3.5 s with the cross cached.
|
|
The HMM smooths along a genetic map, and ours is degenerate: the .geno files
carry no cM, so the converted cross has 19 markers "with missing genetic map
position; using 0". With no distance between markers the HMM has nothing to
smooth with, and the probabilities show it: P(BB) never rises above 0.5 and
every individual is called AA. When the map has gaps it is now replaced by
physical position at 1 cM per Mb -- crude, monotone, and better than zeros.
That fixed part of it (the spread of calls at a marker went from sd 0.21 to
0.34 where the panel has 0.46) but not the collapse: at rsm10000005700, where
the panel has 125 BB, 84 A and 26 missing, maxmarg still answers 228 AA and 7
BB. Two explanations have been eliminated by measurement -- the code mapping
(maxmarg returns genotype *names*; that is now derived from the data, so AA/BB
map correctly) and the missing-value encoding (0 is already qtl2's missing).
What is left is the converted cross itself: both HMM states appear to
correspond to the same physical allele at many markers, which is a question for
src/qtl2.rs, not for the imputation.
So the reply now says so out loud: "NOT YET VALIDATED on a riself panel ...
treat the hmm scan as experimental and prefer none or mean". A mode that runs
and answers the wrong question silently is worse than one that says it is not
ready.
|
|
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).
|
|
impute=none and impute=mean already worked; impute=hmm died every time with
"gemma-wrapper's response listed no association output files", which named
neither the cause nor the place. Three separate faults, each measured:
1. chromosomes_from split the SNP map on whitespace only. The panel's own
file reads "marker, 3001490, 1" (spaces after the commas) and the HMM file
scripts/qtl2-impute-bimbam.R writes reads "marker,3001490,1" -- one token --
so the chromosome list came back empty and ravanan was handed an empty
scatter. It now splits on commas and whitespace both.
2. The HMM calls come from the qtl2 cross, whose individuals are the whole
panel: 235 for BXD.8 against the 198 animals that carry trait values.
Passing the panel's positional values against those columns makes every
individual missing -- GEMMA says "no individuals in common", ravanan says
"no association output files". The R script now also writes
<prefix>.individuals.txt and the ravanan path re-aligns the trait values to
it by name; the reply says how many individuals the HMM calls carry.
3. A relative PREPARE_GENOTYPES ("scripts/prepare-genotypes.sh") is only found
when the server runs from its checkout. An instance started elsewhere
answered "could not run scripts/prepare-genotypes.sh: No such file or
directory". A relative default is now resolved against the checkout that
GEMMA_RAVANAN_WORKFLOW points into.
State after these: none 200 (21 055 rows), mean 200 (21 056 rows, with its
note), hmm now runs the whole workflow (the run took 32 minutes single-machine
before failing) and stops on ravanan's own manifest cache -- "source file
.../manifest.scm newer than compiled .../ccache" -- which is the next thing to
fix and is not about genotypes.
Same-genotype agreement, measured separately (gemma on the HMM BIMBAM versus
pangemma on an LMDB store built from that same file): identical top marker
(rsm10000010578, p 1.04e-05), Spearman rho 0.999971, top-50 overlap 50/50,
median |difference in -log10 p| 0.00000. The engines agree; what was left was
plumbing.
|
|
"How do we treat a missing genotype?" now has one answer shared by every engine,
so the same trait can be mapped both ways and the results compared:
none the file as it stands -- GEMMA does complete-case per marker and reports
n_miss (235 individuals for some markers, 234 for others)
mean every gap takes that marker's mean (complete file, all individuals)
hmm R/qtl2's HMM predicts the gap from flanking markers (maxmarg on the
genotype probabilities, the calls /compute/qtl2 itself maps on)
scripts/prepare-genotypes.sh is that one place. It writes <prefix>.bimbam.txt
and <prefix>.snps.txt and nothing else, so the two engines consume the same
files: /compute/gemma/ravanan takes `impute`, and the pangemma store builder
(the next endpoint) takes the same script with --mode mean|hmm into the LMDB
makers.
On the ravanan path the files are cached under RAVANAN_CACHE_DIR/imputed/
<panel>-<mode>, so a second request for the same panel and treatment costs
nothing: mean is a single pass (1.7 s for BXD.8), hmm is the qtl2 HMM (10 s
including computing the probabilities the first time, then cached beside the
cross). The reply says which treatment ran, and `hmm` refuses without a group
(422 impute_needs_group) since the cross it predicts from is the group's.
Measured, BXD.8 (20 453 markers, 235 individuals), missing calls in the
prepared panel: 1 465 of 4.8M as NA. Both modes produce complete files of 9.2
and 10.0 MB, and a request with impute=mean or impute=hmm writes them and then
proceeds to ravanan. What this box could not finish is the run itself: ravanan
in the scratch instance failed on its own manifest cache ("manifest.scm newer
than compiled ... warning") and, for hmm, answered "no association output
files" -- environment, not the preparation, and the next thing to settle.
Why not keep it in the workflow: the treatment has to be the same for both
engines, and pangemma's store builder needs the file *before* the workflow
exists (it builds an LMDB store from it). One script, two consumers.
|
|
GEMMA's reply offered R/qtl as the way to get significance thresholds,
which is the wrong advice for a relatedness-structured panel: haley-knott's
permutation shuffles phenotypes without regard to the kinship, so its null
is anti-conservative exactly where an LMM was chosen in the first place.
BulkLMM is the same model family as this scan and permutes by rotating the
data through the kinship decomposition, so its thresholds do respect
relatedness -- and it is fast.
The 200 reply now carries three actions in order: draw it (/plot/gemma),
POST /compute/bulklmm with a ready-to-post body (group, trait_name,
samples, nperm 500, seed 1), then POST /compute/rqtl relabelled as a
non-LMM cross-check with a warning that its threshold is anti-conservative
here.
Measured on BXD trait 10001, so the text asserts nothing it has not seen:
GEMMA's best marker is rsm10000005700 on chr8 (p_lrt 5.9e-07, -log10 p
6.23) and BulkLMM's best is the same marker (LOD 3.866, beta -0.0615) --
at the peak the two LMM families agree on the locus. Their thresholds are
not interchangeable: with 500 rotations BulkLMM's 0.05 threshold is LOD
3.78 (the peak clears it, and a second seed gave 3.62), while R/qtl2's
LOCO scan1perm on the same trait and permutation count gives 2.62, so a
global kinship is the stricter null; and LOD 3.87 and -log10 p 6.23 are
different scales for one marker, so a BulkLMM threshold must never be
compared with a GEMMA p-value directly.
The 422 permutations_not_supported text quotes the same measurements
instead of prose, and the suggested body was run verbatim to check it:
POST /compute/bulklmm with it returns 200, 21056 rows, and the threshold
note "500 rotations (seed 1): alpha 0.01 LOD 4.10, alpha 0.05 LOD 3.62".
|
|
Parents and F1s are excluded by default (as in GeneNetwork2/3), with
include_parents_f1 to keep them all. That boolean was not enough for what was
asked -- "include these, drop that substrain" -- and the exclusion list itself
is data (parents_and_f1s.json, seven groups) that no request can reach. F1
names also differ per group (B6D2F1 for BXD, BHF1/HBF1 for BXH,
C57BL/6JxBXD037F1 for the intercross F1s), so pattern matching is the wrong
tool.
Every group-mapping endpoint -- /compute/gemma, /compute/gemma/ravanan,
/compute/rqtl, /compute/qtl2, /compute/fitqtl, /compute/bulklmm -- now takes
"individuals": {"include": [...], "exclude": [...]}
applied after the parent/F1 rule, exclude winning over include. An unknown name
is a 422 invalid_individuals whose message lists the panel: a silently dropped
animal changes a kinship matrix without anyone noticing, so the failure has to
be loud. genotypes::select_panel is the one implementation, and it returns what
it did (dropped parents/F1s, re-included by name, excluded by name) so the
Genotype note can say it: "197 individuals, 38 parents/F1s dropped; 1 excluded
by name".
The note now also spells out the distinction that makes this option
treacherous: the kinship uses *every* individual in the genotype file, the
association uses only those with a trait value -- GEMMA reads no phenotypes for
the kinship. So "include the F1s" changes the relatedness structure without
putting the F1s in the fit, and a request can legitimately have 234 individuals
in the genotype file and 34 in the association. Verified on BXD.8: excluding
BXD1 gives 197 individuals / 33 values; include_parents_f1 with an F1
re-included and a substrain excluded gives 234 / 34.
A basket supplies values by name, so a selection applies to a basket-fed
mapping the same way: the individuals excluded are simply not in the panel any
more, and their basket values are ignored.
GenotypeError gains Invalid for this (422) so a caller's typo is not reported
as a missing genotype file; the read-only endpoints that can never see one map
it the same way for exhaustiveness.
|
|
cannot do
Two gaps, both invisible until a real request ran against a cluster.
The endpoint read only genotype_file, snps_file and trait_values from the
request; group, genotype_version and samples were accepted by the shared
request type and silently dropped. A /compute/gemma-shaped request
(group + samples) therefore arrived as empty paths and empty values and
died with "I/O error: No such file or directory (os error 2)" from
reading "". Running it exposed the second gap in the same breath: the
gate sized the request from trait_values.len(), so a samples-only request
was sized 0 and took no concurrency slot at all.
resolve_inputs is now one function in routes/gemma.rs, called by both
handlers: upload materialised into the pair the engine reads, basket
resolved to named values, group prepared with the parent/F1 and
empty-genotype rules, named samples aligned by name onto whatever
individuals the file has, positional values checked against the panel
size. That block was ~250 lines of duplicated rules inside compute_gemma,
which is how it drifted in the first place; the direct runner now calls
the same function and keeps only its covariates, normalization and gate.
The ravanan reply also carries the input notes now (which genotype
version, how many values aligned, what was dropped), so a run says what it
mapped as well as where the peak is.
Refused rather than ignored, because the CWL workflow has no step for
either: covariates (422 covariates_not_supported) and normalize (422
normalization_not_supported), each naming /compute/gemma as the endpoint
that can do it. A new test asserts both refusals happen before any job is
submitted, so it needs no ravanan, ccwl or cluster.
Verified against the Slurm container from gn-machines: group: BXD became
40 Slurm jobs (20 kinship + 20 GWA, scattered over the snps file's
chromosomes), all completed, 21 055 rows in ~3.5 min. README and
docs/ravanan-slurm.md record the four requirements that run turned up,
three of them not obvious: ccwl on PATH, a ravanan build with the
--slurm-api-endpoint fix, the *server's* HOME writable by the job user
inside the cluster (gemma-wrapper locks $HOME/.<hash>.lck there), and
GUIX_PACKAGE_PATH for the manifest.
|
|
The OpenAPI description still promised "a Bonferroni reference line by
default", and GEMMA's own suggested plot call said the same. Both now say
what the code does, and where the number comes from: the plotter computes
0.05 over the analysed markers -- conservative under linkage and unrelated
to relatedness -- and ?thresholds= takes one computed elsewhere, each line
labelled with its source.
Also corrected in the README's /plot section and in SKILL.md, where the
same promise had been copied.
|
|
We do not run GEMMA permutations -- each repeats the whole LOCO scan and the
gate gives GEMMA one slot -- but "not supported here" is not the same as
"not available". The refusal now says both:
1. POST /compute/bulklmm with nperm: 1000 -- an LMM whose thresholds come
from rotations that keep the kinship (R/qtl's nperm does not, and is
anti-conservative on a structured panel);
2. run GEMMA's own permutation locally. The reply's notes already name the
bimbam pair and the phenotype file, so `gemma-wrapper --permutate` or
`gemma -lmm 9 --permutate` on those inputs reproduces exactly the null
GEMMA would have used -- hours instead of seconds, which is the honest
price of that particular null.
docs/bulklmm.md gains the table this belongs in: three ways to get a
threshold, ordered by how honest the null is for a structured panel
(rotation with kinship; GEMMA's own LOCO permutation run locally; R/qtl's
nperm as a sanity check only). SKILL.md says the same in two lines.
tests/gemma.rs now asserts both halves of the refusal, and the earlier
assertion on /compute/rqtl -- which stopped being true when the refusal was
rewritten -- is replaced rather than left passing by accident.
|
|
Reported: a BulkLMM run does not look multicore. It is not a
misconfiguration. BulkLMM's single-trait `scan()` -- what this endpoint
calls -- has no `Threads.@threads` at all; the package threads
`bulkscan()` (many traits) and bulkscan_helpers, not scan. The
parallelism that was visible before was BLAS (OpenBLAS defaulting to all
96 cores here), which is why `user` time ran 4x `real` while Julia
threads made no difference: --threads 1 13.7 s, --threads 4 12.3 s.
* The driver splits the markers into independent blocks and scans them
on Julia threads (--blocks, default = BULKLMM_THREADS). It is exact:
the LOD for each marker is independent given the null variance
components, which depend on y and K only. Verified identical -- peak
LOD 9.589938 and the same permutation thresholds at 1 and 4 blocks --
and permutation thresholds combine by taking each permutation's
maximum across blocks before the quantiles, which is what a
genome-wide threshold is.
* The parsed matrix and the kinship are cached per panel (read 1.3 s ->
0.4 s, kinship 0.9 s -> 0), because both depend only on the cross.
* The summary in `notes` now says what ran: julia threads, blocks, BLAS
threads, and the read/scan split.
* The hand parser is back: CSV.jl into a DataFrame is an order of
magnitude slower for a 21056 x 235 matrix (14-17 s against 2 s).
* BLAS is capped at 4 threads -- 96 was slower (10.5 s against 7.7 s for
one scan).
Measured on BXD.8 trait 16627 (21056 markers): 1 block 20.9 s, 4 blocks
18.3 s, same answer. The gain is modest because the LMM loop is ~8 s of
the run and each block re-estimates its variance components. Where the
cores pay is bulkscan() -- many traits in one process, threaded over
trait blocks -- which is the shape the next endpoint wants; documented in
the README rather than left as folklore.
|
|
Two things asked for, and one bug each.
* POST /uploads/genotypes with an existing name now REPLACES it. A
genotype is the user's file to keep, not a record the deployment
curates; the digest in every reply says which version ran.
* genotype_upload on all four engines -- /compute/{rqtl,gemma,qtl2,
fitqtl} -- in place of genotype_file/group. The server writes the
form each engine reads: a GN .geno for R/qtl and R/qtl2, a BIMBAM
pair (new: genoupload::to_bimbam, coding from the base's
@mat/@het/@pat, NA for missing, snps as marker/bp/chr) for GEMMA. No
user path travels with a request.
Verified against the full 3811-marker BXD.4 matrix uploaded as an update:
rqtl 3811 rows, gemma 3809, qtl2 3730, fitqtl by marker.
The bug worth naming: values given by name were being aligned against a
file, and for GEMMA that file is BIMBAM, which has no individual names --
so the phenotype file came out empty and the wrapper failed with a Ruby
backtrace that said nothing. GEMMA's values are now ordered by the
upload's own individual list before the pair is written. The related
fixes: rqtl and fitqtl align named values onto the file's individuals
(they previously demanded its column order), and genotypes::align_to_file
is the one place that does it.
tests/genoupload.rs: mapping an upload on rqtl/qtl2/fitqtl with values by
name, and replacing a name (one row in the listing, a new digest). GEMMA's
LOCO kinship needs more markers per chromosome than a small fixture has,
so it is exercised against a full panel rather than in the fixture.
|
|
Three things the first cut was missing, and both were asked for.
* An automatic version history. Revision 1 is the column as first
stored and each PATCH adds one -- with its own digest and Unix
timestamp -- and earlier revisions are kept. GET
/baskets/{name}/revisions is the history, ?revision=N reads an old
column, and a mapping can pin one: {"basket": "wbc-edit@2"}. That is
the point of a digest: a result quoted yesterday can still be
reproduced after the column has moved on.
* Files named for the user, not a hash of the subject:
BASKET_DIR/<user>.sqlite (0600, WAL). Tokens rotate, subjects do not,
so a new token finds the same baskets -- and an operator can see
whose baskets a file holds. A subject that is not filename-safe is
sanitised and disambiguated with a short digest, and a pre-naming
hash file is renamed on first use rather than orphaned.
* /compute/rqtl and /compute/gemma and /compute/fitqtl take `basket`
too, so all four engines share one meaning: a basket resolves to the
same (name, value) pairs a client would have posted, and every reply
records the revision and digest it ran.
The schema upgrade is a real one, not a reset: an older file's single
column becomes revision 1 of the history, cells copied across with the
digest and timestamp they already had. Tested by building the old schema
by hand and opening it (an_older_file_is_upgraded_with_its_column_intact),
which is also how I found that the migration was recreating a table the
base schema had already made.
Verified on all four engines, head and pinned: rqtl 3811 rows, gemma
3809, qtl2 3730, fitqtl 3 markers -- each reply carrying "Basket '...'
revision N (digest ...)".
|
|
The gotcha notes in SKILL.md tell an agent to count the animals per
genotype class before believing a peak; a note in a document is only
found by whoever reads it, so the replies now say it too, at the peak
they just computed.
* suggest::class_hint builds
/groups/{g}/genotypes/{v}/markers/{peak}/classes?trait={trait_id} --
a real GET with one placeholder, because a scan knows the trait's
values, not its PublishXRef.Id.
* /compute/{rqtl,gemma,qtl2,fitqtl} add it to `next` after the PheWAS
link, naming the peak each reply found and the version the request
named (a {version} placeholder when it named none).
* The genotype subtree carries the template too: a version's detail,
and a concrete marker's own links.
* /compute/qtl2 gains the sentence that explains the divergence: on a
riself (riset) panel heterozygous calls are dropped before the scan
(R/qtl's convert2riself) and the HMM re-imputes them, while GEMMA
keeps them at dosage 0.5, so a mostly-H marker cannot peak there and
two engines can name different markers of one region without either
being wrong.
tests/links.rs: a scan's reply offers the class counts at its own peak --
the link names the version and the peak marker the reply reports, and
leaves {trait_id} for the caller.
|
|
A caller that knows only /version should be able to reach anything by
following links. Until now `next` was thin and uneven: the genotype
subtree offered none at all, the group record offered one, /version
offered nothing, and two links it did offer could not be followed.
* suggest:: now builds the graph: root_links (groups, species,
mapping-methods, openapi), genotype_version_links (frequencies,
marker names, a marker's location and tally, the group, the scanning
actions), unlisted_genotype_links, marker_links (location, tally,
marker list, panel tally, PheWAS at that marker), group_links and
trait_links. Envelope::with_links / with_links_except add them,
deduplicating and never suggesting the response the caller is
already reading.
* Wired through the genotype surface (listing, version detail, markers,
location), both frequencies routes, the compute endpoints, groups,
traits, both value routes, species, datasets, publications,
accessions, search, mapping methods, phewas, correlation and
/version.
* Fixed what was not followable, because `next` promises a GET that
returns 200 and a client is the one that finds out otherwise:
- /groups/{g}/phewas without a locus is a 422. Bare PheWAS links are
gone; comput endpoints now link ?locus=<their strongest marker>
(suggest::peak_marker_of, computed before the rows move).
- /datasets and /publications are not routes; root_links offers the
listings that exist (/groups, /species, /mapping-methods) and
/openapi.json.
- /search?q= with an empty query is a 400, so it is not a link.
- the correlation endpoint's "/compute/correlation" was a POST in
`next`; it is in `actions` now.
- marker_links pointed at /markers/{marker}, which is not a route;
it points at /markers/{marker}/location.
tests/links.rs walks the graph two hops from a dozen seeds and fails on
any link that does not answer 200, plus a check that a tally leads to the
marker list and to a marker's location, and a location to that marker's
tally and its PheWAS.
|
|
DOL (200 individuals, 112 913 markers, one genotype version) failed on
R/qtl with "There are missing chromosome IDs" and on GEMMA with a bare
wrapper bail-out. Two unrelated causes, both in our own code.
**R/qtl: a genotype code collided with a chromosome name.** DOL's header
says `@unk:X` -- X is the code for a missing genotype -- and the wrapper
passed that to `read.csv(na.strings=...)` for the *whole* file, so every
marker on the X chromosome lost its chromosome ID and `read.cross.csv`
refused the map. The unknown code now applies to the genotype columns
only. DOL scans: 112 913 markers in 42 s, where before it never got past
reading the file. Same fix in scripts/qtl_fitqtl.R, which shares the read.
**GEMMA: its leave-one-chromosome-out run cannot fit the Y.** With LOCO the
DOL panel is scanned per chromosome, and the Y run dies inside BLAS --
`Enforce failed for N>0 in src/fastblas.cpp ... fast_cblas_dgemm` -- taking
the whole request with it (a 502 whose detail is the wrapper's banner).
The mitochondrial chromosome has the same shape of problem. `prepare` for
the GEMMA engine now writes the bimbam pair without the Y and M markers
(cached beside the individual subset, line-aligned so the geno and snps
stay in step), and the note says what was left out: "46 Y/M markers left
out (GEMMA's LOCO cannot fit them)". DOL maps: 106 515 rows in 49 s.
**And the four tests that had been failing since before this work**, all
stale expectations rather than product bugs:
* `benchmark_questions` pinned two traits to "page 2" of a 100-per-page
search when they rank ~190th and ~219th of 246 -- one re-index pushes
them over. It now walks up to three pages and asserts presence and LOD,
not the page; and the helper `search()` pages, because a benchmark row
can name a trait that ranks outside the first hundred of its own query.
* `no_db_mode_degrades_gracefully` asserted exactly one hit for "alcohol"
from the index alone. The index grew; the behaviour under test is that
the search still answers, within the limit, with the database-backed
fields null. That is what it asserts now.
* `search_proxy_scenarios` and `search_parity_replay` never pinned the
engine they test, so an ambient `SEARCH_ENGINE=native` made the proxy
scenarios answer from the local index: a 200 where a 422 was expected,
and "expected 2 upstream calls, got 0" for every replayed query. Both now
set `SEARCH_ENGINE=forward`.
* src/genotypes.rs: `DEGENERATE_CHROMOSOMES`, `drop_degenerate_chromosomes`,
`Prepared.markers_dropped`.
* src/routes/gemma.rs: also the 500 that `eb5320d` introduced -- counting
parents/F1s from `panel - keep` instead of subtracting the exclusion
*set*, whose length can exceed the panel (subtract overflow).
* scripts/rqtl_wrapper.R, scripts/qtl_fitqtl.R: na.strings scoped to the
genotype columns.
* tests/{benchmark,no_db,search,search_parity}.rs: as above.
Verified through the API on DOL trait 10003: R/qtl 112 913 rows, GEMMA
106 515 rows. gemma/rqtl/fitqtl suites green (14, 10, 4).
|
|
Asking whether the singular matrices could be fixed turned out to have two
answers, one of them a real bug on our side.
The bug: a panel can name individuals whose genotype row is empty, and an
empty row makes the kinship matrix singular. GEMMA then reports
"eigenvalues close to zero" and dies in LAPACK with
`LUDecomp ... input domain error` -- a message about linear algebra for a
problem that is a missing genotype. Measured on this deployment's own files:
BXD-AE.4 136 of 344 individuals have no genotypes
MDP 93 of 178
BXD-Heart-Metals.4 200 of 481
HET3-ITP.3 2867 of 2867 (the whole file is empty)
Dropping them makes those panels map: BXD-AE.4's GWA step goes from a
failure to 3.2 s, and MDP's kinship step from a failure to success. The
individuals contribute nothing to a scan either way, so nothing is lost;
`notes` counts them, and the "Genotype:" line no longer blames parents/F1s
for them (`prepared.excluded` is "panel minus kept", which now includes
both, so the two counts are separated).
Not the cause, but worth naming: `AXB` fails earlier still, on its
annotation -- `ERROR: Enforce failed for D1Mit296 in src/gemma_io.cpp ...
ReadFile_anno` -- which is a broken `.snps` file, not a matrix. That wants a
pre-flight check of the annotation (report the offending marker) rather
than a GEMMA failure, and is not in this commit.
Considered and rejected: a ridge on K (`K + epsilon*I`) would work
mathematically but GEMMA has no option for it and the wrapper caches K by
content hash, so it would mean patching the wrapper's cached matrix; `-gk 2`
and dropping markers do not add rank; and the non-LOCO path is the one that
does not run at all here.
* src/genotypes.rs: `individuals_with_genotypes`, one pass over the bimbam
file marking the individuals with any genotype at all.
* src/routes/gemma.rs: filter `keep` by it before alignment (so the trait
values drop with them), and say so in `notes`.
* tests/gemma.rs: `individuals_with_no_genotypes_are_left_out` -- BXD-AE.4
maps, the note names the drop and the reason, and the genotype line no
longer claims 344 individuals.
* README.md: the behaviour and why it exists, under /compute/gemma.
307 tests pass; the same four as before do not.
|
|
GeneNetwork2's trait page offers a set of normalisations, and its mapping
page warns about outliers without ever fixing them. This adds both, under
one spelling that `/compute/rqtl`, `/compute/gemma` and
`/groups/{g}/traits/{id}/values` all share:
normalize none | log2 | log10 | sqrt | negate | zscore |
robust_zscore | rank (GN2's names `invert` and
`qnorm` accepted)
winsor_quantile clip each tail at a fraction, e.g. 0.05
winsor_fences clip at Q1-k*IQR / Q3+k*IQR, GN2's outlier rule
They run in a fixed, reported order -- transform, then winsorise, then
standardise -- so clipping acts on the scale being analysed and the result
lands exactly on mean 0 / sd 1 rather than on the sd of clipped data. The
note gives the steps *in the order they ran* (`winsorized at Tukey fences,
then zscore`), the count clipped in each tail, and how many values sit
outside Tukey fences -- the warning GN2 gives before mapping and this API
gave nowhere.
**Checked against genenetwork.org itself.** GN2's public trait page embeds
its own reference values (`js_data.qnorm_values` / `zscore_values`, the
`data-qnorm`/`data-zscore` attributes), so there is an oracle for the two
transforms whose definition matters. On BXD trait 10010 (28 samples):
`rank` matches to 0.0005 and `zscore` to 0.0005 -- i.e. GN2's
three-decimal rounding. Getting there found a real disagreement: GN2 uses
`scipy.stats.mstats.zscore`, whose default is `ddof=0`, so its z-scores use
the **population** sd; ours used the sample sd and came out
`sqrt((n-1)/n)` low (1.8% at n = 28). We now match GN2.
Two GN2 quirks deliberately not reproduced: its "Quantile" is a rank-based
inverse-normal (Blom) transform, so it is called `rank` here; and its
`sqrt` silently adds 1 when a value is in [0,1], which shifts every effect
size -- a negative value is refused instead.
* src/normalize.rs (new): the transforms, percentile/Tukey fences, Blom
scores over an Acklam inverse-normal, `Params` for query/body use,
`to_json` for suggestions, and eleven unit tests -- the quantile table,
ties sharing an average rank, missing values never imputed, GN2's own
`find_outliers` example, and the note's wording.
* src/routes/{rqtl,gemma}.rs: the three fields, applied **after**
alignment (over the samples that enter the fit) and before anything reads
the values, with the note; the R/qtl permutation suggestion and GEMMA's
R/qtl suggestion carry the pipeline.
* src/routes/groups.rs, src/suggest.rs: `?normalize=` on the values
endpoint, and the mapping bodies in `actions` carry the same fields -- a
caller who fetches z-scores must map those numbers, not the raw ones.
* tests/groups.rs: values are mean 0 / population sd 1, the note says so,
every `/compute/*` suggestion in `actions` carries it, and an impossible
pipeline is a 422 `invalid_normalization`.
* README.md, docs/www/SKILL.md: what each name means, the order, the
population-sd parity, and that effects come out on the transformed scale.
298 tests pass; the same four as before do not.
|
|
A GEMMA row now carries the effect beside the p-value it belongs to:
`… beta, se, l_mle, additive, p_lrt`. `additive` is `-beta/2`, which is
what GeneNetwork's own tables and CSV call the additive effect
(gn2/wqflask/marker_regression/gemma_mapping.py:240). Halved because half
the difference between the two homozygotes is the usual additive effect;
negated because GN2's BIMBAM conversion codes `@mat` as 1, so GEMMA's beta
is per *maternal* copy while GeneNetwork's published sign is anchored on the
other allele. Two facts that make this worth doing carefully:
* `beta` and `se` are left exactly where GEMMA put them. `se` is what makes
the effect interpretable (`beta +/- 1.96*se` is a 95% interval) and both
are GEMMA's own numbers, so replacing them with a derived one would lose
information;
* the derived column goes *before* the p-value, not after it. `p_lrt` must
stay the last column: `gemma::peak_marker` reads `row.last()` for the peak
(and with it the PheWAS and plot suggestions), and the plotters and the
docs all say "the last column is the p-value". Appending would have
silently pointed every peak at an effect size.
The response also says what the three columns mean, and that they describe
*this run* on these samples and this genotype version -- not the `additive`
trait info reports, which came from the published mapping (trait 20010:
this run -0.54, published +2.118, same peak marker).
Nothing is added when GEMMA wrote no `beta` (a non-LMM run): the columns
are then exactly GEMMA's.
* src/gemma.rs: `with_effect_size`, applied by `parse_assoc_file`, so
/compute/gemma and /compute/gemma/ravanan both get it.
* src/routes/gemma.rs: the note.
* tests: four unit tests (placement, sign and halving, `peak_marker` still
finds the peak from the last column, a table without beta untouched, a
null effect for a row with `NA` beta) and one end-to-end test asserting
the column sits immediately before `p_lrt`, every value is `-beta/2`,
`p_lrt` stays a probability, and the note is there.
* README.md (the response example and what the column means),
docs/www/SKILL.md (how to read and quote it).
286 tests pass; the same four as before do not.
|
|
Two GEMMA runs over one BXD panel drew genuinely different pictures --
traces differ on all 20 chromosomes, peaks -log10 p 5.48 at chr8 97.0 Mb
against 5.43 at chr1 175.6 Mb -- and both came out headed
**"trait gemma: GEMMA association along the genome"**, because GEMMA's
request had no trait label at all: `/compute/gemma` fell back to
`<group>::gemma`, and `/plot/gemma` fell back to "gemma". The plot of each
trait was told apart by its annotation and nothing else.
`trait_name` is now an optional field on `GemmaRequest`, used for the
`Trait: ...` note (first in `notes`, as on `/compute/rqtl`), for the PheWAS
and R/qtl suggestions, and for the `/plot/gemma?trait=` suggestion -- so a
posted response titles its own plot, and `?trait=` still overrides.
Without it nothing changes: the label stays `<group>::gemma`.
* src/routes/gemma.rs: the field, the label resolution, the note, the
plot href.
* tests/gemma.rs: the covariate run names its trait and asserts the note is
first; tests/plot.rs: a GEMMA plot titles itself from the note, and an
explicit `?trait=` wins over it.
* README.md (`/compute/gemma`, and the plot section), docs/www/SKILL.md
(the GEMMA options list, and what the plot title comes from).
281 tests pass; the same four as before do not.
|
|
One threshold for both engines was the wrong shape. For R/qtl the
interesting line is where a `scanone` stops being seconds (a few hundred
individuals is seconds of one core), so 1 000 stays. For GEMMA it is much
earlier, and not because of the runtime:
- every GEMMA run goes through **one shared cache directory**
(`GEMMA_CACHE_DIR`), where `gemma-wrapper` extracts per-chromosome
kinship archives of hundreds of megabytes by content hash. Two runs at
once are two writers over the same archives, and a half-extracted kinship
another run reads surfaces as a GEMMA failure;
- a real BXD WGS run is ~19 s of every core it can get; UM-HET3's 6 382
individuals write 207 MB of kinship per chromosome.
So `GEMMA_LARGE_PANEL` is 50 -- the smallest real panel, which means every
mapping request is gated in practice, and only a handful of individuals (a
four-way cross's parents, a probe of the pipeline) runs free. `ravanan`
uses the same number, since it writes into the same cache. The threshold
moved onto the `Gate` (`large_panel()`, `is_large()`), so each endpoint
carries its own; the policy, the slots and the 409 are unchanged.
Tests, asked and answered: at 50 the three gemma tests that do real work
(fixtures 198 individuals, BXD.4 with `Status` 93, ravanan 198) are gated
and share one token, so on a cold cache two of them at once would collide
into `409 compute_busy` -- a gate doing its job, failing a test that only
wanted to map something. They now take a lock, and only they do; the
validation tests stay parallel, and the rqtl suite is untouched (its gate
still starts at 1 000). Verified: with `GEMMA_CACHE_DIR` pointed at an
empty directory, `cargo test --test gemma` is green twice in a row, 18 s
per run, i.e. really recomputing.
* src/compute_gate.rs: `RQTL_LARGE_PANEL` (1 000), `GEMMA_LARGE_PANEL`
(50), `Gate::large_panel`/`is_large`, `Gate::new(permits, large_panel)`;
the test that pinned one number now pins both and that each endpoint is
wired to its own.
* tests/gemma.rs: the three real-job tests take the lock, and say why.
* README.md, docs/www/ai-instruction.md, docs/www/operator-checklist.md:
the two thresholds and the cache-directory reason for the lower one.
277 tests pass; the same four as before do not.
|
|
Two things that came out of reading a real response rather than a test.
**Say what a case attribute means.** `GET /groups/{group}/case-attributes`
returned names and values, and the per-trait attribute endpoint returned
values, so a caller had to guess that `SeqCvge` is a sequencing depth.
MariaDB has had the answer all along in `CaseAttribute.Description`:
SeqCvge Depth of DNA sequencing for 1 male of each strain in 2016
Status Live= Available at JAX, Cryo=Cryopreserved only, Extinct
Epoch BXD family subgroups. Each number with common parents. ...
Sex F= female, M= male
Both endpoints now carry it -- a `descriptions` map on the group listing, a
`description` field on the per-trait one -- and the covariate notes quote it,
so `/compute/gemma` answers "Covariate SeqCvge (Depth of DNA sequencing for
1 male of each strain in 2016): categorical ..." instead of leaving the name
to be interpreted. It matters most for covariates: `SeqCvge` is a property
of the *genotype* data, its values include compound ones (`40+31L`, two
sequencing runs), and the server codes those as 20-odd levels rather than as
a depth -- a covariate fitted for the wrong reason, which the description is
the first hint against.
**Gate large computations, not every computation.** The gate was applied to
every job, so a 93-strain test request could be refused because somebody
else's 6 000-individual run held the slot -- which is how the test suite
started serialising itself behind a mutex, a workaround for the wrong
problem. What the gate is for is *large* work: a BXD panel of ~200 finishes
in seconds and two at once cost nothing, while UM-HET3's 6 382 write 207 MB
of kinship per chromosome. It now starts at `LARGE_PANEL` (1 000
individuals): below that no slot is taken, nothing waits and nothing is
refused; above it the old policy holds unchanged (1 slot for gemma, 1 for
ravanan, `RQTL_MAX_CONCURRENT` for rqtl, one large job per caller, 409
naming the run in the way).
The size is not known when the request arrives -- the panel is resolved
server-side -- so the decorator now makes a *light* claim and the handler
promotes it (`__gn4_claim.claim_slot_or_busy(individuals, rid)`) at the
point where it knows, then hands it to `Gate::run` around the call that
computes, so the slot still outlives a client disconnect. A light claim
registers nothing and its drop removes nothing: only a held claim may touch
the claimant map.
* src/compute_gate.rs: `LARGE_PANEL`/`is_large`, `Gate::claim_light`,
`Claim::claim_slot_or_busy`/`is_held`, `busy_error` (the 409 policy, moved
out of `claim_or_busy`), and `Gate::run` unchanged in spirit.
* gnauth-macros: binds the light claim; the body keeps one gate call.
* src/routes/{gemma,rqtl}.rs: promotion after the panel/sample count is
known, and the compute call wrapped in `run`; error mapping moved inside
the job so the future returns `ApiError`.
* src/rqtl.rs: `Sample` is `Clone` (the job owns its copy).
* tests: the gemma suite loses its lock entirely (the fixtures and BXD.4 are
under the threshold); rqtl keeps its lock only for the machine's sake --
concurrent `Rscript` scans would compete for cores and scratch, not for a
slot. Four new gate tests pin the threshold, that a small job never takes
the slot, that one caller cannot hold two large jobs, and that another
caller waits rather than fails.
* README.md, docs/www/ai-instruction.md, docs/www/operator-checklist.md:
what the threshold is and why it is 1 000.
Measured on :3001 after the change: two concurrent small-panel GEMMA
requests from one token both answer 200 (one was 409 before), while two
6 382-individual requests answer 502/409 -- the second gated with the usual
`compute_busy` naming the first.
277 tests pass; the same four as before do not.
|
|
`gemma-wrapper --permutate n` repeats the *whole* LOCO association scan
per permutation -- it shuffles the phenotype file and starts over -- so a
thousand permutations is thousands of full scans: hours to days on a real
panel, against the single slot `/compute/gemma` has. That is not a test
this deployment carries, and an assistant asked for significance
thresholds will ask for it, so the answer has to be an explicit one.
Until now the request type simply had no such field and serde ignores
unknown keys, which is the worst of the three outcomes: the caller gets a
200, no thresholds, and no indication that what it asked for was dropped.
`nperm`, `permutations` and `permutate` are now named fields and refused
with `422 permutations_not_supported`, naming the cost, pointing at
`POST /compute/rqtl` with `nperm` (the endpoint that does have the test,
over the same panel and values) and at the `actions` member every
successful GEMMA response already carries, pre-filled with exactly that
call. Zero keeps its usual meaning -- off -- so a client sharing one body
shape across the two endpoints still works.
* src/routes/gemma.rs: the three fields, the refusal before anything
expensive runs, and the response note now saying permutations are
refused rather than merely absent.
* tests/gemma.rs: `compute_gemma_refuses_permutations` pins all three
spellings, the code, and that `nperm: 0` is not a request for any. It
takes the compute lock: the gate answers before the handler does, so a
concurrent job in the same test binary came back 409 instead.
* README.md, docs/www/ai-instruction.md: what to do instead -- judge a
peak against the smallest `p_lrt`, and get thresholds from R/qtl.
273 tests pass; the same four as before do not.
|
|
`POST /compute/gemma` now takes the same `covariates` list `/compute/rqtl`
does -- `{"case_attribute": "Status"}`, an explicit `map`, or per-sample
numbers -- and fits it with `-c` on the association step only. That needed
a covariate file of GEMMA's own, which is not R/qtl's: no header, no sample
names, positional over the genotype panel, numbers only. GEMMA has no
factors, so a categorical covariate is dummy-expanded here into k-1
columns named after their levels (`Status.Live`, the first level being the
reference), where R/qtl's wrapper does that expansion for itself.
The spec shape, the alignment onto the panel and the text coding are now
one module, `src/covariates.rs`, called by both routes; `/compute/rqtl`
behaves as before except that its note also reports the complete cases
(`... 34 with both the trait and the covariate`), which README and the
instructions had been promising all along.
A missing covariate value is written `NA`, which GEMMA treats exactly as
it treats a missing phenotype -- that individual leaves the fit (measured:
one fewer "number of analyzed individuals"). Deliberately not GeneNetwork2's
`-9`, which GEMMA fits as the value minus nine.
Found on live data, not in the fixtures: a level that exists in the panel
but that none of the *fitted* individuals carries becomes an all-zero dummy
column, and GEMMA stops with `LUDecomp ... input domain error` rather than
dropping the term the way R would. Columns that do not vary among the
individuals with both a trait and a covariate are now left out, and the
response names them (`Status.Cyro`, the `Cyro`/`Cryo` typo in BXD); a
covariate left with no columns runs without one, with a note saying so.
Covariates reach only the GWA step, never `-gk`, and gemma-wrapper hashes
its file arguments, so a different covariate set is a different cache entry
while the kinship already computed is still reused. Covariates need a
`group`: individuals are aligned by name, which an explicit
`genotype_file`/`snps_file` request does not carry (`422
covariate_unavailable`), and an attribute the group does not define lists
the ones it has.
* src/covariates.rs (new): `Spec`/`NamedValue` (the request shape, now
`CovariateSpec`/`CovariateValue` in the OpenAPI document), `Level`,
`Covariate`, `code_case_attribute`, `resolve`, `write_covarstruct_file`
(moved out of src/rqtl.rs) and `write_gemma_covariates_file`.
* src/gemma.rs (gwa_args, compute, compute_gwa): the optional covariate
file, `-c` after `-a` and before `-lmm`, and the notes about dropped
individuals and dropped columns.
* src/routes/gemma.rs: the `covariates` field, resolved after the trait
values so the note can count complete cases; `RqtlCovariate` replaced by
the shared spec.
* tests: six new -- the GEMMA file (numerical with `NA`; two and three
levels; inline codes; a dropped degenerate column) and an end-to-end
`compute_gemma_fits_a_case_attribute_as_a_covariate` on BXD/BXD.4 with
`Status`, which also pins that `-c` is in the GWA command and not in the
kinship one, and that the covariate changes the fit rather than reusing
the plain run's cache. The gemma tests now take a lock: the gate answers
a second job from the same caller with 409 instead of queueing it.
* README.md (/compute/gemma covariates rewritten for GEMMA, /compute/rqtl
points at the shared shape and explains `x` vs `NA`), docs/www/
ai-instruction.md (both endpoints; what differs in `notes`).
Also in the instructions: `/version` reporting a `git` value you have not
seen before now says explicitly to pull the repository and re-read
`docs/www/ai-instruction.md` before the next call. This deployment is
updated in place and a stale page does not announce itself -- the API
accepts the request without the new option, or answers with fields the old
text never mentions.
272 tests pass; the four that do not (benchmark, no_db, and two search
parity/proxy replays) fail identically at the parent commit.
|
|
`POST /compute/gemma/ravanan` is now gated like the other two: one
workflow at a time, one per caller, `409 compute_busy` naming the run and
linking `/compute/gemma/status/{id}` (ravanan has no status route of its
own). One slot because ravanan already fans its per-chromosome steps out
-- over Slurm, when that backend is selected -- so a second request would
only queue behind the same scratch directory. Its gate is separate from
`/compute/gemma`'s: different runners, different cache directories, so one
of each at once is the overlap `/compute/rqtl` is already allowed.
Verified with a stub `CCWL_CMD` that sleeps: the holder's request held the
slot for the full 5 s, the same caller's second request was refused at
once, and another caller's waited for the slot and then ran.
While testing that, `GemmaError::Io` turned out to print "failed to run
gemma-wrapper" for *any* I/O failure -- a missing `CCWL_CMD` produced
"failed to run gemma-wrapper: No such file or directory", which sent me
looking at the wrong binary. Spawn failures are now their own variant
naming the command, and plain file I/O says "I/O error: …".
* src/compute_gate.rs (ravanan, permits): `Gate::new(1)`; `permits()`
exposes the slot count, and a test pins all three endpoints' counts
(gemma 1, ravanan 1, rqtl RQTL_MAX_CONCURRENT).
* src/routes/gemma.rs: the decorator on compute_gemma_ravanan, with
`status = "/compute/gemma/status"`.
* src/gemma.rs (Spawn): names the command; the four run_streaming call
sites use it; unit test for both messages.
* README.md (/compute/gemma/ravanan), docs/www/ai-instruction.md (the
slot list is now 1 / 1 / 8), docs/www/operator-checklist.md: concurrency.
|
|
`POST /compute/gemma` now takes a single slot: one job runs at a time
across all callers, a second submission from the same token is refused
immediately with `409 compute_busy` (whatever it would have waited for,
its own job is already in the way), and a submission from another token
waits for the running job and then runs. Nothing else is gated -- ravanan
and /compute/rqtl are untouched.
The gate is one `tokio::sync::Semaphore(1)` (fair: waiters take the
permit in arrival order) plus a `Mutex<HashSet<String>>` of subjects
holding the slot or queued for it, in a per-process static. The claim is
moved into the spawned job task, so a client disconnect -- which does not
kill the child process -- cannot hand the slot to somebody else while the
CPU is still busy.
The endpoint carries none of that: `#[compute_gate(gemma, run_id =
params.id.as_deref())]` expands to a claim and a run, and requires the
handler to take `Ctx` and `AuthToken` (every compute endpoint is
token-only, and the token's sub is the key), so an endpoint that is not
token-gated cannot be decorated. The policy -- the 409's status, code,
wording and next link -- stays in plain Rust (`Gate::claim_or_busy`), so
the gate's own tests cover it; the attribute is decoration over two calls.
* src/compute_gate.rs: new. Gate, Claim (released on drop, including a
panic), Busy, claim/claim_or_busy/run, and four tests, two of them on a
four-thread runtime (the earlier ones ran single-threaded and so never
exercised the cross-thread hand-off; one now asserts at most one task
inside the slot across eight tasks).
* gnauth-macros/src/lib.rs: the `compute_gate` attribute, alongside the
`gnauth` markers it shares `syn`/`quote` with; arguments documented
(gate, endpoint, status, run_id) for the endpoints still to be gated.
* src/routes/gemma.rs: the decorator replaces 57 lines of claim and
spawn plumbing in compute_gemma.
* docs/www/ai-instruction.md (4a, 5): one job at a time per caller, and
that a `compute_busy` 409 means poll, not resubmit.
|
|
The plot endpoints ran the mapping themselves, which meant the picture
could come from a different run than the one the caller was looking at,
and cost a scan to draw. They now take the mapping's own response -- the
JSON /compute/{rqtl,gemma} returned, posted back -- and hand it straight
to the plotter, which is what the scripts were written for
(`python3 plot-rqtl.py result.json -o out.svg --trait …`).
Validation replaces the run: `/plot/rqtl` needs `data.markers` with
positional 4+ column rows, `/plot/gemma` needs `data` rows *and*
`meta.columns` (its plotter reads the column names to find `p_lrt`), and
anything else is a 422 saying "post that response back". `/plot/rqtl`
also accepts just the `data` member; GEMMA cannot, and says why.
The mapping's `actions` suggestion now describes posting its own response
and carries no body -- duplicating a 21 000-row response into a
suggestion would double the envelope for nothing, and the caller already
holds it.
* src/routes/plot.rs: posted result, shape validation, `?trait`/`?title`
and `?bonferroni=false` passthrough to the scripts; no compute imports.
* src/routes/{rqtl,gemma}.rs: the plot suggestion loses its body.
* tests/plot.rs: canned results instead of real mappings -- the tests now
need only the plotter, no Rscript or gemma; covers both engines, the
bare-`data` form, and the 422 for a body that is a request.
* README.md, docs/www/ai-instruction.md (4a), docs/www/operator-checklist.md:
"post the response back", and why GEMMA needs `meta.columns`.
|
|
The two plotters Pjotr added (scripts/plot-rqtl.py, plot-gemma.py) turn a
saved mapping response into an SVG Manhattan panel. They are now
endpoints, and the mapping that produces the response suggests them:
POST /plot/rqtl same body as /compute/rqtl -> image/svg+xml
POST /plot/gemma same body as /compute/gemma -> image/svg+xml
Taking the mapping's own body rather than the mapping's output means one
call gets you the picture, and the plot cannot describe a run you did not
do: the handlers call the compute handlers and hand the resulting
envelope to the script, exactly as the scripts' docstrings describe
(they read `data.markers`, `data.permutation` and the notes' strain
counts). The mapping is re-run, but through the engines' own caches --
seconds on BXD.
The reply is an SVG, not the JSON envelope: an image is not JSON, and the
plotter's one-line peak summary rides back in `x-plot-summary` so a
caller that cannot see the picture still learns where the peak is.
Both compute responses gain the matching suggestion: `actions` carries
"the same request, plotted" (built from the request that ran, like the
permutation suggestion), so an assistant can map, look, and only then
decide whether the peak is worth the 100-permutation run.
* src/plot.rs: run the configured script over the envelope, read the
SVG back, clean up; a missing script is a 502 naming interpreter and
script, not a panic.
* src/routes/plot.rs: the two handlers (token-gated), delegating to
compute_rqtl/compute_gemma so validation and alignment stay in one
place; `x-plot-summary` sanitised into a header.
* src/routes/{rqtl,gemma}.rs: the plot suggestion, before the
permutation one.
* src/config.rs: PLOT_PYTHON, RQTL_PLOTTER, GEMMA_PLOTTER.
* tests/plot.rs: the suggestion resolves to a complete SVG with a peak
summary, and an invalid mapping request is the mapping's own 422.
* tests/{rqtl,phewas}.rs: find suggestions by href rather than position.
* README.md, docs/www/ai-instruction.md (4a), docs/www/operator-checklist.md
(new "Plotting": python3 must be on the server's PATH).
|
|
A scan gives LOD scores; the thresholds that make them readable come from
permuting the phenotype, which R/qtl supports (nperm) and this API
already ran -- but nothing told a caller to run it. So an unpermuted
R/qtl scan now ends with the same scan at nperm=100 in `actions` (a POST,
so not a `next` link), rebuilt from what actually ran: group + version +
the caller's own named samples, or the genotype file. The description
says what the thresholds are for and that it costs about 100 scans.
GEMMA is the honest half: it has no permutation test, and this endpoint
passes it nothing that would create one, so there is no nperm to suggest.
Its response says so in a note -- judge a peak against the smallest
p_lrt, not a genome-wide threshold -- and its `actions` suggests the
R/qtl permutation run over the same group and values instead. That is
real and runnable rather than a flag that would do nothing.
(gemma-wrapper does have `--permutate n`, which shuffles the phenotype
file and writes a permutation-stats file; wiring it up is a separate
job -- docs/genotypes.md and the README say it is not passed.)
* src/routes/rqtl.rs: the nperm=100 suggestion when nperm was 0, built
from the request that ran (original named samples, not the aligned
panel-length vector -- thousands of entries on a real panel).
* src/routes/gemma.rs: the note, and the cross-engine suggestion.
* tests/rqtl.rs: a path-based scan's suggestion reuses the same files.
* tests/phewas.rs: a group-scoped scan suggests both -- the PheWAS in
`next` (resolved) and the permutation run in `actions`.
* README.md, docs/www/ai-instruction.md (4a): what thresholds are, that
R/qtl offers them and GEMMA does not, and what to do about it.
|
|
A mapping's job is not finished when the rows come back: the next two
questions are "what else peaks here?" and "show me". So a group-scoped
mapping response now ends with both --
- `next`: `/groups/{group}/phewas?locus=<peak>&window=10000`, the peak
being the strongest LOD (R/qtl, column 4) or the smallest p_lrt (GEMMA,
last column). A GET that resolves 200, which is what `next` promises;
measured: R/qtl's peak rs48756159 -> 3 traits, GEMMA's
rsm10000005700 -> 12.
- a note saying which two columns to plot: chr against LOD (R/qtl) or
against -log10 of p_lrt (GEMMA). Rows are positional with meta.columns
naming them, so plotting needs no reshaping -- the API does not render
images, and saying exactly what to plot is more useful than pretending
to.
Path-based requests get neither: without a `group` there is no group to
PheWAS over, and the note alone would be noise.
* src/rqtl.rs, src/gemma.rs (peak_marker): strongest LOD / smallest
p_lrt, with unit tests for both shapes and the empty cases.
* src/routes/{rqtl,gemma}.rs: the `next` link and the plot note, when the
request named a group.
* docs/www/ai-instruction.md: 4b rewritten around what a reader does with
a PheWAS -- where the position comes from (a mapping's `next`, a
trait's `locus`, or chr+mb), the parameter table, what a hit contains,
and how to read it (the 460 LRS cap, `traits: []` versus `markers: []`,
peak-only and published-only limits, several traits on one marker),
with the chr 9 example; 4a points at the new forward.
|
|
Until now /compute/{rqtl,gemma} took server paths, so the caller had to
know the deployment's layout, pick a version, and expand a trait's values
onto the panel in the file's order -- none of which the API told it. The
listing endpoint and the group-scoped request remove all three:
GET /groups/{group}/genotypes versions, newest first, no paths
POST /compute/rqtl {group, [genotype_version], samples}
POST /compute/gemma {group, [genotype_version], samples}
The resolver (src/genotypes.rs) applies GeneNetwork2's rule -- the
group's genotype/<Group>.json `genofile` list is newest-first and its
first entry is current; groups with no JSON (HET3-ITP) fall back to the
highest version number, and the listing's notes say which happened --
reads the panel from the .geno header the way GN3 does, and excludes
parents and F1s by default (GN2's `incparentsf1` off, GN3's
`get_sample_list(inc_par=False, inc_f1=False)`).
Excluding them has to subset the genotype matrix, not null-fill the
values: a null keeps an individual out of the fit but not out of GEMMA's
kinship or R/qtl's cross. So `prepare` writes a panel-subset file under
the engine's cache directory, keyed by panel, and reuses it.
Nothing in the listing or the mapping response carries a path: the
endpoint reports versions and sizes, and `notes` names the resolved
version, the panel size and how many values aligned. Explicit
`genotype_file`/`snps_file` remain as an override for files outside the
layout, and the two request shapes are mutually exclusive (422).
* src/genotypes.rs: new. Discovery, resolution, panel parse, parent/F1
exclusion, subset preparation, name alignment; 10 unit tests.
* src/routes/genotypes.rs: new endpoint, with a test that its list has no
path or file name in it.
* src/routes/{rqtl,gemma}.rs: group + genotype_version +
include_parents_f1; named `samples` aligned server-side; notes record
what resolved. gemma also accepts named samples where it used to insist
on positional trait_values.
* src/suggest.rs: suggestions from /groups/{group}/traits/{id}/values now
carry `group` and no placeholders; the dataset-scoped ones keep the
placeholder and say to add the group.
* src/routes/groups.rs: the group record points at /genotypes.
* src/config.rs: GENOTYPE_FILES (default the gn4-data directory).
* tests/genotypes.rs: new integration test (skips without the directory).
* README.md, docs/genotypes.md, docs/www/*: the flow is now "ask for the
versions, map by group" -- measured runs, the parent/F1 rule, the
subsetting requirement, and the restart list unchanged.
|
|
POST /compute/gemma/ravanan used to run every CWL step locally, because
compute_ravanan never passed ravanan a batch system. Add a
RavananBatch setting:
- RAVANAN_BATCH_SYSTEM=single-machine (default) or slurm-api, failing
closed on anything else, exactly like GN4_DB_MODE;
- slurm-api adds --batch-system=slurm-api, --slurm-api-endpoint,
--slurm-jwt (a *file*, which is what ravanan reads) and, when set,
--slurm-partition/--slurm-nice; a slurm selection without an endpoint
or a JWT file refuses to start rather than 502-ing every request;
- --scratch defaults to ravanan_cache_dir for slurm, so the store and
the job scratch space live on the same shared filesystem (with slurm
that directory has to be visible to the compute nodes);
- the response's ravanan note records which backend ran.
The switch building is RavananBatch::ravanan_args so it is unit
testable; compute_ravanan takes the backend and the scratch directory,
and the route passes them from config. docs/ravanan-slurm.md documents
the keys, the shared-directory requirement, and the slurm-side auth
wiring (AuthType=auth/munge + AuthAltTypes=auth/jwt with SLURM_JWT in
slurmrestd's environment) that makes REST-submitted jobs actually run.
|
|
gemma-loco.cwl was a generated artifact (ccwl compile's output), but
was being committed like hand-written source. Remove it, and have
compute_ravanan compile cwl/gemma/gemma-loco.scm to a throwaway CWL
file under its own cache dir on every call instead -- cheap (pure
macro expansion, no Guix build involved), so there's no real cost to
regenerating it fresh each time, and no risk of a stale compiled file
drifting from its ccwl source.
Config gains a ccwl_cmd knob (default "ccwl", resolved via PATH,
alongside ravanan_cmd/gemma_wrapper_cmd); gemma_ravanan_workflow now
names the .scm source, not a .cwl file. Verified end to end by running
the exact compile-then-run sequence compute_ravanan now performs
against the real ccwl/ravanan/gemma-wrapper binaries and the BXD
fixtures: same correctness and timings as before.
|
|
Replace gemma-loco.cwl's single kinship/gwa pair (each one gemma-wrapper
invocation covering all chromosomes, relying on gemma-wrapper's own
internal GNU-parallel fan-out) with one gemma-wrapper invocation PER
CHROMOSOME, restricted via its existing --chromosomes/--no-parallel
flags and scattered by ravanan itself (ScatterFeatureRequirement,
scatterMethod: dotproduct). gemma-wrapper still does the correct
per-chromosome LOCO math (exclude this chromosome from kinship, test
only its markers) against the full genotype/SNP files -- only which
chromosome(s) it loops over changes. compute_ravanan now computes the
chromosome list itself (chromosomes_in, mirroring gemma-wrapper's own
get_chromosomes) and passes it as the workflow's scatter input, and
collates the resulting per-chromosome gwa_json/archive array outputs.
Measured 16.7s wall-clock end-to-end against the BXD fixtures (20
chromosomes), vs. ~19s for /compute/gemma's direct path and ~21s for
the previous sequential ravanan workflow -- confirmed byte-for-byte
identical output (rs31443144's exact values, 7320 total rows).
Also fixes three real, previously-unexercised bugs in compute_ravanan
found getting this to run at all (POST /compute/gemma/ravanan had no
automated test until this commit):
- missing --guix-manifest (ravanan requires it; added
gemma_ravanan_manifest config key and cwl/gemma/manifest.scm)
- missing --store files/logs/data subdirectories (ravanan does not
create them itself)
- --output-directory dropped entirely: every chromosome's gwa archive
shares gemma-wrapper's own content-hash basename (the hash doesn't
factor in --chromosomes), so ravanan's optional flat-symlink step
collides across them; unneeded anyway since results are read
straight from ravanan's --store via its stdout JSON record.
Also found and worked around a ravanan scheduler bug: a step scattered
over exactly one input needs an explicit scatterMethod even though CWL
only requires one for multiple scattered inputs -- ravanan has no
fallback case for a missing one and silently misbehaves.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
So a caller of /compute/gemma(/ravanan) or /compute/rqtl doesn't need
to count data's rows or columns.len() itself. with_columns now takes
the row count too and derives num_cols from the column list.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
Cuts repeated key names out of large /compute/gemma(/ravanan) responses:
data is now a list of positional row arrays instead of one keyed object
per row, with the column names moved to a new meta.columns field shared
with any other endpoint that wants the same shape.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
|