annotate EBGeneMultiCondTest.R @ 36:7be90b1366d5 draft

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