Last data update: 2014.03.03

R: Set Intersect and Venn Diagram Functions
overLapperR Documentation

Set Intersect and Venn Diagram Functions

Description

Function for computing Venn intersects or standard intersects among large numbers of label sets provided as list of vectors. The resulting intersect objects can be used for plotting 2-5 way Venn diagrams or intersect bar plots using the functions vennPlot or olBarplot, respectively. The overLapper function scales to 2-20 or more label vectors for Venn intersect calculations and to much larger sample numbers for standard intersects. The different intersect types are explained below under the definition of the type argument. The upper Venn limit around 20 label sets is unavoidable because the complexity of Venn intersects increases exponentially with the label set number n according to this relationship: 2^n - 1. The current implementation of the plotting function vennPlot supports Venn diagrams for 2-5 label sets. To visually analyze larger numbers of label sets, a variety of intersect methods are introduced in the olBarplot help file. These methods are much more scalable than Venn diagrams, but lack their restrictive intersect logic.

Usage

overLapper(setlist, complexity = "default", sep = "_", cleanup = FALSE, keepdups = FALSE, type)

Arguments

setlist

Object of class list where each list component stores a label set as vector and the name of each label set is stored in the name slot of each list component. The names are used for naming the label sets in all downstream analysis steps and plots.

complexity

Complexity level of intersects specified as integer vector. For Venn intersects it needs to be assigned 1:length(setlist) (default). If complexity=2 the function returns all pairwise intersects.

sep

Character used to separate set labels.

cleanup

If set to TRUE then all characters of the label sets are set to upper case, and leading and trailing spaces are removed. The default cleanup=FALSE omits this step.

keepdups

By default all duplicates are removed from the label sets. The setting keepdups=TRUE will retain duplicates by appending a counter to each entry.

type

With the default setting type="vennsets" the overLapper function computes the typical Venn intersects for the label sets provided under setlist. With the setting type="intersects" the function will compute pairwise intersects (not compatible with Venn diagrams). Venn intersects follow the typical 'only in' intersect logic of Venn comparisons, such as: labels present only in set A, labels present only in the intersect of A & B, etc. Due to this restrictive intersect logic, the combined Venn sets contain no duplicates. In contrast to this, regular intersects follow this logic: labels present in the intersect of A & B, labels present in the intersect of A & B & C, etc. This approach results usually in many duplications of labels among the intersect sets.

Details

Additional Venn diagram resources are provided by the packages limma, gplots, vennerable, eVenn and VennDiagram, or online resources such as shapes, Venn Diagram Generator and Venny.

Value

overLapper returns standard intersect and Venn intersect results as INTERSECTset or VENNset objects, respectively. These S4 objects contain the following components:

setlist

Original label sets accessible with setlist().

intersectmatrix

Present-absent matrix accessible with intersectmatrix(), where each overlap set in the vennlist data component is labeled according to the label set names provided under setlist. For instance, the composite name 'ABC' indicates that the entries are restricted to A, B and C. The seperator used for naming the intersect sets can be specified under the sep argument.

complexitylevels

Complexity levels accessible with complexitylevels().

vennlist

Venn intersects for VENNset objects accessible with vennlist().

intersectlist

Standard intersects for INTERSECTset objects accessible with intersectlist().

Note

The functions provided here are an extension of the Venn diagram resources on this site: http://manuals.bioinformatics.ucr.edu/home/R_BioCondManual#TOC-Venn-Diagrams

Author(s)

Thomas Girke

References

See examples in 'The Electronic Journal of Combinatorics': http://www.combinatorics.org/files/Surveys/ds5/VennSymmExamples.html

See Also

vennPlot, olBarplot

Examples

## Sample data
setlist <- list(A=sample(letters, 18), B=sample(letters, 16),
                C=sample(letters, 20), D=sample(letters, 22),
                E=sample(letters, 18), F=sample(letters, 22))

## 2-way Venn diagram
vennset <- overLapper(setlist[1:2], type="vennsets")
vennPlot(vennset)

## 3-way Venn diagram
vennset <- overLapper(setlist[1:3], type="vennsets")
vennPlot(vennset)

## 4-way Venn diagram
vennset <- overLapper(setlist[1:4], type="vennsets")
vennPlot(list(vennset, vennset))

## Pseudo 4-way Venn diagram with circles
vennPlot(vennset, type="circle")

## 5-way Venn diagram
vennset <- overLapper(setlist[1:5], type="vennsets")
vennPlot(vennset)

## Alternative Venn count input to vennPlot (not recommended!)
counts <- sapply(vennlist(vennset), length)
vennPlot(counts)

