Question: setdiff between GenomicRanges objects keeping metadata
gravatar for Benilton Carvalho
17 months ago by
Benilton Carvalho4.2k wrote:

Hi guys,

Given I have two objects as below:

mydata <- GRanges('chr9', IRanges(37902608, 69267842), info1=1, info2=2)
centromere <- GRanges('chr9', IRanges(46200000, 60800000))
setdiff(mydata, centromere)


How do I get the result of setdiff, but keeping the info1 and info2 fields from mydata?

Many thanks, benilton



ADD COMMENTlink modified 17 months ago by Michael Lawrence9.9k • written 17 months ago by Benilton Carvalho4.2k
gravatar for Michael Lawrence
17 months ago by
United States
Michael Lawrence9.9k wrote:

As with any set operation, it's not obvious how the metadata should propagate. One option would be to use findOverlaps(setdiff_result, mydata) and aggregate/join based on that.  I guess we could make this easier with a revmap. That's supported for reduce(), although in the case of intersect, union and setdiff, we could have two revmaps (one for each argument). 

ADD COMMENTlink written 17 months ago by Michael Lawrence9.9k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 345 users visited in the last hour