2
|
1 library(Biobase)
|
|
2 library(GEOquery)
|
|
3 library(GEOmetadb)
|
|
4 library(limma)
|
|
5 library(jsonlite)
|
|
6 library(affy)
|
|
7 library(dplyr)
|
|
8 library(affyPLM)
|
|
9
|
|
10 cargs<-commandArgs()
|
|
11 cargs<-cargs[(which(cargs=="--args")+1):length(cargs)]
|
|
12 nbargs=length(cargs)
|
|
13
|
|
14 dataFile=cargs[[nbargs-9]]
|
|
15 normalization=cargs[[nbargs-8]]
|
|
16 conditionsFile=cargs[[nbargs-7]]
|
|
17 annotation=cargs[[nbargs-6]]
|
|
18 result_export_eset=cargs[[nbargs-5]]
|
|
19 result=cargs[[nbargs-4]]
|
|
20 result.path=cargs[[nbargs-3]]
|
|
21 result.template=cargs[[nbargs-2]]
|
|
22
|
|
23 dir.create(result.path, showWarnings = TRUE, recursive = FALSE)
|
|
24
|
|
25 data=as.matrix(read.table(file = dataFile))
|
|
26 conditions=read.table(file=conditionsFile,sep = "\t",row.names=1)
|
|
27 htmlfile=readChar(result.template, file.info(result.template)$size)
|
|
28
|
|
29 colnames(conditions)=c("source_name_ch1","description")
|
|
30 phenodata<-new("AnnotatedDataFrame",data=conditions)
|
|
31
|
|
32 eset=ExpressionSet(assayData=data,phenoData=phenodata,annotation=annotation)
|
|
33
|
|
34 if (normalization == "quantile") {
|
|
35 eset <- normalize.ExpressionSet.quantiles(eset, transfn="log")
|
|
36 } else if (normalization == "log2") {
|
|
37 exprs(eset) = log2(exprs(eset))
|
|
38 }
|
|
39
|
|
40 boxplotnorm="boxplotnorm.png"
|
|
41 png(boxplotnorm,width=800,height = 400)
|
|
42 par(mar=c(7,5,1,1))
|
|
43 boxplot(data.frame(exprs(eset)),las=2,outline=FALSE)
|
|
44 dev.off()
|
|
45 htmlfile=gsub(x=htmlfile,pattern = "###BOXPLOTNORM###",replacement = boxplotnorm, fixed = TRUE)
|
|
46 file.copy(boxplotnorm,result.path)
|
|
47
|
|
48 plotMAnorm="plotMAnorm.png"
|
|
49 nblines=length(colnames(data))%/%3 + as.numeric((length(colnames(data))%%3)!=0)
|
|
50 png(plotMAnorm,width=800,height =300*nblines )
|
|
51 par(mfrow=c(nblines,3))
|
|
52 #for (i in 1:length(colnames(data))){
|
|
53 MAplot(eset)
|
|
54 #}
|
|
55
|
|
56 dev.off()
|
|
57 htmlfile=gsub(x=htmlfile,pattern = "###PLOTMANORM###",replacement = plotMAnorm, fixed = TRUE)
|
|
58 file.copy(plotMAnorm,result.path)
|
|
59 #write.table(tolower(c(condition1Name,condition2Name)),quote = FALSE,col.names = FALSE, row.names=FALSE,file=result_export_conditions)
|
|
60 #saveConditions=c(condition1Name,condition2Name)
|
|
61 save(eset,file=result_export_eset)
|
|
62 write(htmlfile,result)
|
|
63
|
|
64 #l=list()
|
|
65 #for(i in 1:length(esets))
|
|
66 #{
|
|
67 # l[[paste("study",i,sep="")]]<-res[[i]]
|
|
68 #}
|
|
69 #l[["Meta"]]=res[[length(res)-1]]
|
|
70 #showVenn(res,file.path(temp.files.path,"venn.png"))
|
|
71 #writeLines(c("<h2>Venn diagram</h2>"),file.conn)
|
|
72 #writeLines(c("<img src='venn.png'><br/><br/>"),file.conn)
|
|
73 #writeLines(c("</body></html>"),file.conn)
|
|
74 #close(file.conn) |