This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Venn Diagram for 3 BEd files

Hi guys!

I want to perform a Venn Diagrama using 3 BED files: 1) Sample1 2)Sample2 3) CFS (common fragile sites)

My idea is try to discover which sample (1 or 2) has more common regions with CFS. To do that I've tried

library(VennDiagram)

#Load files
CFS_list = readPeakFile("CFS_BED", header = F)
CFS_GR = as(CFS_list,"GRanges")
import_File1_list= readPeakFile("file1.BED", header = F)
File_1 = as(import_File1_list, "GRanges")
import_File2_list= readPeakFile("file2.BED", header = F)
File_2 = as(import_File2_list, "GRanges")

#overlap File1 vs CFS
count_overlap_file1= countOverlaps(file1, CFS_GR)
overlap_file1 = findOverlaps(file1, CFS_GR)
draw.pairwise.venn(area1 = length(file1), area2 = length(CFS_GR), cross.area = 51, maxgap = 100, fill = c("light blue", "pink"))

#overlap File2 vs CFS
count_overlap_File2_CFS = countOverlaps(file2, CFS_GR)
overlap_File2_CFS = findOverlaps(file2, CFS_GR)
venn_file2_CFS= draw.pairwise.venn(area1 = length(file2), area2 = length(CFS_GR), cross.area = 1209, maxgap = 100, fill = c("light blue", "pink"))

The problem is that I got the next error:

 #error
ERROR [2017-03-10 14:04:22] Impossible: cross section area too large.
Error in draw.pairwise.venn(area1 = length(file2_GR), area2 = length(CFS_GR),  : 
  Impossible: cross section area too large.

I also want to get the venn diagram for the 3 files.. Any idea?

Thank!

chip overlap cfs

1 answer

1) Could correct the names? Your error message says area1 = length(G4_GR), this var does not exist in your code.

2) this error means that the found overlap is larger than the whole given set (either one), and therefore it says Impossible. You have in cross.area a fixed int..you need to replace it by overlap_File*_CFS

I suggest you print the outcome of length (G4_GR) and length(CFS_GR) to see for yourself

hth

Hi thank you. Yes I've change the name of the files here just to be clear and I forgot that and also yes, what you say is true, but I can't understand why, I mean, the overlap_File2_CFS says that there is a total of 1209 but the length(CFS_GR) is 120 and length(G4_GR) is 7444

Theoretically, if you have two sets: A has 100 elements while B has 500, the maximum value the overlap can reach is 100, i.e. all elements in one set exists in the other.

Regarding the functions you are using, they are used with genomic ranges, please look at the help page to see the difference between their reported values, which in return explains why using length in this case is incorrect.

In short, the overlap in this case 1:M, i.e. if an interval in A was found in different intervals in B they will all be reported, thus the first statement does not hold any more. Have a look at the example in the Help again and check the outcome of findOverlaps(gr,gr1) and countOverlaps(gr,gr1), do you see it now? If you insist on using length, try to use length of count_overlap_File_CFS[count_overlap_File_CFS>1], probably that is what you intended first.

Enjoy

Sorry but I can't see your point. Because if I don't use "length" I have the following error message

venn_file2_CFS= draw.pairwise.venn(area1 = file2, area2 = CFS_GR, cross.area = 1209, maxgap = 100, fill = c("light blue", "pink"))

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘pcompare’ for signature ‘"numeric", "GRanges"’

and if I do as you propose

venn_G4_CFS= draw.pairwise.venn(area1 = length(count_overlap_file2_CFS[count_overlap_file2_CFS>1]), area2 = length(CFS_GR), cross.area = 1209, maxgap = 100, fill = c("light blue", "pink"))

**ERROR [2017-03-16 13:01:26] Impossible: cross section area too large.
Error in draw.pairwise.venn(area1 = length(count_overlap_GR4_CFS[count_overlap_GR4_CFS >  : 
  Impossible: cross section area too large.**

You have in cross.area a fixed int

what I have to put there?

Log in to answer this question.