Skip to content
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
67d65a1
Add function for exploding intervals to loci
Ruchit10 Jul 3, 2025
9b2cae2
Update gnomad/utils/intervals.py
Ruchit10 Jul 3, 2025
31eeac1
Update gnomad/utils/intervals.py
Ruchit10 Jul 3, 2025
b4214e5
Add flexibility to accept MT/HT and adjust to interval including star…
Ruchit10 Jul 10, 2025
e870d3b
Black reformatting
Ruchit10 Jul 10, 2025
f8d53cb
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
3e96a21
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
40e2702
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
53b50d7
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
3d6774d
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
238f547
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
6194688
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
fcf450e
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
77c9f2c
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
caf9dab
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
c2dc321
Update gnomad/utils/intervals.py
Ruchit10 Jul 11, 2025
f4b28a5
Change explode_intervals_to_loci to accept interval expression or HT
Ruchit10 Jul 14, 2025
1162c19
Fix pre-commit
Ruchit10 Jul 14, 2025
1927ed6
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
91a4948
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
defa0b0
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
078ac91
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
020b493
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
04edebc
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
ec2cb97
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
f8864f7
Update gnomad/utils/intervals.py
Ruchit10 Jul 15, 2025
6216cee
update docstrings, add logging and typing imports, fix typos and inde…
Ruchit10 Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions gnomad/utils/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,27 @@ def _add_padding(
return [_add_padding(i) for i in intervals]
else:
return _add_padding(intervals)


def explode_intervals_to_loci(
ht: hl.Table,
keep_intervals: bool = False,
) -> hl.Table:
"""
Expand intervals to loci.

:param ht: Hail Table with an interval field.
:param keep_intervals: If True, keep the original interval as a column in output.
:return: Hail Table keyed by loci and intervals as optional field.
"""
ht = ht.annotate(
pos=hl.range(ht.interval.start.position, ht.interval.end.position + 1),
).explode("pos")
ht = ht.annotate(
locus=hl.locus(
ht.interval.start.contig,
ht.pos,
reference_genome=ht.interval.start.dtype.reference_genome,
),
).key_by("locus")
return ht.drop("interval", "pos") if not keep_intervals else ht.drop("pos")