This is a test version of Biostars. For the public version, visit https://www.biostars.org.
proceeding finding overlap for multiple GRanges in two parallel batches - [solved]

Dear all:

I am looking for robust output representation for overlapping for multiple GRanges simultaneously, to find better output structure for easy to produce and fast for downstream computation. My objective is, proceed overlapping for multiple GRanges in two parallel batches, let its output easy/fast to produce for further needs. Can anyone give me some possible ideas how to let this task more efficiently done? Thanks in advance

simulated data:

foo <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3", "chr4"), c(5, 6, 4, 3)),
  ranges=IRanges(seq(1, by=9, len=18), seq(6, by=9, len=18)),
  rangeName=letters[seq(1:18)], score=sample(1:25, 18, replace = FALSE));     foo$pvalue <- 10^(score(foo)/-1);
bar <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3","chr4"), c(4, 7, 5, 4)),
  ranges=IRanges(seq(2, by=11, len=20), seq(8, by=11, len=20)),
  rangeName=letters[seq(1:20)], score=sample(1:25, 20, replace = FALSE));     bar$pvalue <- 10^(score(bar)/-1);
moo <- GRanges(
  seqnames=Rle(c("chr1", "chr2", "chr3","chr4"), c(8, 7, 6, 4)),
  ranges=IRanges(seq(4, by=11, len=25), seq(9, by=11, len=25)),
  rangeName=letters[seq(1:25)], score=sample(1:25, 25, replace = FALSE));     moo$pvalue <- 10^(score(moo)/-1);

My initial attempt, pretty much what I want to do, let it happen in two parallel batches:

foo.s <- foo %>% subset(pvalue < 1e-12)
foo.w <- foo %>% subset(pvalue < 1e-4 & pvalue >= 1e-12)
foo.noise <- foo %>% subset(pvalue >= 1e-4)
target <- GRangesList(bar, moo)

instead, this is my further attempt, but using nested lapply is not desired, so still looking for alternative for this:

foo_denoise <- GRangesList(foo.s, foo.w)
target <- GRangesList(bar, moo)

func <- function(obj, li) {
  ans <- lapply(li, function(ele_) {
    out <- base::setdiff(obj, li)
  })
  return(ans)
}
my_output <- lapply(foo_denoise, function(x) {
      res <- func(x, target)
    })

I don't want to use nested structure for this task, because it return complicated output format, I am expecting nicer output representation with easy to produce and fast for downstream computation.

I will be grateful if anyone propose possible approach,or ideas to solve this sort of problem. Many thanks

Best regards :

JS

r genome chip-seq granges overlapping

0 answers

No answers yet.

Log in to answer this question.