Mercurial > repos > ning > ebseq
view EBGeneMultiCondTest.R @ 16:7218b8ff560e draft
Uploaded
author | ning |
---|---|
date | Fri, 15 Mar 2013 18:56:03 -0400 |
parents | 4d6d52fafb86 |
children |
line wrap: on
line source
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[4] outputfile <- args[5] MAP.out<-args[6] Sizesout <-args[7] #write.table(PatternFile,outputfile,quote=F,col.names=T,row.names=T,sep = "\t") #write.table(args,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") 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) EBOut=EBMultiTest(Data=GeneMat,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")