PWMEnrich::sequenceReport() and 'res' global variable
0
0
Entering edit mode
enricoferrero ▴ 660
@enricoferrero-6037
Last seen 3.0 years ago
Switzerland
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]]
PWMEnrich PWMEnrich • 885 views
ADD COMMENT

Login before adding your answer.

Traffic: 616 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6