Question: [SOLVED] Trying to apply overlap to each row of a "GRangesList"
0
gravatar for User 7754
3.2 years ago by
User 7754170
United Kingdom
User 7754170 wrote:

Dear Experts,

I have a "GRangesList" object and I am trying to overlap each row of this List to a GRanges object. 

My goal is to get a data frame containing a count for the overlap of the GRanges object repeated for each of the GRangesList like. I have it working with a double loop but this is extremely slow and I am hoping there is a quicker and better solution using some kind of apply functions... I have tried apply, mapply, lapply, but I get the overlap of the two obj1 and objList only and not the repeated obj1 over objList.

Please help..
 

Here are examples of the objList and obj1 in R:

TYPE1 <- GRanges(seqnames = c("chr1", "chr1", "chr1"), ranges=IRanges(start=c(0,9600,24000),
end=c(10000, 20000, 30000)), id=c("Factor1", "Factor2", "Factor3"))

TYPE2 <- GRanges(seqnames = c("chr2", "chr2", "chr2"), ranges=IRanges(start=c(0,9000,14000),
end=c(13000, 20500, 30100)), id=c("Factor1", "Factor2", "Factor3"))

objList <- GRangesList("TYPE1" = TYPE1, "TYPE2" = TYPE2)

obj1 <- GRanges(seqnames = c("chr1", "chr1"), ranges=IRanges(start=c(0,9700), end=c(1, 9701)), id=c("rs1", "rs2"))


And this is what I have working now with loops (to find the overlap of obj1 with each row of objList):

nameList=names(objList)
output=data.frame(row.names=c("rs1","rs2"))
for (name in nameList) {
id= objList[[name]]$id
for (i in 1:length(id)) {
dftemp=as.data.frame(countOverlaps(obj1, objList[[name]][i,], type=c("within")))
output=cbind.data.frame(output,dftemp)
}
}
 

apply loop R • 1.2k views
ADD COMMENTlink modified 16 months ago by Biostar ♦♦ 20 • written 3.2 years ago by User 7754170
2
gravatar for Devon Ryan
3.2 years ago by
Devon Ryan86k
Freiburg, Germany
Devon Ryan86k wrote:

Hello User 7754!

It appears that your post has been cross-posted to another site: http://seqanswers.com/forums/showthread.php?t=63056

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD COMMENTlink written 3.2 years ago by Devon Ryan86k
0
gravatar for User 7754
3.2 years ago by
User 7754170
United Kingdom
User 7754170 wrote:

Yes I am sorry!! answer was kindly provided by dpryan in http://seqanswers.com/forums/showthread.php?p=181564&posted=1#post181564

ADD COMMENTlink written 3.2 years ago by User 7754170
Please log in to add an answer.

Help
Access

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