Skip to content

Allow 'ANY' txdb, eg. EnsDb objects#74

Open
mschubert wants to merge 1 commit into
Bioconductor:develfrom
mschubert:devel
Open

Allow 'ANY' txdb, eg. EnsDb objects#74
mschubert wants to merge 1 commit into
Bioconductor:develfrom
mschubert:devel

Conversation

@mschubert

Copy link
Copy Markdown

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"'

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands predictCoding()’s S4 method dispatch so callers can use transcript annotation providers beyond TxDb (e.g., EnsDb), by relaxing the subject signature to ANY and relying on the presence of the required annotation methods at runtime.

Changes:

  • Broaden predictCoding() method signatures from subject="TxDb" to subject="ANY" for IntegerRanges, CollapsedVCF, ExpandedVCF, GRanges, and VRanges entry points.
  • Enable predictCoding(vr, ensdb, genome) style calls that previously failed dispatch due to EnsDb not inheriting from TxDb.
Comments suppressed due to low confidence (1)

R/methods-predictCoding.R:53

  • The VRanges method calls .predictCoding() directly, so it will bypass any interface validation / cache initialization done in the GRanges method. With subject now ANY, this means VRanges+EnsDb can still fail depending on cdsBy() defaults or missing methods. Consider mirroring the same cache initialization (and clearer error) here before calling .predictCoding().
setMethod("predictCoding", c("VRanges", "ANY", "ANY", "missing"),
    function(query, subject, seqSource, varAllele, ..., ignore.strand=FALSE)
{
    varAllele <- alt(query)
    query <- as(query, "GRanges")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/methods-predictCoding.R
Comment on lines +42 to 47
setMethod("predictCoding", c("GRanges", "ANY", "ANY", "DNAStringSet"),
function(query, subject, seqSource, varAllele, ..., ignore.strand=FALSE)
{
.predictCoding(query, subject, seqSource, varAllele, ...,
ignore.strand=ignore.strand)
})
Comment thread R/methods-predictCoding.R
})

setMethod("predictCoding", c("GRanges", "TxDb", "ANY", "DNAStringSet"),
setMethod("predictCoding", c("GRanges", "ANY", "ANY", "DNAStringSet"),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants