Entering edit mode
Hi Robert,
Hope this finds you well!
I was playing with PWMEnrich and found what might be a bug in the
sequenceReport() function.
In short, if you invoke sequenceReport() from within another function,
it
searches for a global variable of class 'MotifEnrichmentResults' named
'res', instead of using the 'MotifEnrichmentResults' object provided
as
first argument.
###
# this will work:
library(PWMEnrich)
library(PWMEnrich.Hsapiens.background)
data(PWMLogn.hg19.MotifDb.Hsap)
dss <- DNAStringSet(c("CACCAGGATTAACATCGGGATGATCGATGCTAGATCA",
"CAGATAGCCATGACAGGGTACCAA"))
res <- motifEnrichment(dss, PWMLogn.hg19.MotifDb.Hsap)
rprt <- sequenceReport(res, 1)
# clean up:
rm(res, rprt)
# but this will fail:
findMotifs <- function(x) {
res <- motifEnrichment(x, PWMLogn.hg19.MotifDb.Hsap)
rprt <- sequenceReport(res, 1)
}
rprt <- findMotifs(dss)
# the workaround is to use global assignment in the function;
# the 'MotifEnrichmentResults' object needs to be names 'res' for the
workaround to work.
findMotifs <- function(x) {
res <<- motifEnrichment(x, PWMLogn.hg19.MotifDb.Hsap)
rprt <- sequenceReport(res, 1)
}
rprt <- findMotifs(dss)
###
Can you reproduce this?
HTH!
Best,
--
Enrico Ferrero
[[alternative HTML version deleted]]