Skip to content

Commit 31b9b31

Browse files
committed
Fix a side effect of to_plink, version 0.9.1
1 parent 9532f3c commit 31b9b31

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

docs/release-history.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Release History
33
===============
44

5+
v0.9.1 (2021-07-13)
6+
-------------------
7+
8+
Fix a side-effect of to_plink that swapped allele idxs which could affect edge encoding
9+
510
v0.9.0 (2021-07-12)
611
-------------------
712

pandas_genomics/io/plink/to_plink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def save_bed(data, output_bed):
164164

165165

166166
def gt_array_to_plink_bits(gt_series):
167-
allele_ids = gt_series.array.allele_idxs
167+
allele_ids = gt_series.array.allele_idxs.copy()
168168
# Replace missing with 0,1
169169
missing = gt_series.array.is_missing
170170
allele_ids[missing] = (0, 1)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pandas-genomics"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
description = "Pandas ExtensionDtypes and ExtensionArray for working with genomics data"
55
license = "BSD-3-Clause"
66
authors = ["John McGuigan <[email protected]>"]

tests/io/test_plink.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pathlib import Path
22

33
import pytest
4+
from numpy.testing import assert_array_equal
45
from pandas._testing import assert_frame_equal
56

67
from pandas_genomics import io, sim
@@ -41,6 +42,7 @@ def test_round_trip_sim(tmp_path):
4142
d.mkdir()
4243
output = str(d / "test")
4344
data = sim.BAMS().generate_case_control()
45+
original = data.copy()
4446
io.to_plink(
4547
data,
4648
output,
@@ -59,6 +61,11 @@ def test_round_trip_sim(tmp_path):
5961
data, loaded_data, check_categorical=False
6062
) # Categorical order may be different
6163

64+
# Ensure there were no side effects
65+
assert_array_equal(
66+
original["SNP1"].array.allele_idxs, data["SNP1"].array.allele_idxs
67+
)
68+
6269

6370
@pytest.mark.slow
6471
def test_loaded_medium():

0 commit comments

Comments
 (0)