## 6-way Venn comparison as bar plot
vennset <- overLapper(setlist[1:6], type="vennsets")
olBarplot(vennset, mincount=1)

## Bar plot of standard intersect counts
interset <- overLapper(setlist, type="intersects")
olBarplot(interset, mincount=1)

## Accessor methods for VENNset/INTERSECTset objects
names(vennset)
names(interset)
setlist(vennset)
intersectmatrix(vennset)
complexitylevels(vennset)
vennlist(vennset)
intersectlist(interset)

## Coerce VENNset/INTERSECTset object to list
as.list(vennset)
as.list(interset)

## Pairwise intersect matrix and heatmap
olMA <- sapply(names(setlist), 
		function(x) sapply(names(setlist), 
		function(y) sum(setlist[[x]] %in% setlist[[y]])))
olMA
heatmap(olMA, Rowv=NA, Colv=NA)

## Presence-absence matrices for large numbers of sample sets
interset <- overLapper(setlist=setlist, type="intersects", complexity=2)
(paMA <- intersectmatrix(interset))
heatmap(paMA, Rowv=NA, Colv=NA, col=c("white", "gray")) 

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(systemPipeR)
Loading required package: Rsamtools
Loading required package: GenomeInfoDb
Loading required package: stats4
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

Attaching package: 'S4Vectors'

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

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: IRanges
Loading required package: GenomicRanges
Loading required package: Biostrings
Loading required package: XVector
Loading required package: ShortRead
Loading required package: BiocParallel
Loading required package: GenomicAlignments
Loading required package: SummarizedExperiment
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.


> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/systemPipeR/overLapper.Rd_%03d_medium.png", width=480, height=480)
> ### Name: overLapper
> ### Title: Set Intersect and Venn Diagram Functions
> ### Aliases: overLapper setlist setlist-methods intersectmatrix
> ###   intersectmatrix-methods complexitylevels complexitylevels-methods
> ###   vennlist vennlist-methods intersectlist intersectlist-methods
> ### Keywords: utilities
> 
> ### ** Examples
> 
> ## Sample data
> setlist <- list(A=sample(letters, 18), B=sample(letters, 16),
+                 C=sample(letters, 20), D=sample(letters, 22),
+                 E=sample(letters, 18), F=sample(letters, 22))
> 
> ## 2-way Venn diagram
> vennset <- overLapper(setlist[1:2], type="vennsets")
> vennPlot(vennset)
> 
> ## 3-way Venn diagram
> vennset <- overLapper(setlist[1:3], type="vennsets")
> vennPlot(vennset)
> 
> ## 4-way Venn diagram
> vennset <- overLapper(setlist[1:4], type="vennsets")
> vennPlot(list(vennset, vennset))
> 
> ## Pseudo 4-way Venn diagram with circles
> vennPlot(vennset, type="circle")
> 
> ## 5-way Venn diagram
> vennset <- overLapper(setlist[1:5], type="vennsets")
> vennPlot(vennset)
> 
> ## Alternative Venn count input to vennPlot (not recommended!)
> counts <- sapply(vennlist(vennset), length)
> vennPlot(counts)
> 
> ## 6-way Venn comparison as bar plot
> vennset <- overLapper(setlist[1:6], type="vennsets")
> olBarplot(vennset, mincount=1)
> 
> ## Bar plot of standard intersect counts
> interset <- overLapper(setlist, type="intersects")
> olBarplot(interset, mincount=1)
> 
> ## Accessor methods for VENNset/INTERSECTset objects
> names(vennset)
[1] "setlist"          "intersectmatrix"  "complexitylevels" "vennlist"        
> names(interset)
[1] "setlist"          "intersectmatrix"  "complexitylevels" "intersectlist"   
> setlist(vennset)
$A
 [1] "d" "y" "x" "z" "j" "g" "a" "e" "l" "i" "n" "s" "w" "b" "k" "u" "t" "p"

$B
 [1] "u" "b" "v" "l" "k" "j" "p" "g" "z" "x" "w" "a" "e" "i" "h" "n"

$C
 [1] "h" "p" "n" "j" "w" "x" "t" "v" "l" "c" "q" "m" "u" "y" "o" "f" "g" "a" "k"
[20] "d"

$D
 [1] "w" "t" "o" "g" "q" "d" "s" "z" "j" "f" "p" "c" "r" "i" "u" "y" "e" "b" "x"
[20] "h" "m" "n"

$E
 [1] "s" "l" "a" "d" "p" "f" "q" "m" "u" "t" "k" "z" "w" "h" "v" "o" "g" "e"

