Last data update: 2014.03.03
R: Make Venn Diagram from a list of peaks
makeVennDiagram R Documentation
Make Venn Diagram from a list of peaks
Description
Make Venn Diagram from two or more peak ranges, Also calculate p-value to
determine whether those peaks overlap significantly.
Usage
makeVennDiagram(Peaks, NameOfPeaks, maxgap = 0L, minoverlap = 1L,
totalTest, by = c("region", "feature", "base"),
ignore.strand = TRUE, connectedPeaks = c("min",
"merge", "keepAll"), method = c("hyperG",
"permutation"), TxDb, ...)
Arguments
Peaks
A list of peaks in GRanges format:
See example below.
NameOfPeaks
Character vector to specify the name of Peaks, e.g., c("TF1", "TF2"). This will
be used as label in the Venn Diagram.
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.
totalTest
Numeric value to specify the total number of tests performed to obtain the
list of peaks. It should be much larger than the number of peaks in the
largest peak set.
by
"region, "feature" or "base", default = "region". feature means using
feature field in the GRanges for calculating overlap, region means using
chromosome range for calculating overlap, and base means calculating overlap
in nucleotide level.
ignore.strand
Logical: 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 connected peak group.
method
method used for p value calculation. hyperG means
hypergeometric test and permutation means peakPermTest
TxDb
An object of TxDb
...
Additional arguments to be passed to
venn.diagram
Details
For customized graph options, please see venn.diagram in VennDiagram package.
Value
In addition to a Venn Diagram produced, a p.value is calculated by
hypergeometric test to determine whether the peaks or features are
overlapped significantly.
Author(s)
Lihua Julie Zhu, Jianhong Ou
See Also
findOverlapsOfPeaks, venn.diagram,
peakPermTest
Examples
if (interactive()){
peaks1 <- GRanges(seqnames=c("1", "2", "3"),
IRanges(start=c(967654, 2010897, 2496704),
end=c(967754, 2010997, 2496804),
names=c("Site1", "Site2", "Site3")),
strand="+",
feature=c("a","b","f"))
peaks2 = GRanges(seqnames=c("1", "2", "3", "1", "2"),
IRanges(start = c(967659, 2010898,2496700,
3075866,3123260),
end = c(967869, 2011108, 2496920,
3076166, 3123470),
names = c("t1", "t2", "t3", "t4", "t5")),
strand = c("+", "+", "-", "-", "+"),
feature=c("a","b","c","d","a"))
makeVennDiagram(list(peaks1, peaks2), NameOfPeaks=c("TF1", "TF2"),
totalTest=100,scaled=FALSE, euler.d=FALSE)
makeVennDiagram(list(peaks1, peaks2), NameOfPeaks=c("TF1", "TF2"),
totalTest=100)
###### 4-way diagram using annotated feature instead of chromosome ranges
makeVennDiagram(list(peaks1, peaks2, peaks1, peaks2),
NameOfPeaks=c("TF1", "TF2","TF3", "TF4"),
totalTest=100, by="feature",
main = "Venn Diagram for 4 peak lists",
fill=c(1,2,3,4))
}
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/makeVennDiagram.Rd_%03d_medium.png", width=480, height=480)
> ### Name: makeVennDiagram
> ### Title: Make Venn Diagram from a list of peaks
> ### Aliases: makeVennDiagram
> ### Keywords: graph
>
> ### ** Examples
>
> #if (interactive()){
> peaks1 <- GRanges(seqnames=c("1", "2", "3"),
+ IRanges(start=c(967654, 2010897, 2496704),
+ end=c(967754, 2010997, 2496804),
+ names=c("Site1", "Site2", "Site3")),
+ strand="+",
+ feature=c("a","b","f"))
> peaks2 = GRanges(seqnames=c("1", "2", "3", "1", "2"),
+ IRanges(start = c(967659, 2010898,2496700,
+ 3075866,3123260),
+ end = c(967869, 2011108, 2496920,
+ 3076166, 3123470),
+ names = c("t1", "t2", "t3", "t4", "t5")),
+ strand = c("+", "+", "-", "-", "+"),
+ feature=c("a","b","c","d","a"))
> makeVennDiagram(list(peaks1, peaks2), NameOfPeaks=c("TF1", "TF2"),
+ totalTest=100,scaled=FALSE, euler.d=FALSE)
$p.value
TF1 TF2 pval
[1,] 1 1 6.184292e-05
$vennCounts
TF1 TF2 Counts
[1,] 0 0 95
[2,] 0 1 2
[3,] 1 0 0
[4,] 1 1 3
attr(,"class")
[1] "VennCounts"
>
> makeVennDiagram(list(peaks1, peaks2), NameOfPeaks=c("TF1", "TF2"),
+ totalTest=100)
$p.value
TF1 TF2 pval
[1,] 1 1 6.184292e-05
$vennCounts
TF1 TF2 Counts
[1,] 0 0 95
[2,] 0 1 2
[3,] 1 0 0
[4,] 1 1 3
attr(,"class")
[1] "VennCounts"
>
> ###### 4-way diagram using annotated feature instead of chromosome ranges
>
> makeVennDiagram(list(peaks1, peaks2, peaks1, peaks2),
+ NameOfPeaks=c("TF1", "TF2","TF3", "TF4"),
+ totalTest=100, by="feature",
+ main = "Venn Diagram for 4 peak lists",
+ fill=c(1,2,3,4))
$p.value
TF1 TF2 TF3 TF4 pval
[1,] 0 0 1 1 3.586889e-03
[2,] 0 1 0 1 2.550223e-07
[3,] 0 1 1 0 3.586889e-03
[4,] 1 0 0 1 3.586889e-03
[5,] 1 0 1 0 6.184292e-06
[6,] 1 1 0 0 3.586889e-03
$vennCounts
TF1 TF2 TF3 TF4 Counts
[1,] 0 0 0 0 95
[2,] 0 0 0 1 0
[3,] 0 0 1 0 0
[4,] 0 0 1 1 0
[5,] 0 1 0 0 0
[6,] 0 1 0 1 2
[7,] 0 1 1 0 0
[8,] 0 1 1 1 0
[9,] 1 0 0 0 0
[10,] 1 0 0 1 0
[11,] 1 0 1 0 1
[12,] 1 0 1 1 0
[13,] 1 1 0 0 0
[14,] 1 1 0 1 0
[15,] 1 1 1 0 0
[16,] 1 1 1 1 2
attr(,"class")
[1] "VennCounts"
> #}
>
>
>
>
>
> dev.off()
null device
1
>