diff options
| author | Arun Isaac | 2025-11-28 00:49:48 +0000 |
|---|---|---|
| committer | Arun Isaac | 2025-11-28 00:51:34 +0000 |
| commit | 9b426be57a759a9c983a68536dfce8c1c1891c1a (patch) | |
| tree | 8e791adf0035c8017d10c342baf74484924bda8d | |
| parent | 974d562ff0f816f5832356928948e5fbcc362423 (diff) | |
| download | pyhegp-9b426be57a759a9c983a68536dfce8c1c1891c1a.tar.gz pyhegp-9b426be57a759a9c983a68536dfce8c1c1891c1a.tar.lz pyhegp-9b426be57a759a9c983a68536dfce8c1c1891c1a.zip | |
Handle absent optional reference column.
pyhegp was crashing if the optional reference column was absent. We handle it correctly now. And, we add several test cases to catch this in the future.
| -rw-r--r-- | pyhegp/pyhegp.py | 38 | ||||
| -rw-r--r-- | test-data/encrypt-test-genotype-without-reference.tsv | 5 | ||||
| -rw-r--r-- | test-data/encrypt-test-summary-without-reference | 6 | ||||
| -rw-r--r-- | test-data/genotype-without-reference.tsv | 101 | ||||
| -rw-r--r-- | test-data/genotype0-without-reference.tsv | 101 | ||||
| -rw-r--r-- | test-data/genotype1-without-reference.tsv | 101 | ||||
| -rw-r--r-- | test-data/genotype2-without-reference.tsv | 101 | ||||
| -rw-r--r-- | test-data/genotype3-without-reference.tsv | 101 | ||||
| -rw-r--r-- | test-data/pool-test-summary1-without-reference | 5 | ||||
| -rw-r--r-- | test-data/pool-test-summary2-without-reference | 7 | ||||
| -rw-r--r-- | tests/test_pyhegp.py | 68 |
11 files changed, 599 insertions, 35 deletions
diff --git a/pyhegp/pyhegp.py b/pyhegp/pyhegp.py index 4e0bd84..3133c25 100644 --- a/pyhegp/pyhegp.py +++ b/pyhegp/pyhegp.py @@ -49,14 +49,22 @@ def hegp_encrypt(plaintext, key): def hegp_decrypt(ciphertext, key): return np.transpose(key) @ ciphertext +def drop_metadata_columns(genotype): + return (genotype.drop(columns=["chromosome", "position"]) + # The reference column is optional. Do not error out if it + # does not exist. + .drop(columns=["reference"], errors="ignore")) + def genotype_summary(genotype): - matrix = genotype.drop(columns=["chromosome", "position", "reference"]).to_numpy() + matrix = drop_metadata_columns(genotype).to_numpy() return Summary(genotype.shape[0], pd.DataFrame({"chromosome": genotype.chromosome, - "position": genotype.position, - "reference": genotype.reference, - "mean": np.mean(matrix, axis=1), - "std": np.std(matrix, axis=1)})) + "position": genotype.position} + | ({"reference": genotype.reference} + if "reference" in genotype.columns + else {}) + | {"mean": np.mean(matrix, axis=1), + "std": np.std(matrix, axis=1)})) def pool_stats(list_of_stats): sums = [stats.n*stats.mean for stats in list_of_stats] @@ -70,13 +78,17 @@ def pool_stats(list_of_stats): def pool_summaries(summaries): def pool_summaries2(summary1, summary2): + metadata_columns = (["chromosome", "position"] + + (["reference"] + if "reference" in summary1.data.columns + else [])) # Drop any SNPs that are not in both summaries. data = pd.merge(summary1.data.rename(columns={"mean": "mean1", "std": "std1"}), summary2.data.rename(columns={"mean": "mean2", "std": "std2"}), how="inner", - on=("chromosome", "position", "reference")) + on=metadata_columns) pooled_stats = pool_stats([Stats(summary1.n, data.mean1.to_numpy(), data.std2.to_numpy()), @@ -84,13 +96,16 @@ def pool_summaries(summaries): data.mean2.to_numpy(), data.std2.to_numpy())]) return Summary(pooled_stats.n, - pd.concat((data[["chromosome", "position", "reference"]], + pd.concat((data[metadata_columns], pd.DataFrame({"mean": pooled_stats.mean, "std": pooled_stats.std})), axis="columns")) pooled_summary = reduce(pool_summaries2, summaries) return Summary(pooled_summary.n, - pooled_summary.data.drop(columns=["reference"])) + # The reference column is optional. Do not raise an + # error if it is absent. + pooled_summary.data.drop(columns=["reference"], + errors="ignore")) def encrypt_genotype(genotype, key, summary): # Drop SNPs that have a zero standard deviation. Such SNPs have no @@ -102,8 +117,7 @@ def encrypt_genotype(genotype, key, summary): common_genotype = pd.merge(genotype, summary.data[["chromosome", "position"]], on=("chromosome", "position")) - sample_names = (common_genotype.drop( - columns=["chromosome", "position", "reference"]).columns) + sample_names = drop_metadata_columns(common_genotype).columns genotype_matrix = common_genotype[sample_names].to_numpy().T encrypted_genotype_matrix = hegp_encrypt(standardize( genotype_matrix, @@ -202,9 +216,7 @@ def encrypt_command(genotype_file, phenotype_file, summary_file, key_file, force else: summary = genotype_summary(genotype) key = random_key(np.random.default_rng(), - len(genotype - .drop(columns=["chromosome", "position", "reference"]) - .columns)) + len(drop_metadata_columns(genotype).columns)) if key_file: write_key(key_file, key) diff --git a/test-data/encrypt-test-genotype-without-reference.tsv b/test-data/encrypt-test-genotype-without-reference.tsv new file mode 100644 index 0000000..8598e36 --- /dev/null +++ b/test-data/encrypt-test-genotype-without-reference.tsv @@ -0,0 +1,5 @@ +chromosome position sample1 sample2 +chr1 1 0 1 +chr2 19 2 3 +chrX 21 4 5 +chrX 22 4 5 diff --git a/test-data/encrypt-test-summary-without-reference b/test-data/encrypt-test-summary-without-reference new file mode 100644 index 0000000..71a77a3 --- /dev/null +++ b/test-data/encrypt-test-summary-without-reference @@ -0,0 +1,6 @@ +# pyhegp summary file version 1 +# number-of-samples 10 +chromosome position mean standard-deviation +chr1 1 0 1 +chr2 19 2 3 +chrX 21 4 5 diff --git a/test-data/genotype-without-reference.tsv b/test-data/genotype-without-reference.tsv new file mode 100644 index 0000000..cd7cbbd --- /dev/null +++ b/test-data/genotype-without-reference.tsv @@ -0,0 +1,101 @@ +chromosome position Q_CFW-SW/100.0a Q_CFW-SW/100.0c Q_CFW-SW/100.0d Q_CFW-SW/100.0e Q_CFW-SW/100.0f Q_CFW-SW/100.0g Q_CFW-SW/100.0h Q_CFW-SW/100.0i Q_CFW-SW/100.0j Q_CFW-SW/100.0l Q_CFW-SW/100.0m Q_CFW-SW/100.0n Q_CFW-SW/100.0o Q_CFW-SW/100.0p Q_CFW-SW/100.0q Q_CFW-SW/100.0r Q_CFW-SW/10.0b Q_CFW-SW/10.0c Q_CFW-SW/10.0d Q_CFW-SW/10.0f +chr11 3200246 0.4043 0.3655 0.3375 -0.614 0.3452 0.3836 0.3901 0.2411 -0.1418 0.3629 -1.8435 0.3742 -0.5826 0.4141 -0.0555 0.2733 0.408 0.388 -3.6091 0.381 +chr11 3205355 0.395 0.3545 0.3325 -0.5421 0.3433 0.3751 0.3806 0.2034 -0.1 0.3539 -1.9966 0.3681 -0.4778 0.4084 -0.0767 0.2807 0.3991 0.384 -3.5452 0.3728 +chr11 3218908 0.3977 0.3207 0.3134 -0.4491 0.3267 0.3576 0.3449 0.1215 -0.0346 0.3294 -2.3341 0.3548 -0.2218 0.3769 -0.0873 0.3071 0.3728 0.3672 -3.5468 0.3528 +chr11 3414044 -0.3616 -0.328 -0.3234 0.074 -0.2713 -0.2976 -0.339 1.0335 -0.2665 -0.3005 3.5125 -0.3327 -0.2604 -0.3458 0.239 -0.3538 -0.3239 -0.3452 3.6101 -0.3177 +chr11 3460427 -0.341 -0.3363 -0.3346 0.073 -0.2652 -0.2791 -0.3456 1.3293 -0.2961 -0.3032 3.5493 -0.3261 -0.2861 -0.3472 0.051 -0.3419 -0.33 -0.3332 3.664 -0.3154 +chr11 3462290 -0.3552 -0.3281 -0.3287 0.0912 -0.2708 -0.2841 -0.3331 1.3928 -0.2856 -0.3056 3.5419 -0.3303 -0.2974 -0.3477 0.0408 -0.3514 -0.323 -0.343 3.6699 -0.3101 +chr11 3462323 -0.3524 -0.3296 -0.3298 0.0874 -0.2697 -0.2832 -0.3357 1.3896 -0.2873 -0.3051 3.542 -0.3294 -0.2953 -0.3476 0.0418 -0.3495 -0.3244 -0.3411 3.6675 -0.3111 +chr11 3462325 -0.3533 -0.3291 -0.3294 0.0885 -0.27 -0.2835 -0.3349 1.3909 -0.2867 -0.3052 3.5419 -0.3297 -0.296 -0.3476 0.0414 -0.3501 -0.324 -0.3417 3.6682 -0.3108 +chr11 3462348 -0.361 -0.3244 -0.326 0.0986 -0.2731 -0.2864 -0.3279 1.4031 -0.2807 -0.3064 3.541 -0.3318 -0.3018 -0.3476 0.0372 -0.3551 -0.32 -0.3469 3.6751 -0.3079 +chr11 3464016 -0.3461 -0.334 -0.3331 0.08 -0.2672 -0.2805 -0.3413 1.3757 -0.2937 -0.3044 3.543 -0.328 -0.2906 -0.3479 0.0464 -0.3455 -0.3279 -0.3369 3.6601 -0.3138 +chr11 3554197 0.3393 0.3346 0.0862 -0.1332 0.2532 0.2705 0.3409 -0.5622 0.3082 0.2896 -3.4878 0.3228 0.3214 0.3396 0.017 0.3492 0.3396 0.3289 -3.5317 0.3086 +chr11 3558414 -0.3648 -0.3172 0.0754 0.1639 -0.2644 -0.286 -0.3239 0.5833 -0.2805 -0.2923 3.3617 -0.3305 -0.342 -0.3407 -0.0391 -0.3686 -0.3297 -0.3505 3.5287 -0.2993 +chr11 3619052 -0.3394 -0.3269 1.0859 0.2534 -0.2429 -0.2508 -0.3166 0.2133 -0.3278 -0.2838 1.7148 -0.3089 -0.3337 -0.3288 -0.0442 -0.3453 -0.3142 -0.3346 2.9131 -0.2884 +chr11 3883306 -0.3207 -0.2844 2.6043 0.0664 -0.227 -0.2504 -8e-04 -0.2199 -0.3104 -0.2247 0.2938 -0.3079 -0.2412 -0.3312 -0.2698 -0.3016 -0.2836 -0.2786 -0.2529 -0.3149 +chr11 4017210 -0.3655 -0.3608 1.5442 -0.0087 -0.2506 -0.3213 0.215 -0.3742 -0.396 -0.2641 0.2322 -0.3503 -0.2296 -0.405 -0.3226 -0.3643 -0.2958 -0.3026 -0.4183 -0.3808 +chr11 4017211 -0.3685 -0.356 1.5489 -0.0107 -0.2535 -0.3241 0.2125 -0.3624 -0.3916 -0.261 0.2295 -0.3533 -0.2325 -0.4005 -0.3256 -0.3673 -0.2987 -0.3055 -0.4064 -0.3776 +chr11 4017223 -0.3824 -0.3338 1.5704 -0.02 -0.2667 -0.3373 0.2009 -0.3071 -0.3708 -0.2466 0.2171 -0.3669 -0.2459 -0.3794 -0.3394 -0.3812 -0.3125 -0.3194 -0.3509 -0.3623 +chr11 4017385 -0.3677 -0.3524 1.5514 -0.0141 -0.2529 -0.3236 0.2108 -0.3557 -0.3879 -0.2582 0.2295 -0.3526 -0.2317 -0.3968 -0.3258 -0.3665 -0.2982 -0.3048 -0.3998 -0.3746 +chr11 4022004 -0.3702 -0.3553 1.5401 -0.0114 -0.2548 -0.3259 0.2141 -0.3604 -0.3909 -0.2607 0.2282 -0.3548 -0.2332 -0.3998 -0.3266 -0.3692 -0.3 -0.307 -0.4045 -0.3774 +chr11 4024616 -0.7473 1.1971 0.937 -0.4412 -0.7211 -0.7083 -0.6358 2.9722 1.1229 0.7712 -0.7234 -0.733 -0.7373 1.1363 -0.723 -0.7502 -0.7397 -0.7496 2.9891 0.8355 +chr11 4110988 0.8081 -1.0677 -1.2622 0.66 0.7659 0.7943 0.6125 -2.8791 -1.0382 -0.985 0.6983 0.8009 0.7614 -1.0441 0.7859 0.7916 0.781 0.7821 -2.8836 -1.038 +chr11 4124677 0.8076 -0.9793 -1.1824 0.6428 0.7643 0.795 0.6135 -2.7181 -0.9575 -0.9426 0.705 0.7998 0.7611 -0.9601 0.7821 0.7882 0.78 0.7807 -2.7205 -0.9568 +chr11 4139413 -0.7222 1.0853 1.0928 -0.7139 -0.7198 -0.7216 -0.7119 2.8902 1.084 1.0653 -0.7167 -0.7218 -0.7196 1.0836 -0.721 -0.721 -0.7207 -0.7207 2.8905 1.084 +chr11 4139426 -0.717 1.0865 1.0815 -0.714 -0.7171 -0.717 -0.7172 2.8896 1.0862 1.0652 -0.7172 -0.717 -0.7171 1.0857 -0.717 -0.7171 -0.7171 -0.7171 2.8898 1.0862 +chr11 4140742 -0.7174 1.0856 1.0817 -0.7139 -0.7173 -0.7173 -0.717 2.8881 1.0853 1.0651 -0.7173 -0.7173 -0.7174 1.0848 -0.7173 -0.7174 -0.7174 -0.7174 2.8883 1.0853 +chr11 4141532 -0.7187 1.0779 1.0748 -0.7101 -0.7185 -0.7186 -0.7176 2.874 1.0776 1.0579 -0.7185 -0.7186 -0.7186 1.0771 -0.7184 -0.7187 -0.7187 -0.7187 2.8742 1.0776 +chr11 4141701 -0.7173 1.0861 1.0826 -0.7144 -0.7172 -0.7172 -0.7169 2.889 1.0858 1.066 -0.7172 -0.7172 -0.7172 1.0853 -0.7172 -0.7173 -0.7173 -0.7173 2.8892 1.0858 +chr11 4141949 -0.7188 1.077 1.0742 -0.7098 -0.7186 -0.7187 -0.7176 2.8724 1.0767 1.0573 -0.7186 -0.7188 -0.7187 1.0762 -0.7185 -0.7188 -0.7188 -0.7188 2.8726 1.0768 +chr11 4142088 -0.7176 1.0803 1.0756 -0.7115 -0.7178 -0.7176 -0.7181 2.8781 1.0802 1.0604 -0.7182 -0.7176 -0.7179 1.0796 -0.7176 -0.7178 -0.7178 -0.7178 2.8783 1.0802 +chr11 4142629 -0.7175 1.0852 1.0823 -0.7143 -0.7174 -0.7174 -0.7169 2.8875 1.0849 1.0657 -0.7173 -0.7175 -0.7174 1.0844 -0.7174 -0.7175 -0.7174 -0.7174 2.8877 1.085 +chr11 4142987 -0.7215 1.0388 1.0379 -0.6896 -0.7209 -0.7213 -0.7178 2.7987 1.0385 1.0202 -0.7215 -0.7214 -0.7213 1.038 -0.7204 -0.7216 -0.7215 -0.7216 2.7988 1.0386 +chr11 4143502 -0.7178 1.0846 1.0826 -0.7143 -0.7175 -0.7177 -0.7167 2.8867 1.0844 1.0657 -0.7173 -0.7177 -0.7176 1.0839 -0.7176 -0.7177 -0.7177 -0.7177 2.8869 1.0845 +chr11 4143779 -0.717 1.0858 1.0825 -0.7149 -0.7171 -0.717 -0.7172 2.8885 1.0857 1.0669 -0.7172 -0.717 -0.7171 1.0852 -0.7171 -0.7171 -0.7171 -0.7171 2.8887 1.0858 +chr11 4143838 -0.7169 1.086 1.0824 -0.715 -0.717 -0.7169 -0.7173 2.8888 1.0859 1.0671 -0.7171 -0.7169 -0.717 1.0854 -0.717 -0.717 -0.717 -0.717 2.889 1.086 +chr11 4143850 -0.7174 1.0853 1.0828 -0.7147 -0.7173 -0.7173 -0.7169 2.8879 1.0852 1.0666 -0.7172 -0.7174 -0.7173 1.0847 -0.7173 -0.7174 -0.7174 -0.7174 2.888 1.0853 +chr11 4144873 -0.7173 1.0832 1.08 -0.7137 -0.7174 -0.7173 -0.7176 2.8836 1.0831 1.0648 -0.7176 -0.7173 -0.7175 1.0827 -0.7173 -0.7174 -0.7174 -0.7174 2.8838 1.0832 +chr11 4146736 -0.7189 1.072 1.0698 -0.7082 -0.7189 -0.7189 -0.7183 2.8629 1.072 1.0548 -0.7193 -0.7189 -0.719 1.0718 -0.7187 -0.719 -0.719 -0.7191 2.863 1.072 +chr11 4147532 -0.7188 1.0764 1.0753 -0.7106 -0.7186 -0.7187 -0.7177 2.8713 1.0763 1.0596 -0.7186 -0.7187 -0.7187 1.0762 -0.7185 -0.7188 -0.7187 -0.7187 2.8714 1.0763 +chr11 4147579 -0.7181 1.0791 1.0773 -0.712 -0.7181 -0.7181 -0.7177 2.8762 1.0791 1.0623 -0.7183 -0.7181 -0.7182 1.079 -0.718 -0.7182 -0.7182 -0.7182 2.8763 1.0791 +chr11 4148004 -0.7169 1.0852 1.0828 -0.7152 -0.717 -0.7169 -0.7174 2.8873 1.0853 1.0685 -0.7172 -0.7169 -0.717 1.0853 -0.7169 -0.717 -0.717 -0.717 2.8874 1.0853 +chr11 4148006 -0.717 1.0857 1.0837 -0.7155 -0.717 -0.717 -0.7171 2.8882 1.0857 1.069 -0.7171 -0.717 -0.717 1.0857 -0.717 -0.717 -0.717 -0.717 2.8883 1.0857 +chr11 4149618 -0.7171 1.0848 1.0834 -0.7153 -0.7171 -0.7171 -0.7172 2.8867 1.0848 1.069 -0.7172 -0.7171 -0.7172 1.0848 -0.7171 -0.7172 -0.7172 -0.7172 2.8868 1.0848 +chr11 4151366 -0.7118 0.9346 0.9387 -0.633 -0.7105 -0.7113 -0.7033 2.5804 0.9343 0.9214 -0.7123 -0.7116 -0.7114 0.9344 -0.709 -0.712 -0.7119 -0.712 2.5804 0.9343 +chr11 4151391 -0.7119 0.9356 0.9395 -0.6336 -0.7106 -0.7114 -0.7036 2.5826 0.9354 0.9224 -0.7125 -0.7117 -0.7115 0.9355 -0.7091 -0.7121 -0.712 -0.7121 2.5826 0.9353 +chr11 4151936 -0.7173 1.0841 1.0834 -0.7152 -0.7173 -0.7173 -0.7172 2.8854 1.0841 1.0697 -0.7173 -0.7173 -0.7173 1.0841 -0.7172 -0.7173 -0.7173 -0.7173 2.8854 1.0841 +chr11 4156606 -0.7123 0.9336 0.9411 -0.6338 -0.7107 -0.7118 -0.7026 2.5788 0.9332 0.9265 -0.7122 -0.7121 -0.7116 0.9333 -0.7095 -0.7124 -0.7123 -0.7123 2.5788 0.9332 +chr11 4156658 -0.7125 0.9334 0.9414 -0.6337 -0.7108 -0.7119 -0.7024 2.5786 0.9331 0.9265 -0.7122 -0.7122 -0.7116 0.9332 -0.7096 -0.7125 -0.7124 -0.7124 2.5786 0.9331 +chr11 4156678 -0.7124 0.9335 0.9412 -0.6338 -0.7107 -0.7118 -0.7025 2.5787 0.9332 0.9266 -0.7122 -0.7121 -0.7116 0.9333 -0.7095 -0.7124 -0.7123 -0.7124 2.5787 0.9332 +chr11 4157061 -0.7159 1.0851 1.0835 -0.7163 -0.7164 -0.716 -0.7183 2.8866 1.0854 1.0774 -0.7172 -0.716 -0.7165 1.0853 -0.7162 -0.7162 -0.7163 -0.7163 2.8866 1.0854 +chr11 4157575 -0.7172 0.9675 0.9739 -0.6531 -0.7159 -0.7168 -0.7093 2.6516 0.9672 0.962 -0.7171 -0.717 -0.7166 0.9673 -0.7149 -0.7172 -0.7172 -0.7172 2.6516 0.9672 +chr11 4157625 -0.7124 0.9339 0.9416 -0.6342 -0.7108 -0.7119 -0.7027 2.5796 0.9336 0.9288 -0.7123 -0.7122 -0.7116 0.9337 -0.7096 -0.7124 -0.7124 -0.7124 2.5796 0.9336 +chr11 4157692 -0.7123 0.9332 0.941 -0.6338 -0.7107 -0.7118 -0.7025 2.5781 0.9329 0.9282 -0.7122 -0.7121 -0.7115 0.933 -0.7095 -0.7124 -0.7123 -0.7123 2.5782 0.9329 +chr11 4157786 -0.7124 0.9338 0.9415 -0.6342 -0.7108 -0.7119 -0.7026 2.5793 0.9334 0.9289 -0.7122 -0.7122 -0.7116 0.9336 -0.7096 -0.7124 -0.7123 -0.7124 2.5793 0.9334 +chr11 4157829 -0.7125 0.9344 0.9421 -0.6345 -0.7109 -0.712 -0.7027 2.5807 0.9341 0.9296 -0.7124 -0.7123 -0.7117 0.9342 -0.7097 -0.7126 -0.7125 -0.7125 2.5807 0.9341 +chr11 4157846 -0.712 0.9311 0.9389 -0.6327 -0.7104 -0.7115 -0.702 2.5735 0.9308 0.9264 -0.7118 -0.7117 -0.7112 0.9309 -0.7091 -0.712 -0.7119 -0.712 2.5736 0.9308 +chr11 4158681 -0.7117 0.9288 0.9369 -0.6316 -0.71 -0.7112 -0.7016 2.5687 0.9285 0.9257 -0.7115 -0.7114 -0.7109 0.9287 -0.7088 -0.7117 -0.7116 -0.7117 2.5688 0.9285 +chr11 4159249 -0.7176 1.0827 1.0845 -0.7156 -0.7175 -0.7176 -0.7171 2.883 1.0827 1.0799 -0.7174 -0.7176 -0.7175 1.0827 -0.7175 -0.7176 -0.7176 -0.7176 2.883 1.0827 +chr11 4159512 -0.7124 0.9326 0.9407 -0.6341 -0.7108 -0.7119 -0.7025 2.5774 0.9325 0.9312 -0.7122 -0.7122 -0.7116 0.9326 -0.7096 -0.7124 -0.7123 -0.7124 2.5774 0.9325 +chr11 4159576 -0.7181 0.974 0.9804 -0.6574 -0.7169 -0.7177 -0.7105 2.6659 0.9739 0.9725 -0.718 -0.7179 -0.7175 0.974 -0.7159 -0.7181 -0.7181 -0.7181 2.6659 0.9739 +chr11 4160767 -0.7174 1.084 1.0858 -0.7164 -0.7173 -0.7174 -0.7169 2.8852 1.0839 1.0831 -0.7172 -0.7174 -0.7173 1.0839 -0.7173 -0.7173 -0.7173 -0.7173 2.8852 1.0839 +chr11 4161449 -0.7208 1.009 1.0136 -0.677 -0.72 -0.7205 -0.7157 2.7387 1.0089 1.0085 -0.7209 -0.7207 -0.7204 1.009 -0.7193 -0.7209 -0.7208 -0.7209 2.7387 1.0089 +chr11 4163009 -0.7123 0.9296 0.9385 -0.6333 -0.7106 -0.7118 -0.7017 2.5713 0.9295 0.9297 -0.7118 -0.7121 -0.7113 0.9296 -0.7094 -0.7123 -0.7122 -0.7122 2.5713 0.9295 +chr11 4164110 -0.7171 1.0839 1.085 -0.7166 -0.7171 -0.7171 -0.7173 2.885 1.084 1.0831 -0.7172 -0.7171 -0.7171 1.084 -0.7171 -0.7171 -0.7171 -0.7171 2.885 1.084 +chr11 4165583 -0.719 0.9823 0.9883 -0.6632 -0.7179 -0.7187 -0.7121 2.6835 0.9822 0.9821 -0.719 -0.7189 -0.7184 0.9823 -0.717 -0.7191 -0.719 -0.719 2.6835 0.9822 +chr11 4166188 -0.7173 1.0834 1.0848 -0.7165 -0.7173 -0.7173 -0.7172 2.884 1.0833 1.0827 -0.7173 -0.7173 -0.7173 1.0833 -0.7173 -0.7173 -0.7173 -0.7173 2.884 1.0833 +chr11 4169047 -0.7169 1.075 1.0725 -0.7124 -0.7176 -0.7171 -0.7197 2.8675 1.0753 1.0742 -0.7188 -0.717 -0.7178 1.0753 -0.7171 -0.7173 -0.7174 -0.7174 2.8676 1.0753 +chr11 4169344 -0.7172 1.0836 1.085 -0.7169 -0.7172 -0.7172 -0.7171 2.8844 1.0836 1.0833 -0.7172 -0.7172 -0.7172 1.0836 -0.7172 -0.7172 -0.7172 -0.7172 2.8844 1.0836 +chr11 4173901 -0.7189 1.0782 1.0815 -0.7145 -0.7184 -0.7188 -0.7169 2.8749 1.078 1.0782 -0.718 -0.7188 -0.7184 1.078 -0.7186 -0.7187 -0.7186 -0.7186 2.8749 1.078 +chr11 4174384 -0.7174 1.0824 1.0838 -0.7165 -0.7174 -0.7174 -0.7173 2.8822 1.0824 1.0822 -0.7174 -0.7174 -0.7174 1.0824 -0.7174 -0.7174 -0.7174 -0.7174 2.8822 1.0824 +chr11 4177048 -0.7173 1.0818 1.0827 -0.7163 -0.7174 -0.7173 -0.7176 2.881 1.0818 1.0816 -0.7175 -0.7173 -0.7174 1.0818 -0.7173 -0.7174 -0.7174 -0.7174 2.881 1.0818 +chr11 4178320 -0.7127 0.932 0.9397 -0.637 -0.7111 -0.7122 -0.7032 2.5766 0.9319 0.9332 -0.7126 -0.7126 -0.7118 0.932 -0.7101 -0.7127 -0.7127 -0.7127 2.5766 0.9319 +chr11 4178518 -0.7173 1.083 1.0843 -0.717 -0.7173 -0.7173 -0.7173 2.8834 1.083 1.0829 -0.7173 -0.7173 -0.7173 1.083 -0.7173 -0.7173 -0.7173 -0.7173 2.8834 1.083 +chr11 4183635 -0.7212 1.0541 1.0574 -0.703 -0.7207 -0.721 -0.7185 2.8293 1.0541 1.0546 -0.7209 -0.7211 -0.7208 1.0541 -0.7205 -0.7211 -0.7211 -0.7211 2.8293 1.0541 +chr11 4185242 -0.7173 1.0826 1.0836 -0.7172 -0.7174 -0.7173 -0.7175 2.8825 1.0826 1.0825 -0.7174 -0.7173 -0.7174 1.0826 -0.7173 -0.7173 -0.7174 -0.7174 2.8825 1.0826 +chr11 4209116 -0.7166 1.0819 1.0809 -0.717 -0.7171 -0.7168 -0.7183 2.8809 1.0821 1.0817 -0.7176 -0.7167 -0.7171 1.0821 -0.7169 -0.7169 -0.7169 -0.7169 2.8809 1.0821 +chr11 4211694 -0.7214 1.0487 1.0515 -0.7011 -0.7209 -0.7213 -0.7187 2.8188 1.0487 1.0497 -0.7213 -0.7214 -0.721 1.0487 -0.7208 -0.7214 -0.7214 -0.7213 2.8188 1.0487 +chr11 4228604 -0.718 1.0783 1.0782 -0.7154 -0.718 -0.718 -0.7179 2.8746 1.0783 1.0784 -0.7181 -0.718 -0.718 1.0783 -0.7179 -0.718 -0.718 -0.718 2.8746 1.0783 +chr11 4229176 -0.7175 1.0824 1.0825 -0.7173 -0.7174 -0.7175 -0.7173 2.8822 1.0824 1.0824 -0.7174 -0.7175 -0.7174 1.0824 -0.7174 -0.7174 -0.7174 -0.7174 2.8822 1.0824 +chr11 4229195 -0.7173 1.0823 1.0821 -0.7173 -0.7173 -0.7173 -0.7175 2.882 1.0823 1.0823 -0.7174 -0.7173 -0.7173 1.0824 -0.7173 -0.7173 -0.7173 -0.7173 2.882 1.0824 +chr11 4230918 -0.7175 1.0814 1.0811 -0.7169 -0.7175 -0.7175 -0.7176 2.8804 1.0815 1.0827 -0.7176 -0.7175 -0.7175 1.0815 -0.7175 -0.7175 -0.7175 -0.7175 2.8804 1.0815 +chr11 4237235 -0.7217 1.0411 1.0425 -0.6978 -0.7212 -0.7216 -0.7187 2.8039 1.0416 1.0465 -0.7217 -0.7217 -0.7213 1.0411 -0.7211 -0.7217 -0.7217 -0.7217 2.8039 1.0411 +chr11 4238100 -0.7218 1.0417 1.0433 -0.6981 -0.7212 -0.7216 -0.7186 2.8051 1.0422 1.0474 -0.7216 -0.7218 -0.7213 1.0417 -0.7211 -0.7218 -0.7218 -0.7217 2.8051 1.0417 +chr11 4246351 -0.7189 1.0638 1.0612 -0.7087 -0.7193 -0.719 -0.7199 2.847 1.0643 1.0699 -0.7202 -0.7191 -0.7194 1.0639 -0.719 -0.7193 -0.7193 -0.7193 2.847 1.064 +chr11 4246985 -0.7219 1.0396 1.041 -0.6971 -0.7212 -0.7217 -0.7186 2.8009 1.0403 1.047 -0.7218 -0.7218 -0.7213 1.0395 -0.7212 -0.7218 -0.7218 -0.7217 2.8009 1.0395 +chr11 4261375 -0.7176 1.0824 1.0813 -0.7174 -0.7176 -0.7176 -0.7173 2.8823 1.0823 1.0909 -0.7175 -0.7176 -0.7175 1.0823 -0.7176 -0.7176 -0.7176 -0.7176 2.8823 1.0823 +chr11 4273327 -0.7175 1.0831 1.0711 -0.7175 -0.7175 -0.7175 -0.7176 2.8838 1.0832 1.0925 -0.7176 -0.7175 -0.7175 1.0828 -0.7175 -0.7175 -0.7175 -0.7175 2.8839 1.0832 +chr11 4283717 0.7233 -1.1344 0.391 0.7222 0.7241 0.7246 0.715 -2.9824 -1.1255 -1.1348 0.7251 0.722 0.7227 0.3988 0.7242 0.7249 0.7253 0.7249 -2.9836 -1.1298 +chr11 4284110 0.7062 -1.1375 0.5957 0.7058 0.7066 0.7066 0.7038 -2.9797 -1.1346 -1.1381 0.7068 0.7058 0.7059 0.6075 0.7065 0.7067 0.7068 0.7067 -2.9807 -1.1376 +chr11 4285090 0.7024 -1.0934 0.683 0.6975 0.7021 0.7022 0.7056 -2.8862 -1.1106 -1.0931 0.7035 0.7028 0.7026 0.6985 0.7024 0.7034 0.703 0.703 -2.8865 -1.0925 +chr11 4286016 0.6998 -1.1324 0.6815 0.699 0.6994 0.6997 0.699 -2.9626 -1.133 -1.1317 0.6996 0.6997 0.6992 0.698 0.6996 0.6996 0.6997 0.6997 -2.9627 -1.1315 +chr11 4288936 0.7042 -1.0649 0.6806 0.6939 0.7021 0.7037 0.7027 -2.8246 -1.0924 -1.064 0.7039 0.704 0.7031 0.7012 0.7032 0.704 0.704 0.7041 -2.8247 -1.061 +chr11 4301371 0.6999 -1.1332 0.6817 0.6989 0.6992 0.6998 0.698 -2.9638 -1.1331 -1.1326 0.6994 0.6997 0.699 0.6981 0.6996 0.6994 0.6996 0.6996 -2.964 -1.1323 +chr11 4310171 0.6995 -1.1496 0.6833 0.6991 0.6993 0.6995 0.7 -2.96 -1.1325 -1.1305 0.6997 0.6996 0.6991 0.6988 0.6995 0.6997 0.6996 0.6996 -2.9604 -1.1308 +chr11 4330042 0.7035 -1.1568 0.6829 0.6965 0.7019 0.7033 0.7023 -2.8717 -1.109 -1.0874 0.7035 0.7036 0.7021 0.7013 0.703 0.7035 0.7036 0.7037 -2.8725 -1.0853 +chr11 4908477 -0.2937 -0.2945 -0.2933 -0.2939 -0.2938 -0.2937 -0.2943 -0.2937 -0.2939 -0.2945 -0.2937 3.3684 -0.2934 -0.2937 -0.2934 3.3681 -0.2937 -0.2934 -0.2938 -0.2937 +chr11 4941705 -0.2927 -0.289 -0.3024 -0.2936 -0.2913 -0.2911 -0.293 -0.2925 -0.2917 -0.2893 -0.2991 3.3273 -0.3012 -0.2917 -0.3011 3.3298 -0.2983 -0.2982 -0.2917 -0.2924 +chr11 4944016 -0.2944 -0.2943 -0.2946 -0.2944 -0.2943 -0.2943 -0.2944 -0.2944 -0.2944 -0.2943 -0.2945 3.3274 -0.2946 -0.2944 -0.2946 3.3274 -0.2945 -0.2945 -0.2944 -0.2944 +chr11 4945582 -0.2944 -0.2943 -0.2946 -0.2944 -0.2943 -0.2944 -0.2944 -0.2944 -0.2944 -0.2943 -0.2945 3.3273 -0.2946 -0.2944 -0.2946 3.3273 -0.2945 -0.2945 -0.2944 -0.2944 +chr11 4949541 -0.2948 -0.2942 -0.294 -0.2943 -0.2945 -0.295 -0.2941 -0.2947 -0.2946 -0.2942 -0.2934 3.3271 -0.2941 -0.295 -0.294 3.3267 -0.2941 -0.2944 -0.2948 -0.2948 +chr11 4971995 -0.2958 -0.2957 -0.2949 -0.2955 -0.2957 -0.296 -0.2954 -0.2957 -0.2957 -0.2957 -0.2948 3.3243 -0.295 -0.2959 -0.295 3.3241 -0.2952 -0.2954 -0.2958 -0.2958 diff --git a/test-data/genotype0-without-reference.tsv b/test-data/genotype0-without-reference.tsv new file mode 100644 index 0000000..5b408cd --- /dev/null +++ b/test-data/genotype0-without-reference.tsv @@ -0,0 +1,101 @@ +chromosome position Q_CFW-SW/100.0a Q_CFW-SW/100.0c Q_CFW-SW/100.0d Q_CFW-SW/100.0e Q_CFW-SW/100.0f +chr11 3200246 0.4043 0.3655 0.3375 -0.614 0.3452 +chr11 3205355 0.395 0.3545 0.3325 -0.5421 0.3433 +chr11 3218908 0.3977 0.3207 0.3134 -0.4491 0.3267 +chr11 3414044 -0.3616 -0.328 -0.3234 0.074 -0.2713 +chr11 3460427 -0.341 -0.3363 -0.3346 0.073 -0.2652 +chr11 3462290 -0.3552 -0.3281 -0.3287 0.0912 -0.2708 +chr11 3462323 -0.3524 -0.3296 -0.3298 0.0874 -0.2697 +chr11 3462325 -0.3533 -0.3291 -0.3294 0.0885 -0.27 +chr11 3462348 -0.361 -0.3244 -0.326 0.0986 -0.2731 +chr11 3464016 -0.3461 -0.334 -0.3331 0.08 -0.2672 +chr11 3554197 0.3393 0.3346 0.0862 -0.1332 0.2532 +chr11 3558414 -0.3648 -0.3172 0.0754 0.1639 -0.2644 +chr11 3619052 -0.3394 -0.3269 1.0859 0.2534 -0.2429 +chr11 3883306 -0.3207 -0.2844 2.6043 0.0664 -0.227 +chr11 4017210 -0.3655 -0.3608 1.5442 -0.0087 -0.2506 +chr11 4017211 -0.3685 -0.356 1.5489 -0.0107 -0.2535 +chr11 4017223 -0.3824 -0.3338 1.5704 -0.02 -0.2667 +chr11 4017385 -0.3677 -0.3524 1.5514 -0.0141 -0.2529 +chr11 4022004 -0.3702 -0.3553 1.5401 -0.0114 -0.2548 +chr11 4024616 -0.7473 1.1971 0.937 -0.4412 -0.7211 +chr11 4110988 0.8081 -1.0677 -1.2622 0.66 0.7659 +chr11 4124677 0.8076 -0.9793 -1.1824 0.6428 0.7643 +chr11 4139413 -0.7222 1.0853 1.0928 -0.7139 -0.7198 +chr11 4139426 -0.717 1.0865 1.0815 -0.714 -0.7171 +chr11 4140742 -0.7174 1.0856 1.0817 -0.7139 -0.7173 +chr11 4141532 -0.7187 1.0779 1.0748 -0.7101 -0.7185 +chr11 4141701 -0.7173 1.0861 1.0826 -0.7144 -0.7172 +chr11 4141949 -0.7188 1.077 1.0742 -0.7098 -0.7186 +chr11 4142088 -0.7176 1.0803 1.0756 -0.7115 -0.7178 +chr11 4142629 -0.7175 1.0852 1.0823 -0.7143 -0.7174 +chr11 4142987 -0.7215 1.0388 1.0379 -0.6896 -0.7209 +chr11 4143502 -0.7178 1.0846 1.0826 -0.7143 -0.7175 +chr11 4143779 -0.717 1.0858 1.0825 -0.7149 -0.7171 +chr11 4143838 -0.7169 1.086 1.0824 -0.715 -0.717 +chr11 4143850 -0.7174 1.0853 1.0828 -0.7147 -0.7173 +chr11 4144873 -0.7173 1.0832 1.08 -0.7137 -0.7174 +chr11 4146736 -0.7189 1.072 1.0698 -0.7082 -0.7189 +chr11 4147532 -0.7188 1.0764 1.0753 -0.7106 -0.7186 +chr11 4147579 -0.7181 1.0791 1.0773 -0.712 -0.7181 +chr11 4148004 -0.7169 1.0852 1.0828 -0.7152 -0.717 +chr11 4148006 -0.717 1.0857 1.0837 -0.7155 -0.717 +chr11 4149618 -0.7171 1.0848 1.0834 -0.7153 -0.7171 +chr11 4151366 -0.7118 0.9346 0.9387 -0.633 -0.7105 +chr11 4151391 -0.7119 0.9356 0.9395 -0.6336 -0.7106 +chr11 4151936 -0.7173 1.0841 1.0834 -0.7152 -0.7173 +chr11 4156606 -0.7123 0.9336 0.9411 -0.6338 -0.7107 +chr11 4156658 -0.7125 0.9334 0.9414 -0.6337 -0.7108 +chr11 4156678 -0.7124 0.9335 0.9412 -0.6338 -0.7107 +chr11 4157061 -0.7159 1.0851 1.0835 -0.7163 -0.7164 +chr11 4157575 -0.7172 0.9675 0.9739 -0.6531 -0.7159 +chr11 4157625 -0.7124 0.9339 0.9416 -0.6342 -0.7108 +chr11 4157692 -0.7123 0.9332 0.941 -0.6338 -0.7107 +chr11 4157786 -0.7124 0.9338 0.9415 -0.6342 -0.7108 +chr11 4157829 -0.7125 0.9344 0.9421 -0.6345 -0.7109 +chr11 4157846 -0.712 0.9311 0.9389 -0.6327 -0.7104 +chr11 4158681 -0.7117 0.9288 0.9369 -0.6316 -0.71 +chr11 4159249 -0.7176 1.0827 1.0845 -0.7156 -0.7175 +chr11 4159512 -0.7124 0.9326 0.9407 -0.6341 -0.7108 +chr11 4159576 -0.7181 0.974 0.9804 -0.6574 -0.7169 +chr11 4160767 -0.7174 1.084 1.0858 -0.7164 -0.7173 +chr11 4161449 -0.7208 1.009 1.0136 -0.677 -0.72 +chr11 4163009 -0.7123 0.9296 0.9385 -0.6333 -0.7106 +chr11 4164110 -0.7171 1.0839 1.085 -0.7166 -0.7171 +chr11 4165583 -0.719 0.9823 0.9883 -0.6632 -0.7179 +chr11 4166188 -0.7173 1.0834 1.0848 -0.7165 -0.7173 +chr11 4169047 -0.7169 1.075 1.0725 -0.7124 -0.7176 +chr11 4169344 -0.7172 1.0836 1.085 -0.7169 -0.7172 +chr11 4173901 -0.7189 1.0782 1.0815 -0.7145 -0.7184 +chr11 4174384 -0.7174 1.0824 1.0838 -0.7165 -0.7174 +chr11 4177048 -0.7173 1.0818 1.0827 -0.7163 -0.7174 +chr11 4178320 -0.7127 0.932 0.9397 -0.637 -0.7111 +chr11 4178518 -0.7173 1.083 1.0843 -0.717 -0.7173 +chr11 4183635 -0.7212 1.0541 1.0574 -0.703 -0.7207 +chr11 4185242 -0.7173 1.0826 1.0836 -0.7172 -0.7174 +chr11 4209116 -0.7166 1.0819 1.0809 -0.717 -0.7171 +chr11 4211694 -0.7214 1.0487 1.0515 -0.7011 -0.7209 +chr11 4228604 -0.718 1.0783 1.0782 -0.7154 -0.718 +chr11 4229176 -0.7175 1.0824 1.0825 -0.7173 -0.7174 +chr11 4229195 -0.7173 1.0823 1.0821 -0.7173 -0.7173 +chr11 4230918 -0.7175 1.0814 1.0811 -0.7169 -0.7175 +chr11 4237235 -0.7217 1.0411 1.0425 -0.6978 -0.7212 +chr11 4238100 -0.7218 1.0417 1.0433 -0.6981 -0.7212 +chr11 4246351 -0.7189 1.0638 1.0612 -0.7087 -0.7193 +chr11 4246985 -0.7219 1.0396 1.041 -0.6971 -0.7212 +chr11 4261375 -0.7176 1.0824 1.0813 -0.7174 -0.7176 +chr11 4273327 -0.7175 1.0831 1.0711 -0.7175 -0.7175 +chr11 4283717 0.7233 -1.1344 0.391 0.7222 0.7241 +chr11 4284110 0.7062 -1.1375 0.5957 0.7058 0.7066 +chr11 4285090 0.7024 -1.0934 0.683 0.6975 0.7021 +chr11 4286016 0.6998 -1.1324 0.6815 0.699 0.6994 +chr11 4288936 0.7042 -1.0649 0.6806 0.6939 0.7021 +chr11 4301371 0.6999 -1.1332 0.6817 0.6989 0.6992 +chr11 4310171 0.6995 -1.1496 0.6833 0.6991 0.6993 +chr11 4330042 0.7035 -1.1568 0.6829 0.6965 0.7019 +chr11 4908477 -0.2937 -0.2945 -0.2933 -0.2939 -0.2938 +chr11 4941705 -0.2927 -0.289 -0.3024 -0.2936 -0.2913 +chr11 4944016 -0.2944 -0.2943 -0.2946 -0.2944 -0.2943 +chr11 4945582 -0.2944 -0.2943 -0.2946 -0.2944 -0.2943 +chr11 4949541 -0.2948 -0.2942 -0.294 -0.2943 -0.2945 +chr11 4971995 -0.2958 -0.2957 -0.2949 -0.2955 -0.2957 diff --git a/test-data/genotype1-without-reference.tsv b/test-data/genotype1-without-reference.tsv new file mode 100644 index 0000000..c766ca5 --- /dev/null +++ b/test-data/genotype1-without-reference.tsv @@ -0,0 +1,101 @@ +chromosome position Q_CFW-SW/100.0g Q_CFW-SW/100.0h Q_CFW-SW/100.0i Q_CFW-SW/100.0j Q_CFW-SW/100.0l +chr11 3200246 0.3836 0.3901 0.2411 -0.1418 0.3629 +chr11 3205355 0.3751 0.3806 0.2034 -0.1 0.3539 +chr11 3218908 0.3576 0.3449 0.1215 -0.0346 0.3294 +chr11 3414044 -0.2976 -0.339 1.0335 -0.2665 -0.3005 +chr11 3460427 -0.2791 -0.3456 1.3293 -0.2961 -0.3032 +chr11 3462290 -0.2841 -0.3331 1.3928 -0.2856 -0.3056 +chr11 3462323 -0.2832 -0.3357 1.3896 -0.2873 -0.3051 +chr11 3462325 -0.2835 -0.3349 1.3909 -0.2867 -0.3052 +chr11 3462348 -0.2864 -0.3279 1.4031 -0.2807 -0.3064 +chr11 3464016 -0.2805 -0.3413 1.3757 -0.2937 -0.3044 +chr11 3554197 0.2705 0.3409 -0.5622 0.3082 0.2896 +chr11 3558414 -0.286 -0.3239 0.5833 -0.2805 -0.2923 +chr11 3619052 -0.2508 -0.3166 0.2133 -0.3278 -0.2838 +chr11 3883306 -0.2504 -8e-04 -0.2199 -0.3104 -0.2247 +chr11 4017210 -0.3213 0.215 -0.3742 -0.396 -0.2641 +chr11 4017211 -0.3241 0.2125 -0.3624 -0.3916 -0.261 +chr11 4017223 -0.3373 0.2009 -0.3071 -0.3708 -0.2466 +chr11 4017385 -0.3236 0.2108 -0.3557 -0.3879 -0.2582 +chr11 4022004 -0.3259 0.2141 -0.3604 -0.3909 -0.2607 +chr11 4024616 -0.7083 -0.6358 2.9722 1.1229 0.7712 +chr11 4110988 0.7943 0.6125 -2.8791 -1.0382 -0.985 +chr11 4124677 0.795 0.6135 -2.7181 -0.9575 -0.9426 +chr11 4139413 -0.7216 -0.7119 2.8902 1.084 1.0653 +chr11 4139426 -0.717 -0.7172 2.8896 1.0862 1.0652 +chr11 4140742 -0.7173 -0.717 2.8881 1.0853 1.0651 +chr11 4141532 -0.7186 -0.7176 2.874 1.0776 1.0579 +chr11 4141701 -0.7172 -0.7169 2.889 1.0858 1.066 +chr11 4141949 -0.7187 -0.7176 2.8724 1.0767 1.0573 +chr11 4142088 -0.7176 -0.7181 2.8781 1.0802 1.0604 +chr11 4142629 -0.7174 -0.7169 2.8875 1.0849 1.0657 +chr11 4142987 -0.7213 -0.7178 2.7987 1.0385 1.0202 +chr11 4143502 -0.7177 -0.7167 2.8867 1.0844 1.0657 +chr11 4143779 -0.717 -0.7172 2.8885 1.0857 1.0669 +chr11 4143838 -0.7169 -0.7173 2.8888 1.0859 1.0671 +chr11 4143850 -0.7173 -0.7169 2.8879 1.0852 1.0666 +chr11 4144873 -0.7173 -0.7176 2.8836 1.0831 1.0648 +chr11 4146736 -0.7189 -0.7183 2.8629 1.072 1.0548 +chr11 4147532 -0.7187 -0.7177 2.8713 1.0763 1.0596 +chr11 4147579 -0.7181 -0.7177 2.8762 1.0791 1.0623 +chr11 4148004 -0.7169 -0.7174 2.8873 1.0853 1.0685 +chr11 4148006 -0.717 -0.7171 2.8882 1.0857 1.069 +chr11 4149618 -0.7171 -0.7172 2.8867 1.0848 1.069 +chr11 4151366 -0.7113 -0.7033 2.5804 0.9343 0.9214 +chr11 4151391 -0.7114 -0.7036 2.5826 0.9354 0.9224 +chr11 4151936 -0.7173 -0.7172 2.8854 1.0841 1.0697 +chr11 4156606 -0.7118 -0.7026 2.5788 0.9332 0.9265 +chr11 4156658 -0.7119 -0.7024 2.5786 0.9331 0.9265 +chr11 4156678 -0.7118 -0.7025 2.5787 0.9332 0.9266 +chr11 4157061 -0.716 -0.7183 2.8866 1.0854 1.0774 +chr11 4157575 -0.7168 -0.7093 2.6516 0.9672 0.962 +chr11 4157625 -0.7119 -0.7027 2.5796 0.9336 0.9288 +chr11 4157692 -0.7118 -0.7025 2.5781 0.9329 0.9282 +chr11 4157786 -0.7119 -0.7026 2.5793 0.9334 0.9289 +chr11 4157829 -0.712 -0.7027 2.5807 0.9341 0.9296 +chr11 4157846 -0.7115 -0.702 2.5735 0.9308 0.9264 +chr11 4158681 -0.7112 -0.7016 2.5687 0.9285 0.9257 +chr11 4159249 -0.7176 -0.7171 2.883 1.0827 1.0799 +chr11 4159512 -0.7119 -0.7025 2.5774 0.9325 0.9312 +chr11 4159576 -0.7177 -0.7105 2.6659 0.9739 0.9725 +chr11 4160767 -0.7174 -0.7169 2.8852 1.0839 1.0831 +chr11 4161449 -0.7205 -0.7157 2.7387 1.0089 1.0085 +chr11 4163009 -0.7118 -0.7017 2.5713 0.9295 0.9297 +chr11 4164110 -0.7171 -0.7173 2.885 1.084 1.0831 +chr11 4165583 -0.7187 -0.7121 2.6835 0.9822 0.9821 +chr11 4166188 -0.7173 -0.7172 2.884 1.0833 1.0827 +chr11 4169047 -0.7171 -0.7197 2.8675 1.0753 1.0742 +chr11 4169344 -0.7172 -0.7171 2.8844 1.0836 1.0833 +chr11 4173901 -0.7188 -0.7169 2.8749 1.078 1.0782 +chr11 4174384 -0.7174 -0.7173 2.8822 1.0824 1.0822 +chr11 4177048 -0.7173 -0.7176 2.881 1.0818 1.0816 +chr11 4178320 -0.7122 -0.7032 2.5766 0.9319 0.9332 +chr11 4178518 -0.7173 -0.7173 2.8834 1.083 1.0829 +chr11 4183635 -0.721 -0.7185 2.8293 1.0541 1.0546 +chr11 4185242 -0.7173 -0.7175 2.8825 1.0826 1.0825 +chr11 4209116 -0.7168 -0.7183 2.8809 1.0821 1.0817 +chr11 4211694 -0.7213 -0.7187 2.8188 1.0487 1.0497 +chr11 4228604 -0.718 -0.7179 2.8746 1.0783 1.0784 +chr11 4229176 -0.7175 -0.7173 2.8822 1.0824 1.0824 +chr11 4229195 -0.7173 -0.7175 2.882 1.0823 1.0823 +chr11 4230918 -0.7175 -0.7176 2.8804 1.0815 1.0827 +chr11 4237235 -0.7216 -0.7187 2.8039 1.0416 1.0465 +chr11 4238100 -0.7216 -0.7186 2.8051 1.0422 1.0474 +chr11 4246351 -0.719 -0.7199 2.847 1.0643 1.0699 +chr11 4246985 -0.7217 -0.7186 2.8009 1.0403 1.047 +chr11 4261375 -0.7176 -0.7173 2.8823 1.0823 1.0909 +chr11 4273327 -0.7175 -0.7176 2.8838 1.0832 1.0925 +chr11 4283717 0.7246 0.715 -2.9824 -1.1255 -1.1348 +chr11 4284110 0.7066 0.7038 -2.9797 -1.1346 -1.1381 +chr11 4285090 0.7022 0.7056 -2.8862 -1.1106 -1.0931 +chr11 4286016 0.6997 0.699 -2.9626 -1.133 -1.1317 +chr11 4288936 0.7037 0.7027 -2.8246 -1.0924 -1.064 +chr11 4301371 0.6998 0.698 -2.9638 -1.1331 -1.1326 +chr11 4310171 0.6995 0.7 -2.96 -1.1325 -1.1305 +chr11 4330042 0.7033 0.7023 -2.8717 -1.109 -1.0874 +chr11 4908477 -0.2937 -0.2943 -0.2937 -0.2939 -0.2945 +chr11 4941705 -0.2911 -0.293 -0.2925 -0.2917 -0.2893 +chr11 4944016 -0.2943 -0.2944 -0.2944 -0.2944 -0.2943 +chr11 4945582 -0.2944 -0.2944 -0.2944 -0.2944 -0.2943 +chr11 4949541 -0.295 -0.2941 -0.2947 -0.2946 -0.2942 +chr11 4971995 -0.296 -0.2954 -0.2957 -0.2957 -0.2957 diff --git a/test-data/genotype2-without-reference.tsv b/test-data/genotype2-without-reference.tsv new file mode 100644 index 0000000..d237634 --- /dev/null +++ b/test-data/genotype2-without-reference.tsv @@ -0,0 +1,101 @@ +chromosome position Q_CFW-SW/100.0m Q_CFW-SW/100.0n Q_CFW-SW/100.0o Q_CFW-SW/100.0p Q_CFW-SW/100.0q +chr11 3200246 -1.8435 0.3742 -0.5826 0.4141 -0.0555 +chr11 3205355 -1.9966 0.3681 -0.4778 0.4084 -0.0767 +chr11 3218908 -2.3341 0.3548 -0.2218 0.3769 -0.0873 +chr11 3414044 3.5125 -0.3327 -0.2604 -0.3458 0.239 +chr11 3460427 3.5493 -0.3261 -0.2861 -0.3472 0.051 +chr11 3462290 3.5419 -0.3303 -0.2974 -0.3477 0.0408 +chr11 3462323 3.542 -0.3294 -0.2953 -0.3476 0.0418 +chr11 3462325 3.5419 -0.3297 -0.296 -0.3476 0.0414 +chr11 3462348 3.541 -0.3318 -0.3018 -0.3476 0.0372 +chr11 3464016 3.543 -0.328 -0.2906 -0.3479 0.0464 +chr11 3554197 -3.4878 0.3228 0.3214 0.3396 0.017 +chr11 3558414 3.3617 -0.3305 -0.342 -0.3407 -0.0391 +chr11 3619052 1.7148 -0.3089 -0.3337 -0.3288 -0.0442 +chr11 3883306 0.2938 -0.3079 -0.2412 -0.3312 -0.2698 +chr11 4017210 0.2322 -0.3503 -0.2296 -0.405 -0.3226 +chr11 4017211 0.2295 -0.3533 -0.2325 -0.4005 -0.3256 +chr11 4017223 0.2171 -0.3669 -0.2459 -0.3794 -0.3394 +chr11 4017385 0.2295 -0.3526 -0.2317 -0.3968 -0.3258 +chr11 4022004 0.2282 -0.3548 -0.2332 -0.3998 -0.3266 +chr11 4024616 -0.7234 -0.733 -0.7373 1.1363 -0.723 +chr11 4110988 0.6983 0.8009 0.7614 -1.0441 0.7859 +chr11 4124677 0.705 0.7998 0.7611 -0.9601 0.7821 +chr11 4139413 -0.7167 -0.7218 -0.7196 1.0836 -0.721 +chr11 4139426 -0.7172 -0.717 -0.7171 1.0857 -0.717 +chr11 4140742 -0.7173 -0.7173 -0.7174 1.0848 -0.7173 +chr11 4141532 -0.7185 -0.7186 -0.7186 1.0771 -0.7184 +chr11 4141701 -0.7172 -0.7172 -0.7172 1.0853 -0.7172 +chr11 4141949 -0.7186 -0.7188 -0.7187 1.0762 -0.7185 +chr11 4142088 -0.7182 -0.7176 -0.7179 1.0796 -0.7176 +chr11 4142629 -0.7173 -0.7175 -0.7174 1.0844 -0.7174 +chr11 4142987 -0.7215 -0.7214 -0.7213 1.038 -0.7204 +chr11 4143502 -0.7173 -0.7177 -0.7176 1.0839 -0.7176 +chr11 4143779 -0.7172 -0.717 -0.7171 1.0852 -0.7171 +chr11 4143838 -0.7171 -0.7169 -0.717 1.0854 -0.717 +chr11 4143850 -0.7172 -0.7174 -0.7173 1.0847 -0.7173 +chr11 4144873 -0.7176 -0.7173 -0.7175 1.0827 -0.7173 +chr11 4146736 -0.7193 -0.7189 -0.719 1.0718 -0.7187 +chr11 4147532 -0.7186 -0.7187 -0.7187 1.0762 -0.7185 +chr11 4147579 -0.7183 -0.7181 -0.7182 1.079 -0.718 +chr11 4148004 -0.7172 -0.7169 -0.717 1.0853 -0.7169 +chr11 4148006 -0.7171 -0.717 -0.717 1.0857 -0.717 +chr11 4149618 -0.7172 -0.7171 -0.7172 1.0848 -0.7171 +chr11 4151366 -0.7123 -0.7116 -0.7114 0.9344 -0.709 +chr11 4151391 -0.7125 -0.7117 -0.7115 0.9355 -0.7091 +chr11 4151936 -0.7173 -0.7173 -0.7173 1.0841 -0.7172 +chr11 4156606 -0.7122 -0.7121 -0.7116 0.9333 -0.7095 +chr11 4156658 -0.7122 -0.7122 -0.7116 0.9332 -0.7096 +chr11 4156678 -0.7122 -0.7121 -0.7116 0.9333 -0.7095 +chr11 4157061 -0.7172 -0.716 -0.7165 1.0853 -0.7162 +chr11 4157575 -0.7171 -0.717 -0.7166 0.9673 -0.7149 +chr11 4157625 -0.7123 -0.7122 -0.7116 0.9337 -0.7096 +chr11 4157692 -0.7122 -0.7121 -0.7115 0.933 -0.7095 +chr11 4157786 -0.7122 -0.7122 -0.7116 0.9336 -0.7096 +chr11 4157829 -0.7124 -0.7123 -0.7117 0.9342 -0.7097 +chr11 4157846 -0.7118 -0.7117 -0.7112 0.9309 -0.7091 +chr11 4158681 -0.7115 -0.7114 -0.7109 0.9287 -0.7088 +chr11 4159249 -0.7174 -0.7176 -0.7175 1.0827 -0.7175 +chr11 4159512 -0.7122 -0.7122 -0.7116 0.9326 -0.7096 +chr11 4159576 -0.718 -0.7179 -0.7175 0.974 -0.7159 +chr11 4160767 -0.7172 -0.7174 -0.7173 1.0839 -0.7173 +chr11 4161449 -0.7209 -0.7207 -0.7204 1.009 -0.7193 +chr11 4163009 -0.7118 -0.7121 -0.7113 0.9296 -0.7094 +chr11 4164110 -0.7172 -0.7171 -0.7171 1.084 -0.7171 +chr11 4165583 -0.719 -0.7189 -0.7184 0.9823 -0.717 +chr11 4166188 -0.7173 -0.7173 -0.7173 1.0833 -0.7173 +chr11 4169047 -0.7188 -0.717 -0.7178 1.0753 -0.7171 +chr11 4169344 -0.7172 -0.7172 -0.7172 1.0836 -0.7172 +chr11 4173901 -0.718 -0.7188 -0.7184 1.078 -0.7186 +chr11 4174384 -0.7174 -0.7174 -0.7174 1.0824 -0.7174 +chr11 4177048 -0.7175 -0.7173 -0.7174 1.0818 -0.7173 +chr11 4178320 -0.7126 -0.7126 -0.7118 0.932 -0.7101 +chr11 4178518 -0.7173 -0.7173 -0.7173 1.083 -0.7173 +chr11 4183635 -0.7209 -0.7211 -0.7208 1.0541 -0.7205 +chr11 4185242 -0.7174 -0.7173 -0.7174 1.0826 -0.7173 +chr11 4209116 -0.7176 -0.7167 -0.7171 1.0821 -0.7169 +chr11 4211694 -0.7213 -0.7214 -0.721 1.0487 -0.7208 +chr11 4228604 -0.7181 -0.718 -0.718 1.0783 -0.7179 +chr11 4229176 -0.7174 -0.7175 -0.7174 1.0824 -0.7174 +chr11 4229195 -0.7174 -0.7173 -0.7173 1.0824 -0.7173 +chr11 4230918 -0.7176 -0.7175 -0.7175 1.0815 -0.7175 +chr11 4237235 -0.7217 -0.7217 -0.7213 1.0411 -0.7211 +chr11 4238100 -0.7216 -0.7218 -0.7213 1.0417 -0.7211 +chr11 4246351 -0.7202 -0.7191 -0.7194 1.0639 -0.719 +chr11 4246985 -0.7218 -0.7218 -0.7213 1.0395 -0.7212 +chr11 4261375 -0.7175 -0.7176 -0.7175 1.0823 -0.7176 +chr11 4273327 -0.7176 -0.7175 -0.7175 1.0828 -0.7175 +chr11 4283717 0.7251 0.722 0.7227 0.3988 0.7242 +chr11 4284110 0.7068 0.7058 0.7059 0.6075 0.7065 +chr11 4285090 0.7035 0.7028 0.7026 0.6985 0.7024 +chr11 4286016 0.6996 0.6997 0.6992 0.698 0.6996 +chr11 4288936 0.7039 0.704 0.7031 0.7012 0.7032 +chr11 4301371 0.6994 0.6997 0.699 0.6981 0.6996 +chr11 4310171 0.6997 0.6996 0.6991 0.6988 0.6995 +chr11 4330042 0.7035 0.7036 0.7021 0.7013 0.703 +chr11 4908477 -0.2937 3.3684 -0.2934 -0.2937 -0.2934 +chr11 4941705 -0.2991 3.3273 -0.3012 -0.2917 -0.3011 +chr11 4944016 -0.2945 3.3274 -0.2946 -0.2944 -0.2946 +chr11 4945582 -0.2945 3.3273 -0.2946 -0.2944 -0.2946 +chr11 4949541 -0.2934 3.3271 -0.2941 -0.295 -0.294 +chr11 4971995 -0.2948 3.3243 -0.295 -0.2959 -0.295 diff --git a/test-data/genotype3-without-reference.tsv b/test-data/genotype3-without-reference.tsv new file mode 100644 index 0000000..177a626 --- /dev/null +++ b/test-data/genotype3-without-reference.tsv @@ -0,0 +1,101 @@ +chromosome position Q_CFW-SW/100.0r Q_CFW-SW/10.0b Q_CFW-SW/10.0c Q_CFW-SW/10.0d Q_CFW-SW/10.0f +chr11 3200246 0.2733 0.408 0.388 -3.6091 0.381 +chr11 3205355 0.2807 0.3991 0.384 -3.5452 0.3728 +chr11 3218908 0.3071 0.3728 0.3672 -3.5468 0.3528 +chr11 3414044 -0.3538 -0.3239 -0.3452 3.6101 -0.3177 +chr11 3460427 -0.3419 -0.33 -0.3332 3.664 -0.3154 +chr11 3462290 -0.3514 -0.323 -0.343 3.6699 -0.3101 +chr11 3462323 -0.3495 -0.3244 -0.3411 3.6675 -0.3111 +chr11 3462325 -0.3501 -0.324 -0.3417 3.6682 -0.3108 +chr11 3462348 -0.3551 -0.32 -0.3469 3.6751 -0.3079 +chr11 3464016 -0.3455 -0.3279 -0.3369 3.6601 -0.3138 +chr11 3554197 0.3492 0.3396 0.3289 -3.5317 0.3086 +chr11 3558414 -0.3686 -0.3297 -0.3505 3.5287 -0.2993 +chr11 3619052 -0.3453 -0.3142 -0.3346 2.9131 -0.2884 +chr11 3883306 -0.3016 -0.2836 -0.2786 -0.2529 -0.3149 +chr11 4017210 -0.3643 -0.2958 -0.3026 -0.4183 -0.3808 +chr11 4017211 -0.3673 -0.2987 -0.3055 -0.4064 -0.3776 +chr11 4017223 -0.3812 -0.3125 -0.3194 -0.3509 -0.3623 +chr11 4017385 -0.3665 -0.2982 -0.3048 -0.3998 -0.3746 +chr11 4022004 -0.3692 -0.3 -0.307 -0.4045 -0.3774 +chr11 4024616 -0.7502 -0.7397 -0.7496 2.9891 0.8355 +chr11 4110988 0.7916 0.781 0.7821 -2.8836 -1.038 +chr11 4124677 0.7882 0.78 0.7807 -2.7205 -0.9568 +chr11 4139413 -0.721 -0.7207 -0.7207 2.8905 1.084 +chr11 4139426 -0.7171 -0.7171 -0.7171 2.8898 1.0862 +chr11 4140742 -0.7174 -0.7174 -0.7174 2.8883 1.0853 +chr11 4141532 -0.7187 -0.7187 -0.7187 2.8742 1.0776 +chr11 4141701 -0.7173 -0.7173 -0.7173 2.8892 1.0858 +chr11 4141949 -0.7188 -0.7188 -0.7188 2.8726 1.0768 +chr11 4142088 -0.7178 -0.7178 -0.7178 2.8783 1.0802 +chr11 4142629 -0.7175 -0.7174 -0.7174 2.8877 1.085 +chr11 4142987 -0.7216 -0.7215 -0.7216 2.7988 1.0386 +chr11 4143502 -0.7177 -0.7177 -0.7177 2.8869 1.0845 +chr11 4143779 -0.7171 -0.7171 -0.7171 2.8887 1.0858 +chr11 4143838 -0.717 -0.717 -0.717 2.889 1.086 +chr11 4143850 -0.7174 -0.7174 -0.7174 2.888 1.0853 +chr11 4144873 -0.7174 -0.7174 -0.7174 2.8838 1.0832 +chr11 4146736 -0.719 -0.719 -0.7191 2.863 1.072 +chr11 4147532 -0.7188 -0.7187 -0.7187 2.8714 1.0763 +chr11 4147579 -0.7182 -0.7182 -0.7182 2.8763 1.0791 +chr11 4148004 -0.717 -0.717 -0.717 2.8874 1.0853 +chr11 4148006 -0.717 -0.717 -0.717 2.8883 1.0857 +chr11 4149618 -0.7172 -0.7172 -0.7172 2.8868 1.0848 +chr11 4151366 -0.712 -0.7119 -0.712 2.5804 0.9343 +chr11 4151391 -0.7121 -0.712 -0.7121 2.5826 0.9353 +chr11 4151936 -0.7173 -0.7173 -0.7173 2.8854 1.0841 +chr11 4156606 -0.7124 -0.7123 -0.7123 2.5788 0.9332 +chr11 4156658 -0.7125 -0.7124 -0.7124 2.5786 0.9331 +chr11 4156678 -0.7124 -0.7123 -0.7124 2.5787 0.9332 +chr11 4157061 -0.7162 -0.7163 -0.7163 2.8866 1.0854 +chr11 4157575 -0.7172 -0.7172 -0.7172 2.6516 0.9672 +chr11 4157625 -0.7124 -0.7124 -0.7124 2.5796 0.9336 +chr11 4157692 -0.7124 -0.7123 -0.7123 2.5782 0.9329 +chr11 4157786 -0.7124 -0.7123 -0.7124 2.5793 0.9334 +chr11 4157829 -0.7126 -0.7125 -0.7125 2.5807 0.9341 +chr11 4157846 -0.712 -0.7119 -0.712 2.5736 0.9308 +chr11 4158681 -0.7117 -0.7116 -0.7117 2.5688 0.9285 +chr11 4159249 -0.7176 -0.7176 -0.7176 2.883 1.0827 +chr11 4159512 -0.7124 -0.7123 -0.7124 2.5774 0.9325 +chr11 4159576 -0.7181 -0.7181 -0.7181 2.6659 0.9739 +chr11 4160767 -0.7173 -0.7173 -0.7173 2.8852 1.0839 +chr11 4161449 -0.7209 -0.7208 -0.7209 2.7387 1.0089 +chr11 4163009 -0.7123 -0.7122 -0.7122 2.5713 0.9295 +chr11 4164110 -0.7171 -0.7171 -0.7171 2.885 1.084 +chr11 4165583 -0.7191 -0.719 -0.719 2.6835 0.9822 +chr11 4166188 -0.7173 -0.7173 -0.7173 2.884 1.0833 +chr11 4169047 -0.7173 -0.7174 -0.7174 2.8676 1.0753 +chr11 4169344 -0.7172 -0.7172 -0.7172 2.8844 1.0836 +chr11 4173901 -0.7187 -0.7186 -0.7186 2.8749 1.078 +chr11 4174384 -0.7174 -0.7174 -0.7174 2.8822 1.0824 +chr11 4177048 -0.7174 -0.7174 -0.7174 2.881 1.0818 +chr11 4178320 -0.7127 -0.7127 -0.7127 2.5766 0.9319 +chr11 4178518 -0.7173 -0.7173 -0.7173 2.8834 1.083 +chr11 4183635 -0.7211 -0.7211 -0.7211 2.8293 1.0541 +chr11 4185242 -0.7173 -0.7174 -0.7174 2.8825 1.0826 +chr11 4209116 -0.7169 -0.7169 -0.7169 2.8809 1.0821 +chr11 4211694 -0.7214 -0.7214 -0.7213 2.8188 1.0487 +chr11 4228604 -0.718 -0.718 -0.718 2.8746 1.0783 +chr11 4229176 -0.7174 -0.7174 -0.7174 2.8822 1.0824 +chr11 4229195 -0.7173 -0.7173 -0.7173 2.882 1.0824 +chr11 4230918 -0.7175 -0.7175 -0.7175 2.8804 1.0815 +chr11 4237235 -0.7217 -0.7217 -0.7217 2.8039 1.0411 +chr11 4238100 -0.7218 -0.7218 -0.7217 2.8051 1.0417 +chr11 4246351 -0.7193 -0.7193 -0.7193 2.847 1.064 +chr11 4246985 -0.7218 -0.7218 -0.7217 2.8009 1.0395 +chr11 4261375 -0.7176 -0.7176 -0.7176 2.8823 1.0823 +chr11 4273327 -0.7175 -0.7175 -0.7175 2.8839 1.0832 +chr11 4283717 0.7249 0.7253 0.7249 -2.9836 -1.1298 +chr11 4284110 0.7067 0.7068 0.7067 -2.9807 -1.1376 +chr11 4285090 0.7034 0.703 0.703 -2.8865 -1.0925 +chr11 4286016 0.6996 0.6997 0.6997 -2.9627 -1.1315 +chr11 4288936 0.704 0.704 0.7041 -2.8247 -1.061 +chr11 4301371 0.6994 0.6996 0.6996 -2.964 -1.1323 +chr11 4310171 0.6997 0.6996 0.6996 -2.9604 -1.1308 +chr11 4330042 0.7035 0.7036 0.7037 -2.8725 -1.0853 +chr11 4908477 3.3681 -0.2937 -0.2934 -0.2938 -0.2937 +chr11 4941705 3.3298 -0.2983 -0.2982 -0.2917 -0.2924 +chr11 4944016 3.3274 -0.2945 -0.2945 -0.2944 -0.2944 +chr11 4945582 3.3273 -0.2945 -0.2945 -0.2944 -0.2944 +chr11 4949541 3.3267 -0.2941 -0.2944 -0.2948 -0.2948 +chr11 4971995 3.3241 -0.2952 -0.2954 -0.2958 -0.2958 diff --git a/test-data/pool-test-summary1-without-reference b/test-data/pool-test-summary1-without-reference new file mode 100644 index 0000000..5ea4287 --- /dev/null +++ b/test-data/pool-test-summary1-without-reference @@ -0,0 +1,5 @@ +# pyhegp summary file version 1 +# number-of-samples 10 +chromosome position mean standard-deviation +chr1 1 0 1 +chr2 19 2 3 diff --git a/test-data/pool-test-summary2-without-reference b/test-data/pool-test-summary2-without-reference new file mode 100644 index 0000000..e0aede0 --- /dev/null +++ b/test-data/pool-test-summary2-without-reference @@ -0,0 +1,7 @@ +# pyhegp summary file version 1 +# number-of-samples 5 +chromosome position mean standard-deviation +chr1 1 0 1 +chr2 19 2 3 +chrX 21 4 5 +chrX 21 4 5 diff --git a/tests/test_pyhegp.py b/tests/test_pyhegp.py index d119858..cdf3a7f 100644 --- a/tests/test_pyhegp.py +++ b/tests/test_pyhegp.py @@ -26,6 +26,7 @@ from hypothesis import given, strategies as st from hypothesis.extra.numpy import arrays, array_shapes import numpy as np import pandas as pd +import pytest from pytest import approx from pyhegp.pyhegp import Stats, main, hegp_encrypt, hegp_decrypt, random_key, pool_stats, standardize, unstandardize, genotype_summary, encrypt_genotype, encrypt_phenotype, cat_genotype, cat_phenotype @@ -52,12 +53,17 @@ def test_pool_stats(pools): and pooled_stats.std == approx(np.std(combined_pool, axis=0, ddof=1), rel=1e-6)) -def test_encrypt_command(tmp_path): - shutil.copy("test-data/encrypt-test-genotype.tsv", tmp_path) - ciphertext = tmp_path / "encrypt-test-genotype.tsv.hegp" +@pytest.mark.parametrize("genotype_file,summary_file", + [(Path("test-data/encrypt-test-genotype.tsv"), + Path("test-data/encrypt-test-summary")), + (Path("test-data/encrypt-test-genotype-without-reference.tsv"), + Path("test-data/encrypt-test-summary-without-reference"))]) +def test_encrypt_command(tmp_path, genotype_file, summary_file): + shutil.copy(genotype_file, tmp_path) + ciphertext = tmp_path / f"{genotype_file.name}.hegp" result = CliRunner().invoke(main, ["encrypt", - "-s", "test-data/encrypt-test-summary", - str(tmp_path / "encrypt-test-genotype.tsv")]) + "-s", summary_file, + str(tmp_path / genotype_file.name)]) assert result.exit_code == 0 assert ciphertext.exists() assert "Dropped 1 SNP(s)" in result.output @@ -143,13 +149,17 @@ def test_encrypt_genotype_does_not_produce_na(genotype, key): def test_encrypt_phenotype_does_not_produce_na(phenotype, key): assert not encrypt_phenotype(phenotype, key).isna().any(axis=None) -def test_pool_command(tmp_path): +@pytest.mark.parametrize("summary_files", + [[Path("test-data/pool-test-summary1"), + Path("test-data/pool-test-summary2")], + [Path("test-data/pool-test-summary1-without-reference"), + Path("test-data/pool-test-summary2-without-reference")]]) +def test_pool_command(tmp_path, summary_files): columns = ["chromosome", "position", "reference", "mean", "std"] complete_summary = tmp_path / "complete-summary" result = CliRunner().invoke(main, ["pool", "-o", complete_summary, - "test-data/pool-test-summary1", - "test-data/pool-test-summary2"], + *(str(summary_file) for summary_file in summary_files)], catch_exceptions=True) assert result.exit_code == 0 assert complete_summary.exists() @@ -203,21 +213,33 @@ def test_cat_phenotype(phenotypes): pd.testing.assert_frame_equal(complete_phenotype, cat_phenotype(split_phenotypes)) -def test_simple_workflow(tmp_path): - shutil.copy(f"test-data/genotype.tsv", tmp_path) - ciphertext = tmp_path / "genotype.tsv.hegp" +@pytest.mark.parametrize("genotype_file", + [Path("test-data/genotype.tsv"), + Path("test-data/genotype-without-reference.tsv")]) +def test_simple_workflow(tmp_path, genotype_file): + shutil.copy(genotype_file, tmp_path) + ciphertext = tmp_path / f"{genotype_file.name}.hegp" result = CliRunner().invoke(main, - ["encrypt", str(tmp_path / "genotype.tsv")]) + ["encrypt", str(tmp_path / genotype_file.name)]) assert result.exit_code == 0 assert ciphertext.exists() -def test_joint_workflow(tmp_path): +@pytest.mark.parametrize("genotype_files", + [[Path("test-data/genotype0.tsv"), + Path("test-data/genotype1.tsv"), + Path("test-data/genotype2.tsv"), + Path("test-data/genotype3.tsv")], + [Path("test-data/genotype0-without-reference.tsv"), + Path("test-data/genotype1-without-reference.tsv"), + Path("test-data/genotype2-without-reference.tsv"), + Path("test-data/genotype3-without-reference.tsv")]]) +def test_joint_workflow(tmp_path, genotype_files): runner = CliRunner() - for i in range(4): - shutil.copy(f"test-data/genotype{i}.tsv", tmp_path) - summary = tmp_path / f"summary{i}" + for genotype_file in genotype_files: + shutil.copy(genotype_file, tmp_path) + summary = tmp_path / f"{genotype_file.name}.summary" result = runner.invoke( - main, ["summary", str(tmp_path / f"genotype{i}.tsv"), + main, ["summary", str(tmp_path / genotype_file.name), "-o", summary]) assert result.exit_code == 0 assert summary.exists() @@ -225,21 +247,23 @@ def test_joint_workflow(tmp_path): result = runner.invoke( main, ["pool", "-o", complete_summary, - *(str(tmp_path / f"summary{i}") for i in range(4))]) + *(str(tmp_path / f"{genotype_file.name}.summary") + for genotype_file in genotype_files)]) assert result.exit_code == 0 assert complete_summary.exists() - for i in range(4): - ciphertext = tmp_path / f"genotype{i}.tsv.hegp" + for genotype_file in genotype_files: + ciphertext = tmp_path / f"{genotype_file.name}.hegp" result = runner.invoke( main, ["encrypt", "-s", complete_summary, - str(tmp_path / f"genotype{i}.tsv")]) + str(tmp_path / f"{genotype_file.name}")]) assert result.exit_code == 0 assert ciphertext.exists() complete_ciphertext = tmp_path / "complete-genotype.tsv.hegp" result = runner.invoke( main, ["cat-genotype", "-o", complete_ciphertext, - *(str(tmp_path / f"genotype{i}.tsv.hegp") for i in range(4))]) + *(str(tmp_path / f"{genotype_file.name}.hegp") + for genotype_file in genotype_files)]) assert result.exit_code == 0 assert complete_ciphertext.exists() |