$F
 [1] "o" "w" "c" "k" "r" "z" "h" "t" "p" "u" "s" "e" "v" "g" "m" "y" "a" "i" "j"
[20] "n" "b" "f"

> intersectmatrix(vennset)
  A B C D E F
a 1 1 1 0 1 1
b 1 1 0 1 0 1
c 0 0 1 1 0 1
d 1 0 1 1 1 0
e 1 1 0 1 1 1
f 0 0 1 1 1 1
g 1 1 1 1 1 1
h 0 1 1 1 1 1
i 1 1 0 1 0 1
j 1 1 1 1 0 1
k 1 1 1 0 1 1
l 1 1 1 0 1 0
m 0 0 1 1 1 1
n 1 1 1 1 0 1
o 0 0 1 1 1 1
p 1 1 1 1 1 1
q 0 0 1 1 1 0
r 0 0 0 1 0 1
s 1 0 0 1 1 1
t 1 0 1 1 1 1
u 1 1 1 1 1 1
v 0 1 1 0 1 1
w 1 1 1 1 1 1
x 1 1 1 1 0 0
y 1 0 1 1 0 1
z 1 1 0 1 1 1
> complexitylevels(vennset)
 [1] 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[39] 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 6
> vennlist(vennset)
$A
character(0)

$B
character(0)

$C
character(0)

$D
character(0)

$E
character(0)

$F
character(0)

$A_B
character(0)

$A_C
character(0)

$A_D
character(0)

$A_E
character(0)

$A_F
character(0)

$B_C
character(0)

$B_D
character(0)

$B_E
character(0)

$B_F
character(0)

$C_D
character(0)

$C_E
character(0)

$C_F
character(0)

$D_E
character(0)

$D_F
[1] "r"

$E_F
character(0)

$A_B_C
character(0)

$A_B_D
character(0)

$A_B_E
character(0)

$A_B_F
character(0)

$A_C_D
character(0)

$A_C_E
character(0)

$A_C_F
character(0)

$A_D_E
character(0)

$A_D_F
character(0)

$A_E_F
character(0)

$B_C_D
character(0)

$B_C_E
character(0)

$B_C_F
character(0)

$B_D_E
character(0)

$B_D_F
character(0)

$B_E_F
character(0)

$C_D_E
[1] "q"

$C_D_F
[1] "c"

$C_E_F
character(0)

$D_E_F
character(0)

$A_B_C_D
[1] "x"

$A_B_C_E
[1] "l"

$A_B_C_F
character(0)

$A_B_D_E
character(0)

$A_B_D_F
[1] "b" "i"

$A_B_E_F
character(0)

$A_C_D_E
[1] "d"

$A_C_D_F
[1] "y"

$A_C_E_F
character(0)

$A_D_E_F
[1] "s"

$B_C_D_E
character(0)

$B_C_D_F
character(0)

$B_C_E_F
[1] "v"

$B_D_E_F
character(0)

$C_D_E_F
[1] "f" "m" "o"

$A_B_C_D_E
character(0)

$A_B_C_D_F
[1] "j" "n"

$A_B_C_E_F
[1] "a" "k"

$A_B_D_E_F
[1] "e" "z"

$A_C_D_E_F
[1] "t"

$B_C_D_E_F
[1] "h"

$A_B_C_D_E_F
[1] "g" "p" "u" "w"

> intersectlist(interset)
$A
 [1] "a" "b" "d" "e" "g" "i" "j" "k" "l" "n" "p" "s" "t" "u" "w" "x" "y" "z"

$B
 [1] "a" "b" "e" "g" "h" "i" "j" "k" "l" "n" "p" "u" "v" "w" "x" "z"

$C
 [1] "a" "c" "d" "f" "g" "h" "j" "k" "l" "m" "n" "o" "p" "q" "t" "u" "v" "w" "x"
[20] "y"

$D
 [1] "b" "c" "d" "e" "f" "g" "h" "i" "j" "m" "n" "o" "p" "q" "r" "s" "t" "u" "w"
[20] "x" "y" "z"

$E
 [1] "a" "d" "e" "f" "g" "h" "k" "l" "m" "o" "p" "q" "s" "t" "u" "v" "w" "z"

$F
 [1] "a" "b" "c" "e" "f" "g" "h" "i" "j" "k" "m" "n" "o" "p" "r" "s" "t" "u" "v"
[20] "w" "y" "z"

$A_B
 [1] "a" "b" "e" "g" "i" "j" "k" "l" "n" "p" "u" "w" "x" "z"

