Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extra comp het filtering #4430

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
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
25 changes: 5 additions & 20 deletions hail_search/queries/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,43 +624,28 @@ def _annotate_families_inheritance(
if genotype:
entry_indices_by_gt[genotype][family_index].append(sample_index)

min_unaffected = None
if inheritance_mode == COMPOUND_HET:
family_unaffected_counts = [
len(i) for i in entry_indices_by_gt[INHERITANCE_FILTERS[COMPOUND_HET][UNAFFECTED_ID]].values()
]
self.max_unaffected_samples = max(family_unaffected_counts) if family_unaffected_counts else 0
if self.max_unaffected_samples > 1:
min_unaffected = min(family_unaffected_counts)

for genotype, entry_indices in entry_indices_by_gt.items():
if not entry_indices:
continue
entry_indices = hl.dict(entry_indices)
ht = ht.annotate(**{
annotation: hl.enumerate(ht[entries_ht_field]).starmap(
lambda i, family_samples: self._valid_genotype_family_entries(
family_samples, entry_indices.get(i), genotype, min_unaffected
)
lambda family_i, family_samples: hl.or_missing(
~entry_indices.contains(family_i) | entry_indices[family_i].all(
lambda sample_i: self.GENOTYPE_QUERY_MAP[genotype](family_samples[sample_i].GT)
), family_samples,
),
)
})

return ht

@classmethod
def _valid_genotype_family_entries(cls, entries: list, genotype_entry_indices, genotype: str, min_unaffected: int):
is_valid = hl.is_missing(genotype_entry_indices) | genotype_entry_indices.all(
lambda i: cls.GENOTYPE_QUERY_MAP[genotype](entries[i].GT)
)
if min_unaffected is not None and genotype == HAS_REF:
unaffected_filter = genotype_entry_indices.any(
lambda i: cls.GENOTYPE_QUERY_MAP[REF_REF](entries[i].GT)
)
if min_unaffected < 2:
unaffected_filter |= genotype_entry_indices.size() < 2
is_valid &= unaffected_filter
return hl.or_missing(is_valid, entries)

def _get_family_passes_quality_filter(self, quality_filter, ht, **kwargs):
quality_filter = quality_filter or {}

Expand Down
Loading