fix: readVcfStack(param=ScanVcfParam()) reads all files when which= is empty (#50)#10
Open
jmg421 wants to merge 1 commit into
Open
fix: readVcfStack(param=ScanVcfParam()) reads all files when which= is empty (#50)#10jmg421 wants to merge 1 commit into
jmg421 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
paramis provided butwhich=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 emptyGRanges, andi = intersect(names(files(x)), as.character(seqnames(gr)))then evaluates tocharacter(0)— sox = x[i]produces an empty stack and nothing is read.This is inconsistent with both:
readVcfStack(rstack)(no param) which reads everythingreadVcf(vf, genome, param=ScanVcfParam())which correctly reads all variantsFix
In
R/VcfStack-class.R, whenparamis provided butgris empty, fall back toi = names(files(x))so all files are read — matching the documented behaviour ofScanVcfParam()where an unspecifiedwhich=means "return all ranges".Test
Added two checks to
inst/unitTests/test_VcfStack-class.R:readVcfStack(Rstack, param=ScanVcfParam())returns same dims asreadVcfStack(Rstack)readVcfStack(stack, param=ScanVcfParam())returns same dims asreadVcfStack(stack)Fixes #50