view read_make_design_datasets/Make_Design.R @ 1:af310a65590b draft default tip

Deleted selected files
author proteomisc
date Fri, 01 Dec 2023 09:59:11 +0000
parents fda6b789e267
children
line wrap: on
line source

options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)})
sink(stdout(), type = "message")
suppressWarnings(suppressMessages(library("batch")))
suppressWarnings(suppressMessages(library(tools)))
listArguments = parseCommandArgs(evaluate=FALSE)
print(listArguments)
technology = listArguments[["technology"]]
designway = listArguments[["designway"]]
listArguments[["designway"]]<-NULL
listArguments[["technology"]]<-NULL
listcelsfullpath=c()
listfullnames=c()
listcelsnames=c("sample")
listgroup=c("group")
designpath =""
designo=c()
currentgroup=""
ingroup=F
names(listArguments)
if(designway=="makeit"){
	for (name in names(listArguments)) {
        print(name) 
        if(!is.na(pmatch("group",name))){
                currentgroup=listArguments[[name]]
    	} 
    	if(!is.na(pmatch("rank",name))){
                listcelsnames=c(listcelsnames,file_path_sans_ext(basename(listArguments[[name]]))) 
               listfullnames=c(listfullnames,basename(listArguments[[name]]))
		  listgroup=c(listgroup,currentgroup)
    	}
        if(!is.na(pmatch("file",name))){

                listcelsfullpath=c(listcelsfullpath,listArguments[[name]]) 
    	} 
        
	}
	write.table(format(cbind(listcelsnames,listgroup), justify="right"),sep="\t", quote=FALSE,
            row.names=F, col.names=F,file="Imported.DataSet.Design.tsv")
       designo <- as.data.frame(cbind(listcelsnames[-1],listgroup[-1],deparse.level = 0),colnames=c("sample","group"))
        colnames(designo)<-c("sample","group")
	

}else{

	designpath =listArguments[["designfile"]] 
       listArguments[["designfile"]]<-NULL
	designo <- read.table(designpath,header = TRUE)
	for (name in names(listArguments)) {
    	if(!is.na(pmatch("rank",name))){
                listcelsnames=c(listcelsnames,file_path_sans_ext(basename(listArguments[[name]]))) 
                listfullnames=c(listfullnames,basename(listArguments[[name]]))
    	}
        if(!is.na(pmatch("file",name))){
                listcelsfullpath=c(listcelsfullpath,listArguments[[name]]) 
    	} 
	}
}
rm(listArguments)
save.image(paste("Imported.Project.Information","RData",sep="."))