methylKit
methylKit copied to clipboard
provide simple function to find dmrs
#' Find regions of differential methylation
#'
#' This function performs unsupervised segmentation of
#' the methylation differences calculated from calculateDiffMeth.
#' Then it classifies hyper and hypo methylated segments based
#' on a methylation difference threshold and joins
#' neighbouring segments with the same class.
#'
#' @param methylDiff methylDiff or methylDiffDB object generated with calculateDiffMeth
#' @param meth.diff integer methylation difference threshold
#'
#' @return A GRanges object with segment classification and information.
#' 'seg.mean' column shows the mean methylation per segment.
#' 'seg.group' column shows the segment groups obtained by mixture modeling
#' @export
#'
#' @examples
find_DMR <- function(methylDiff, meth.diff = 25) {
# segment first
mDiffRegion <- methSeg(methylDiffDB, )
# reassign groups based on meth.diff cutoff
mDiffRegion$seg.group <- "none"
mDiffRegion[mDiffRegion$seg.mean < -meth.diff]$seg.group <- "hypo"
mDiffRegion[mDiffRegion$seg.mean > meth.diff]$seg.group <- "hyper"
# join neighbouring with same groups
mDiffRegionJoined <- joinSegmentNeighbours(mDiffRegion)
return(mDiffRegionJoined)
}
@al2na do you think this would make sense to be added? In general it is just a wrapper about existing functionality.
For aggregating region level statistics, we can do the same what methcp does, use either fisher's method or stouffer method
https://github.com/boyinggong/MethCP/blob/master/R/segmentMethCP.R https://github.com/boyinggong/MethCP/blob/master/R/utils.R