From 4bf51a31c251f3d788325c58c8a78f534409f90f Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 3 Jan 2024 10:10:12 +0300 Subject: Parse the phenotype data from the R/qtl2 bundle. --- r_qtl/r_qtl2.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'r_qtl') 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 -- cgit v1.2.3