Mercurial > repos > sblanck > mpagenomics_normalize
comparison selection.R @ 6:7dc6ce39fb89 default tip
add selection tool
author | blanck |
---|---|
date | Wed, 29 Apr 2015 10:08:52 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:b7f3854e08f8 | 6:7dc6ce39fb89 |
---|---|
1 args<-commandArgs(TRUE) | |
2 | |
3 input=args[1] | |
4 dataResponse=args[2] | |
5 chrom=args[3] | |
6 tmp_dir=args[4] | |
7 signal=args[5] | |
8 snp=type.convert(args[6]) | |
9 settingsType=args[7] | |
10 tumor=args[8] | |
11 fold=as.integer(args[9]) | |
12 loss=args[10] | |
13 plot=type.convert(args[11]) | |
14 output=args[12] | |
15 user=args[13] | |
16 package=args[14] | |
17 | |
18 | |
19 library(MPAgenomics) | |
20 library(glmnet) | |
21 library(spikeslab) | |
22 library(lars) | |
23 workdir=file.path(tmp_dir, "mpagenomics",user) | |
24 setwd(workdir) | |
25 | |
26 if (grepl("all",tolower(chrom)) | chrom=="None") { | |
27 chrom_vec=c(1:25) | |
28 } else { | |
29 chrom_tmp <- strsplit(chrom,",") | |
30 chrom_vecstring <-unlist(chrom_tmp) | |
31 chrom_vec <- as.numeric(chrom_vecstring) | |
32 } | |
33 | |
34 | |
35 if (settingsType == "tumor") { | |
36 if (signal=="CN") { | |
37 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, normalTumorArray=tumor, onlySNP=snp, loss=loss, plot=plot, nbFolds=fold, pkg=package) | |
38 } else { | |
39 res=markerSelection(input,dataResponse, chromosome=chrom_vec,signal=signal,normalTumorArray=tumor, loss=loss, plot=plot, nbFolds=fold,pkg=package) | |
40 } | |
41 } else { | |
42 if (signal=="CN") { | |
43 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, onlySNP=snp, loss=loss, plot=plot, nbFolds=fold,pkg=package) | |
44 } else { | |
45 res=markerSelection(input,dataResponse, chromosome=chrom_vec, signal=signal, loss=loss, plot=plot, nbFolds=fold,pkg=package) | |
46 } | |
47 } | |
48 | |
49 res | |
50 | |
51 df=data.frame() | |
52 list_chr=names(res) | |
53 markerSelected=FALSE | |
54 | |
55 for (i in list_chr) { | |
56 chr_data=res[[i]] | |
57 len=length(chr_data$markers.index) | |
58 if (len != 0) | |
59 { | |
60 markerSelected=TRUE | |
61 chrdf=data.frame(rep(i,len),chr_data$markers.position,chr_data$markers.index,chr_data$markers.names,chr_data$coefficient) | |
62 df=rbind(df,chrdf) | |
63 } | |
64 } | |
65 | |
66 if (markerSelected) { | |
67 colnames(df) <- c("chr","position","index","names","coefficient") | |
68 sink(output) | |
69 print(format(df),row.names=FALSE) | |
70 sink() | |
71 #write.table(df,output,row.names = FALSE, quote = FALSE, sep = "\t") | |
72 } else | |
73 writeLines("no SNP selected", output) | |
74 | |
75 |