R/dimReduction.R

Defines functions rca_projection

#' RCA feature Construction for two expression matrix
#' @param  tpmMat TPM matrix in log scale
#' @param refMat reference expression matrix in log scale
#' @param power power for enlarge difference between correlation value
#' @export
rca_projection <- function(tpmMat, refMat, method = c("pearson"), power = 4) {
  if ( nrow(tpmMat) != nrow(refMat)) {
    stop("genes of tpmMat and panelMat are not the same")
  }

  #sort matrix
  tpmMat = tpmMat[rownames(refMat),]

  # correlation
  wholeMat = cbind(tpmMat, refMat)
  corMat = cor(wholeMat, method = method)
  #-- Subset
  corMat = corMat[(ncol(refMat) + 1):nrow(corMat), 1:ncol(tpmMat)]
  #-- Power
  # IMPORTANT TRICK FOR this method
  corMat = abs(corMat)^(power) * sign(corMat) #
  #if (scale) {
  #  corMat = scale(corMat,center=TRUE,scale=TRUE);
  #}

  corMat
}
ahy1221/abort documentation built on Aug. 19, 2017, 12:14 a.m.