I have a set of 200 genes that are split into numerical high and low, encoded as (1/2).
I have set this variable this way for linearity of the model. Also, stratified by cancer and normal cases.
I tried to do coxph()
for all of them and almost all of them are significant with a very low p-values. But the exp(coef)
(HR) were crazy huge like 115.0 or something.
so, I decided to do elastic net selection, so as to not bias my selection of covariates to include in the model.
I am using this code snippet below to fit the model, to do a simple cross-validation, and then to get p-values from coxph()
.
I got 80 non-zero coefficients from glmnet()
and I forced these coefficients into coxph()
# x is a model matrix
# y is a Surv matrix
fit <- glmnet(x, stratifySurv(y, genesX$case) , family = "cox" ,
type.measure ="deviance", maxit = 3000, alpha = 0.5)
# find lambda for which dev.ratio is max
max.dev.index <- which.max(fit$dev.ratio)
optimal.lambda <- fit$lambda[max.dev.index]
# take beta for optimal lambda
optimal.beta <- fit$beta[,max.dev.index]
# find non zero beta coef
nonzero.coef <- abs(optimal.beta)>0
table(nonzero.coef)
## 80 genes
sig_genes <- names(nonzero.coef[nonzero.coef == T])
selectedBeta <- optimal.beta[nonzero.coef]
# CROSS Validation
cvfit <- cv.glmnet(x, stratifySurv(y, genesX$case) , family = "cox" ,
type.measure ="deviance", maxit = 3000, alpha = 0.5, nfolds = 10)
plot(cvfit)
cvfit$lambda.1se
cvfit$lambda.min
# Cox model
coxfit <- coxph( as.formula(paste("Surv(Stime, OSS) ~ ", paste(sig_genes,collapse="+"), "+strata(case)" )) ,
init = selectedBeta,
iter = 0,
ties = "breslow",
data = genesX)
plot(selectedBeta,coef(coxfit))
I find if I force the model like that, I get zero significant genes in the final model. Otherwise, if I run coxph()
like this:
coxfit <- coxph( as.formula(paste("Surv(Stime, OSS) ~ ", paste(sig_genes,collapse="+"), "+strata(case)" )) ,
data = t_v_genesX)
I get totally different results where the coefficients plots are not correlated, some of the selected genes are non-significant and again the sky-high coefficients results.
strata(case)
, how many strata are there versus how many total cases you have? $\endgroup$