Skip to content

fix: readVcfStack(param=ScanVcfParam()) reads all files when which= is empty (#50)#10

Open
jmg421 wants to merge 1 commit into
Bioconductor:develfrom
jmg421:fix/50-readVcfStack-empty-which
Open

fix: readVcfStack(param=ScanVcfParam()) reads all files when which= is empty (#50)#10
jmg421 wants to merge 1 commit into
Bioconductor:develfrom
jmg421:fix/50-readVcfStack-empty-which

Conversation

@jmg421

@jmg421 jmg421 commented Jul 6, 2026

Copy link
Copy Markdown

Problem

When param is provided but which= is not specified (e.g. param=ScanVcfParam()), readVcfStack() silently returned a 0-row VCF.

Root cause: in the else { # use param } branch, gr <- GRanges(vcfWhich(param)) produces an empty GRanges, and i = intersect(names(files(x)), as.character(seqnames(gr))) then evaluates to character(0) — so x = x[i] produces an empty stack and nothing is read.

This is inconsistent with both:

  • readVcfStack(rstack) (no param) which reads everything
  • readVcf(vf, genome, param=ScanVcfParam()) which correctly reads all variants

Fix

In R/VcfStack-class.R, when param is provided but gr is empty, fall back to i = names(files(x)) so all files are read — matching the documented behaviour of ScanVcfParam() where an unspecified which= means "return all ranges".

Test

Added two checks to inst/unitTests/test_VcfStack-class.R:

  • readVcfStack(Rstack, param=ScanVcfParam()) returns same dims as readVcfStack(Rstack)
  • readVcfStack(stack, param=ScanVcfParam()) returns same dims as readVcfStack(stack)

Fixes #50

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