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
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
library(clusterProfiler)
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.
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.