R/cell_to_mod_pval.R

Defines functions cell_to_mod_pval

Documented in cell_to_mod_pval

#' @title cell_to_mod_pval
#' @description Calculates Spearman correlation between module scoring and cell log ratio.  Operates on "immune_cell_logratios" input to "run_ICLite"
#' @param score_mat A score matrix generated by mod_score_matrix_assembly.
#' @return A matrix of Spearman correlation p-values
#' @export

cell_to_mod_pval<-function(score_mat){

  total_modules<-ncol(score_mat)
  cell_to_mod_mat<-matrix(ncol = ncol(score_mat), nrow = ncol(immune_cell_logratios))

  for(y in 1:total_modules){

    for(x in 1:ncol(immune_cell_logratios)){
      cell_to_mod_mat[x,y]<-cor.test(immune_cell_logratios[,x], score_mat[,y],
                                     method = "spearman")$p.value
    }
  }

  return(cell_to_mod_mat)

}
camiolomj/ICLite documentation built on July 28, 2021, 6:33 a.m.