diff options
| author | Pjotr Prins | 2025-08-02 12:56:22 +0200 |
|---|---|---|
| committer | Pjotr Prins | 2025-08-02 12:56:22 +0200 |
| commit | f5ec159d3c14bd12f410ca2fa64560121308f25b (patch) | |
| tree | 273db1374f9d1db8dd9cd780a1cd97caeaad43fc /gn/data | |
| parent | 8f402821b743edae1e69cd8bf0736dcfcdd97d55 (diff) | |
| download | gn-guile-f5ec159d3c14bd12f410ca2fa64560121308f25b.tar.gz | |
Write gemma trait values (pheno file)
Diffstat (limited to 'gn/data')
| -rw-r--r-- | gn/data/dataset.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm index c21a663..f099171 100644 --- a/gn/data/dataset.scm +++ b/gn/data/dataset.scm @@ -7,15 +7,18 @@ #:use-module (srfi srfi-1) #:use-module (dbi dbi) #:use-module (gn db mysql) + #:use-module (gn data genotype) #:use-module (gn data group) #:use-module (gn util convert) #:use-module (web gn-uri) + #:use-module (rnrs base) ; for assert #:export ( dataset-name get-bxd-publish-list get-bxd-publish-values-list get-bxd-publish-name-value-dict + write-pheno-file )) (define (get-dataset db probesetfreeze-id) @@ -68,3 +71,28 @@ `(,(assoc-ref r "Name") . ,(assoc-ref r "value")) ) '()))) ))))) + + +(define (write-pheno-file fn traits) + (define bxd-inds (geno-inds-bxd (pk "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"))] + (if value + (begin + (format #t "~s ~s" ind outvalue) + (newline))) + (display outvalue port) + (newline port)))) + bxd-inds) + (close port) + )) +) |
