Annotate the closest feature
annotate_nearest_features.RdThis works similar as annotate nearby features but is
Examples
features_gr <- GenomicRanges::GRanges(
seqnames = c("chr1", "chr1"),
IRanges::IRanges(c(10,22), c(20,30)),
strand = c("-", "-"),
name = c("Feat_A", "Feat_B")
)
gr <- GenomicRanges::GRanges(
seqnames = c("chr1"),
IRanges::IRanges(15, 25),
strand = "+"
)
annotate_nearest_features(gr, features_gr, "name")
#> GRanges object with 1 range and 2 metadata columns:
#> seqnames ranges strand | annotation distance
#> <Rle> <IRanges> <Rle> | <character> <integer>
#> [1] chr1 15-25 + | Feat_A,Feat_B 0
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths