R/get.multipcf.R

Defines functions get.multipcf

Documented in get.multipcf

#' get.multipcf
#'
#' `get.multipcf` uses the multi-sample pcf algorithm to segment the LogR ratios across multiple samples.
#'
#' @param raw.LogR The table showing the logR ratios directly from conumee.
#' @return Returns the list of segmented LogR with different gamma values
#' @importFrom magrittr %>%
#'
#' @export

get.multipcf <- function(raw.LogR) {
  LogR_for_pcf <- raw.LogR[,c(1,4,6:ncol(raw.LogR))]
  LogR_for_pcf <- LogR_for_pcf %>% dplyr::mutate(chr = sub("chr" , "", chr))
  wins.data <- copynumber::winsorize(LogR_for_pcf, k = 15, return.outliers = F, verbose = F)
  multi.seg.list <- list()
  multi.seg.estimates.list <- list()
  if (ncol(wins.data) >= 4) {
    for (gamma in c("05", "06", "07", "08", "09", "10", "15")) {
      multi.seg.list[[gamma]] <- copynumber::multipcf(data = wins.data,
                                          gamma = as.numeric(gamma),
                                          verbose = F, return.est = T, fast = T)
      multi.seg.estimates.list[[gamma]] <-
        cbind(raw.LogR[, c(1:3)],multi.seg.list[[gamma]]$estimates[,-c(1:2)])
    }
  }
  return(multi.seg.estimates.list)
}
chulingding/MultiSEPhyR documentation built on Dec. 19, 2021, 4:06 p.m.