# vcountPDict on a DNAStringSet works bsgenome <- BSgenome.Mmusculus.UCSC.mm10::Mmusculus seqs <- c("CTTATATTGTCTCCAGCAGAAGG", "CTTATATTGTCTCCAGCAGAAGG", "ATATTGTCAAGTTGACAACCAGG") Biostrings::vcountPDict( Biostrings::DNAStringSet(seqs), bsgenome, min.mismatch = mismatch, max.mismatch = mismatch) # vcountPDict on a PDict fails (contrary to documentation!) Biostrings::vcountPDict( Biostrings::PDict(cas9seqdt$cas9seq, max.mismatch=0), bsgenome, min.mismatch = mismatch, max.mismatch = mismatch) Error in .local(pdict, subject, max.mismatch, min.mismatch, fixed, algorithm, : 'pdict' must be a DNAStringSet object
Maybe you were looking at the wrong man page.
vcountPDict() is a generic function with dispatch on the 2nd argument (
library(BSgenome) vcountPDict # standardGeneric for "vcountPDict" defined from package "Biostrings" # function (pdict, subject, max.mismatch = 0, min.mismatch = 0, # with.indels = FALSE, fixed = TRUE, algorithm = "auto", collapse = FALSE, # weight = 1L, verbose = FALSE, ...) # standardGeneric("vcountPDict") # <bytecode: 0xfdc27c8> # <environment: 0xfd96f80> # Methods may be defined for arguments: subject # Use showMethods("vcountPDict") for currently available ones.
Let's look at the list of its methods:
showMethods("vcountPDict") # Function: vcountPDict (package Biostrings) # subject="BSgenome" # subject="MaskedXString" # subject="XString" # subject="XStringSet" # subject="XStringViews"
This generic function and most of its methods are actually defined and documented in the Biostrings package. The method that you are trying to use (and that fails on a PDict object) is the method defined for BSgenome objects i.e. it's the method that handles a
subject that is a BSgenome object. You can open the man page for this particular method with:
As you can see, unlike the man page for the other methods which is from the Biostrings package, this man page is from the BSgenome package. It says:
pdict: A DNAStringSet object containing the pattern sequences.
Anyway, I've enhanced the
vcountPDict() methods for BSgenome objects in BioC devel to accept a PDict object. The change is in BSgenome 1.53.1 (see it on GitHub). BSgenome 1.53.1 should become available to BioC devel (i.e. BioC 3.10) users via
BiocManager::install() in the next 24h or so.