annotate mpagenomics_normalize-7dc6ce39fb89/markersSelection.R @ 0:84b13b0e2b85

Uploaded
author sblanck
date Thu, 07 May 2015 08:22:36 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
1 args<-commandArgs(TRUE)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
2
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
3 input=args[1]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
4 response=args[2]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
5 tmp_dir=args[3]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
6 nbFolds=as.numeric(args[4])
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
7 loss=args[5]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
8 output=args[6]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
9
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
10 library(MPAgenomics)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
11 workdir=file.path(tmp_dir, "mpagenomics")
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
12 setwd(workdir)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
13
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
14 CN=read.table(input,header=TRUE,check.names=FALSE)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
15 drops=c("chromosome","position","probeName")
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
16 CNsignal=CN[,!(names(CN)%in% drops)]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
17 samples=names(CNsignal)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
18 CNsignalMatrix=t(data.matrix(CNsignal))
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
19 resp=read.table(response,header=TRUE,sep=",")
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
20 listOfFile=resp[[1]]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
21 responseValue=resp[[2]]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
22 index = match(listOfFile,rownames(CNsignalMatrix))
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
23 responseValueOrder=responseValue[index]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
24
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
25 result=variableSelection(CNsignalMatrix,responseValueOrder,nbFolds=nbFolds,loss=loss,plot=TRUE)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
26
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
27 CNsignalResult=CN[result$markers.index,(names(CN)%in% drops)]
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
28
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
29 CNsignalResult["coefficient"]=result$coefficient
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
30 CNsignalResult["index"]=result$markers.index
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
31
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
32 sink(output)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
33 print(format(CNsignalResult),row.names=FALSE)
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
34 sink()
84b13b0e2b85 Uploaded
sblanck
parents:
diff changeset
35 #write.table(CNsignalResult,output,row.names = FALSE, quote=FALSE, sep = "\t")