$A_C
 [1] "a" "d" "g" "j" "k" "l" "n" "p" "t" "u" "w" "x" "y"

$A_D
 [1] "b" "d" "e" "g" "i" "j" "n" "p" "s" "t" "u" "w" "x" "y" "z"

$A_E
 [1] "a" "d" "e" "g" "k" "l" "p" "s" "t" "u" "w" "z"

$A_F
 [1] "a" "b" "e" "g" "i" "j" "k" "n" "p" "s" "t" "u" "w" "y" "z"

$B_C
 [1] "a" "g" "h" "j" "k" "l" "n" "p" "u" "v" "w" "x"

$B_D
 [1] "b" "e" "g" "h" "i" "j" "n" "p" "u" "w" "x" "z"

$B_E
 [1] "a" "e" "g" "h" "k" "l" "p" "u" "v" "w" "z"

$B_F
 [1] "a" "b" "e" "g" "h" "i" "j" "k" "n" "p" "u" "v" "w" "z"

$C_D
 [1] "c" "d" "f" "g" "h" "j" "m" "n" "o" "p" "q" "t" "u" "w" "x" "y"

$C_E
 [1] "a" "d" "f" "g" "h" "k" "l" "m" "o" "p" "q" "t" "u" "v" "w"

$C_F
 [1] "a" "c" "f" "g" "h" "j" "k" "m" "n" "o" "p" "t" "u" "v" "w" "y"

$D_E
 [1] "d" "e" "f" "g" "h" "m" "o" "p" "q" "s" "t" "u" "w" "z"

$D_F
 [1] "b" "c" "e" "f" "g" "h" "i" "j" "m" "n" "o" "p" "r" "s" "t" "u" "w" "y" "z"

$E_F
 [1] "a" "e" "f" "g" "h" "k" "m" "o" "p" "s" "t" "u" "v" "w" "z"

$A_B_C
 [1] "a" "g" "j" "k" "l" "n" "p" "u" "w" "x"

$A_B_D
 [1] "b" "e" "g" "i" "j" "n" "p" "u" "w" "x" "z"

$A_B_E
[1] "a" "e" "g" "k" "l" "p" "u" "w" "z"

$A_B_F
 [1] "a" "b" "e" "g" "i" "j" "k" "n" "p" "u" "w" "z"

$A_C_D
 [1] "d" "g" "j" "n" "p" "t" "u" "w" "x" "y"

$A_C_E
[1] "a" "d" "g" "k" "l" "p" "t" "u" "w"

$A_C_F
 [1] "a" "g" "j" "k" "n" "p" "t" "u" "w" "y"

$A_D_E
[1] "d" "e" "g" "p" "s" "t" "u" "w" "z"

$A_D_F
 [1] "b" "e" "g" "i" "j" "n" "p" "s" "t" "u" "w" "y" "z"

$A_E_F
 [1] "a" "e" "g" "k" "p" "s" "t" "u" "w" "z"

$B_C_D
[1] "g" "h" "j" "n" "p" "u" "w" "x"

$B_C_E
[1] "a" "g" "h" "k" "l" "p" "u" "v" "w"

$B_C_F
 [1] "a" "g" "h" "j" "k" "n" "p" "u" "v" "w"

$B_D_E
[1] "e" "g" "h" "p" "u" "w" "z"

$B_D_F
 [1] "b" "e" "g" "h" "i" "j" "n" "p" "u" "w" "z"

$B_E_F
 [1] "a" "e" "g" "h" "k" "p" "u" "v" "w" "z"

$C_D_E
 [1] "d" "f" "g" "h" "m" "o" "p" "q" "t" "u" "w"

$C_D_F
 [1] "c" "f" "g" "h" "j" "m" "n" "o" "p" "t" "u" "w" "y"

$C_E_F
 [1] "a" "f" "g" "h" "k" "m" "o" "p" "t" "u" "v" "w"

$D_E_F
 [1] "e" "f" "g" "h" "m" "o" "p" "s" "t" "u" "w" "z"

$A_B_C_D
[1] "g" "j" "n" "p" "u" "w" "x"

$A_B_C_E
[1] "a" "g" "k" "l" "p" "u" "w"

$A_B_C_F
[1] "a" "g" "j" "k" "n" "p" "u" "w"

$A_B_D_E
[1] "e" "g" "p" "u" "w" "z"

$A_B_D_F
 [1] "b" "e" "g" "i" "j" "n" "p" "u" "w" "z"

$A_B_E_F
[1] "a" "e" "g" "k" "p" "u" "w" "z"

$A_C_D_E
[1] "d" "g" "p" "t" "u" "w"

