aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2024-06-27 05:29:26 -0500
committerPjotr Prins2024-06-27 05:29:26 -0500
commit9708991177a8450f8c17dad732f35a4b9c95c287 (patch)
tree97ef69d53150ecd2700f77277b134480390facd6
parente4775ccc0c24351e1ee428cddb0f320022509137 (diff)
downloadgn-guile-9708991177a8450f8c17dad732f35a4b9c95c287.tar.gz
Simplified gemma runner
-rw-r--r--gn/runner/gemma.scm29
-rwxr-xr-xscripts/precompute/run-gemma.scm4
2 files changed, 28 insertions, 5 deletions
diff --git a/gn/runner/gemma.scm b/gn/runner/gemma.scm
index 4c1c374..ec2a4d6 100644
--- a/gn/runner/gemma.scm
+++ b/gn/runner/gemma.scm
@@ -11,6 +11,7 @@
#:export (
write-pheno-file
+ invoke-gemma-wrapper-loco
run-gemma
))
@@ -27,8 +28,10 @@
(outvalue (if value
value
"NA"))]
- (format #t "~s ~s" ind outvalue)
- (newline)
+ (if value
+ (begin
+ (format #t "~s ~s" ind outvalue)
+ (newline)))
(display outvalue port)
(newline port))))
bxd-inds)
@@ -36,6 +39,27 @@
))
)
+(define (invoke-gemma-wrapper-loco name trait-name pheno-fn)
+ "Create a tmpdir and invoke gemma-wrapper using parallel LOCO. Note that at this point we use a number of defaults for BXD"
+ (let* [(population "BXD")
+ (sys-tmpdir (getenv "TMPDIR"))
+ (tmpdir (mkdtemp (string-append sys-tmpdir "/run-gemma-XXXXXX")))
+ (k-json-fn (string-append tmpdir "/K.json"))
+ (gwa-json-fn (string-append tmpdir "/GWA.json"))]
+ ;; --- First we compute K - control output goes to K.json
+ (let [(err (system (string-append "gemma-wrapper --verbose --population \"" population "\" --name \"" name "\" --trait \"" trait-name "\" --verbose --loco --json --parallel -- -gk -g BXD.8_geno.txt.gz -p " pheno-fn " -a BXD.8_snps.txt > " k-json-fn )))]
+ (if (not (= err 0))
+ (exit err)))
+ (let [(err (system (string-append "gemma-wrapper --population \"" population "\" --name \"" name "\" --id \"" trait-name "\" --trait \"" trait-name "\" --verbose --loco --json --input " k-json-fn " -- -g BXD.8_geno.txt.gz -p " pheno-fn " -a BXD.8_snps.txt -lmm 9 -maf 0.1 > " gwa-json-fn)))]
+ (if (not (= err 0))
+ (exit err)))
+ ;; (delete-file pheno-fn)
+ ;; (delete-file gwa-json-fn)
+ ;; (delete-file k-json-fn)
+ ;; (rmdir tmpdir)
+ )
+ )
+
(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 ids (string-append (int-to-string data-id) ","
@@ -46,7 +70,6 @@
(display ids)
(display traits)
(newline)
- ;; ---- write phenotype file
(let* [(sys-tmpdir (getenv "TMPDIR"))
(tmpdir (mkdtemp (string-append sys-tmpdir "/run-gemma-XXXXXX")))
(pheno-fn (string-append tmpdir "/pheno.txt"))
diff --git a/scripts/precompute/run-gemma.scm b/scripts/precompute/run-gemma.scm
index 36edf8b..48222b4 100755
--- a/scripts/precompute/run-gemma.scm
+++ b/scripts/precompute/run-gemma.scm
@@ -9,7 +9,7 @@ Run from base dir with
and with some extra paths (for gemma)
-. .guix-shell ruby --expose=/home/wrk/iwrk/opensource/code/genetics/gemma-wrapper/=/gemma-wrapper --expose=/home/wrk/iwrk/opensource/code/genetics/gemma/=/gemma -- env TMPDIR=tmp guile -L . -s ./scripts/precompute/run-gemma.scm
+guix shell -C -F xz tar time parallel gemma coreutils-minimal guile guile-dbi guile-json ruby --expose=/home/wrk/iwrk/opensource/code/genetics/gemma-wrapper/=/gemma-wrapper --expose=/home/wrk/iwrk/opensource/code/genetics/gemma/=/gemma -- env TMPDIR=tmp guile -L . -e main -s ./scripts/precompute/run-gemma.scm test
!#
@@ -49,5 +49,5 @@ Usage: list-traits-to-compute [options...]
]
(display dataset)
(write-pheno-file "pheno.txt" traits)
- ; (run-gemma "BXD" data-id probeset-id probesetfreeze-id name trait-name traits)))
+ (invoke-gemma-wrapper-loco dataset-name trait-name "pheno.txt")
))))))