From 9eab14f7f6c40c401c29d11d69ac54303415ab87 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 4 Jan 2024 11:50:04 +0300 Subject: Process sex and cross information data in "covar" files. --- tests/r_qtl/test_files/test_covar.zip | Bin 490 -> 562 bytes tests/r_qtl/test_files/test_covar_transposed.zip | Bin 541 -> 594 bytes tests/r_qtl/test_r_qtl2_covar.py | 30 +++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/r_qtl/test_files/test_covar.zip b/tests/r_qtl/test_files/test_covar.zip index 6fbb5e9..61961a0 100644 Binary files a/tests/r_qtl/test_files/test_covar.zip and b/tests/r_qtl/test_files/test_covar.zip differ diff --git a/tests/r_qtl/test_files/test_covar_transposed.zip b/tests/r_qtl/test_files/test_covar_transposed.zip index 5e933cc..c0758a3 100644 Binary files a/tests/r_qtl/test_files/test_covar_transposed.zip and b/tests/r_qtl/test_files/test_covar_transposed.zip differ diff --git a/tests/r_qtl/test_r_qtl2_covar.py b/tests/r_qtl/test_r_qtl2_covar.py index c18ee74..eef7a33 100644 --- a/tests/r_qtl/test_r_qtl2_covar.py +++ b/tests/r_qtl/test_r_qtl2_covar.py @@ -10,19 +10,21 @@ from r_qtl import r_qtl2 as rqtl2 @pytest.mark.parametrize( "filepath,expected", (("tests/r_qtl/test_files/test_covar.zip", - ({"id": "1", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "2", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "3", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "146", "sex": "f", "cross_direction": "(BxS)x(BxS)"}, - {"id": "147", "sex": "f", "cross_direction": "(BxS)x(BxS)"}, - {"id": "148", "sex": "f", "cross_direction": "(BxS)x(BxS)"})), + ({"id": "1", "sex": "male", "cross_direction": 1}, + {"id": "2", "sex": "male", "cross_direction": 1}, + {"id": "3", "sex": "male", "cross_direction": 1}, + {"id": "71", "sex": "male", "cross_direction": 0}, + {"id": "72", "sex": "male", "cross_direction": 0}, + {"id": "146", "sex": "female", "cross_direction": 1}, + {"id": "147", "sex": "female", "cross_direction": 1}, + {"id": "148", "sex": "female", "cross_direction": 1})), ("tests/r_qtl/test_files/test_covar_transposed.zip", - ({"id": "1", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "2", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "3", "sex": "m", "cross_direction": "(BxS)x(BxS)"}, - {"id": "146", "sex": "f", "cross_direction": "(BxS)x(BxS)"}, - {"id": "147", "sex": "f", "cross_direction": "(BxS)x(BxS)"}, - {"id": "148", "sex": "f", "cross_direction": "(BxS)x(BxS)"})), + ({"id": "1", "sex": "male", "cross_direction": 1}, + {"id": "2", "sex": "male", "cross_direction": 1}, + {"id": "3", "sex": "male", "cross_direction": 1}, + {"id": "146", "sex": "female", "cross_direction": 1}, + {"id": "147", "sex": "female", "cross_direction": 1}, + {"id": "148", "sex": "female", "cross_direction": 1})), )) def test_parse_covar_files(filepath, expected): """Test parsing of 'covar' files from the R/qtl2 bundle. @@ -33,4 +35,6 @@ def test_parse_covar_files(filepath, expected): """ with ZipFile(Path(filepath).absolute(), "r") as zfile: cdata = rqtl2.control_data(zfile) - assert tuple(rqtl2.file_data(zfile, "covar", cdata)) == expected + process_fns = rqtl2.make_process_data_covar(cdata) + assert tuple( + rqtl2.file_data(zfile, "covar", cdata, *process_fns)) == expected -- cgit v1.2.3