$A_C_D_F
[1] "g" "j" "n" "p" "t" "u" "w" "y"

$A_C_E_F
[1] "a" "g" "k" "p" "t" "u" "w"

$A_D_E_F
[1] "e" "g" "p" "s" "t" "u" "w" "z"

$B_C_D_E
[1] "g" "h" "p" "u" "w"

$B_C_D_F
[1] "g" "h" "j" "n" "p" "u" "w"

$B_C_E_F
[1] "a" "g" "h" "k" "p" "u" "v" "w"

$B_D_E_F
[1] "e" "g" "h" "p" "u" "w" "z"

$C_D_E_F
[1] "f" "g" "h" "m" "o" "p" "t" "u" "w"

$A_B_C_D_E
[1] "g" "p" "u" "w"

$A_B_C_D_F
[1] "g" "j" "n" "p" "u" "w"

$A_B_C_E_F
[1] "a" "g" "k" "p" "u" "w"

$A_B_D_E_F
[1] "e" "g" "p" "u" "w" "z"

$A_C_D_E_F
[1] "g" "p" "t" "u" "w"

$B_C_D_E_F
[1] "g" "h" "p" "u" "w"

$A_B_C_D_E_F
[1] "g" "p" "u" "w"

> 
> ## Coerce VENNset/INTERSECTset object to list
> as.list(vennset)
$setlist
$setlist$A
 [1] "d" "y" "x" "z" "j" "g" "a" "e" "l" "i" "n" "s" "w" "b" "k" "u" "t" "p"

$setlist$B
 [1] "u" "b" "v" "l" "k" "j" "p" "g" "z" "x" "w" "a" "e" "i" "h" "n"

$setlist$C
 [1] "h" "p" "n" "j" "w" "x" "t" "v" "l" "c" "q" "m" "u" "y" "o" "f" "g" "a" "k"
[20] "d"

$setlist$D
 [1] "w" "t" "o" "g" "q" "d" "s" "z" "j" "f" "p" "c" "r" "i" "u" "y" "e" "b" "x"
[20] "h" "m" "n"

$setlist$E
 [1] "s" "l" "a" "d" "p" "f" "q" "m" "u" "t" "k" "z" "w" "h" "v" "o" "g" "e"

$setlist$F
 [1] "o" "w" "c" "k" "r" "z" "h" "t" "p" "u" "s" "e" "v" "g" "m" "y" "a" "i" "j"
[20] "n" "b" "f"


$intersectmatrix
  A B C D E F
a 1 1 1 0 1 1
b 1 1 0 1 0 1
c 0 0 1 1 0 1
d 1 0 1 1 1 0
e 1 1 0 1 1 1
f 0 0 1 1 1 1
g 1 1 1 1 1 1
h 0 1 1 1 1 1
i 1 1 0 1 0 1
j 1 1 1 1 0 1
k 1 1 1 0 1 1
l 1 1 1 0 1 0
m 0 0 1 1 1 1
n 1 1 1 1 0 1
o 0 0 1 1 1 1
p 1 1 1 1 1 1
q 0 0 1 1 1 0
r 0 0 0 1 0 1
s 1 0 0 1 1 1
t 1 0 1 1 1 1
u 1 1 1 1 1 1
v 0 1 1 0 1 1
w 1 1 1 1 1 1
x 1 1 1 1 0 0
y 1 0 1 1 0 1
z 1 1 0 1 1 1

$complexitylevels
 [1] 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[39] 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 6

$vennlist
$vennlist$A
character(0)

$vennlist$B
character(0)

$vennlist$C
character(0)

$vennlist$D
character(0)

$vennlist$E
character(0)

$vennlist$F
character(0)

$vennlist$A_B
character(0)

$vennlist$A_C
character(0)

$vennlist$A_D
character(0)

$vennlist$A_E
character(0)

$vennlist$A_F
character(0)

$vennlist$B_C
character(0)

$vennlist$B_D
character(0)

$vennlist$B_E
character(0)

$vennlist$B_F
character(0)

$vennlist$C_D
character(0)

$vennlist$C_E
character(0)

$vennlist$C_F
character(0)

$vennlist$D_E
character(0)

$vennlist$D_F
[1] "r"

$vennlist$E_F
character(0)

$vennlist$A_B_C
character(0)

$vennlist$A_B_D
character(0)

$vennlist$A_B_E
character(0)

$vennlist$A_B_F
character(0)

$vennlist$A_C_D
character(0)

$vennlist$A_C_E
character(0)

$vennlist$A_C_F
character(0)

$vennlist$A_D_E
character(0)

$vennlist$A_D_F
character(0)

$vennlist$A_E_F
character(0)

$vennlist$B_C_D
character(0)

$vennlist$B_C_E
character(0)

$vennlist$B_C_F
character(0)

$vennlist$B_D_E
character(0)

$vennlist$B_D_F
character(0)

$vennlist$B_E_F
character(0)

$vennlist$C_D_E
[1] "q"

$vennlist$C_D_F
[1] "c"

$vennlist$C_E_F
character(0)

$vennlist$D_E_F
character(0)

$vennlist$A_B_C_D
[1] "x"

$vennlist$A_B_C_E
[1] "l"

$vennlist$A_B_C_F
character(0)

$vennlist$A_B_D_E
character(0)

$vennlist$A_B_D_F
[1] "b" "i"

$vennlist$A_B_E_F
character(0)

$vennlist$A_C_D_E
[1] "d"

$vennlist$A_C_D_F
[1] "y"

$vennlist$A_C_E_F
character(0)

$vennlist$A_D_E_F
[1] "s"

$vennlist$B_C_D_E
character(0)

$vennlist$B_C_D_F
character(0)

$vennlist$B_C_E_F
[1] "v"

$vennlist$B_D_E_F
character(0)

$vennlist$C_D_E_F
[1] "f" "m" "o"

$vennlist$A_B_C_D_E
character(0)

$vennlist$A_B_C_D_F
[1] "j" "n"

$vennlist$A_B_C_E_F
[1] "a" "k"

$vennlist$A_B_D_E_F
[1] "e" "z"

$vennlist$A_C_D_E_F
[1] "t"

$vennlist$B_C_D_E_F
[1] "h"

$vennlist$A_B_C_D_E_F
[1] "g" "p" "u" "w"


> as.list(interset)
$setlist
$setlist$A
 [1] "d" "y" "x" "z" "j" "g" "a" "e" "l" "i" "n" "s" "w" "b" "k" "u" "t" "p"

$setlist$B
 [1] "u" "b" "v" "l" "k" "j" "p" "g" "z" "x" "w" "a" "e" "i" "h" "n"

$setlist$C
 [1] "h" "p" "n" "j" "w" "x" "t" "v" "l" "c" "q" "m" "u" "y" "o" "f" "g" "a" "k"
[20] "d"

$setlist$D
 [1] "w" "t" "o" "g" "q" "d" "s" "z" "j" "f" "p" "c" "r" "i" "u" "y" "e" "b" "x"
[20] "h" "m" "n"

$setlist$E
 [1] "s" "l" "a" "d" "p" "f" "q" "m" "u" "t" "k" "z" "w" "h" "v" "o" "g" "e"

$setlist$F
 [1] "o" "w" "c" "k" "r" "z" "h" "t" "p" "u" "s" "e" "v" "g" "m" "y" "a" "i" "j"
[20] "n" "b" "f"


$intersectmatrix
  A B C D E F
a 1 1 1 0 1 1
b 1 1 0 1 0 1
c 0 0 1 1 0 1
d 1 0 1 1 1 0
e 1 1 0 1 1 1
f 0 0 1 1 1 1
g 1 1 1 1 1 1
h 0 1 1 1 1 1
i 1 1 0 1 0 1
j 1 1 1 1 0 1
k 1 1 1 0 1 1
l 1 1 1 0 1 0
m 0 0 1 1 1 1
n 1 1 1 1 0 1
o 0 0 1 1 1 1
p 1 1 1 1 1 1
q 0 0 1 1 1 0
r 0 0 0 1 0 1
s 1 0 0 1 1 1
t 1 0 1 1 1 1
u 1 1 1 1 1 1
v 0 1 1 0 1 1
w 1 1 1 1 1 1
x 1 1 1 1 0 0
y 1 0 1 1 0 1
z 1 1 0 1 1 1

$complexitylevels
 [1] 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[39] 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 6

$intersectlist
$intersectlist$A
 [1] "a" "b" "d" "e" "g" "i" "j" "k" "l" "n" "p" "s" "t" "u" "w" "x" "y" "z"

$intersectlist$B
 [1] "a" "b" "e" "g" "h" "i" "j" "k" "l" "n" "p" "u" "v" "w" "x" "z"

$intersectlist$C
 [1] "a" "c" "d" "f" "g" "h" "j" "k" "l" "m" "n" "o" "p" "q" "t" "u" "v" "w" "x"
[20] "y"

$intersectlist$D
 [1] "b" "c" "d" "e" "f" "g" "h" "i" "j" "m" "n" "o" "p" "q" "r" "s" "t" "u" "w"
