5
|
1 args<-commandArgs(TRUE)
|
|
2
|
|
3 chrom=args[1]
|
|
4 dataset=args[2]
|
|
5 output=args[3]
|
|
6 tmp_dir=args[4]
|
|
7 input=args[5]
|
|
8 tumorcsv=args[6]
|
|
9 signal=args[7]
|
|
10 snp=type.convert(args[8])
|
|
11 user=args[9]
|
|
12 symmetrize=args[10]
|
|
13
|
|
14 library(MPAgenomics)
|
|
15 workdir=file.path(tmp_dir, "mpagenomics",user)
|
|
16 setwd(workdir)
|
|
17
|
|
18
|
|
19 if (grepl("all",tolower(chrom)) | chrom=="None") {
|
|
20 chrom_vec=c(1:25)
|
|
21 } else {
|
|
22 chrom_tmp <- strsplit(chrom,",")
|
|
23 chrom_vecstring <-unlist(chrom_tmp)
|
|
24 chrom_vec <- as.numeric(chrom_vecstring)
|
|
25 }
|
|
26 if (signal == "CN")
|
|
27 {
|
|
28 if (input == "dataset") {
|
|
29 if (tumorcsv== "None")
|
|
30 {
|
|
31 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, onlySNP=snp)
|
|
32
|
|
33 } else {
|
|
34 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, onlySNP=snp)
|
|
35 }
|
|
36 } else {
|
|
37 input_tmp <- strsplit(input,",")
|
|
38 input_tmp_vecstring <-unlist(input_tmp)
|
|
39 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
|
|
40 if (tumorcsv== "None")
|
|
41 {
|
|
42 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, listOfFiles=input_vecstring, onlySNP=snp)
|
|
43 } else {
|
|
44 CN=getCopyNumberSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, listOfFiles=input_vecstring, onlySNP=snp )
|
|
45 }
|
|
46 }
|
|
47
|
|
48 list_chr=names(CN)
|
|
49 CN_global=data.frame(check.names = FALSE)
|
|
50 for (i in list_chr) {
|
|
51 chr_data=data.frame(CN[[i]],check.names = FALSE)
|
|
52 CN_global=rbind(CN_global,chr_data)
|
|
53 }
|
|
54 names(CN_global)[names(CN_global)=="featureNames"] <- "probeName"
|
|
55 write.table(format(CN_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
|
|
56
|
|
57 } else {
|
|
58 if (symmetrize=="TRUE") {
|
|
59 if (input == "dataset") {
|
|
60 input_vecstring = getListOfFiles(dataset)
|
|
61 } else {
|
|
62 input_tmp <- strsplit(input,",")
|
|
63 input_tmp_vecstring <-unlist(input_tmp)
|
|
64 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
|
|
65 }
|
|
66
|
|
67 symFracB_global=data.frame(check.names = FALSE)
|
|
68
|
|
69 for (currentFile in input_vecstring) {
|
|
70 cat(paste0("extracting signal from ",currentFile,".\n"))
|
|
71 currentSymFracB=data.frame()
|
|
72 symFracB=getSymFracBSignal(dataset,chromosome=chrom_vec,file=currentFile,normalTumorArray=tumorcsv)
|
|
73 list_chr=names(symFracB)
|
|
74 for (i in list_chr) {
|
|
75 cat(paste0(" extracting ",i,".\n"))
|
|
76 chr_data=data.frame(symFracB[[i]]$tumor,check.names = FALSE)
|
|
77 currentSymFracB=rbind(currentSymFracB,chr_data)
|
|
78
|
|
79 }
|
|
80 if (is.null(symFracB_global) || nrow(symFracB_global)==0) {
|
|
81 symFracB_global=currentSymFracB
|
|
82 } else {
|
|
83 symFracB_global=cbind(symFracB_global,currentFile=currentSymFracB[[3]])
|
|
84 }
|
|
85 }
|
|
86 names(symFracB_global)[names(symFracB_global)=="featureNames"] <- "probeName"
|
|
87
|
|
88 write.table(format(symFracB_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
|
|
89 } else {
|
|
90 if (input == "dataset") {
|
|
91 if (tumorcsv== "None")
|
|
92 {
|
|
93 fracB=getFracBSignal(dataset,chromosome=chrom_vec)
|
|
94
|
|
95 } else {
|
|
96 fracB=getFracBSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv)
|
|
97 }
|
|
98 } else {
|
|
99 input_tmp <- strsplit(input,",")
|
|
100 input_tmp_vecstring <-unlist(input_tmp)
|
|
101 input_vecstring = sub("^([^.]*).*", "\\1", input_tmp_vecstring)
|
|
102 if (tumorcsv== "None")
|
|
103 {
|
|
104 fracB=getFracBSignal(dataset,chromosome=chrom_vec, listOfFiles=input_vecstring)
|
|
105 } else {
|
|
106 fracB=getFracBSignal(dataset,chromosome=chrom_vec, normalTumorArray=tumorcsv, listOfFiles=input_vecstring)
|
|
107 }
|
|
108 }
|
|
109 #formatage des données
|
|
110 list_chr=names(fracB)
|
|
111 fracB_global=data.frame(check.names = FALSE)
|
|
112 for (i in list_chr) {
|
|
113 chr_data=data.frame(fracB[[i]]$tumor,check.names = FALSE)
|
|
114 fracB_global=rbind(fracB_global,chr_data)
|
|
115 }
|
|
116 names(fracB_global)[names(fracB_global)=="featureNames"] <- "probeName"
|
|
117 write.table(format(fracB_global), output, row.names = FALSE, quote = FALSE, sep = "\t")
|
|
118 }
|
|
119
|
|
120 } |