segmentMethCP {MethCP} | R Documentation

## Perform segmentation on a `MethCP` object.

### Description

Perform CBS algorithm that segments the genome into similar levels of sigficance.

### Usage

    segmentMethCP(
        methcp.object, bs.object,
        region.test = c(
            "fisher", "stouffer", "weighted-variance", "weighted-coverage"),
        min.width = 2, sig.level = 0.01,
        presegment_dist = 600, BPPARAM = bpparam(), ...)

### Arguments

`methcp.object` | a `MethCP` object.
`bs.object` | a `BSseq` object from the `bsseq` package.
`region.test` | The meta-analysis method used to create region-based test statistics.
`min.width` | the minimum width for the segments, which is used as termination rule for the segmentation algorithm.
`sig.level` | the significance level of the segments, which is used as termination rule for the segmentation algorithm.
`presegment_dist` | the maximum distance between cytosines for the presegmentation.
`BPPARAM` | An optional BiocParallelParam instance determining the parallel back-end to be used during evaluation, or a list of BiocParallelParam instances, to be applied in sequence for nested calls to BiocParallel functions. Default bpparam().
`...` | argument to be passed to segment function in DNAcopy package

### Details

The `MethCP` object `methcp.object` can be generated from functions `calcLociStat`, `calcLociStatTimeCourse`, or `methcpFromStat`.

If `region.test = "fisher"`, Fisher's combined probability test is used.

If `region.test = stouffer` Stouffer's test is applied.

If `region.test = "weighted-variance"` we use the variance of the test to combine per-cytosine based statistcis into a region-based statistic.

If `region.test = "weighted-coverage"` we use the coverage of the test to combine per-cytosine based statistcis into a region-based statistic.

### Value

a `MethCP` object that is not segmented.

### Examples

    library(bsseq)
    # Simulate a small dataset with 2000 cyotsine and 6 samples,
    # 3 in the treatment group and 3 in the control group. The
    # methylation ratio are generated using Binomial distribution
    # with probability 0.3.
    nC <- 2000
    sim_cov <- rnbinom(6*nC, 5, 0.5) + 5
    sim_M <- vapply(
        sim_cov, function(x) rbinom(1, x, 0.3), FUN.VALUE = numeric(1))
    sim_cov <- matrix(sim_cov, ncol = 6)
    sim_M <- matrix(sim_M, ncol = 6)
    # methylation ratios in the DMRs in the treatment group are
    # generated using Binomial(0.7)
    DMRs <- c(600:622, 1089:1103, 1698:1750)
    sim_M[DMRs, 1:3] <- vapply(
        sim_cov[DMRs, 1:3], function(x) rbinom(1, x, 0.7),
        FUN.VALUE = numeric(1))
    # sample names
    sample_names <- c(paste0("treatment", 1:3), paste0("control", 1:3))
    colnames(sim_cov) <- sample_names
    colnames(sim_M) <- sample_names

    # create a bs.object
    bs_object <- BSseq(gr = GRanges(
        seqnames = "Chr01", IRanges(start = (1:nC)*10, width = 1)),
        Cov = sim_cov, M = sim_M,
        sampleNames = sample_names)
    DMRs_pos <- DMRs*10
    methcp_obj1 <- calcLociStat(
        bs_object,
        group1 = paste0("treatment", 1:3),
        group2 = paste0("control", 1:3),
        test = "methylKit")
    methcp_obj1 <- segmentMethCP(
        methcp_obj1, bs_object,
        region.test = "fisher")

[Package MethCP version 1.8.0 Index]