[20] "x" "y" "z"

$intersectlist$E
 [1] "a" "d" "e" "f" "g" "h" "k" "l" "m" "o" "p" "q" "s" "t" "u" "v" "w" "z"

$intersectlist$F
 [1] "a" "b" "c" "e" "f" "g" "h" "i" "j" "k" "m" "n" "o" "p" "r" "s" "t" "u" "v"
[20] "w" "y" "z"

$intersectlist$A_B
 [1] "a" "b" "e" "g" "i" "j" "k" "l" "n" "p" "u" "w" "x" "z"

$intersectlist$A_C
 [1] "a" "d" "g" "j" "k" "l" "n" "p" "t" "u" "w" "x" "y"

$intersectlist$A_D
 [1] "b" "d" "e" "g" "i" "j" "n" "p" "s" "t" "u" "w" "x" "y" "z"

$intersectlist$A_E
 [1] "a" "d" "e" "g" "k" "l" "p" "s" "t" "u" "w" "z"

$intersectlist$A_F
 [1] "a" "b" "e" "g" "i" "j" "k" "n" "p" "s" "t" "u" "w" "y" "z"

$intersectlist$B_C
 [1] "a" "g" "h" "j" "k" "l" "n" "p" "u" "v" "w" "x"

$intersectlist$B_D
 [1] "b" "e" "g" "h" "i" "j" "n" "p" "u" "w" "x" "z"

$intersectlist$B_E
 [1] "a" "e" "g" "h" "k" "l" "p" "u" "v" "w" "z"

$intersectlist$B_F
 [1] "a" "b" "e" "g" "h" "i" "j" "k" "n" "p" "u" "v" "w" "z"

$intersectlist$C_D
 [1] "c" "d" "f" "g" "h" "j" "m" "n" "o" "p" "q" "t" "u" "w" "x" "y"

$intersectlist$C_E
 [1] "a" "d" "f" "g" "h" "k" "l" "m" "o" "p" "q" "t" "u" "v" "w"

$intersectlist$C_F
 [1] "a" "c" "f" "g" "h" "j" "k" "m" "n" "o" "p" "t" "u" "v" "w" "y"

$intersectlist$D_E
 [1] "d" "e" "f" "g" "h" "m" "o" "p" "q" "s" "t" "u" "w" "z"

$intersectlist$D_F
 [1] "b" "c" "e" "f" "g" "h" "i" "j" "m" "n" "o" "p" "r" "s" "t" "u" "w" "y" "z"

$intersectlist$E_F
 [1] "a" "e" "f" "g" "h" "k" "m" "o" "p" "s" "t" "u" "v" "w" "z"

$intersectlist$A_B_C
 [1] "a" "g" "j" "k" "l" "n" "p" "u" "w" "x"

$intersectlist$A_B_D
 [1] "b" "e" "g" "i" "j" "n" "p" "u" "w" "x" "z"

$intersectlist$A_B_E
[1] "a" "e" "g" "k" "l" "p" "u" "w" "z"

$intersectlist$A_B_F
 [1] "a" "b" "e" "g" "i" "j" "k" "n" "p" "u" "w" "z"

$intersectlist$A_C_D
 [1] "d" "g" "j" "n" "p" "t" "u" "w" "x" "y"

$intersectlist$A_C_E
[1] "a" "d" "g" "k" "l" "p" "t" "u" "w"

$intersectlist$A_C_F
 [1] "a" "g" "j" "k" "n" "p" "t" "u" "w" "y"

$intersectlist$A_D_E
[1] "d" "e" "g" "p" "s" "t" "u" "w" "z"

$intersectlist$A_D_F
 [1] "b" "e" "g" "i" "j" "n" "p" "s" "t" "u" "w" "y" "z"

$intersectlist$A_E_F
 [1] "a" "e" "g" "k" "p" "s" "t" "u" "w" "z"

$intersectlist$B_C_D
[1] "g" "h" "j" "n" "p" "u" "w" "x"

$intersectlist$B_C_E
[1] "a" "g" "h" "k" "l" "p" "u" "v" "w"

$intersectlist$B_C_F
 [1] "a" "g" "h" "j" "k" "n" "p" "u" "v" "w"

$intersectlist$B_D_E
[1] "e" "g" "h" "p" "u" "w" "z"

$intersectlist$B_D_F
 [1] "b" "e" "g" "h" "i" "j" "n" "p" "u" "w" "z"

$intersectlist$B_E_F
 [1] "a" "e" "g" "h" "k" "p" "u" "v" "w" "z"

