Skip to content

Add source-agnostic tokenized dataset with bedbase source - #20

Open
nsheff wants to merge 2 commits into
devfrom
bedbase-training-dataset
Open

Add source-agnostic tokenized dataset with bedbase source#20
nsheff wants to merge 2 commits into
devfrom
bedbase-training-dataset

Conversation

@nsheff

@nsheff nsheff commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

Adds geniml/dataset/: a source-agnostic tokenized training dataset built on the RegionSet/BedSet abstraction, connecting bedbase (the read half) to HF-Trainer training (the train half) — the previously-missing adapter. It separates source (where region sets come from) from dataset (tokenize + window + batch), so a new data origin is a small source, not a new dataset. Bedbase is the first concrete source.

What's here

Source interface (source.py)

  • RegionSetSource — minimal Protocol yielding (RegionSet, meta)
  • BedSetSource (wraps geniml.io.BedSet / BBClient.load_bedset output), FileListSource (local BED paths)

Tokenization core (tokenize.py) — pure, unit-testable

  • tokenize_regionset (unk filtering, huge-file skip) + sample_and_remove windowing

Dataset (dataset.py)

  • TokenizedRegionDataset: materialize mode (on-disk parquet, cached on selection + universe + context_size, optional multiprocess tokenization) and stream mode (torch IterableDataset with .gtok cache, DataLoader-sharded)

Bedbase source (bedbase.py)

  • select_bedbase_samples queries the live /v1/bed/list API into a dated, serializable SampleSelection manifest (replaces the lost all_hg38_good_meta.csv); BedbaseSource reads each bed only via BBClient.load_bed

Provenance (manifest.py) — cache keying + write_provenance (dataset_provenance.json)

Integrations & docs

  • region2vec's file-list BEDDataset refactored onto FileListSource
  • How-to doc + mkdocs nav entry

Heavy deps (datasets, torch) are imported lazily so the source and tokenize halves work on a base install; only building a dataset requires geniml[ml].

Notes

  • gtars-bbcache is absent against gtars 0.9.1, so this stays on BBClient; the swap point is localized to BedbaseSource.
  • The matching --data-source {parquet,bedbase} training-script change lives in the separate atacformer-bedbase analysis repo, not here.

Testing

  • 13 tests pass (tests/test_dataset.py): materialize + cache, stream + DataLoader, parallel tokenization, windowing, bedbase selection/manifest, cache keying. Live bedbase selection verified with --bedbase.
  • ruff + black clean.

nsheff added 2 commits July 18, 2026 12:32
Add geniml/dataset/: a source-agnostic tokenized training dataset built on
the RegionSet/BedSet abstraction, connecting bedbase (the read half) to
HF-Trainer training (the train half) — the previously-missing adapter.

- RegionSetSource Protocol + concrete sources: BedbaseSource, FileListSource,
  BedSetSource
- Pure tokenize_regionset / sample_and_remove windowing core (unk filtering,
  context-size chunking, huge-file skip)
- TokenizedRegionDataset: materialize mode (on-disk parquet cached on
  selection + universe + context_size) and stream mode (torch IterableDataset
  with .gtok cache)
- select_bedbase_samples queries the live bedbase /v1/bed/list API into a
  dated, serializable SampleSelection manifest (replaces the lost
  all_hg38_good_meta.csv); BedbaseSource reads only via BBClient.load_bed
- Provenance: cache keying + write_provenance (dataset_provenance.json)
- Refactor region2vec's file-list BEDDataset onto FileListSource
- How-to doc + mkdocs nav entry

heavy deps (datasets, torch) are imported lazily so the source and tokenize
halves work on a base install. 13 tests pass.
- setup.py: add geniml.dataset to the packages list so it ships with the
  install (it was missing, so pip install would not include the new package).
- Guard module-level optional-dependency imports in test_scembed (scanpy / sc
  extra) and test_search / test_text2bednn (qdrant_client / search extra) with
  pytest.importorskip, matching test_dataset's importorskip(datasets). These
  modules previously errored at collection under an [ml]-only install; execution
  of the network/service tests remains gated by --bedbase/--qdrant/--huggingface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant