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

Julian Gehring julian.gehring at embl.de
Thu Feb 6 10:46:22 CET 2014


Hi Michael,

Thanks for the fast patching.  However, going a step further and trying 
to read the VCF again fails (with VariantAnnotation_1.9.35
).  I'm not sure if this is related to the same issue.

#+BEGIN_SRC R

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

#+END_SRC

Error in `rownames<-`(`*tmp*`, value = c("chr1", "chr2")) :
   invalid rownames length

Best wishes
Julian


On 02/05/2014 08:38 PM, Michael Lawrence wrote:
> Thanks, fixed in 1.9.35/1.8.11.
>
>
> On Wed, Feb 5, 2014 at 12:35 AM, Julian Gehring <julian.gehring at embl.de>wrote:
>
>> 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
>>
>> _______________________________________________
>> Bioc-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>
>



More information about the Bioc-devel mailing list