Learn R Programming

jointseg (version 1.0.2)

doDynamicProgramming: Run segmentation by dynamic programming

Description

High-level function for univariate or multivariate segmentation by dynamic programming

Usage

doDynamicProgramming(Y, K, stat = NULL, verbose = FALSE)

Arguments

Y

A numeric vector or a matrix, the signal to be segmented

K

The number of change points to find

stat

A vector containing the names or indices of the columns of Y to be segmented

verbose

A logical value: should extra information be output ? Defaults to FALSE.

Value

bkp

A vector of K indices for candidate change points

dpseg

A list of two elements

bkp

A list of vectors of change point positions for the best model with k change points, for k=1, 2, ... K

rse

A vector of K+1 residual squared errors

Details

If the signal is uni-dimensional, this function simply uses the segmentation method provided in the cghseg package reshapes the results.

If the signal is multi-dimensional, this function applies the pruneByDP function and reshapes the results.

References

Rigaill, G. (2015). A pruned dynamic programming algorithm to recover the best segmentations with 1 to K_max change-points. Journal de la Societe Francaise de Statistique, 156(4), 180-205.

Examples

Run this code
# NOT RUN {
## load known real copy number regions
affyDat <- acnr::loadCnRegionData(dataSet="GSE29172", tumorFraction=1)

## generate a synthetic CN profile
K <- 10
len <- 1e4
sim <- getCopyNumberDataByResampling(len, K, minLength=100, regData=affyDat)
datS <- sim$profile

## run pruned DPA segmentation
resDP <- doDynamicProgramming(datS[["c"]], K=K)
getTpFp(resDP$bkp, sim$bkp, tol=5, relax = -1)   ## true and false positives
plotSeg(datS, breakpoints=list(sim$bkp, resDP$bkp))

## run 2d dynamic programming segmentation
K <- 2
len <- 1e3
sim <- getCopyNumberDataByResampling(len, K, minLength=100, regData=affyDat)
datS <- sim$profile
datS$d <- 2*abs(datS$b-1/2)
datS[which(datS$genotype!=0.5),"d"] <- NA
Y = cbind(datS$c,datS$d)
resDP2d <- doDynamicProgramming(Y, K = K)

# }

Run the code above in your browser using DataLab