require(survJamda.data)
data(gse4335)
data(gse4335pheno)
data(gse1992)
data(gse1992pheno)
common.gene = intersect(colnames(gse4335), colnames(gse1992))
data = rbind(gse4335[,common.gene], gse1992[,common.gene])
surv = c(gse4335pheno[,6],gse1992pheno[,19])
censor = c(gse4335pheno[,5],gse1992pheno[,18])
# An integer is used as batchID
batchID = rep(1,nrow(gse4335))
batchID = c(batchID,rep(2,nrow(gse1992)))
#Or the name of the data sets is used as batch ID
#batchID = rep("gse4335",nrow(gse4335))
#batchID = c(batchID,rep("gse1992",nrow(gse1992)))
#And run the following script:
#iter.crossval.combat(data, surv,censor, batchID)
## The function is currently defined as
function (data, surv, censor, batchID, ngroup=10, plot.roc = 0, method = "none",
gn.nb = 100){
require(survival)
require(survivalROC)
if(!exists("batchID"))
stop("\rSet batchID", call.=FALSE)
niter = ifelse(ngroup == length(surv), 1,10)
res = NULL
file.name=deparse(substitute(data))
if (plot.roc)
init.plot(file.name)
data =data[!is.na(surv),]
censor= censor[!is.na(surv)]
surv= surv[!is.na(surv)]
cat ("Iteration\tAUC\tHR(CI)\t\tP-val\n")
for (i in 1:niter){
new.lst = cross.val.combat(data, surv, censor,method = "none",
gn.nb, plot.roc, ngroup, i)
res = rbind (res, new.lst)
}
if(ngroup != length(surv)){
cat ("Avg AUC+/-SD\tHR(CI)\n")
if (plot.roc)
legend (0.55,0.1, legend = paste("AUC+/-SD =", sprintf("%.2f",
as.numeric(mean(res[,1],na.rm = TRUE))), "+/-", sprintf("%.2f",
sd (res[,1],na.rm = TRUE)), sep = " "), bty = "n")
cat (sprintf("%.2f",as.numeric(mean(res[,1], na.rm = TRUE))),
"+/-", sprintf("%.2f",sd (res[,1],na.rm = TRUE)), "\t",
gm(res[,2]), "(", sprintf("%.2f",ci.gm(res[,2])[1]), "-",
sprintf("%.2f",ci.gm(res[,2])[2]), ")\n", sep = "")
}
}
Run the code above in your browser using DataLab