comparison EBGeneMultiCondTest.R @ 32:d049be55e5cf draft

Uploaded
author ning
date Mon, 16 Jun 2014 16:22:13 -0400
parents
children
comparison
equal deleted inserted replaced
31:4b2731768f01 32:d049be55e5cf
1 sink(file="/tmp/none")
2 sink("/dev/null")
3 options(warn=-1)
4 options(echo=F)
5
6 invisible("EBSeq")
7 suppressMessages(library("EBSeq"))
8
9 args <- commandArgs(trailingOnly = T)
10 inputfile <- args[1]
11 WhetherSampleName <- args[2]
12 CondIn <- args[3]
13 PatternFile <- args[4]
14 outputfile <- args[5]
15 MAP.out<-args[6]
16 Sizesout <-args[7]
17
18 #write.table(PatternFile,outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
19
20 #write.table(args,outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
21
22 Conditions=strsplit(CondIn,split=",")[[1]]
23
24 if(WhetherSampleName=="y"){
25 ReadIn=read.table(inputfile,stringsAsFactors=F,header=T, sep="\t")
26 Names=names(ReadIn)[-1]
27 }
28 if(WhetherSampleName=="n"){
29 ReadIn=read.table(inputfile,stringsAsFactors=F,header=F, sep="\t")
30 Names=paste0("S",1:length(Conditions))
31 }
32
33 #PatternIn=read.table(PatternFile,stringsAsFactors=F,header=T,sep="\t")
34 PatternIn=read.table(PatternFile,stringsAsFactors=F,header=T,sep="\t",row.names=1) ##cms - changed on 11/15/13
35
36 if(class(ReadIn[[1]])=="character"){
37 GeneMat=do.call(cbind,ReadIn[-1])
38 rownames(GeneMat)=ReadIn[[1]]
39 colnames(GeneMat)=Names
40 }
41 if(class(ReadIn[[1]])=="numeric"){
42 GeneMat=data.matrix(ReadIn)
43 colnames(GeneMat)=Names
44 }
45
46 Patterns=data.matrix(PatternIn)
47
48
49 Sizes=MedianNorm(GeneMat)
50 EBOut=EBMultiTest(Data=GeneMat,Conditions=as.factor(Conditions),
51 AllParti=Patterns,sizeFactors=Sizes, maxround=5)
52 PPout=GetMultiPP(EBOut)
53 MultiPP=PPout$PP
54 MultiMAP=PPout$MAP
55 Data.norm=round(GetNormalizedMat(GeneMat, Sizes),2)
56
57 Mat=cbind(MultiMAP,Data.norm[names(MultiMAP),])
58
59 colnames(Mat)=
60 c("MAP",Names)
61 options(warn=-1)
62
63 #write.table(round(MultiPP,2),file=outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
64 write.table(round(MultiPP,2),file=outputfile,quote=F,col.names=NA,row.names=T,sep = "\t") ##cms - changed on 11/15/13
65 #write.table(Mat,file=MAP.out ,quote=F,col.names=T,row.names=T,sep = "\t")
66 write.table(Mat,file=MAP.out ,quote=F,col.names=NA,row.names=T,sep = "\t") ##cms - changed on 11/15/13
67 write.table(Sizes,file=Sizesout,quote=F,col.names=F,row.names=F,sep = "\t")
68