annotate selection.R @ 8:d5ed62b4d3ac draft default tip

planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
author sblanck
date Tue, 12 May 2020 13:40:07 +0000
parents af4f63f27c77
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
1 #!/usr/bin/env Rscript
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
2 # setup R error handling to go to stderr
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
4
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
7
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
8 library("optparse")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
9
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
10 ##### Read options
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
11 option_list=list(
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
12 make_option("--chrom",type="character",default=NULL, dest="chrom"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
13 make_option("--input",type="character",default=NULL, dest="input"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
14 make_option("--output",type="character",default=NULL, dest="output"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
15 make_option("--new_file_path",type="character",default=NULL, dest="new_file_path"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
16 make_option("--response",type="character",default=NULL, dest="response"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
17 make_option("--settingsType",type="character",default=NULL, dest="settingsType"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
18 make_option("--outputgraph",type="character",default=NULL, dest="outputgraph"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
19 make_option("--settingsSnp",type="character",default=NULL, dest="settingsSnp"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
20 make_option("--settingsSignal",type="character",default=NULL, dest="settingsSignal"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
21 make_option("--settingsLoss",type="character",default=NULL, dest="settingsLoss"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
22 make_option("--pdffigures",type="character",default=NULL, dest="pdffigures"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
23 make_option("--folds",type="character",default=NULL, dest="folds"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
24 make_option("--outputlog",type="character",default=NULL, dest="outputlog"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
25 make_option("--log",type="character",default=NULL, dest="log"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
26 make_option("--userId",type="character",default=NULL, dest="userid"),
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
27 make_option("--settingsPackage",type="character",default=NULL, dest="settingsPackage")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
28 );
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
29
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
30 opt_parser = OptionParser(option_list=option_list);
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
31 opt = parse_args(opt_parser);
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
32
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
33 if(is.null(opt$input)){
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
34 print_help(opt_parser)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
35 stop("input required.", call.=FALSE)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
36 }
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
37
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
38 #loading libraries
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
39
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
40
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
41 chrom=opt$chrom
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
42 dataset=opt$input
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
43 dataResponse=opt$response
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
44 output=opt$output
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
45 tmp_dir=opt$new_file_path
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
46 signal=opt$settingsSignal
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
47 settingsType=opt$settingsType
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
48 outputfigures=type.convert(opt$outputgraph)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
49 snp=type.convert(opt$settingsSnp)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
50 user=opt$userid
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
51 folds=as.numeric(opt$folds)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
52 loss=opt$settingsLoss
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
53 log=opt$log
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
54 outputlog=opt$outputlog
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
55 outputgraph=opt$outputgraph
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
56 pdffigures=opt$pdffigures
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
57 package=opt$settingsPackage
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
58
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
59
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
60 library(MPAgenomics)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
61 library(glmnet)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
62 library(spikeslab)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
63 library(lars)
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
64
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
65 inputDataset=read.table(file=dataset,stringsAsFactors=FALSE)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
66 input=inputDataset[1,2]
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
67 workdir=file.path(tmp_dir, "mpagenomics",user)
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
68 print(workdir)
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
69 setwd(workdir)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
70
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
71 if (grepl("all",tolower(chrom)) | chrom=="None") {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
72 chrom_vec=c(1:25)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
73 } else {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
74 chrom_tmp <- strsplit(chrom,",")
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
75 chrom_vecstring <-unlist(chrom_tmp)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
76 chrom_vec <- as.numeric(chrom_vecstring)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
77 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
78
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
79 if (outputlog){
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
80 sinklog <- file(log, open = "wt")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
81 sink(sinklog ,type = "output")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
82 sink(sinklog, type = "message")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
83 }
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
84
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
85 if (settingsType == "tumor") {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
86 if (signal=="CN") {
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
87 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, normalTumorArray=tumor, onlySNP=snp, loss=loss, plot=outputfigures, nbFolds=folds, pkg=package)
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
88 } else {
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
89 res=markerSelection(input,dataResponse, chromosome=chrom_vec,signal=signal,normalTumorArray=tumor, loss=loss, plot=outputfigures, nbFolds=folds,pkg=package)
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
90 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
91 } else {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
92 if (signal=="CN") {
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
93 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, onlySNP=snp, loss=loss, plot=outputfigures, nbFolds=folds,pkg=package)
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
94 } else {
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
95 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, loss=loss, plot=outputfigures, nbFolds=folds,pkg=package)
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
96 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
97 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
98
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
99 res
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
100
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
101 df=data.frame()
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
102 list_chr=names(res)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
103 markerSelected=FALSE
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
104
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
105 for (i in list_chr) {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
106 chr_data=res[[i]]
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
107 len=length(chr_data$markers.index)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
108 if (len != 0)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
109 {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
110 markerSelected=TRUE
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
111 chrdf=data.frame(rep(i,len),chr_data$markers.position,chr_data$markers.index,chr_data$markers.names,chr_data$coefficient)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
112 df=rbind(df,chrdf)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
113 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
114 }
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
115
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
116 if (outputgraph){
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
117 file.rename(file.path(tmp_dir,"mpagenomics",user,"Rplots.pdf"), pdffigures)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
118 }
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
119
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
120 if (outputlog){
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
121 sink(type="output")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
122 sink(type="message")
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
123 close(sinklog)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
124 }
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
125
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
126 if (markerSelected) {
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
127 colnames(df) <- c("chr","position","index","names","coefficient")
8
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
128 #sink(output)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
129 #print(format(df),row.names=FALSE)
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
130 #sink()
d5ed62b4d3ac planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233
sblanck
parents: 5
diff changeset
131 write.table(df,output,row.names = FALSE, quote = FALSE, sep = "\t")
5
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
132 } else
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
133 writeLines("no SNP selected", output)
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
134
af4f63f27c77 planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 11d660a2de749dae548b2fae0dd81f9f2b2c4b4f
sblanck
parents:
diff changeset
135