annotate loadandplot.R @ 3:ce633cc8f5f9 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/iwtomics commit 69ca0c7a7e444f54b56d111e16432f5d8dddb96d
author iuc
date Wed, 21 Feb 2018 14:16:45 -0500
parents 0027f3287b34
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
1 if (require("IWTomics",character.only = TRUE,quietly = FALSE)) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
2 args=commandArgs(TRUE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
3
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
4 # get args names and values
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
5 args_values=strsplit(args,'=')
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
6 args_names=unlist(lapply(args_values,function(arg) arg[1]))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
7 names(args_values)=args_names
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
8 args_values=lapply(args_values,function(arg) arg[2])
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
9 # read filenames
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
10 outrdata=args_values$outrdata
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
11 outregions=args_values$outregions
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
12 outfeatures=args_values$outfeatures
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
13 outpdf=args_values$outpdf
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
14 regionspaths=unlist(strsplit(args_values$regionspaths,'\\|'))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
15 if("regionsheaderfile" %in% args_names){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
16 # the file regionsheaderfile must contain as first column the (unique) regionsfilenames,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
17 # as second column the corresponding ids and as third column the names
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
18 tryCatch({
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
19 regionsheader=read.delim(args_values$regionsheaderfile,header=FALSE,stringsAsFactors=FALSE,row.names=1,sep="\t")
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
20 regionsfilenames=unlist(strsplit(args_values$regionsfilenames,'\\|'))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
21 if(length(setdiff(regionsfilenames,row.names(regionsheader)))) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
22 write("IWTomics message: Not all region files are present in the first column of header file for regions.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
23 quit(save="no", status=11)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
24 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
25 id_regions=regionsheader[regionsfilenames,1]
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
26 name_regions=regionsheader[regionsfilenames,2]
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
27 }, error = function(err) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
28 write("IWTomics message: An error has occurred reading the header file for regions. Please try again.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
29 quit(save="no", status=10) #error on header file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
30 })
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
31 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
32 eval(parse(text=args[[which(args_names=='regionsgalaxyids')]]))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
33 id_regions=paste0('data_',regionsgalaxyids)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
34 name_regions=paste0('data_',regionsgalaxyids)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
35 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
36 featurespaths=unlist(strsplit(args_values$featurespaths,'\\|'))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
37 if("featuresheaderfile" %in% args_names){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
38 # the file featuresheaderfile must contain as first column the (unique) featuresfilenames,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
39 # as second column the corresponding ids and as third column the names
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
40 tryCatch({
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
41 featuresheader=read.delim(args_values$featuresheaderfile,header=FALSE,stringsAsFactors=FALSE,row.names=1,sep="\t")
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
42 featuresfilenames=unlist(strsplit(args_values$featuresfilenames,'\\|'))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
43 if(length(setdiff(featuresfilenames,row.names(featuresheader)))) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
44 write("IWTomics message: Not all feature files are present in the first column of header file for features.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
45 quit(save="no", status=21)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
46 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
47 id_features=featuresheader[featuresfilenames,1]
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
48 name_features=featuresheader[featuresfilenames,2]
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
49 }, error = function(err) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
50 write("IWTomics message: An error has occurred reading the header file for features. Please try again.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
51 quit(save="no", status=20) #error on header file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
52 })
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
53 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
54 eval(parse(text=args[[which(args_names=='featuresgalaxyids')]]))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
55 id_features=paste0('data_',featuresgalaxyids)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
56 name_features=paste0('data_',featuresgalaxyids)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
57 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
58 # read parameters (from smoothing on)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
59 i_smoothing=which(args_names=='smoothing')
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
60 for(i in i_smoothing:length(args)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
61 eval(parse(text=args[[i]]))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
62 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
63
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
64 # load data
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
65 tryCatch({
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
66 regionsFeatures=IWTomicsData(regionspaths,featurespaths,alignment,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
67 id_regions,name_regions,id_features,name_features,start.are.0based=start.are.0based)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
68 }, error = function(err) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
69 if(grepl('invalid format',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
70 write("IWTomics message: Not enough columns in input file.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
71 quit(save="no", status=31) # error, not enough columns in input file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
72 }else if(grepl('duplicated regions',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
73 write("IWTomics message: Duplicated regions in region file.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
74 quit(save="no", status=32) # error, duplicated regions in region file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
75 }else if(grepl('duplicated windows',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
76 write("IWTomics message: Duplicated windows in feature file.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
77 quit(save="no", status=33) # error, duplicated windows in feature file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
78 }else if(grepl('overlapping windows',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
79 write("IWTomics message: Overlapping windows in feature file.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
80 quit(save="no", status=34) # error, overlapping windows in feature file
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
81 }else if(grepl('not all regions in datasets',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
82 write("IWTomics message: Windows in feature files do not cover all regions in region files.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
83 quit(save="no", status=35) # error, windows in feature files do not cover all regions in region files
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
84 }else if(grepl('ifferent size windows',err$message)){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
85 write("IWTomics message: All windows in a feature file must have the same size.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
86 quit(save="no", status=36) # error, all windows in a feature files must have the same size
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
87 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
88 #error loading data
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
89 write("IWTomics message: An error has occurred reading the data. Please try again.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
90 quit(save="no", status=30)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
91 })
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
92
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
93 # smooth data
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
94 if(smoothing!='no'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
95 tryCatch({
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
96 if(smoothing=='locpoly'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
97 dist_knots=10
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
98 }else if(smoothing=='kernel'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
99 degree=3
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
100 dist_knots=10
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
101 }else if(smoothing=='splines'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
102 bandwidth=5
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
103 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
104 if(alignment=='scale'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
105 if(scale==0){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
106 regionsFeatures=smooth(regionsFeatures,type=smoothing,fill_gaps=fill_gaps,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
107 bandwidth=bandwidth,degree=degree,dist_knots=dist_knots)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
108 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
109 regionsFeatures=smooth(regionsFeatures,type=smoothing,fill_gaps=fill_gaps,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
110 bandwidth=bandwidth,degree=degree,dist_knots=dist_knots,scale_grid=scale)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
111 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
112 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
113 regionsFeatures=smooth(regionsFeatures,type=smoothing,fill_gaps=fill_gaps,
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
114 bandwidth=bandwidth,degree=degree,dist_knots=dist_knots)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
115 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
116 }, error = function(err) {
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
117 write("IWTomics message: An error has occurred smoothing the data. Please try again.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
118 quit(save="no", status=40) #error on smoothing
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
119 })
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
120 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
121
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
122 # plot data
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
123 pdf(outpdf,width=10,height=8)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
124 if(plottype=='boxplot'){
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
125 # fix repeated probs
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
126 probs=sort(unique(probs))
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
127 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
128 probs=c(0.25,0.5,0.75)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
129 }
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
130 plot(regionsFeatures,type=plottype,probs=probs,average=average,size=size,ask=FALSE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
131 dev.off()
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
132
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
133 # create output
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
134 #write.table(cbind(unlist(strsplit(args_values$regionsfilenames,'\\|')),idRegions(regionsFeatures),nameRegions(regionsFeatures)),
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
135 #file=outregions,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
136 write.table(as.data.frame(t(idRegions(regionsFeatures))),file=outregions,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
137 #write.table(cbind(unlist(strsplit(args_values$featuresfilenames,'\\|')),idFeatures(regionsFeatures),nameFeatures(regionsFeatures)),
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
138 #file=outfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
139 write.table(as.data.frame(t(idFeatures(regionsFeatures))),file=outfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
140 save(regionsFeatures,file=outrdata)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
141 }else{
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
142 write("IWTomics message: Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr())
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
143 quit(save="no", status=255)
0027f3287b34 planemo upload for repository https://github.com/fabio-cumbo/IWTomics4Galaxy commit 90c984bb9f803e1531fe4cb670e876809d48d205
iuc
parents:
diff changeset
144 }