comparison testandplot.R @ 74:2bb6b44093ba draft

Uploaded 20170619
author fabio
date Mon, 19 Jun 2017 12:08:59 -0400
parents 1e677d6b1aaf
children
comparison
equal deleted inserted replaced
73:156b29da2f0b 74:2bb6b44093ba
30 # retrieve region1, region2 and features_subset ids and check they are in the RData 30 # retrieve region1, region2 and features_subset ids and check they are in the RData
31 id_region1=regionids[region1] 31 id_region1=regionids[region1]
32 id_region2=regionids[region2] 32 id_region2=regionids[region2]
33 id_features_subset=featureids[features_subset] 33 id_features_subset=featureids[features_subset]
34 if(length(setdiff(c(id_region1,id_region2),idRegions(regionsFeatures)))!=0){ 34 if(length(setdiff(c(id_region1,id_region2),idRegions(regionsFeatures)))!=0){
35 write("Wrong region ids.", stderr())
35 quit(save="no", status=10) 36 quit(save="no", status=10)
36 stop('Wrong region ids')
37 } 37 }
38 if(length(setdiff(id_features_subset,idFeatures(regionsFeatures)))!=0){ 38 if(length(setdiff(id_features_subset,idFeatures(regionsFeatures)))!=0){
39 write("Wrong feature ids.", stderr())
39 quit(save="no", status=20) 40 quit(save="no", status=20)
40 stop('Wrong feature ids')
41 } 41 }
42 if(sum(duplicated(paste0(id_region1,id_region2)))){ 42 if(sum(duplicated(paste0(id_region1,id_region2)))){
43 write("Same test repeated multiple times.", stderr())
43 quit(save="no", status=30) 44 quit(save="no", status=30)
44 stop('Same test repeated multiple times.')
45 } 45 }
46 46
47 # perform test 47 # perform test
48 tryCatch({ 48 tryCatch({
49 # fix repeated probs 49 # fix repeated probs
65 write.table(pval,file=adjustedpvaluematrix,append=TRUE,sep='\t',quote=FALSE,row.names=TRUE,col.names=FALSE) 65 write.table(pval,file=adjustedpvaluematrix,append=TRUE,sep='\t',quote=FALSE,row.names=TRUE,col.names=FALSE)
66 write('',file=adjustedpvaluematrix,append=TRUE,sep='\t') 66 write('',file=adjustedpvaluematrix,append=TRUE,sep='\t')
67 } 67 }
68 } 68 }
69 }, error = function(err) { 69 }, error = function(err) {
70 write("Testing error.", stderr())
70 quit(save="no", status=40) #error testing 71 quit(save="no", status=40) #error testing
71 stop(err)
72 }) 72 })
73 73
74 # plot test results 74 # plot test results
75 pdf(iwtomicsrespdf,width=5,height=7) 75 pdf(iwtomicsrespdf,width=5,height=7)
76 if(plottype=='boxplot'){ 76 if(plottype=='boxplot'){
92 # create output 92 # create output
93 write.table(as.data.frame(t(paste(id_region1,'vs',id_region2))),file=iwtomicstests,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE) 93 write.table(as.data.frame(t(paste(id_region1,'vs',id_region2))),file=iwtomicstests,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
94 write.table(as.data.frame(t(idFeatures(regionsFeatures_test))),file=iwtomicsselectedfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE) 94 write.table(as.data.frame(t(idFeatures(regionsFeatures_test))),file=iwtomicsselectedfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
95 save(regionsFeatures_test,file=iwtomicsrdata) 95 save(regionsFeatures_test,file=iwtomicsrdata)
96 }else{ 96 }else{
97 write("Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr())
97 quit(save="no", status=255) 98 quit(save="no", status=255)
98 stop("Missing IWTomics package")
99 } 99 }