I'll start with an example, and then describe the logic I'm trying to use.
I have two normal IRanges objects that span the same total range, but may do so in a different number of ranges. Each IRanges has one mcol, but that mcol is different across IRanges.
a
#IRanges object with 1 range and 1 metadata column:
# start end width | on_betalac
# <integer> <integer> <integer> | <logical>
# [1] 1 167 167 | FALSE
b
#IRanges object with 3 ranges and 1 metadata column:
# start end width | on_other
# <integer> <integer> <integer> | <logical>
# [1] 1 107 107 | FALSE
# [2] 108 112 5 | TRUE
# [3] 113 167 55 | FALSE
You can see both of these IRanges span 1 to 167, but a has one range and b has three. I would like to combine them to get output like this:
my_great_function(a, b)
#IRanges object with 3 ranges and 2 metadata columns:
# start end width | on_betalac on_other
# <integer> <integer> <integer> | <logical> <logical>
# [1] 1 107 107 | FALSE FALSE
# [2] 108 112 5 | FALSE TRUE
# [3] 113 167 55 | FALSE FALSE
The output is a like a disjoin of the inputs, but it keeps the mcols, and even spreads them so that the output range has the same value of the mcol as the input range that led to it.