Question: How to subset S4 list with 5 Granges elements
gravatar for khani.sajjad
10 weeks ago by
khani.sajjad0 wrote:

I have a S4 list (peakAnnoList) which contains many Chip-Seq data in the Granges format.

I would like to subset/filter peakAnnoList based on one of its slot ($width > 4000). Here is the code to generate peakAnnoList:

  ## loading packages
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene

files <- getSampleFiles()
peakAnnoList <- lapply(files, annotatePeak, TxDb=txdb,
                       tssRegion=c(-3000, 3000), verbose=FALSE)

peakAnnoList is a list with 5 elements and each elements contains combination of "csAnno" and "GRanges" and some other objects. I would like to filter all 5 elements of peakAnnoList for width > 4000. Here is the position of width (peakAnnoList[[1]]@anno@ranges@width). I can do that with only 1 elements of list by converting it to data.frame, but I would like to have it for all the elements.

chip-seq • 147 views
ADD COMMENTlink modified 8 weeks ago by RamRS21k • written 10 weeks ago by khani.sajjad0

It's the problem of R dataframe and file handling. Please tag R, data.frame and related tags. Also, please provide the file sample from which you want to extract the data. Without knowing S4 list structure it's hard to imagine the solution.

ADD REPLYlink written 8 weeks ago by kashiff00750
gravatar for RamRS
8 weeks ago by
Houston, TX
RamRS21k wrote:

You should look into apply family of functions, especially lapply. Given that peakAnnoList is a list, you should be able to

filteredItems <- lapply(peakAnnoList, 
                            function(item) {
                                if(item@anno@ranges@width > 4000)
ADD COMMENTlink modified 8 weeks ago • written 8 weeks ago by RamRS21k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 818 users visited in the last hour