diff --git a/R/methSeg.R b/R/methSeg.R index 9ab0207e..c9eae628 100644 --- a/R/methSeg.R +++ b/R/methSeg.R @@ -141,7 +141,7 @@ methSeg<-function(obj, diagnostic.plot=TRUE, join.neighbours=FALSE, ...){ # if joining, show clustering after joining if(join.neighbours) { message("joining neighbouring segments") - seg.res <- .joinSegmentNeighbours(seg.res) + seg.res <- joinSegmentNeighbours(seg.res) diagnostic.plot=TRUE # get the new density @@ -308,10 +308,13 @@ colramp=colorRamp(c("gray","green", "darkgreen")) #} -#' Join directly neighbouring segments of same class +#' Join directly neighbouring segments produced by methSeg #' #' -# @param res object returned from a methSeg call +#' Segmentation and clustering are two distinct steps in methSeg(), +#' leading to adjacent segments of the same class. +#' This leads to a bias segment length distributions, +#' which is removed by joining those neighbours. #' #' @param res A \code{\link[GenomicRanges]{GRanges}} object with segment #' classification and information prudoced by \code{\link{methSeg}} @@ -325,13 +328,13 @@ colramp=colorRamp(c("gray","green", "darkgreen")) #' @importFrom data.table copy ":=" # @noRd # @examples -.joinSegmentNeighbours <- function(res) { +joinSegmentNeighbours <- function(res) { # require(data.table) if (length(unique(seqnames(res))) > 1 ) { ## call recursively for multiple chromosomes - gr <- lapply(split(res,seqnames(res)),.joinSegmentNeighbours) + gr <- lapply(split(res,seqnames(res)),joinSegmentNeighbours) gr <- do.call(c, unlist(gr,use.names = FALSE) ) return( gr ) } diff --git a/man/joinSegmentNeighbours.Rd b/man/joinSegmentNeighbours.Rd new file mode 100644 index 00000000..2b76a71e --- /dev/null +++ b/man/joinSegmentNeighbours.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/methSeg.R +\name{joinSegmentNeighbours} +\alias{joinSegmentNeighbours} +\title{Join directly neighbouring segments produced by methSeg} +\usage{ +joinSegmentNeighbours(res) +} +\arguments{ +\item{res}{A \code{\link[GenomicRanges]{GRanges}} object with segment +classification and information prudoced by \code{\link{methSeg}}} +} +\value{ +A \code{\link[GenomicRanges]{GRanges}} object with segment + classification and information. +} +\description{ +Segmentation and clustering are two distinct steps in methSeg(), +leading to adjacent segments of the same class. +This leads to a bias segment length distributions, +which is removed by joining those neighbours. +} +\seealso{ +\code{\link{methSeg}} +} diff --git a/man/methSeg.Rd b/man/methSeg.Rd index 61448311..bb73897b 100644 --- a/man/methSeg.Rd +++ b/man/methSeg.Rd @@ -75,7 +75,7 @@ unlink(list.files(pattern="H1.chr21.chr22",full.names=TRUE)) } \seealso{ -\code{\link{methSeg2bed}} +\code{\link{methSeg2bed}}, \code{\link{joinSegmentNeighbours}} } \author{ Altuna Akalin, contributions by Arsene Wabo