Skip to content

Commit

Permalink
export joinSegmentNeighbours and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexg9010 committed Aug 28, 2017
1 parent c0e6c18 commit 93483a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
13 changes: 8 additions & 5 deletions R/methSeg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}}
Expand All @@ -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 )
}
Expand Down
25 changes: 25 additions & 0 deletions man/joinSegmentNeighbours.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/methSeg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 93483a6

Please sign in to comment.