$intersectlist$C_D_E
 [1] "d" "f" "g" "h" "m" "o" "p" "q" "t" "u" "w"

$intersectlist$C_D_F
 [1] "c" "f" "g" "h" "j" "m" "n" "o" "p" "t" "u" "w" "y"

$intersectlist$C_E_F
 [1] "a" "f" "g" "h" "k" "m" "o" "p" "t" "u" "v" "w"

$intersectlist$D_E_F
 [1] "e" "f" "g" "h" "m" "o" "p" "s" "t" "u" "w" "z"

$intersectlist$A_B_C_D
[1] "g" "j" "n" "p" "u" "w" "x"

$intersectlist$A_B_C_E
[1] "a" "g" "k" "l" "p" "u" "w"

$intersectlist$A_B_C_F
[1] "a" "g" "j" "k" "n" "p" "u" "w"

$intersectlist$A_B_D_E
[1] "e" "g" "p" "u" "w" "z"

$intersectlist$A_B_D_F
 [1] "b" "e" "g" "i" "j" "n" "p" "u" "w" "z"

$intersectlist$A_B_E_F
[1] "a" "e" "g" "k" "p" "u" "w" "z"

$intersectlist$A_C_D_E
[1] "d" "g" "p" "t" "u" "w"

$intersectlist$A_C_D_F
[1] "g" "j" "n" "p" "t" "u" "w" "y"

$intersectlist$A_C_E_F
[1] "a" "g" "k" "p" "t" "u" "w"

$intersectlist$A_D_E_F
[1] "e" "g" "p" "s" "t" "u" "w" "z"

$intersectlist$B_C_D_E
[1] "g" "h" "p" "u" "w"

$intersectlist$B_C_D_F
[1] "g" "h" "j" "n" "p" "u" "w"

$intersectlist$B_C_E_F
[1] "a" "g" "h" "k" "p" "u" "v" "w"

$intersectlist$B_D_E_F
[1] "e" "g" "h" "p" "u" "w" "z"

$intersectlist$C_D_E_F
[1] "f" "g" "h" "m" "o" "p" "t" "u" "w"

$intersectlist$A_B_C_D_E
[1] "g" "p" "u" "w"

$intersectlist$A_B_C_D_F
[1] "g" "j" "n" "p" "u" "w"

$intersectlist$A_B_C_E_F
[1] "a" "g" "k" "p" "u" "w"

$intersectlist$A_B_D_E_F
[1] "e" "g" "p" "u" "w" "z"

$intersectlist$A_C_D_E_F
[1] "g" "p" "t" "u" "w"

$intersectlist$B_C_D_E_F
[1] "g" "h" "p" "u" "w"

$intersectlist$A_B_C_D_E_F
[1] "g" "p" "u" "w"


> 
> ## Pairwise intersect matrix and heatmap
> olMA <- sapply(names(setlist), 
+ 		function(x) sapply(names(setlist), 
+ 		function(y) sum(setlist[[x]] %in% setlist[[y]])))
> olMA
   A  B  C  D  E  F
A 18 14 13 15 12 15
B 14 16 12 12 11 14
C 13 12 20 16 15 16
D 15 12 16 22 14 19
E 12 11 15 14 18 15
F 15 14 16 19 15 22
> heatmap(olMA, Rowv=NA, Colv=NA)
> 
> ## Presence-absence matrices for large numbers of sample sets
> interset <- overLapper(setlist=setlist, type="intersects", complexity=2)
> (paMA <- intersectmatrix(interset))
  A B C D E F
a 1 1 1 0 1 1
b 1 1 0 1 0 1
c 0 0 1 1 0 1
d 1 0 1 1 1 0
e 1 1 0 1 1 1
f 0 0 1 1 1 1
g 1 1 1 1 1 1
h 0 1 1 1 1 1
i 1 1 0 1 0 1
j 1 1 1 1 0 1
k 1 1 1 0 1 1
l 1 1 1 0 1 0
m 0 0 1 1 1 1
n 1 1 1 1 0 1
o 0 0 1 1 1 1
p 1 1 1 1 1 1
q 0 0 1 1 1 0
r 0 0 0 1 0 1
s 1 0 0 1 1 1
t 1 0 1 1 1 1
u 1 1 1 1 1 1
v 0 1 1 0 1 1
w 1 1 1 1 1 1
x 1 1 1 1 0 0
y 1 0 1 1 0 1
z 1 1 0 1 1 1
> heatmap(paMA, Rowv=NA, Colv=NA, col=c("white", "gray")) 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>