Skip to content

Commit b9494a5

Browse files
committed
Make plink code follow original logic
1 parent 669fdf3 commit b9494a5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

bio2zarr/plink.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class PlinkFormat:
1414
def __init__(self, path):
1515
self.path = path
16-
self.bed = bed_reader.open_bed(path, num_threads=1)
16+
self.bed = bed_reader.open_bed(path, num_threads=1, count_A1=False)
1717
self.num_records = self.bed.sid_count
1818
self.samples = list(self.bed.iid)
1919
self.num_samples = len(self.samples)
@@ -43,10 +43,11 @@ def iter_genotypes(self, shape, start, stop):
4343
gt = np.zeros(shape, dtype=np.int8)
4444
phased = np.zeros(shape[:-1], dtype=bool)
4545
for values in bed_chunk:
46-
gt[values == -127] = -1 # Missing values
47-
gt[values == 0] = [1, 1] # Homozygous ALT (2 in PLINK)
48-
gt[values == 1] = [1, 0] # Heterozygous (1 in PLINK)
49-
gt[values == 2] = [0, 0] # Homozygous REF (0 in PLINK)
46+
gt[:]= 0
47+
gt[values == -127] = -1
48+
gt[values == 2] = 1
49+
gt[values == 1, 0] = 1
50+
5051
yield gt, phased
5152

5253
def generate_schema(

0 commit comments

Comments
 (0)