Last data update: 2014.03.03

R: Find the overlapping peaks for two peak ranges.
findOverlappingPeaksR Documentation

Find the overlapping peaks for two peak ranges.

Description

Find the overlapping peaks for two input peak ranges.

This function is to keep the backward compatibility with previous versions for RangedData object.

The new function findOverlapsOfPeaks is recommended.

Convert RangedData to GRanges with toGRanges function.

Usage

findOverlappingPeaks(Peaks1, Peaks2, maxgap = 0L,
    minoverlap=1L, multiple = c(TRUE, FALSE), 
    NameOfPeaks1 = "TF1", NameOfPeaks2 = "TF2",
    select=c("all", "first","last","arbitrary"), annotate = 0,
    ignore.strand=TRUE, 
    connectedPeaks=c("min", "merge"), ...)

Arguments

Peaks1

RangedData: See example below.

Peaks2

RangedData: See example below.

maxgap

Non-negative integer. Intervals with a separation of maxgap or less are considered to be overlapping.

minoverlap

Non-negative integer. Intervals with an overlapping of minoverlap or more are considered to be overlapping.

multiple

TRUE or FALSE: TRUE may return multiple overlapping peaks in Peaks2 for one peak in Peaks1; FALSE will return at most one overlapping peaks in Peaks2 for one peak in Peaks1. This parameter is kept for backward compatibility, please use select.

NameOfPeaks1

Name of the Peaks1, used for generating column name.

NameOfPeaks2

Name of the Peaks2, used for generating column name.

select

all may return multiple overlapping peaks, first will return the first overlapping peak, last will return the last overlapping peak and arbitrary will return one of the overlapping peaks.

annotate

Include overlapFeature and shortestDistance in the OverlappingPeaks or not. 1 means yes and 0 means no. Default to 0.

ignore.strand

When set to TRUE, the strand information is ignored in the overlap calculations.

connectedPeaks

If multiple peaks involved in overlapping in several groups, set it to "merge" will count it as only 1, while set it to "min" will count it as the minimal involved peaks in any concered groups

...

Objects of GRanges or RangedData: See also findOverlapsOfPeaks.

Details

Efficiently perform overlap queries with an interval tree implemented in IRanges.

Value

OverlappingPeaks

a data frame consists of input peaks information with added information: overlapFeature (upstream: peak1 resides upstream of the peak2; downstream: peak1 resides downstream of the peak2; inside: peak1 resides inside the peak2 entirely; overlapStart: peak1 overlaps with the start of the peak2; overlapEnd: peak1 overlaps with the end of the peak2; includeFeature: peak1 include the peak2 entirely) and shortestDistance (shortest distance between the overlapping peaks)

MergedPeaks

RangedData contains merged overlapping peaks

Author(s)

Lihua Julie Zhu

References

1.Interval tree algorithm from: Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford. Introduction to Algorithms, second edition, MIT Press and McGraw-Hill. ISBN 0-262-53196-8

2.Zhu L.J. et al. (2010) ChIPpeakAnno: a Bioconductor package to annotate ChIP-seq and ChIP-chip data. BMC Bioinformatics 2010, 11:237 doi:10.1186/1471-2105-11-237

3. Zhu L (2013). Integrative analysis of ChIP-chip and ChIP-seq dataset. In Lee T and Luk ACS (eds.), Tilling Arrays, volume 1067, chapter 4, pp. -19. Humana Press. http://dx.doi.org/10.1007/978-1-62703-607-8_8

See Also

findOverlapsOfPeaks, annotatePeakInBatch, makeVennDiagram

Examples

    if (interactive())
    {    
    peaks1 = 
        RangedData(IRanges(start=c(1543200,1557200,1563000,1569800,167889600),
                           end=c(1555199,1560599,1565199,1573799,167893599),
                           names=c("p1","p2","p3","p4","p5")),
                   strand=as.integer(1),space=c(6,6,6,6,5))
    peaks2 = 
        RangedData(IRanges(start=c(1549800,1554400,1565000,1569400,167888600),
                           end=c(1550599,1560799,1565399,1571199,167888999),
                           names=c("f1","f2","f3","f4","f5")),
                   strand=as.integer(1),space=c(6,6,6,6,5))
    t1 =findOverlappingPeaks(peaks1, peaks2, maxgap=1000, 
          NameOfPeaks1="TF1", NameOfPeaks2="TF2", select="all", annotate=1) 
    r = t1$OverlappingPeaks
    pie(table(r$overlapFeature))
    as.data.frame(t1$MergedPeaks)
    }

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ChIPpeakAnno)
Loading required package: grid
Loading required package: IRanges
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: Biostrings
Loading required package: XVector
Loading required package: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: VennDiagram
Loading required package: futile.logger

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/ChIPpeakAnno/findOverlappingPeaks.Rd_%03d_medium.png", width=480, height=480)
> ### Name: findOverlappingPeaks
> ### Title: Find the overlapping peaks for two peak ranges.
> ### Aliases: findOverlappingPeaks findOverlappingPeaks-deprecated
> ### Keywords: misc
> 
> ### ** Examples
> 
> #    if (interactive())
> #    {    
>     peaks1 = 
+         RangedData(IRanges(start=c(1543200,1557200,1563000,1569800,167889600),
+                            end=c(1555199,1560599,1565199,1573799,167893599),
+                            names=c("p1","p2","p3","p4","p5")),
+                    strand=as.integer(1),space=c(6,6,6,6,5))
>     peaks2 = 
+         RangedData(IRanges(start=c(1549800,1554400,1565000,1569400,167888600),
+                            end=c(1550599,1560799,1565399,1571199,167888999),
+                            names=c("f1","f2","f3","f4","f5")),
+                    strand=as.integer(1),space=c(6,6,6,6,5))
>     t1 =findOverlappingPeaks(peaks1, peaks2, maxgap=1000, 
+           NameOfPeaks1="TF1", NameOfPeaks2="TF2", select="all", annotate=1) 
Warning message:
'findOverlappingPeaks' is deprecated.
Use 'findOverlapsOfPeaks' instead.
See help("Deprecated") 
>     r = t1$OverlappingPeaks
>     pie(table(r$overlapFeature))
>     as.data.frame(t1$MergedPeaks)
  space     start       end width                              names strand
1     5 167888600 167893599  5000                   TF2__f5__TF1__p5      *
2     6   1543200   1560799 17600 TF1__p1__TF2__f1__TF2__f2__TF1__p2      *
3     6   1563000   1565399  2400                   TF1__p3__TF2__f3      *
4     6   1569400   1573799  4400                   TF2__f4__TF1__p4      *
> #    }
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>