TFBSTools: Appending objects to PFMatrixList
1
1
Entering edit mode
@nathanlawlor03-9169
Last seen 7.5 years ago

I have > 2000 motif files (in meme format) which I have imported into R and converted each into PFMatrix objects. Next, I want to store each of these PFMatrix objects into a PFMatrixList object using a "for loop". 

My first thoughts were to store each PFMatrix object into a base list() object as I imported them into R as such:

# move to directory of motif files
fl <- list.files()

# create an empty list
empty.list <- list()
for (i in 1:length(fl)) {
  # load in meme file
  meme <- read.delim(fl[i], ...)
  # create a pfmatrix
  pfm.matrix <- PFMatrix(ID = ...)

  # add PFMatrix object to list
  empty.list <- c(empty.list, pfm.matrix)
}

Instead of a base list() object I would prefer to add these PFMatrix objects to a PFMatrixList object in a similar manner, however, when I try to add a PFMatrix object to an already existing/or empty PFMatrixList object with the PFMatrixList() function, I get the error:

Error in .local(x, use.names, ...) : 
  PFMatrixList() only accepts PFMatrix objects!    
  

 

Is there a way to append PFMatrix objects to an already existing PFMatrixList object?

 

 

 

 

 

TFBSTools looping PFMatrixList PFMatrix bioconductor • 2.2k views
ADD COMMENT
0
Entering edit mode
@nathanlawlor03-9169
Last seen 7.5 years ago

Provided from Ge Tan (author of TFBSTools) a simple solution is:

pfm.list <- do.call(PFMatrixList, empty.list)

ADD COMMENT

Login before adding your answer.

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