diff EBIsoformMultiCondTest.R @ 9:c20070b11b55 draft

Uploaded
author ning
date Fri, 15 Mar 2013 18:22:24 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EBIsoformMultiCondTest.R	Fri Mar 15 18:22:24 2013 -0400
@@ -0,0 +1,66 @@
+sink(file="/tmp/none")
+sink("/dev/null")
+options(warn=-1)
+options(echo=F) 
+
+invisible("EBSeq")
+suppressMessages(library("EBSeq"))
+
+args <- commandArgs(trailingOnly = T)
+inputfile <- args[1]
+WhetherSampleName <- args[2]
+CondIn <- args[3]
+PatternFile <- args[5]
+Ig.file <- args[4]
+outputfile <- args[6]
+MAP.out<-args[7]
+Sizesout <-args[8]
+
+#write.table(args,file=outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
+
+
+Conditions=strsplit(CondIn,split=",")[[1]]
+if(WhetherSampleName=="y"){
+	ReadIn=read.table(inputfile,stringsAsFactors=F,header=T, sep="\t")
+	Names=names(ReadIn)[-1]
+	}
+if(WhetherSampleName=="n"){
+	ReadIn=read.table(inputfile,stringsAsFactors=F,header=F, sep="\t")
+	Names=paste0("S",1:length(Conditions))
+}
+
+PatternIn=read.table(PatternFile,stringsAsFactors=F,header=T,sep="\t")
+IgVIn=read.table(Ig.file,stringsAsFactors=F,header=F,sep="\t")
+IgV=IgVIn[[1]]
+
+if(class(ReadIn[[1]])=="character"){
+	GeneMat=do.call(cbind,ReadIn[-1])
+	rownames(GeneMat)=ReadIn[[1]]
+	colnames(GeneMat)=Names
+}
+if(class(ReadIn[[1]])=="numeric"){
+	GeneMat=data.matrix(ReadIn)
+	colnames(GeneMat)=Names
+	}
+
+Patterns=data.matrix(PatternIn)
+
+Sizes=MedianNorm(GeneMat)
+#write.table(Conditions,file=outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
+EBOut=EBMultiTest(Data=GeneMat,NgVector=IgV,Conditions=as.factor(Conditions),
+			AllParti=Patterns,sizeFactors=Sizes, maxround=5)
+PPout=GetMultiPP(EBOut)
+MultiPP=PPout$PP
+MultiMAP=PPout$MAP
+Data.norm=round(GetNormalizedMat(GeneMat, Sizes),2)
+
+Mat=cbind(MultiMAP,Data.norm[names(MultiMAP),])
+
+colnames(Mat)=
+c("MAP",Names)
+options(warn=-1)
+
+write.table(round(MultiPP,2),file=outputfile,quote=F,col.names=T,row.names=T,sep = "\t")
+write.table(Mat,file=MAP.out ,quote=F,col.names=T,row.names=T,sep = "\t")
+write.table(Sizes,file=Sizesout,quote=F,col.names=F,row.names=F,sep = "\t")
+