calculate all univariate(all genes alone) coxmodels for the given expressionmatrix
# source("subscripts/postBT_small_ideas/calc.coxmodel.R")
cox.univariate <- function(exprmat
,pheno.df
,survtimename
,surveventname
,corr.formulastring=c("+SEX", "+(Alter>45)", "+Stadium", "+IPS")
,corr.formulastring.name=c("Sex", "AgeD", "Stadium", "IPS")
,whichmodel="allCovariates"){
univariate.models <- apply(cbind(seq(1, nrow(exprmat)), exprmat), 1, function(geneX){
calc.coxmodel(response = geneX[-1]
,pheno.df = pheno.df
,survtimename = survtimename
,surveventname = surveventname
,corr.formulastring = corr.formulastring
,corr.formulastring.name = corr.formulastring.name
,all.corrections = TRUE
,responsename = rownames(exprmat)[geneX[1]]
,corrections.univariat = TRUE)
})
cox.per.gene <- lapply(univariate.models, function(coxGeneX) coxGeneX[[whichmodel]])
# pvalues from the first coefficient (the genescore)
pval.per.gene <- unlist(lapply(cox.per.gene, function(coxModelX)summary(coxModelX)$coef[1, 5]))
pval.df <- tibble::tibble("Gene"=names(pval.per.gene), "pValue"=pval.per.gene, "pValBonferroni"=pval.per.gene*length(pval.per.gene))
return(pval.df)
}