following up on some previous posts (below), I was wondering if there is any other (simpler) way to intersect 2 GRanges and keep all the information in the metacolumns (perhaps using any newer package/newer operations in BioC ?);
The example I have is :
## DNAse gr2 <- GRanges("chr1", IRanges(8:12, width=5, names=paste0("dnase:", letters[1:5])), score2=10:14) ## SNP gr1 <- GRanges("chr1", IRanges(1:5, width=5, names=paste0("rsid:", letters[1:5])), score1=1:5) ## interaction : ranges <- subsetByOverlaps(gr2, gr1) hits <- findOverlaps(gr2, gr1) idx <- unique(subjectHits(hits))
## idx <- subjectHits(hits)
values <- DataFrame(rsid=names(gr1)[idx], snpscore=gr1$score1[idx]) mcols(ranges) <- c(mcols(ranges), values) ranges
thank you very much !