findOverlapsOfPeaks() of package ChIPpeakAnno in R
1
0
Entering edit mode
7.0 years ago
salamandra ▴ 550

When running the following code with ChIPpeakAnno package in R:

gr3 = GRanges(seqnames = c("chr1"), strand = c("+","+","+"), ranges = IRanges(start = c(1,3,5), width = 3))
gr3
> gr3
GRanges object with 3 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1    [1, 3]      +
  [2]     chr1    [3, 5]      +
  [3]     chr1    [5, 7]      +
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
gr4 = GRanges(seqnames = c("chr1"), strand = c("+","+","+","+"), ranges = IRanges(start = c(2,4,6,8), width = 3))
gr4
> gr4
GRanges object with 4 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1   [2,  4]      +
  [2]     chr1   [4,  6]      +
  [3]     chr1   [6,  8]      +
  [4]     chr1   [8, 10]      +
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

In gr4, the interval:

[4]     chr1   [8, 10]      +

doesn't intersect with intervals in gr3, so it's an interval of gr4 alone, but when we do:

ol1 <- findOverlapsOfPeaks(gr3, gr4)
ol1$venn_cnt
> ol1$venn_cnt
     gr3 gr4 Counts
[1,]   0   0      0
[2,]   0   1      0
[3,]   1   0      0
[4,]   1   1      3
attr(,"class")
[1] "VennCounts"

there is no interval in gr4 alone (zero counts in 2nd row) When I do the same inverting the order:

ol2 <- findOverlapsOfPeaks(gr4, gr3)
 ol2$venn_cnt
> ol2$venn_cnt
         gr4 gr3 Counts
    [1,]   0   0      0
    [2,]   0   1      0
    [3,]   1   0      0
    [4,]   1   1      3
    attr(,"class")
    [1] "VennCounts"

the same happens.

Shouldn't there be 1 count for gr4 only? What am I interpreting wrong?

R • 2.5k views
ADD COMMENT
0
Entering edit mode
3.1 years ago
hukai916 ▴ 10

I agree with your interpretations, actually, the newer versions of ChIPpeakAnno already fix this problem:

library(ChIPpeakAnno)
packageVersion("ChIPpeakAnno")

gr3 = GRanges(seqnames = c("chr1"), strand = c("+","+","+"), ranges = IRanges(start = c(1,3,5), width = 3))
gr4 = GRanges(seqnames = c("chr1"), strand = c("+","+","+","+"), ranges = IRanges(start = c(2,4,6,8), width = 3))

ol1 <- findOverlapsOfPeaks(gr3, gr4)
ol2 <- findOverlapsOfPeaks(gr4, gr3)
ol1$venn_cnt
ol2$venn_cnt

Here are the output:

> packageVersion("ChIPpeakAnno")
[1] '3.25.1'
> ol1$venn_cnt
     gr3 gr4 Counts count.gr3 count.gr4
[1,]   0   0      0         0         0
[2,]   0   1      1         0         1
[3,]   1   0      0         0         0
[4,]   1   1      3         3         3
> ol2$venn_cnt
     gr4 gr3 Counts count.gr4 count.gr3
[1,]   0   0      0         0         0
[2,]   0   1      0         0         0
[3,]   1   0      1         1         0
[4,]   1   1      3         3         3

For your future reference, it is encouraged to post Bioconductor-related questions at the support site: https://support.bioconductor.org. This site is actively monitored and answered by R package developers. You are supposed to get quicker responses there. You can also search for specific tags to view all related questions and answers there.

ADD COMMENT

Login before adding your answer.

Traffic: 1621 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6