annotate EBIsoformMultiCondTest.R @ 45:9bebd9fd9f1b draft default tip

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