aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-03 10:10:12 +0300
committerFrederick Muriuki Muriithi2024-01-03 10:10:12 +0300
commit4bf51a31c251f3d788325c58c8a78f534409f90f (patch)
tree30e5c1657c7c6c4afac3e489700fa679739da912 /r_qtl
parent3edc6f67bb50552d0ce0e3ec372b06efb736cdb8 (diff)
downloadgn-uploader-4bf51a31c251f3d788325c58c8a78f534409f90f.tar.gz
Parse the phenotype data from the R/qtl2 bundle.
Diffstat (limited to 'r_qtl')
-rw-r--r--r_qtl/r_qtl2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index bc3a86f..2256609 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -163,3 +163,16 @@ def map_data(zfile: ZipFile, map_type: str, cdata: dict) -> Iterator[dict]:
for row in with_transposed(zfile, map_file_key, cdata, __merge__):
yield row
+
+def phenotype_data(zfile: ZipFile, cdata: dict) -> Iterator[dict]:
+ """Load phenotype file data."""
+ if not cdata.get("pheno_transposed", False):
+ for row in with_non_transposed(zfile, "pheno", cdata, lambda val: val):
+ yield row
+ return
+
+ def __merge__(id_key, ids, vals):
+ return tuple(dict(zip([id_key, vals[0]], items))
+ for items in zip(ids, vals[1:]))
+ for row in with_transposed(zfile, "pheno", cdata, __merge__):
+ yield row