annotate EBGeneMultiCondTest.R @ 15:58bb88f53765 draft

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