[Bioc-devel] VariantAnnotation: writeVcf fails for factors with unused levels

Julian Gehring julian.gehring at embl.de
Wed Feb 5 09:35:10 CET 2014


Hi,

I just stumbled over the fact that 'writeVcf' for a 'VRanges' fails if 
'sampleNames' is a factor with unused levels.  Here a small example:

#+BEGIN_SRC R

library(VariantAnnotation)
example(VRanges)
writeVcf(vr, "out.vcf") ## works

f = sampleNames(vr)
f ## levels: a, b
levels(f) = c("a", "b", "c") ## c in unused
f ## levels: a, b, c
sampleNames(vr) = f
writeVcf(vr, "out.vcf")  ## fails

#+END_SRC

Error in writeVcf(as(obj, "VCF"), filename, ...) :
   error in evaluating the argument 'obj' in selecting a method for 
function 'writeVcf': Error in ans[sampleToUniq] <- as.vector(v) : 
replacement has length zero

This occurs both with the latest bioc-release and bioc-devel.  I don't 
know what exactly is causing this, but please let me know if I can be of 
any help.

Best wishes
Julian



More information about the Bioc-devel mailing list