Hi Reberto,
For the survival analysis, we divide samples by each gene expression data. Then we use Surv(), coxph() to calculate the logrank P value. At last, we use p.adjust() to get Q value.
Here is our script for this survival anlaysis:
cox.simple=function(vv, st, se) {
vv=as.numeric(vv)
ind=complete.cases(vv, st, se)
vv=vv[ind]
if (length(vv)<5) return(rep(NA, 5))
#first, check whether or not the data quantile is good to try survival curve.
brks0=quantile(vv, c(0, 0.25, 0.50, 0.75, 1))
brks0 <- unique(brks0)
brks0b=round(brks0, 2)
vv2=as.numeric(cut(vv, brks0, include.lowest=T))
# the number of intervals of quantile is the number of clusters to try survival curve.
n.quantile.interval = length(table(vv2))
#print("trying cox.simple...check. how many intervals of data quantile for survival curve?")
#print(n.quantile.interval)
if(n.quantile.interval==1){
res=NA
}else{
ss=Surv(st[ind], se[ind])
# Try coxph to get p.val using qantile interval categories of the data
fit = coxph(ss~factor(vv2))
fit2=summary(fit)
logrank_P=as.vector(fit2$sctest[3]) #c('logrank_P')
res= logrank_P
}
return(res)
}
Best,
Hailei