R/Cdseq.R

Defines functions Cdseq

Documented in Cdseq

#' The deconvolution methods of CDseq
#'
#' @param bulkdata A matrix with genes in rows and samples in columns.
#' @param signature   A data-frame containing signatures of different cell types
#' @import CDSeq
#' @return  A data frame of Mixed cellular fractions.
#' @export
#'
#' @examples
#'
#' Bulk <- Bulk_GSE60424
#' res <- Cdseq(bulkdata = Bulk,
#'                     signature = LM22 )
#'



Cdseq <- function(bulkdata, signature ){

   CDSeqLength <- deconvBench::CDSeqLength

  row.names(CDSeqLength) <- CDSeqLength[,1]

  Gene <- Reduce(intersect,list(CDSeqLength$ENSEMBL,rownames(signature),rownames(bulkdata)))

  CDSeqLength <- CDSeqLength[Gene,]

  bulk_data <- bulkdata[Gene,]

  signature <- signature[Gene,]

  genelength <- round(as.numeric(CDSeqLength$length))

  cdseq.res <- CDSeq::CDSeq(bulk_data  = bulk_data,
                            cell_type_number = 22,
                            mcmc_iterations = 5, # increase the mcmc_iterations to 700 or above
                            gene_length = genelength , #每个基因的碱基长度
                            reference_gep = signature ,  # gene expression profile of pure cell lines
                            cpu_number = 1)

  res_Cdseq <- cdseq.res$estProp


  return(res_Cdseq)


}
libcell/deconvBench documentation built on Sept. 24, 2022, 12:36 p.m.