Dear all,
I am struggling with what should probably be a trivial problem. I have 2 seg files with the following structure:
chr start end feature.1 feature.2
1 1000 1200 0.5 0.001
chr start end feature.1 feature.2
1 1100 1400 0.7 0.004
Let's call them A and B. I want to obtain a unique file like this:
chr start end feature.1.a feature.1.b
1 1000 1100 0.5 NA
1 1100 1200 0.5 0.7
1 1200 1400 NA 0.7
If a region is covered by only A or B, then it would contain only the corresponding values and it would have NA in the other fields. Otherwise, I want to retrieve both of them. This looks close to what bedtools -intersect does, and indeed I am trying to use the package Bedr to solve this task, but it seems to leave out regions covered only in one file. Maybe GenomicRanges is another possibility. If you have any hint on this it would be very helpful to me. Thank you
See if this example in this answer helps:
A: Struggling to filter data with R, tidyverse
Thank you, even though the operation is not symmetrical it definitely helped out with my problem. I can add it as a solution myself or you can add it and I will close the post. Thank you again.
Feel free to answer your own question, and accept as answer.
There's a
--partition
option in BEDOPSbedops
that solves this pretty easily. Some people don't seem to like using this kit for some reason, but if you're interested, let me know and I'll put together an answer.