VariantAnnotation icon indicating copy to clipboard operation
VariantAnnotation copied to clipboard

Allow 'ANY' txdb, eg. EnsDb objects

Open mschubert opened this issue 8 months ago • 0 comments

Thank for for the VariantAnnotation package, it makes it very easy to annotate mutations found in VCF files!

There is, however, one limitation that I find unnecessarily restrictive: The predictCoding method expects a TxDb object as its second argument and will not be able to process gene and transcript annotations otherwise.

I propose that the limitation here should be any object that supports the cdsBy and transcriptsBy methods, e.g. an EnsDb object. As they do not share a common base class, I allow ANY type that will then error if the associated methods are not found.

In particular, the code that previously failed now works successfully:

ens106 = AnnotationHub::AnnotationHub()[["AH100643"]]
asm = BSgenome.Hsapiens.NCBI.GRCh38::BSgenome.Hsapiens.NCBI.GRCh38
fname = system.file("extdata", "chr22.vcf.gz", package="VariantAnnotation")
vr = VariantAnnotation::readVcfAsVRanges(fname)
res = predictCoding(vr, ens106, asm)
# Error in (function (classes, fdef, table)  :
#   unable to find an inherited method for 'predictCoding' for signature '"VRanges", "EnsDb", "BSgenome", "missing"'

mschubert avatar Nov 06 '23 12:11 mschubert