PreMean <- matrix(ncol=3, nrow=2, byrow=TRUE) PreMean[1, ] <- c(1, -1, 0) PreMean[2, ] <- c(-0.8, 0, 0.8) PreZeta <- c(0.4, 1.8, 1) GenExpression <- function(x, cancertype, sdv) { rnorm(1, PreMean[x,cancertype], sdv) } GenSurvival <- function(funtype, cancertype, x1, x2, cancerprob) { # rm(.Random.seed) S <- runif(1, 0, 1) if(cancertype==1) { h <- 0.3*x1 + 0.4*x2 - 0.1 } if(cancertype==2) { h <- 0.5*(x1-x2)^2 + 1 } if(cancertype==3) { h <- 0.006*x1^3 - 0.2*x2 } if(funtype=="1") { -(log(S)/exp(-h)) } #survival function is Weibull exp((-log(S)/exp(-h))^(1/PreZeta[cancertype])) } patientProfile <- matrix(nrow=50, ncol=3000, byrow=TRUE); patientCancertype <- sample(c(1, 2, 3), 50, TRUE, c(0.3, 0.4, 0.3)); patientT <- c(); patientZ <- c(); for(i in 1:50) { patientProfile[i,1] <- GenExpression(1, patientCancertype[i], sqrt(0.3)); patientProfile[i,2] <- GenExpression(2, patientCancertype[i], sqrt(0.3)); patientProfile[i,3:3000] <- rnorm(3000-2, 0, 1); failureTime <- GenSurvival(1, patientCancertype[i], patientProfile[i,1],patientProfile[i, 2], c(0.3, 0.4, 0.3)); censorTime <- runif(1, 20, 50); if(failureTime > censorTime) { patientT[i] <- failureTime; z <- 0;} else { patientT[i] <- censorTime; z <- 1; } write.table(patientProfile[i,], file="./temp/ec1afd6712a87a6b9880f15259c0b608.R.profile", quote=FALSE, col.names=FALSE, row.names=FALSE, sep="\t"); }