I would like to use the following code to get exon annotation within my package
genes <- AnnotationDbi::keys(Mus.musculus, "GENEID") exon_data <- AnnotationDbi::select( Mus.musculus, keys = genes, keytype = "GENEID", columns = c( "GENEID", "TXID", "EXONCHROM", "EXONSTRAND", "EXONSTART", "EXONEND", "SYMBOL" ) )
However I want to do this without loading in the Mus.musculus package. Simply getting the Mus.musculus object from the package using getFromNamespace is not enough to make this work. I could library it inside the function and detach it before return, but this has the unwanted side-effect that users with Mus.musculus already loaded will find it detached after running my function.