Given a set of segments defined by "chrom", "start", "end" and various data, it merges consecutive rows (sorted by "chrom" then "start") that share same data. As an example, it is useful to merge consecutive regions of the genome sharing same copy numbers after modelization, or filling small gaps.
segMerge(segTable, on = names(segTable), fun = list(unique, start=min, end=max),
group = NULL)
Returns a data.frame
similar to segTable
.
A data.frame
of segments, with at least "chrom", "start" and "end" columns. Standard behavior (default fun
value) assumes "start" and "end" to be at least numeric
, preferably integer
.
Character vector, segTable
columns that must all be identical for the consecutive rows to be merged. For convenience, "chrom" is forced in and "start" / "end" are forced out.
A list
of function
s, defining how to merge values when merging rows. It should contain an unamed element for the default function, and named elements to deal with specific columns.
A vector with as many values as segTable
rows. If provided, on
is ignored and group
is directly used as a grouping factor to merge consecutive rows.
Sylvain Mareschal
segOverlap