This operation is similar to bedtools merge
.
merge_bed(x, max_dist = 0, operation = NULL)
x | A |
---|---|
max_dist | Maximum distance between features allowed for features to be merged. Default is 0. That is, overlapping and/or book-ended features are merged. |
operation | Specify what operations should be applied to merged
intervals. Default is |
A GRanges
object containing merged intervals.
Manual page of bedtools merge
:
https://bedtools.readthedocs.io/en/latest/content/tools/merge.html
bedtbl <- read_bed(system.file("extdata", "example_merge.bed", package = "bedtorch")) merged <- merge_bed(bedtbl) head(merged) #> GRanges object with 6 ranges and 0 metadata columns: #> seqnames ranges strand #> <Rle> <IRanges> <Rle> #> [1] 21 4-6 * #> [2] 21 11-25 * #> [3] 21 27-35 * #> [4] 21 37-50 * #> [5] 21 54-56 * #> [6] 22 28-41 * #> ------- #> seqinfo: 2 sequences from an unspecified genome; no seqlengths merged <- merge_bed(bedtbl, max_dist = 10, operation = list(score1 = list(on = "score", func = mean), score2 = list(on = "score", func = sum))) head(merged) #> GRanges object with 2 ranges and 2 metadata columns: #> seqnames ranges strand | score1 score2 #> <Rle> <IRanges> <Rle> | <numeric> <integer> #> [1] 21 4-56 * | 5.3 53 #> [2] 22 28-72 * | 6.3 63 #> ------- #> seqinfo: 2 sequences from an unspecified genome; no seqlengths