# 25 patients, none lost to followup
followup <- rep(1, 25)
# first 5 patients have good survival (in days)
time <- c(25, 27, 24, 21, 26, sample(1:3, 20, TRUE))*365
# create data for 100 genes, 25 patients
dat <- matrix(rnorm(25*100), nrow=25, ncol=100)
colnames(dat) <- as.character(1:100)
# create random genesets of 5 genes
set1 <- sample(colnames(dat), 5)
# get gene data for set1
set1_data <- dat[, set1]
# shouldn't achieve significance
p_pure <- calculatePPure(set1_data, time, followup)
p_pure$p_pure
# alter expression data for first 5 patients for set1
dat[1:5, set1] <- dat[1:5, set1]+10
set1_data <- dat[, set1]
# now p_pure should be significant
p_pure <- calculatePPure(set1_data, time, followup)
p_pure$p_pure
Run the code above in your browser using DataLab