Vignette: range queries across a set of BED files

Open
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
r
Domain
documentation

Research direction

Start from the bedbaser vignette, adding a section that uses bb_beds_in_bedset() to pick IDs and bb_beds_to_grangeslist() to fetch whole files as a GRangesList. Then show subsetByOverlaps() for whole-file hits and endoapply() for per-file regions, with a genome(which) check first. Run it against the live API to confirm it renders. This depends on #26, so check that issue is merged before you start.

Written by the indexing model from the issue text.

Description

The question "which BED files in bedbase have regions overlapping my GRanges, and what are they" comes up often and bedbaser doesn't show how to answer it. Benchmarks in databio/bedhost#291 showed that per-range remote access (the bedhost regions endpoint, or rtracklayer reading bigBeds with which=) loses to downloading whole files by more than 10x for a typical file, even for a single range. So the pattern is two steps: pick records by metadata, download them whole, overlap locally.

A vignette section showing exactly that:

ids <- bb_beds_in_bedset(bedbase, "lola_hg38_ucsc_features")$id   # or text/exact search, or the snapshot
grl <- bb_beds_to_grangeslist(bedbase, ids)

subsetByOverlaps(grl, which)              # files with any hit, whole
endoapply(grl, subsetByOverlaps, which)   # overlapping regions within each file; lengths() gives hits per file

Points to make in the text:

  • subsetByOverlaps on a GRangesList works at the element level: it returns whole files that overlap at all. endoapply is for the regions inside each file, and keeps zero-length elements so lengths() lines up with the input.
  • Check the genome of the records against genome(which) before fetching; a mismatch returns zero hits with no error.
  • This covers hundreds of files comfortably. It won't find overlaps across all 665k records; that needs an index on the bedbase side, which is the open request upstream.

Depends on #26. Gets better as #27 and #28 land, but can be written against the BEDset route alone.

Drafted with Claude Code.

Dominant language
R
Stars
3
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from waldronlab/bedbaser

All issues in waldronlab/bedbaser

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.