Mercurial > repos > fabio > iwtomics
comparison plotwithscale.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 |
|---|---|
| 38 scale_subset=unlist(lapply(unlisted,function(l) l$scale_subset)) | 38 scale_subset=unlist(lapply(unlisted,function(l) l$scale_subset)) |
| 39 testids=as.character(read.delim(iwtomicstests,header=FALSE,sep='\t',stringsAsFactors=FALSE)) | 39 testids=as.character(read.delim(iwtomicstests,header=FALSE,sep='\t',stringsAsFactors=FALSE)) |
| 40 featureids=as.character(read.delim(iwtomicsselectedfeatures,header=FALSE,sep='\t',stringsAsFactors=FALSE)) | 40 featureids=as.character(read.delim(iwtomicsselectedfeatures,header=FALSE,sep='\t',stringsAsFactors=FALSE)) |
| 41 id_features_subset=featureids[feature_subset] | 41 id_features_subset=featureids[feature_subset] |
| 42 if(sum(testids!=paste(testInput(regionsFeatures_test)$id_region1,'vs',testInput(regionsFeatures_test)$id_region2))){ | 42 if(sum(testids!=paste(testInput(regionsFeatures_test)$id_region1,'vs',testInput(regionsFeatures_test)$id_region2))){ |
| 43 write("Wrong test ids.", stderr()) | |
| 43 quit(save="no", status=10) | 44 quit(save="no", status=10) |
| 44 stop('Wrong test ids') | |
| 45 } | 45 } |
| 46 if(sum(featureids!=idFeatures(regionsFeatures_test))){ | 46 if(sum(featureids!=idFeatures(regionsFeatures_test))){ |
| 47 write("Wrong feature ids.", stderr()) | |
| 47 quit(save="no", status=20) | 48 quit(save="no", status=20) |
| 48 stop('Wrong feature ids') | |
| 49 } | 49 } |
| 50 # retrieve test and features_subset ids | 50 # retrieve test and features_subset ids |
| 51 id_features_subset=featureids[feature_subset] | 51 id_features_subset=featureids[feature_subset] |
| 52 if(sum(duplicated(paste0(test_subset,id_features_subset)))){ | 52 if(sum(duplicated(paste0(test_subset,id_features_subset)))){ |
| 53 write("Two scale thresholds selected for the same test and feature.", stderr()) | |
| 53 quit(save="no", status=30) | 54 quit(save="no", status=30) |
| 54 stop('Two scale thresholds selected for the same test and feature.') | |
| 55 } | 55 } |
| 56 # If scale_subset=0, do not change the threshold | 56 # If scale_subset=0, do not change the threshold |
| 57 default=(scale_subset==0) | 57 default=(scale_subset==0) |
| 58 scale_subset=scale_subset[!default] | 58 scale_subset=scale_subset[!default] |
| 59 test_subset=test_subset[!default] | 59 test_subset=test_subset[!default] |
| 62 # get scale threshold | 62 # get scale threshold |
| 63 scale_threshold=lapply(regionsFeatures_test@test$result, | 63 scale_threshold=lapply(regionsFeatures_test@test$result, |
| 64 function(result) unlist(lapply(result,function(feature) feature$max_scale))) | 64 function(result) unlist(lapply(result,function(feature) feature$max_scale))) |
| 65 for(i in seq_along(test_subset)){ | 65 for(i in seq_along(test_subset)){ |
| 66 if(scale_threshold[[test_subset[i]]][id_features_subset[i]]<scale_subset[i]){ | 66 if(scale_threshold[[test_subset[i]]][id_features_subset[i]]<scale_subset[i]){ |
| 67 write("Scale threshold too high.", stderr()) | |
| 67 quit(save="no", status=40) | 68 quit(save="no", status=40) |
| 68 stop('Scale threshold too high.') | |
| 69 } | 69 } |
| 70 scale_threshold[[test_subset[i]]][id_features_subset[i]]=scale_subset[i] | 70 scale_threshold[[test_subset[i]]][id_features_subset[i]]=scale_subset[i] |
| 71 } | 71 } |
| 72 | 72 |
| 73 # create adjustedvalue output | 73 # create adjustedvalue output |
| 101 pdf(iwtomicssumpdf,width=15,height=10) | 101 pdf(iwtomicssumpdf,width=15,height=10) |
| 102 plotSummary(regionsFeatures_test,alpha=summaryalpha,only_significant=only_significant,groupby=groupby,scale_threshold=scale_threshold,ask=FALSE,append=TRUE) | 102 plotSummary(regionsFeatures_test,alpha=summaryalpha,only_significant=only_significant,groupby=groupby,scale_threshold=scale_threshold,ask=FALSE,append=TRUE) |
| 103 dev.off() | 103 dev.off() |
| 104 }, error = function(err) { | 104 }, error = function(err) { |
| 105 if (grepl('selected features with different resolution',err$message)) { | 105 if (grepl('selected features with different resolution',err$message)) { |
| 106 write("Group by 'test' but selected features with different resolution.", stderr()) | |
| 106 quit(save="no", status=50) #error: groupby 'test' but selected features with different resolution. | 107 quit(save="no", status=50) #error: groupby 'test' but selected features with different resolution. |
| 107 stop(err) | |
| 108 } | 108 } |
| 109 write("Summary plot error. Please try again.", stderr()) | |
| 109 quit(save="no", status=60) #error | 110 quit(save="no", status=60) #error |
| 110 stop(err) | |
| 111 }) | 111 }) |
| 112 } | 112 } |
| 113 | 113 |
| 114 }else{ | 114 }else{ |
| 115 write("Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr()) | |
| 115 quit(save="no", status=255) | 116 quit(save="no", status=255) |
| 116 stop("Missing IWTomics package") | |
| 117 } | 117 } |
