Monday, July 5, 2010

Venn diagrams in R


This is my first attempt to use R, the well known program for statistics.

I am using the package LIMMA and the instructions found here in order to draw Venn diagrams. My code is

-----------------------------------------
library(limma)

data1<-read.csv("/home/rcabrera/Documents/source/mathematica/Xiongmao/VennDiagram/H1h1.csv", sep=',', header=T)
data2<-read.csv("/home/rcabrera/Documents/source/mathematica/Xiongmao/VennDiagram/H1h2.csv", sep=',', header=T)
data3<-read.csv("/home/rcabrera/Documents/source/mathematica/Xiongmao/VennDiagram/H1h3.csv", sep=',', header=T)

set1<-data1$x
set2<-data2$x
set3<-data3$x

set123<-union(set1,union(set2,set3))

bool1 = logical(length(set123))
bool2 = logical(length(set123))
bool3 = logical(length(set123))

for(i in 1:length(set123)) bool1[i]<-is.element(set123[i],set1)
for(i in 1:length(set123)) bool2[i]<-is.element(set123[i],set2)
for(i in 1:length(set123)) bool3[i]<-is.element(set123[i],set3)

c3<-cbind(bool1, bool2, bool3)

a <- vennCounts(c3)

vennDiagram(a)
-----------------------------------------------

Note.- The data is stored in a column with label "x"

1 comment: