From e4775ccc0c24351e1ee428cddb0f320022509137 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 26 Jun 2024 04:45:13 -0500 Subject: Read pheno JSON file and write out pheno file for gemma --- gn/runner/gemma.scm | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'gn/runner') 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 -- cgit v1.2.3