Items in intersection of a venn diagram

Hi there,

I've ben having issues regarding venn diagrams. I have a really simple code for a venn diagram with a list of genes and i would like a list of the common genes i.e a list of the genes in the intersection

Cellcykel4 <-read.csv2(file.choose(),header = FALSE)    
cclist4 <- Cellcykel4$V1                                   

zd2 <-read.csv2(file.choose(),header = FALSE)              
ZDlist2 <- zd2$V1                                          


venn.diagram(list("Cellcykel"=cclist4, "ZD"=ZDlist2),
             fill = c("cyan","red"),
             cex= 1.5,
             filename = "4.C-mot-2.ZD.png",
             print.mode =c("raw", "percent"))

I get a very nice image from this but how do I get the actual list of items in the intersection?

Kind regards,

probably the calculate.overlap function from that package

# A simple single-set diagram
cardiome <- letters[1:10]
superset <- letters[8:24]
overlap <- calculate.overlap(
  x = list(
    "Cardiome" = cardiome,
    "SuperSet" = superset

# or without the venn diagram package, using only base r
baseoverlap <- intersect(cardiome,superset)
1 Like

It worked now that I tried opening the data frames from start, than you so much for the help i get a perfect list now!
Have a great day!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

if your intersection result is stored in baseoverlap name then

cat(paste0(baseoverlap ,collapse = "\n"))

thank you this was very helpful!
I have another question, now that I've done this is get the items like this in the console:

[1] "abcd4" "abhd4" "acot13" "adam15"
[5] "adipor1" "aga" "aldh2" "amigo2"
[9] "aprt" "arfip1" "arfip2" "arl3"
[13] "arpc1b" "asic3" "atp1b1" "atp6v0d1"
[17] "atp6v1f" "b4galt7" "bahd1" "baiap2"
[21] "bri3" "btg1" "casp9" "cat"
[25] "ccdc159" "cdkl3" "cers1" "cgref1"
[29] "cmip" "cnppd1" "mvp" "comtd1"
[33] "copz2" "creld1" "cstb" "ctsd"

is it possible to get it in a list form that i can copy and paste into excel for example?
thanks again!

sorry, im unclear whats going on here.
Lets reset. I need to ask you to run exactly this code and tell me the output you get

cardiome <- letters[1:10]
superset <- letters[8:24]
overlap <- intersect(cardiome,superset)
cat(paste0(overlap, collapse = "\n"))

I get


Mine looks like this

cat(paste0(overlap, collapse = "\n"))

But the answer i get in the console is this:

Error: unexpected symbol in:
"cat(paste0(overlap, collapse = "\n")

I am pretty new in R that is why i am a little slow hehehe

when i run your code i get the exact same output but why doesn't is work with my code?

Cellcykel <-read.csv2(file.choose(),header = FALSE)      
cclist <- Cellcykel$V1                                  

zd <-read.csv2(file.choose(),header = FALSE)              
ZDlist <- zd$V1                                           


venn.diagram(list("Cellcykel"=cclist, "ZD"=ZDlist),
             fill = c("cyan","red"),
             cex= 1.5,
             filename = "C-mot-.ZD.png",
             print.mode =c("raw", "percent"))

overlap <- intersect(cclist, ZDlist)

cat(paste0(overlap, collapse = "\n"))

what am i doing wrong?