non-numeric argument to binary operator error with makeBackground() in PWMEnrich
1
0
Entering edit mode
elliott77 • 0
@elliott77-6778
Last seen 3.4 years ago
United States

Hi, Elliott Ferris here from the Neurobiology Department at the University of Utah. I am working to make a custom background for a motif enrichment analysis with PWMenrich. ​I've rum into a problem with makeBackground().  Here is a simplified example of the code I am running:


library("PWMenrich")
library("MotifDb.Hsap.PFM")
library(BSgenome.Hsapiens.UCSC.hg19)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
gn <- sort(genes(txdb))
up1000 <- flank(gn, width=1000)
genome <- BSgenome.Hsapiens.UCSC.hg19
up1000seqs <- getSeq(genome, up1000)

background <- makeBackground(MotifDb.Hsap.PFM, organism = Hsapiens, bg.seq = up1000seqs, type="logn", bg.len = 1000)

I get the following error:

Error in (acgt.count/sum(acgt.count)) * bg.pseudo.count : 
  non-numeric argument to binary operator

I see this error on the computer cluster I am running on but not my desktop.  Let me know if you have ideas as to how to troubleshoot this.  

Thanks!

Elliott

 

 

pwmenrich MotifDB • 2.4k views
ADD COMMENT
0
Entering edit mode
@robert-stojnic-6136
Last seen 8.7 years ago
United Kingdom

Hi Elliott,

You had some typos in your code, which is where the error came from. I've added one more line of code to remove background sequences with Ns in them (this will otherwise produce an error). I've also fixed your call of the makeBackground() function.

Note that this code will take a long time, so you might want to consider turning on parallel executioni (see the PWMEnrich vignette for how to do this).

 

library("PWMEnrich")
library("PWMEnrich.Hsapiens.background")
data("MotifDb.Hsap.PFM")
library(BSgenome.Hsapiens.UCSC.hg19)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
gn <- sort(genes(txdb))
up1000 <- flank(gn, width=1000)
genome <- BSgenome.Hsapiens.UCSC.hg19
up1000seqs <- getSeq(genome, up1000)

# remove sequences with Ns and make background
up1000seqs <- up1000seqs[alphabetFrequency(up1000seqs)[,"N"]==0]
background <- makeBackground(MotifDb.Hsap.PFM, algorith="human", bg.seq = up1000seqs, type="logn")

 

Cheers, Robert

ADD COMMENT

Login before adding your answer.

Traffic: 655 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