aboutsummaryrefslogtreecommitdiff
path: root/gn/runner/gemma.scm
blob: 067800e6773860540c0552ea9032b2f91b073adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(define-module (gn runner gemma)
  #:use-module (json)
  #:use-module (gn data genotype)
  #:use-module (ice-9 match)
  #:use-module (ice-9 format)
  #:use-module (ice-9 iconv)
  #:use-module (ice-9 receive)
  #:use-module (ice-9 string-fun)
  #:use-module (rnrs base)

  #:export (
            run-gemma
            ))

(define (run-gemma data-id name trait-name traits)
  (define bxd-inds (geno-inds-bxd "BXD.json"))
  (assert (= 235 (length bxd-inds)))
  (if name
      (display (string-append "WE HAVE OUR BXD DATASET " name " and trait " trait-name " for precompute!\n")))
  (display data-id)
  (display traits)
  (newline)
  ;; ---- write phenotype file
  (call-with-output-file "pheno.txt"
    (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)))

  ;; 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
  (system (string-append "env GEMMA_COMMAND=gemma /gemma-wrapper/bin/gemma-wrapper --name " name " --trait " trait-name " --verbose --loco --json --debug --parallel -- -gk -g BXD.8_geno.txt.gz -p pheno.txt -a BXD.8_snps.txt > K.json"  ))
  (system (string-append "env GEMMA_COMMAND=gemma /gemma-wrapper/bin/gemma-wrapper --name " name " --trait " trait-name " --verbose --loco --json --debug --parallel --input K.json -- -g BXD.8_geno.txt.gz -p pheno.txt -a BXD.8_snps.txt -lmm 2 -maf 0.1 > GWA.json"))
  )