groupGRangesBy {ORFik} | R Documentation |
It will group / split the GRanges object by the argument 'other'. For example if you would like to to group GRanges object by gene, set other to gene names.
groupGRangesBy(gr, other = NULL)
gr |
a GRanges object |
other |
a vector of unique names to group by |
If 'other' is not specified function will try to use the names of the GRanges object. It will then be similar to 'split(gr, names(gr))'.
It is important that all groups in 'other' are unique, otherwise duplicates will be grouped together.
a GRangesList named after names(Granges) if other is NULL, else names are from unique(other)
ORFranges <- GRanges(seqnames = Rle(rep("1", 3)), ranges = IRanges(start = c(1, 10, 20), end = c(5, 15, 25)), strand = "+") ORFranges2 <- GRanges("1", ranges = IRanges(start = c(20, 30, 40), end = c(25, 35, 45)), strand = "+") names(ORFranges) = rep("tx1_1", 3) names(ORFranges2) = rep("tx1_2", 3) grl <- GRangesList(tx1_1 = ORFranges, tx1_2 = ORFranges2) gr <- unlist(grl, use.names = FALSE) ## now recreate the grl ## group by orf grltest <- groupGRangesBy(gr) # using the names to group identical(grl, grltest) ## they are identical ## group by transcript names(gr) <- txNames(gr) grltest <- groupGRangesBy(gr) identical(grl, grltest) ## they are not identical