Skip to content

Merge Claudiu Craciun and Alan Kuznicki's semester project work into main - #5

Draft
alankuznicki wants to merge 40 commits into
mainfrom
everything
Draft

Merge Claudiu Craciun and Alan Kuznicki's semester project work into main#5
alankuznicki wants to merge 40 commits into
mainfrom
everything

Conversation

@alankuznicki

Copy link
Copy Markdown
Collaborator

TODO

@alankuznicki alankuznicki self-assigned this Aug 6, 2026
@alankuznicki alankuznicki added the enhancement New feature or request label Aug 6, 2026
@alankuznicki
alankuznicki marked this pull request as draft August 6, 2026 13:07
Comment thread src/asap/dataloader/bw_to_data.py Outdated
Comment on lines +148 to +182
# --- Correct behavior (current) ---
# Fraction of bases in [start, start+extent) that are actually
# unmappable, computed once for the whole chromosome via a prefix
# sum over the mappability track, then sliced per candidate window.
frac = _unmappable_fraction(mappability_track, seq_starts, extent)
seq_starts = seq_starts[frac <= unmap_threshold]

# --- Old (buggy) behavior, kept here for reference ---
# The original filter_idx_by_unmap_threshold (data_bed.py) computed,
# per window, `overlap_length = sum(overlaps.end - overlaps.start)`
# using the RAW, unclamped length of every unmap interval that
# touched the window at all -- even when only a sliver of that
# interval actually fell inside the window. So a single long
# unmappable region (e.g. 60bp) could cause a window that only
# overlapped it by a handful of bp to be dropped entirely, because
# the full 60bp counted against the threshold budget instead of the
# true (much smaller) overlap. This was a bug, not an intentional
# design choice -- verified against the original by differential
# testing (see conversation/PR notes). If bit-identical window
# selection against an old cached index or trained checkpoint is
# ever needed, this reproduces the dominant effect of that bug
# (raw interval length, not clipped overlap) without reintroducing
# the original's slow per-window pandas loop -- it loops over
# unmap intervals instead, which are typically far fewer than
# candidate windows. Uncomment in place of the two lines above:
#
# unmap_df = pd.read_csv(unmappable_bed_file, delimiter='\t', header=None,
# names=['chr', 'start', 'end'])
# unmap_df = unmap_df[(unmap_df.chr == f'chr{chrom}') | (unmap_df.chr.astype(str) == f'{chrom}')]
# window_end = seq_starts + extent
# raw_overlap_length = np.zeros(len(seq_starts), dtype=np.int64)
# for gs, ge in zip(unmap_df.start.to_numpy(), unmap_df.end.to_numpy()):
# touches = (seq_starts < ge) & (gs < window_end)
# raw_overlap_length[touches] += (ge - gs) # bug: full interval length, not clipped
# seq_starts = seq_starts[raw_overlap_length <= unmap_threshold * extent]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude said that this was a genuine behavior-affecting bug in the original code. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant