Skip to content

Public per-variant filter (or a public chunk type) for flat variant windows #418

Description

@d-laub

Problem

A downstream consumer that needs to filter variants out of a fetched window has no public
type to build the result with. In aster we have now accumulated three stand-in
dataclasses that duck-type gvl internals, all in one module:

  • _FlatScalar — stands in for the per-field scalar wrapper, so we can rebuild
    fw.fields[k] after indexing.
  • _FlatWindow — stands in for gvl's private _FlatWindow, carrying data and
    seq_offsets.
  • a ProvenanceChunk that we now return from a filter function that attaches no
    provenance, purely because it has the right shape.

None of these are supported API. They work today because the attribute names happen to
match; a rename inside gvl breaks them silently, and nothing in our test suite would
attribute the failure to gvl.

Why we need it

Panel/exome-restricted views over a WGS dataset must drop variants outside the capture
footprint (see #417 — there is no way to clip the regions themselves, so the filtering has
to happen on the fetched window). The natural operation is "give me this window with a
boolean mask applied over its variants", preserving the ragged per-variant layout.

Request

Either of:

  1. A public per-variant filter on the flat variant-window type —
    fw.filter(keep: NDArray[np.bool_]) / fw[keep] — returning the same type with
    ref_window, alt, and every entry of fields subset consistently and re-packed.
  2. A public chunk type with the window's shape (data + seq_offsets, ragged
    per-variant accessors, a fields mapping) that consumers can construct, so the
    filtering can live downstream without duck-typing private classes.

(1) is the better fit — the re-packing of the ragged offsets is exactly the part a consumer
should not be reimplementing, and it is where an off-by-one silently corrupts sequence
content rather than raising.

Status

Not blocking: aster has a working local implementation. Filing so the private-API
dependency is recorded rather than discovered at the next rename.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions