I think that's a fair solution for solving the problem related to overlapping elements, but there's a critical gap remaining. I intend to perform this "intersection" on only a sample of a items, yet need to do so over and over. I'm not concerned with the knowing the absolute intersection, only the intersection from smaller samples of a to the whole b.
How might I perform this iteratively with a simple loop, and ask to write the ouput into a text file formatted as follows:
Trial (n) Intersections (y)
[1] 500
[2] 154
[3] 10
[4] 95
.
.
.
[10000] 299
Are
aandbjust numbers or are they genomic positions (e.g. from aGRangesobject)? The former case is quite simple:The latter case will depend on the object, though many objects allow intersects and comparisons. BTW, avoid
forloops in R, they're really slow.