Entering edit mode
Hi, I am trying to remove duplicated entries in a set of GRangesList
. Not sure what happened but I am pretty sure that I used to use the duplicated()
or unique()
function for removing duplicates but now it's not working. Could someone advise on alternatives?
This is an example that is not producing the expected value
library(GenomicRanges)
# Create a sample GRangesList with some duplicated GRanges objects
gr1 <- GRanges(seqnames = "chr1", ranges = IRanges(c(1,30), c(10,50)), strand = "+")
gr2 <- GRanges(seqnames = "chr2", ranges = IRanges(c(20,60), c(30,100)), strand = "-")
gr3 <- GRanges(seqnames = "chr1", ranges = IRanges(c(1,20), c(10,30)), strand = "+")
my_grl <- GRangesList(gr1, gr2, gr3, gr1) # Duplicating gr1
duplicated(my_grl)
#LogicalList of length 4
#[[1]] FALSE FALSE
#[[2]] FALSE FALSE
#[[3]] FALSE FALSE
#[[4]] FALSE FALSE
length(my_grl) == length(unique(my_grl))
#[1] TRUE
Thanks