diff options
author | Pjotr Prins | 2024-06-26 04:45:13 -0500 |
---|---|---|
committer | Pjotr Prins | 2024-06-26 04:45:13 -0500 |
commit | e4775ccc0c24351e1ee428cddb0f320022509137 (patch) | |
tree | 868406d4c55b988a46bbd97e4c7fda543dcd2bc0 /gn | |
parent | 41735d8fbf4fbd0d137224f25b20cda6556ad484 (diff) | |
download | gn-guile-e4775ccc0c24351e1ee428cddb0f320022509137.tar.gz |
Read pheno JSON file and write out pheno file for gemma
Diffstat (limited to 'gn')
-rw-r--r-- | gn/runner/gemma.scm | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/gn/runner/gemma.scm b/gn/runner/gemma.scm index 131284a..4c1c374 100644 --- a/gn/runner/gemma.scm +++ b/gn/runner/gemma.scm @@ -10,16 +10,37 @@ #:use-module (rnrs base) #:export ( + write-pheno-file run-gemma )) +(define (write-pheno-file fn traits) + (define bxd-inds (geno-inds-bxd "BXD.json")) + (assert (= 235 (length bxd-inds))) + (display bxd-inds) + (call-with-output-file fn + (lambda (port) + (for-each + (lambda (ind) + (begin + (let* [(value (assoc-ref traits ind)) + (outvalue (if value + value + "NA"))] + (format #t "~s ~s" ind outvalue) + (newline) + (display outvalue port) + (newline port)))) + bxd-inds) + (close port) + )) +) + (define (run-gemma population data-id probeset-id probesetfreeze-id name trait-name traits) "Run gemma-wrapper to compute GRM and GWA. On failure the run will stop(!)" - (define bxd-inds (geno-inds-bxd "BXD.json")) (define ids (string-append (int-to-string data-id) "," (int-to-string probeset-id) "," (int-to-string probesetfreeze-id))) - (assert (= 235 (length bxd-inds))) (if name (display (string-append "WE HAVE OUR " population " DATASET " name " and trait " trait-name " for precompute!\n"))) (display ids) @@ -31,24 +52,6 @@ (pheno-fn (string-append tmpdir "/pheno.txt")) (k-json-fn (string-append tmpdir "/K.json")) (gwa-json-fn (string-append tmpdir "/GWA.json"))] - (call-with-output-file pheno-fn - (lambda (port) - (for-each (lambda (ind) - (begin - (let* [(value (assoc-ref traits ind)) - (outvalue (if value - value - "NA"))] - (display outvalue) - (newline) - (display outvalue port) - (newline port)))) - bxd-inds) - (close port) - )) - - ;; set up with ./.guix-shell -- guile -L . -s ./scripts/precompute/precompute-hits.scm - ;; ---- to start GEMMA precompute inside container ;; env TMPDIR=. LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib/ guile -L . -s ./scripts/precompute/precompute-hits.scm ;; --- First we compute K - control output goes to K.json |