Last data update: 2014.03.03

R: Add metadata of the GRanges objects used for...
addMetadataR Documentation

Add metadata of the GRanges objects used for findOverlapsOfPeaks

Description

Add metadata to to overlapping peaks after calling findOverlapsOfPeaks.

Usage

addMetadata(ol, colNames=NULL, FUN=c, ...)

Arguments

ol

An object of overlappingPeaks, which is output of findOverlapsOfPeaks.

colNames

Names of metadata column to be added. If it is NULL, addMetadata will guess what to add.

FUN

A function to be called

...

Arguments to the function call.

Value

return value is An object of overlappingPeaks.

Author(s)

Jianhong Ou

See Also

See Also as findOverlapsOfPeaks

Examples

peaks1 <- GRanges(seqnames=c(6,6,6,6,5),
                 IRanges(start=c(1543200,1557200,1563000,1569800,167889600),
                         end=c(1555199,1560599,1565199,1573799,167893599),
                         names=c("p1","p2","p3","p4","p5")),
                 strand="+",
                 score=1:5, id=letters[1:5])
peaks2 <- GRanges(seqnames=c(6,6,6,6,5),
                  IRanges(start=c(1549800,1554400,1565000,1569400,167888600),
                          end=c(1550599,1560799,1565399,1571199,167888999),
                          names=c("f1","f2","f3","f4","f5")),
                  strand="+",
                  score=6:10, id=LETTERS[1:5])
ol <- findOverlapsOfPeaks(peaks1, peaks2)
addMetadata(ol)

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/addMetadata.Rd_%03d_medium.png", width=480, height=480)
> ### Name: addMetadata
> ### Title: Add metadata of the GRanges objects used for findOverlapsOfPeaks
> ### Aliases: addMetadata
> ### Keywords: misc
> 
> ### ** Examples
> 
> peaks1 <- GRanges(seqnames=c(6,6,6,6,5),
+                  IRanges(start=c(1543200,1557200,1563000,1569800,167889600),
+                          end=c(1555199,1560599,1565199,1573799,167893599),
+                          names=c("p1","p2","p3","p4","p5")),
+                  strand="+",
+                  score=1:5, id=letters[1:5])
> peaks2 <- GRanges(seqnames=c(6,6,6,6,5),
+                   IRanges(start=c(1549800,1554400,1565000,1569400,167888600),
+                           end=c(1550599,1560799,1565399,1571199,167888999),
+                           names=c("f1","f2","f3","f4","f5")),
+                   strand="+",
+                   score=6:10, id=LETTERS[1:5])
> ol <- findOverlapsOfPeaks(peaks1, peaks2)
> addMetadata(ol)
$venn_cnt
     peaks1 peaks2 Counts
[1,]      0      0      0
[2,]      0      1      1
[3,]      1      0      1
[4,]      1      1      4
attr(,"class")
[1] "VennCounts"

$peaklist
$peaklist$peaks2
GRanges object with 1 range and 3 metadata columns:
      seqnames                 ranges strand |       peakNames          id
         <Rle>              <IRanges>  <Rle> | <CharacterList> <character>
  [1]        5 [167888600, 167888999]      + |      peaks2__f5           E
            score
      <character>
  [1]          10
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths

$peaklist$peaks1
GRanges object with 1 range and 3 metadata columns:
      seqnames                 ranges strand |       peakNames          id
         <Rle>              <IRanges>  <Rle> | <CharacterList> <character>
  [1]        5 [167889600, 167893599]      + |      peaks1__p5           e
            score
      <character>
  [1]           5
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths

$peaklist$`peaks1///peaks2`
GRanges object with 3 ranges and 3 metadata columns:
      seqnames             ranges strand |                            peakNames
         <Rle>          <IRanges>  <Rle> |                      <CharacterList>
  [1]        6 [1543200, 1560799]      + | peaks1__p1,peaks2__f1,peaks2__f2,...
  [2]        6 [1563000, 1565399]      + |                peaks1__p3,peaks2__f3
  [3]        6 [1569400, 1573799]      + |                peaks2__f4,peaks1__p4
            id    score
        <list>   <list>
  [1] ######## ########
  [2] ######## ########
  [3] ######## ########
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths


$overlappingPeaks
$overlappingPeaks$`peaks1///peaks2`
                          peaks1 seqnames   start     end width strand
peaks1__p1_peaks2__f1 peaks1__p1        6 1543200 1555199 12000      +
peaks1__p1_peaks2__f2 peaks1__p1        6 1543200 1555199 12000      +
peaks1__p2_peaks2__f2 peaks1__p2        6 1557200 1560599  3400      +
peaks1__p3_peaks2__f3 peaks1__p3        6 1563000 1565199  2200      +
peaks1__p4_peaks2__f4 peaks1__p4        6 1569800 1573799  4000      +
                          peaks2 seqnames   start     end width strand
peaks1__p1_peaks2__f1 peaks2__f1        6 1549800 1550599   800      +
peaks1__p1_peaks2__f2 peaks2__f2        6 1554400 1560799  6400      +
peaks1__p2_peaks2__f2 peaks2__f2        6 1554400 1560799  6400      +
peaks1__p3_peaks2__f3 peaks2__f3        6 1565000 1565399   400      +
peaks1__p4_peaks2__f4 peaks2__f4        6 1569400 1571199  1800      +
                      overlapFeature shortestDistance
peaks1__p1_peaks2__f1 includeFeature             4600
peaks1__p1_peaks2__f2   overlapStart              799
peaks1__p2_peaks2__f2         inside              200
peaks1__p3_peaks2__f3   overlapStart              199
peaks1__p4_peaks2__f4     overlapEnd              400


$all.peaks
$all.peaks[[1]]
GRanges object with 5 ranges and 2 metadata columns:
             seqnames                 ranges strand |     score          id
                <Rle>              <IRanges>  <Rle> | <integer> <character>
  peaks1__p1        6 [  1543200,   1555199]      + |         1           a
  peaks1__p2        6 [  1557200,   1560599]      + |         2           b
  peaks1__p3        6 [  1563000,   1565199]      + |         3           c
  peaks1__p4        6 [  1569800,   1573799]      + |         4           d
  peaks1__p5        5 [167889600, 167893599]      + |         5           e
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths

$all.peaks[[2]]
GRanges object with 5 ranges and 2 metadata columns:
             seqnames                 ranges strand |     score          id
                <Rle>              <IRanges>  <Rle> | <integer> <character>
  peaks2__f1        6 [  1549800,   1550599]      + |         6           A
  peaks2__f2        6 [  1554400,   1560799]      + |         7           B
  peaks2__f3        6 [  1565000,   1565399]      + |         8           C
  peaks2__f4        6 [  1569400,   1571199]      + |         9           D
  peaks2__f5        5 [167888600, 167888999]      + |        10           E
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths


attr(,"class")
[1] "overlappingPeaks"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>