annotate EBIsoformMultiCondTest.R @ 9:c20070b11b55 draft

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