Skip to content

Commit 7e2cb26

Browse files
committed
Move float conversion around
1 parent adbc674 commit 7e2cb26

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

v03_pipeline/lib/misc/nested_field.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,4 @@ def parse_nested_field(t: hl.MatrixTable | hl.Table, fields: str):
1212
]
1313
else:
1414
expression = expression[field]
15-
# Parse float64s into float32s to save space!
16-
if expression.dtype == hl.tfloat64:
17-
expression = hl.float32(expression)
1815
return expression

v03_pipeline/lib/model/dataset_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def row_fields(
138138
'lof_genes': hl.tset(hl.tstr),
139139
'num_exon': hl.tint32,
140140
'sc': hl.tint32,
141-
'sf': hl.tfloat32,
141+
'sf': hl.tfloat64,
142142
'start': hl.tint32,
143143
'strvctvre_score': hl.tstr,
144144
'svtype': hl.tstr,

v03_pipeline/lib/reference_datasets/misc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
BIALLELIC = 2
1818

1919

20+
def compress_floats(ht: hl.Table):
21+
# Parse float64s into float32s to save space!
22+
return ht.select(
23+
**{
24+
k: hl.float32(v) if v.dtype == hl.tfloat64 else v
25+
for k, v in ht.row_value.items()
26+
},
27+
)
28+
29+
2030
def generate_random_string(length=5):
2131
"""Generates a random string of the specified length."""
2232
letters = string.ascii_letters + string.digits

v03_pipeline/lib/reference_datasets/reference_dataset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
filter_contigs,
1717
filter_mito_contigs,
1818
get_enum_select_fields,
19+
compress_floats,
1920
)
2021

2122
DATASET_TYPES = 'dataset_types'
@@ -115,6 +116,7 @@ def get_ht(
115116
)
116117
path = self.path(reference_genome)
117118
ht = module.get_ht(path, reference_genome)
119+
ht = compress_floats(ht)
118120
enum_selects = get_enum_select_fields(ht, self.enums)
119121
if enum_selects:
120122
ht = ht.transmute(**enum_selects)

0 commit comments

Comments
 (0)