I want to compare and get the overlapping regions in three different dataset. The comparison should also be based on the CNA.
data1
chr start end CNA
1 170900001 171500001 loss
1 11840001 19420001 loss
1 60300001 62700001 gain
1 25520001 25820001 gain
data2
chr start end CNA
1 170940001 171500001 gain
1 60300001 62700001 gain
1 25520001 25840001 gain
1 119860001 123040001 loss
1 171500001 171580001 gain
1 79240001 84420001 gain
data 3
chr start end CNA
1 170950001 171500001 gain
1 60300001 62700001 loss
1 25530001 25840001 gain
expected output
chr start end CNA
1 170950001 171500001 gain
1 25530001 25840001 gain
I used GenomicRanges for the comparison. First i tried to sort the genomic regions based on the "gain" and "loss". Then i used findOverlaps between each group separately for eg. df1 <- findOverlaps(data1,data2) and then findOverlaps(df1,data3). I know there are options bed tools but would be great to know if there is any alternative methods in getting the desired output using GenomicRanges?