Skip to content

Commit ac33696

Browse files
committed
Change Ploidy -> Sex
1 parent f76c161 commit ac33696

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

v03_pipeline/lib/methods/sex_check.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import hail as hl
22

3-
from v03_pipeline.lib.model import Ploidy
3+
from v03_pipeline.lib.model import Sex
44

55
IMPUTE_SEX_ANNOTATIONS = [
66
'is_female',
@@ -41,13 +41,13 @@ def call_sex(mt: hl.MatrixTable) -> hl.Table:
4141
ht = ht.annotate(
4242
sex=(
4343
hl.case()
44-
.when(hl.is_missing(ht.is_female), Ploidy.UNKNOWN.value)
45-
.when(ht.is_female, Ploidy.FEMALE.value)
46-
.default(Ploidy.MALE.value)
44+
.when(hl.is_missing(ht.is_female), Sex.UNKNOWN.value)
45+
.when(ht.is_female, Sex.FEMALE.value)
46+
.default(Sex.MALE.value)
4747
),
4848
)
4949
ambiguous_perc = ht.aggregate(
50-
hl.agg.fraction(ht.sex == Ploidy.UNKNOWN.value),
50+
hl.agg.fraction(ht.sex == Sex.UNKNOWN.value),
5151
)
5252
if ambiguous_perc > AMBIGUOUS_THRESHOLD_PERC:
5353
msg = f'{ambiguous_perc:.2%} of samples identified as ambiguous. Please contact the methods team to investigate the callset.'

v03_pipeline/lib/misc/family_loading_failures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55

66
from v03_pipeline.lib.misc.pedigree import Family, Relation, Sample
7-
from v03_pipeline.lib.model import Ploidy
7+
from v03_pipeline.lib.model import Sex
88

99

1010
def passes_relatedness_check(
@@ -121,13 +121,13 @@ def build_relatedness_check_lookup(
121121
def build_sex_check_lookup(
122122
sex_check_ht: hl.Table,
123123
remap_lookup: hl.dict,
124-
) -> dict[str, Ploidy]:
124+
) -> dict[str, Sex]:
125125
# Build sex check lookup
126126
sex_check_ht = sex_check_ht.key_by(
127127
s=remap_lookup.get(sex_check_ht.s, sex_check_ht.s),
128128
)
129129
sex_check_ht = sex_check_ht.select('sex')
130-
return {r.s: Ploidy(r.sex) for r in sex_check_ht.collect()}
130+
return {r.s: Sex(r.sex) for r in sex_check_ht.collect()}
131131

132132

133133
def get_families_failed_missing_samples(

v03_pipeline/lib/misc/family_loading_failures_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
from v03_pipeline.lib.misc.io import import_pedigree
1212
from v03_pipeline.lib.misc.pedigree import Sample, parse_pedigree_ht_to_families
13-
from v03_pipeline.lib.model import Ploidy
13+
from v03_pipeline.lib.model import Sex
1414

1515
TEST_PEDIGREE_6 = 'v03_pipeline/var/test/pedigrees/test_pedigree_6.tsv'
1616

@@ -72,12 +72,12 @@ def test_build_sex_check_lookup(self):
7272
self.assertEqual(
7373
build_sex_check_lookup(ht, hl.dict({'ROS_006_18Y03226_D1': 'remapped_id'})),
7474
{
75-
'remapped_id': Ploidy.MALE,
76-
'ROS_006_18Y03227_D1': Ploidy.MALE,
77-
'ROS_006_18Y03228_D1': Ploidy.MALE,
78-
'ROS_007_19Y05919_D1': Ploidy.MALE,
79-
'ROS_007_19Y05939_D1': Ploidy.FEMALE,
80-
'ROS_007_19Y05987_D1': Ploidy.MALE,
75+
'remapped_id': Sex.MALE,
76+
'ROS_006_18Y03227_D1': Sex.MALE,
77+
'ROS_006_18Y03228_D1': Sex.MALE,
78+
'ROS_007_19Y05919_D1': Sex.MALE,
79+
'ROS_007_19Y05939_D1': Sex.FEMALE,
80+
'ROS_007_19Y05987_D1': Sex.MALE,
8181
},
8282
)
8383

@@ -96,7 +96,7 @@ def test_all_relatedness_checks(self):
9696
('sample_1', 'sample_4'): [0.25, 0.5, 0.25, 0.5],
9797
}
9898
sample = Sample(
99-
sex=Ploidy.FEMALE,
99+
sex=Sex.FEMALE,
100100
sample_id='sample_1',
101101
mother='sample_2',
102102
paternal_grandfather='sample_3',
@@ -107,7 +107,7 @@ def test_all_relatedness_checks(self):
107107

108108
# Defined grandparent missing in relatedness table
109109
sample = Sample(
110-
sex=Ploidy.FEMALE,
110+
sex=Sex.FEMALE,
111111
sample_id='sample_1',
112112
mother='sample_2',
113113
paternal_grandfather='sample_3',
@@ -130,7 +130,7 @@ def test_all_relatedness_checks(self):
130130
('sample_1', 'sample_4'): [0.5, 0.5, 0, 0.25],
131131
}
132132
sample = Sample(
133-
sex=Ploidy.FEMALE,
133+
sex=Sex.FEMALE,
134134
sample_id='sample_1',
135135
mother='sample_2',
136136
paternal_grandfather='sample_3',
@@ -157,7 +157,7 @@ def test_all_relatedness_checks(self):
157157
],
158158
}
159159
sample = Sample(
160-
sex=Ploidy.FEMALE,
160+
sex=Sex.FEMALE,
161161
sample_id='sample_1',
162162
mother='sample_2',
163163
paternal_grandfather='sample_3',

v03_pipeline/lib/misc/pedigree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import hail as hl
66

7-
from v03_pipeline.lib.model import Ploidy
7+
from v03_pipeline.lib.model import Sex
88

99

1010
class Relation(Enum):
@@ -28,7 +28,7 @@ def coefficients(self):
2828
@dataclass
2929
class Sample:
3030
sample_id: str
31-
sex: Ploidy
31+
sex: Sex
3232
mother: str = None
3333
father: str = None
3434
maternal_grandmother: str = None
@@ -69,7 +69,7 @@ def parse_direct_lineage(rows: list[hl.Struct]) -> dict[str, Sample]: # noqa: C
6969
for row in rows:
7070
samples[row.s] = Sample(
7171
sample_id=row.s,
72-
sex=Ploidy(row.sex),
72+
sex=Sex(row.sex),
7373
mother=row.maternal_s,
7474
father=row.paternal_s,
7575
)

v03_pipeline/lib/misc/pedigree_test.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from v03_pipeline.lib.misc.io import import_pedigree
66
from v03_pipeline.lib.misc.pedigree import Family, Sample, parse_pedigree_ht_to_families
7-
from v03_pipeline.lib.model import Ploidy
7+
from v03_pipeline.lib.model import Sex
88

99
TEST_PEDIGREE_1 = 'v03_pipeline/var/test/pedigrees/test_pedigree_1.tsv'
1010
TEST_PEDIGREE_2 = 'v03_pipeline/var/test/pedigrees/test_pedigree_2.tsv'
@@ -74,7 +74,7 @@ def test_parse_lineage(self) -> None:
7474
{
7575
'sample_1': Sample(
7676
sample_id='sample_1',
77-
sex=Ploidy.FEMALE,
77+
sex=Sex.FEMALE,
7878
mother=None,
7979
father=None,
8080
maternal_grandmother=None,
@@ -87,7 +87,7 @@ def test_parse_lineage(self) -> None:
8787
),
8888
'sample_2': Sample(
8989
sample_id='sample_2',
90-
sex=Ploidy.MALE,
90+
sex=Sex.MALE,
9191
mother='sample_3',
9292
father=None,
9393
maternal_grandmother=None,
@@ -100,7 +100,7 @@ def test_parse_lineage(self) -> None:
100100
),
101101
'sample_3': Sample(
102102
sample_id='sample_3',
103-
sex=Ploidy.FEMALE,
103+
sex=Sex.FEMALE,
104104
mother=None,
105105
father='sample_7',
106106
maternal_grandmother=None,
@@ -113,7 +113,7 @@ def test_parse_lineage(self) -> None:
113113
),
114114
'sample_4': Sample(
115115
sample_id='sample_4',
116-
sex=Ploidy.MALE,
116+
sex=Sex.MALE,
117117
mother='sample_3',
118118
father='sample_8',
119119
maternal_grandmother=None,
@@ -126,7 +126,7 @@ def test_parse_lineage(self) -> None:
126126
),
127127
'sample_5': Sample(
128128
sample_id='sample_5',
129-
sex=Ploidy.MALE,
129+
sex=Sex.MALE,
130130
mother='sample_3',
131131
father='sample_8',
132132
maternal_grandmother=None,
@@ -139,7 +139,7 @@ def test_parse_lineage(self) -> None:
139139
),
140140
'sample_6': Sample(
141141
sample_id='sample_6',
142-
sex=Ploidy.MALE,
142+
sex=Sex.MALE,
143143
mother='sample_9',
144144
father='sample_10',
145145
maternal_grandmother=None,
@@ -152,7 +152,7 @@ def test_parse_lineage(self) -> None:
152152
),
153153
'sample_7': Sample(
154154
sample_id='sample_7',
155-
sex=Ploidy.MALE,
155+
sex=Sex.MALE,
156156
mother=None,
157157
father=None,
158158
maternal_grandmother=None,
@@ -165,7 +165,7 @@ def test_parse_lineage(self) -> None:
165165
),
166166
'sample_8': Sample(
167167
sample_id='sample_8',
168-
sex=Ploidy.FEMALE,
168+
sex=Sex.FEMALE,
169169
mother='sample_9',
170170
father='sample_10',
171171
maternal_grandmother=None,
@@ -178,7 +178,7 @@ def test_parse_lineage(self) -> None:
178178
),
179179
'sample_9': Sample(
180180
sample_id='sample_9',
181-
sex=Ploidy.FEMALE,
181+
sex=Sex.FEMALE,
182182
mother=None,
183183
father=None,
184184
maternal_grandmother=None,
@@ -191,7 +191,7 @@ def test_parse_lineage(self) -> None:
191191
),
192192
'sample_10': Sample(
193193
sample_id='sample_10',
194-
sex=Ploidy.MALE,
194+
sex=Sex.MALE,
195195
mother=None,
196196
father=None,
197197
maternal_grandmother=None,
@@ -215,7 +215,7 @@ def test_parse_project(self) -> None:
215215
samples={
216216
'BBL_BC1-000345_01_D1': Sample(
217217
sample_id='BBL_BC1-000345_01_D1',
218-
sex=Ploidy.FEMALE,
218+
sex=Sex.FEMALE,
219219
mother='BBL_BC1-000345_03_D1',
220220
father='BBL_BC1-000345_02_D1',
221221
maternal_grandmother=None,
@@ -228,7 +228,7 @@ def test_parse_project(self) -> None:
228228
),
229229
'BBL_BC1-000345_02_D1': Sample(
230230
sample_id='BBL_BC1-000345_02_D1',
231-
sex=Ploidy.MALE,
231+
sex=Sex.MALE,
232232
mother=None,
233233
father=None,
234234
maternal_grandmother=None,
@@ -241,7 +241,7 @@ def test_parse_project(self) -> None:
241241
),
242242
'BBL_BC1-000345_03_D1': Sample(
243243
sample_id='BBL_BC1-000345_03_D1',
244-
sex=Ploidy.FEMALE,
244+
sex=Sex.FEMALE,
245245
mother=None,
246246
father=None,
247247
maternal_grandmother=None,
@@ -259,7 +259,7 @@ def test_parse_project(self) -> None:
259259
samples={
260260
'BBL_HT-007-5195_01_D1': Sample(
261261
sample_id='BBL_HT-007-5195_01_D1',
262-
sex=Ploidy.FEMALE,
262+
sex=Sex.FEMALE,
263263
mother='BBL_HT-007-5195_03_D1',
264264
father='BBL_HT-007-5195_02_D1',
265265
maternal_grandmother=None,
@@ -276,7 +276,7 @@ def test_parse_project(self) -> None:
276276
),
277277
'BBL_HT-007-5195_02_D1': Sample(
278278
sample_id='BBL_HT-007-5195_02_D1',
279-
sex=Ploidy.MALE,
279+
sex=Sex.MALE,
280280
mother=None,
281281
father=None,
282282
maternal_grandmother=None,
@@ -289,7 +289,7 @@ def test_parse_project(self) -> None:
289289
),
290290
'BBL_HT-007-5195_03_D1': Sample(
291291
sample_id='BBL_HT-007-5195_03_D1',
292-
sex=Ploidy.FEMALE,
292+
sex=Sex.FEMALE,
293293
mother=None,
294294
father=None,
295295
maternal_grandmother=None,
@@ -302,7 +302,7 @@ def test_parse_project(self) -> None:
302302
),
303303
'BBL_HT-007-5195_04_D1': Sample(
304304
sample_id='BBL_HT-007-5195_04_D1',
305-
sex=Ploidy.MALE,
305+
sex=Sex.MALE,
306306
mother='BBL_HT-007-5195_03_D1',
307307
father='BBL_HT-007-5195_02_D1',
308308
maternal_grandmother=None,
@@ -315,7 +315,7 @@ def test_parse_project(self) -> None:
315315
),
316316
'BBL_HT-007-5195_05_D1': Sample(
317317
sample_id='BBL_HT-007-5195_05_D1',
318-
sex=Ploidy.FEMALE,
318+
sex=Sex.FEMALE,
319319
mother='BBL_HT-007-5195_03_D1',
320320
father='BBL_HT-007-5195_02_D1',
321321
maternal_grandmother=None,
@@ -328,7 +328,7 @@ def test_parse_project(self) -> None:
328328
),
329329
'BBL_HT-007-5195_06_D1': Sample(
330330
sample_id='BBL_HT-007-5195_06_D1',
331-
sex=Ploidy.MALE,
331+
sex=Sex.MALE,
332332
mother='BBL_HT-007-5195_03_D1',
333333
father='BBL_HT-007-5195_02_D1',
334334
maternal_grandmother=None,
@@ -346,7 +346,7 @@ def test_parse_project(self) -> None:
346346
samples={
347347
'BBL_SDS1-000178_01_D1': Sample(
348348
sample_id='BBL_SDS1-000178_01_D1',
349-
sex=Ploidy.FEMALE,
349+
sex=Sex.FEMALE,
350350
mother=None,
351351
father=None,
352352
maternal_grandmother=None,

v03_pipeline/lib/model/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from v03_pipeline.lib.model.definitions import (
66
AccessControl,
77
PipelineVersion,
8-
Ploidy,
8+
Sex,
99
ReferenceGenome,
1010
SampleType,
1111
)
@@ -19,7 +19,7 @@
1919
'CachedReferenceDatasetQuery',
2020
'DatasetType',
2121
'Env',
22-
'Ploidy',
22+
'Sex',
2323
'PipelineVersion',
2424
'ReferenceDatasetCollection',
2525
'ReferenceGenome',

v03_pipeline/lib/model/definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class AccessControl(Enum):
88
PRIVATE = 'private'
99

1010

11-
class Ploidy(Enum):
11+
class Sex(Enum):
1212
FEMALE = 'F'
1313
MALE = 'M'
1414
UNKNOWN = 'U'

0 commit comments

Comments
 (0)