### R code from vignette source 'GSReg.Rnw' ################################################### ### code chunk number 1: start ################################################### options(width=85) options(continue=" ") #rm(list=ls()) ################################################### ### code chunk number 2: GSReg.Rnw:165-170 ################################################### library(GSBenchMark) data(diracpathways) class(diracpathways) names(diracpathways)[1:5] class(diracpathways[[1]]) ################################################### ### code chunk number 3: GSReg.Rnw:179-181 ################################################### data(GSBenchMarkDatasets) print(GSBenchMark.Dataset.names) ################################################### ### code chunk number 4: GSReg.Rnw:187-190 ################################################### DataSetStudy = GSBenchMark.Dataset.names[[9]] print(DataSetStudy) data(list=DataSetStudy) ################################################### ### code chunk number 5: GSReg.Rnw:199-201 ################################################### if(sum(apply(is.nan(exprsdata),1,sum)>0)) exprsdata = exprsdata[-which(apply(is.nan(exprsdata),1,sum)>0),]; ################################################### ### code chunk number 6: GSReg.Rnw:205-207 ################################################### genenames = rownames(exprsdata); genenames[1:10] ################################################### ### code chunk number 7: GSReg.Rnw:237-238 ################################################### library(GSReg) ################################################### ### code chunk number 8: GSReg.Rnw:244-248 ################################################### Nperm = 10 system.time({DIRACperm =GSReg.GeneSets.DIRAC(exprsdata,diracpathways,phenotypes,Nperm=Nperm)}) system.time({DIRACAn =GSReg.GeneSets.DIRAC(exprsdata,diracpathways,phenotypes)}) ################################################### ### code chunk number 9: GSReg.Rnw:251-252 ################################################### hist(DIRACAn$pvalues,xlab="pvalue",main="Hist of pvalues applying DIRAC Analysis.") ################################################### ### code chunk number 10: GSReg.Rnw:259-268 ################################################### plot(x=abs(DIRACAn$zscores),y=DIRACperm$pvalues,xlab="|Z-score|", ylab="p-value",col="red1",main="DIRAC p-value comparisons") zscorelin <- seq(min(abs(DIRACAn$zscores)),max(abs(DIRACAn$zscores)),by = 0.1) pvaltheoretic = (1-pnorm(zscorelin))*2 lines(x=zscorelin,y=pvaltheoretic,type="l",pch=50,lty=5,col="darkblue") legend("topright",legend=c("permutation test","Normal Approx."), col=c("red1","blue"),text.col=c("red1","blue"), lty=c(NA,1),lwd=c(NA,2.5),pch=c(21,NA)) ################################################### ### code chunk number 11: GSReg.Rnw:300-309 ################################################### #Calculating the variance for the pathways #Calculate how much it takes to calculate the statistics and their p-value for all pathways system.time({VarAnKendallV = GSReg.GeneSets.EVA(geneexpres=exprsdata, pathways=diracpathways, phenotypes=as.factor(phenotypes)) }) names(VarAnKendallV)[[1]] VarAnKendallV[[1]] ################################################### ### code chunk number 12: GSReg.Rnw:320-337 ################################################### Nperm = 10; VarAnPerm = vector(mode="list",length=Nperm) for( i in seq_len(Nperm)) { VarAnPerm[[i]] = GSReg.GeneSets.EVA(geneexpres=exprsdata, pathways=diracpathways, phenotypes=sample(phenotypes)) } pvaluesperm = vector(mode="numeric",length=length(VarAnPerm[[1]])) for( i in seq_along(VarAnPerm[[1]])) { z = sapply(VarAnPerm,function(x) x[[i]]$E1 - x[[i]]$E2) pvaluesperm[i] = mean(abs(VarAnKendallV[[i]]$E1-VarAnKendallV[[i]]$E2)