annotate extractCN.R @ 0:4d539083cf7f draft

planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
author sblanck
date Tue, 12 May 2020 10:40:36 -0400
parents
children 3fcbb8030fcc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
1 #!/usr/bin/env Rscript
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
2 # setup R error handling to go to stderr
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
3 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
4
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
5 # we need that to not crash galaxy with an UTF8 error on German LC settings.
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
6 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
7
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
8 library("optparse")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
9
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
10 ##### Read options
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
11 option_list=list(
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
12 make_option("--chrom",type="character",default=NULL, dest="chrom"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
13 make_option("--input",type="character",default=NULL, dest="input"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
14 make_option("--output",type="character",default=NULL, dest="output"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
15 make_option("--new_file_path",type="character",default=NULL, dest="new_file_path"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
16 make_option("--settings_type",type="character",default=NULL, dest="settings_type"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
17 make_option("--settings_tumor",type="character",default=NULL, dest="settings_tumor"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
18 make_option("--symmetrize",type="character",default=NULL, dest="symmetrize"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
19 make_option("--settings_signal",type="character",default=NULL, dest="settings_signal"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
20 make_option("--settings_snp",type="character",default=NULL, dest="settings_snp"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
21 make_option("--outputlog",type="character",default=NULL, dest="outputlog"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
22 make_option("--log",type="character",default=NULL, dest="log"),
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
23 make_option("--userid",type="character",default=NULL, dest="userid")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
24 );
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
25
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
26 opt_parser = OptionParser(option_list=option_list);
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
27 opt = parse_args(opt_parser);
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
28
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
29 if(is.null(opt$input)){
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
30 print_help(opt_parser)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
31 stop("input required.", call.=FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
32 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
33
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
34 #loading libraries
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
35
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
36 chrom=opt$chrom
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
37 input=opt$input
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
38 tmp_dir=opt$new_file_path
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
39 output=opt$output
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
40 settingsType=opt$settings_type
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
41 tumorcsv=opt$settings_tumor
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
42 symmetrize=opt$symmetrize
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
43 signal=opt$settings_signal
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
44 snp=type.convert(opt$settings_snp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
45 outputlog=opt$outputlog
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
46 log=opt$log
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
47 user=opt$userid
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
48
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
49 library(MPAgenomics)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
50 workdir=file.path(tmp_dir, "mpagenomics",user)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
51 setwd(workdir)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
52
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
53 inputDataset=read.table(file=input,stringsAsFactors=FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
54 dataset=inputDataset[1,2]
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
55
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
56 if (outputlog){
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
57 sinklog <- file(log, open = "wt")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
58 sink(sinklog ,type = "output")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
59 sink(sinklog, type = "message")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
60 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
61
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
62
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
63 if (grepl("all",tolower(chrom)) | chrom=="None") {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
64 chrom_vec=c(1:25)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
65 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
66 chrom_tmp <- strsplit(chrom,",")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
67 chrom_vecstring <-unlist(chrom_tmp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
68 chrom_vec <- as.numeric(chrom_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
69 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
70 if (signal == "CN")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
71 {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
72 if (settingsType == "dataset") {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
73 if (tumorcsv== "None")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
74 {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
75 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, onlySNP=snp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
76
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
77 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
78 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, onlySNP=snp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
79 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
80 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
81 input_tmp <- strsplit(settingsType,",")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
82 input_tmp_vecstring <-unlist(input_tmp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
83 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
84 if (tumorcsv== "None")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
85 {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
86 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, listOfFiles=input_vecstring, onlySNP=snp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
87 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
88 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, listOfFiles=input_vecstring, onlySNP=snp )
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
89 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
90 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
91
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
92 list_chr=names(CN)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
93 CN_global=data.frame(check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
94 for (i in list_chr) {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
95 chr_data=data.frame(CN[[i]],check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
96 CN_global=rbind(CN_global,chr_data)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
97 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
98 names(CN_global)[names(CN_global)=="featureNames"] <- "probeName"
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
99 write.table(format(CN_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
100
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
101 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
102 if (symmetrize=="TRUE") {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
103 if (settingsType == "dataset") {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
104 input_vecstring = getListOfFiles(dataset)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
105 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
106 input_tmp <- strsplit(settingsType,",")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
107 input_tmp_vecstring <-unlist(input_tmp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
108 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
109 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
110
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
111 symFracB_global=data.frame(check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
112
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
113 for (currentFile in input_vecstring) {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
114 cat(paste0("extracting signal from ",currentFile,".\n"))
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
115 currentSymFracB=data.frame()
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
116 symFracB=getSymFracBSignal(dataset,chromosome=chrom_vec,file=currentFile,normalTumorArray=tumorcsv)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
117 list_chr=names(symFracB)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
118 for (i in list_chr) {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
119 cat(paste0(" extracting ",i,".\n"))
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
120 chr_data=data.frame(symFracB[[i]]$tumor,check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
121 currentSymFracB=rbind(currentSymFracB,chr_data)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
122
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
123 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
124 if (is.null(symFracB_global) || nrow(symFracB_global)==0) {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
125 symFracB_global=currentSymFracB
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
126 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
127 symFracB_global=cbind(symFracB_global,currentFile=currentSymFracB[[3]])
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
128 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
129 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
130 names(symFracB_global)[names(symFracB_global)=="featureNames"] <- "probeName"
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
131
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
132 write.table(format(symFracB_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
133 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
134 if (settingsType == "dataset") {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
135 if (tumorcsv== "None")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
136 {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
137 fracB=getFracBSignal(dataset,chromosome=chrom_vec)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
138
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
139 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
140 fracB=getFracBSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
141 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
142 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
143 input_tmp <- strsplit(settingsType,",")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
144 input_tmp_vecstring <-unlist(input_tmp)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
145 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
146 if (tumorcsv== "None")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
147 {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
148 fracB=getFracBSignal(dataset,chromosome=chrom_vec, listOfFiles=input_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
149 } else {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
150 fracB=getFracBSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, listOfFiles=input_vecstring)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
151 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
152 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
153 #formatage des données
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
154 list_chr=names(fracB)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
155 fracB_global=data.frame(check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
156 for (i in list_chr) {
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
157 chr_data=data.frame(fracB[[i]]$tumor,check.names = FALSE)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
158 fracB_global=rbind(fracB_global,chr_data)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
159 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
160 names(fracB_global)[names(fracB_global)=="featureNames"] <- "probeName"
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
161 write.table(format(fracB_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
162 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
163
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
164 }
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
165
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
166 if (outputlog){
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
167 sink(type="output")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
168 sink(type="message")
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
169 close(sinklog)
4d539083cf7f planemo upload for repository https://github.com/sblanck/MPAgenomics4Galaxy/tree/master/mpagenomics_wrappers commit 689d0d8dc899a683ee18700ef385753559850233-dirty
sblanck
parents:
diff changeset
170 }