Defining an S4 coercer in my multicrispr package
methods::setAs( "BSgenome", "GRanges", function(from) from %>% GenomeInfoDb::seqinfo() %>% as('GRanges'))
gives this byte compile message:
** byte-compile and prepare package for lazy loading in method for 'coerce' with signature '"BSgenome","GRanges"': no definition for class "BSgenome"
BSgenome class in advance avoids these messages, but attaches many dependency packages:
BSgenome <- methods::getClassDef('BSgenome', package = 'BSgenome') Loading required package: BSgenome Loading required package: BiocGenerics Loading required package: parallel Attaching package: ‘BiocGenerics’ The following objects are masked from ‘package:parallel’: clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, clusterExport, clusterMap, parApply, parCapply, parLapply, parLapplyLB, parRapply, parSapply, parSapplyLB The following objects are masked from ‘package:stats’: IQR, mad, sd, var, xtabs The following objects are masked from ‘package:base’: anyDuplicated, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which, which.max, which.min Loading required package: S4Vectors Loading required package: stats4 Attaching package: ‘S4Vectors’ The following object is masked from ‘package:base’: expand.grid Loading required package: IRanges Attaching package: ‘IRanges’ The following object is masked from ‘package:grDevices’: windows Loading required package: GenomeInfoDb Loading required package: GenomicRanges Loading required package: Biostrings Loading required package: XVector Attaching package: ‘Biostrings’ The following object is masked from ‘package:base’: strsplit Loading required package: rtracklayer
Is there a way to define the S4 coercer without attaching these dependencies?