@@ -141,7 +141,7 @@ methSeg<-function(obj, diagnostic.plot=TRUE, join.neighbours=FALSE, ...){
141141 # if joining, show clustering after joining
142142 if (join.neighbours ) {
143143 message(" joining neighbouring segments" )
144- seg.res <- . joinSegmentNeighbours(seg.res )
144+ seg.res <- joinSegmentNeighbours(seg.res )
145145 diagnostic.plot = TRUE
146146
147147 # get the new density
@@ -308,10 +308,13 @@ colramp=colorRamp(c("gray","green", "darkgreen"))
308308# }
309309
310310
311- # ' Join directly neighbouring segments of same class
311+ # ' Join directly neighbouring segments produced by methSeg
312312# '
313313# '
314- # @param res object returned from a methSeg call
314+ # ' Segmentation and clustering are two distinct steps in methSeg(),
315+ # ' leading to adjacent segments of the same class.
316+ # ' This leads to a bias segment length distributions,
317+ # ' which is removed by joining those neighbours.
315318# '
316319# ' @param res A \code{\link[GenomicRanges]{GRanges}} object with segment
317320# ' classification and information prudoced by \code{\link{methSeg}}
@@ -325,13 +328,13 @@ colramp=colorRamp(c("gray","green", "darkgreen"))
325328# ' @importFrom data.table copy ":="
326329# @noRd
327330# @examples
328- . joinSegmentNeighbours <- function (res ) {
331+ joinSegmentNeighbours <- function (res ) {
329332
330333 # require(data.table)
331334
332335 if (length(unique(seqnames(res ))) > 1 ) {
333336 # # call recursively for multiple chromosomes
334- gr <- lapply(split(res ,seqnames(res )),. joinSegmentNeighbours )
337+ gr <- lapply(split(res ,seqnames(res )),joinSegmentNeighbours )
335338 gr <- do.call(c , unlist(gr ,use.names = FALSE ) )
336339 return ( gr )
337340 }
0 commit comments