Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: Annotation of Genetic Variants
Description: Annotate variants, compute amino acid coding changes,
predict coding outcomes.
Version: 1.59.0
Version: 1.59.1
Authors@R: c(
person("Valerie", "Oberchain", role="aut"),
person("Martin", "Morgan", role="aut"),
Expand Down
13 changes: 13 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
CHANGES IN VERSION 1.59.1
-------------------------

BUG FIXES

o expand() no longer errors with "'data' must be of a vector type,
was 'NULL'" when called on sites-only VCFs (e.g., gnomAD allele
frequency files) that declare FORMAT fields in the header but have
no sample columns. The internal .expandAD() helper now returns an
appropriately-shaped empty array when the geno data is an empty
list (0 samples), instead of passing NULL to array(). (GitHub
issue #72)

CHANGES IN VERSION 1.36.0
-------------------------

Expand Down
6 changes: 6 additions & 0 deletions R/methods-expand.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ setMethod("expand", "CollapsedVCF",
.expandAD <- function(AD, idxlen, xcols)
{
if (is.list(AD)) {
## No data to expand (e.g., sites-only VCF with 0 samples;
## list elements may all be NULL). Return empty array.
## (GitHub issue #72)
if (length(AD) == 0L || xcols == 0L)
return(array(integer(0L), c(idxlen, xcols, 2L)))

adpart <- PartitioningByWidth(AD)
if (any(zeros <- width(adpart) == 0L)) {
AD[zeros] <- list(rep(NA_integer_, 2L))
Expand Down
9 changes: 9 additions & 0 deletions inst/unitTests/cases/sites_only.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
##fileformat=VCFv4.2
##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##FORMAT=<ID=AD,Number=R,Type=Integer,Description="Allelic depths">
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 100 rs1 A C,T 50 PASS AF=0.1,0.2;DP=100
chr1 200 rs2 G A 30 PASS AF=0.3;DP=50
chr1 300 rs3 T G,C,A 99 PASS AF=0.4,0.3,0.1;DP=200
31 changes: 31 additions & 0 deletions inst/unitTests/test_expand-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,34 @@ test_expand_adr_adf <- function()
})

}

## ---------------------------------------------------------------
## Test for GitHub issue #72: expand() errors with 'data' must be
## of a vector type, was 'NULL' on sites-only VCFs (e.g. gnomAD).
## ---------------------------------------------------------------
test_expand_sitesOnly_issue72 <- function()
{
fl <- system.file("unitTests", "cases", "sites_only.vcf",
package="VariantAnnotation")
vcf <- readVcf(fl, "")

## Verify this is indeed a sites-only VCF (0 samples)
checkIdentical(ncol(vcf), 0L)
checkTrue(nrow(vcf) > 0L)

## expand() must not error on sites-only VCF with FORMAT headers
exp <- expand(vcf)
checkTrue(is(exp, "ExpandedVCF"))

## Multi-allelic rows are expanded correctly
## Input: 3 rows with ALT counts 2, 1, 3 => 6 expanded rows
checkIdentical(nrow(exp), 6L)
checkIdentical(ncol(exp), 0L)

## INFO Number=A fields are expanded and scalar
checkTrue(is.numeric(info(exp)$AF))
checkEquals(info(exp)$AF, c(0.1, 0.2, 0.3, 0.4, 0.3, 0.1))

## Geno data is preserved (empty but valid structure)
checkTrue(length(geno(exp)) >= 0L)
}