Hi,
I am having a problem with my code. I am working with 5 datasets, 4 of them work fine with my code, however one is throwing up an error.
I am trying to calculate survival on the dataset i.e. get Hazard Ratio and p- value..
heres my code:
create a matrix for survival output
genes in rows , HR and P in columns
survival_gse4573_matrix <- matrix(nrow=colNum,ncol=2)
colnames(survival_gse4573_matrix) <- c("HR","P")
rownames(survival_gse4573_matrix) <- colnames(current_study)
get survival time and censored survival time based on status binary
survival_cens <- datTraits$STATUS.0.alive..1.dead.[358:487]
survival_time <- as.numeric(datTraits$suvival..months)[358:487]
for(i in 1:dim(gse4573_di_matrix)[2]){
a <- coxph(Surv(survival_time,as.numeric(survival_cens)) ~ gse4573_di_matrix[,i])
coeffs <- coef(summary(a))
HR <- coeffs[,2]
pVal <- (coeffs[,5])
fill matrix with HR and P for each gene
survival_gse4573_matrix[i,2] <- pVal
survival_gse4573_matrix[i,1] <- HR }
and the error:
coxph(Surv(survival_time, as.numeric(survival_cens)) ~ gse4573_di_matrix[,1])
Error in coxph(Surv(survival_time,as.numeric(survival_cens)) ~ gse4573_di_matrix[, : No (non-missing) observations
In addition:
Warning message: In
max(event[who2]) : no non-missing arguments to max; returning -Inf
The survival_cens contains only "NAs" as there was no status data for this dataset, is this the problem? If so, is there a way of solving it ?
Thanks, R
Is it because you are assigning it to
survival_cens
andsurvival_time
, then in formula for coxph you are usingsurvivalcens
andsurvivaltime
?No that is justhow the error puts them up... Im almost sure its due to status being effectively empty
If survival_cens is all NAs, I'm not sure how you could hope to do the computation, the result would be unknowable.