Skip to content

B4: Subset, split and query #94

Closed

Description

@Claptar

Part of #87.

wave 2 · 0.17.5 · size M · starts after: B1 (#89) (both edit core/subset.py and commands/split.py)

Goal. Selections keep exactly the rows the user named, and every element kind is subset the way anndata does it.

Owns: core/subset.py (selection and element handling), core/select.py, core/query.py, util/names.py, commands/split.py, docs/reference/query.md

Approach:

  • Name lists:
    • a repeated index label selects every matching row, or is refused with a count (F014);
    • the list parser respects quotes (F012).
  • Query semantics:
    • numeric and bool equality compares values, not repr strings (F120);
    • operators work without surrounding spaces (F119).
  • Element handling:
    • obsm/varm arrays of any rank are subset on their first axis (F059);
    • unused categories are dropped in obsm dataframes (F124) and in untagged categorical groups (F123).
  • split:
    • output names are claimed case-insensitively, so they cannot collide (F044);
    • a missing label and an empty-string label stay apart (F122).
  • Remove the dead parameters (F162).
  • Oracle: layers, obsp, varp and raw are checked against anndata's own subsetting (F092).

Findings

Ref Sev Finding Where
F012 H in / not in lists split quoted values at commas, so labels containing commas select the wrong rows src/adata/core/query.py:177
F014 H --obs/--var name lists keep only the first row for each name, silently dropping rows that share an index label src/adata/core/subset.py:117
F044 M split filenames can collide (sanitised suffixes, or case on macOS/Windows) and crash with an opaque HDF5/Zarr error src/adata/commands/split.py:76
F059 M obsm/varm arrays that are not 2-D are copied whole, not subset, giving an output anndata cannot read src/adata/core/subset.py:428
F092 M Values of layers, obsp, varp and raw after subset/split are checked only against the tool's own output, not an oracle tests/test_subset_fan_out.py:203
F119 L Queries written without spaces around operators fail with a misleading 'Unexpected end of query.' src/adata/core/query.py:36
F120 L Query equality on numeric/bool columns compares Python repr strings: total_counts != 0 keeps the zeros and float32 thresholds misfire src/adata/core/query.py:212
F122 L split merges rows with a missing label and rows whose label is the empty string into one output src/adata/core/select.py:100
F123 L Untagged categorical groups in a dataframe are copied whole rather than narrowed (the fallback is unreachable) src/adata/core/subset.py:316
F124 L subset/split keep unused categories in obsm/varm dataframes; anndata's subsetting drops them src/adata/core/subset.py:771
F162 L Dead parameters and test-only shim modules src/adata/core/subset.py:1083

Done when one PR on fix/b4 closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions