aboutsummaryrefslogtreecommitdiff
path: root/r_qtl/r_qtl2.py
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl/r_qtl2.py')
-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