comparison AffyQCnormalization.R @ 2:93451f832736 draft

Uploaded
author sblanck
date Tue, 21 Mar 2017 10:28:47 -0400
parents
children 7f74250a083d
comparison
equal deleted inserted replaced
1:f8a2f1fec8ef 2:93451f832736
1 library(Biobase)
2 library(GEOquery)
3 library(GEOmetadb)
4 library(limma)
5 library(jsonlite)
6 library(affy)
7 library(affyPLM)
8 library(dplyr)
9
10 cargs<-commandArgs()
11 cargs<-cargs[(which(cargs=="--args")+1):length(cargs)]
12 nbargs=length(cargs)
13 celList=vector()
14 celFileNameList=vector()
15 for (i in seq(1,nbargs-7,2))
16 {
17 celList=c(celList,cargs[[i]])
18 celFileNameList=c(celFileNameList,cargs[[i+1]])
19 }
20
21
22 normalization=cargs[[nbargs-6]]
23 result_export_eset=cargs[[nbargs-5]]
24 result=cargs[[nbargs-4]]
25 result.path=cargs[[nbargs-3]]
26 result.template=cargs[[nbargs-2]]
27
28 dir.create(result.path, showWarnings = TRUE, recursive = TRUE)
29 for(i in 1:length(celList))
30 {
31 file.copy(celList[i],paste0("./",celFileNameList[i]))
32 }
33
34 data <- ReadAffy(filenames=celFileNameList, celfile.path=".")
35 htmlfile=readChar(result.template, file.info(result.template)$size)
36
37 boxplot="boxplot.png"
38 png(boxplot,width=800,height = 400)
39 par(mar=c(7,5,1,1))
40 boxplot(data,las=2,outline=FALSE)
41 dev.off()
42 htmlfile=gsub(x=htmlfile,pattern = "###BOXPLOT###",replacement = boxplot, fixed = TRUE)
43 file.copy(boxplot,result.path)
44
45 images="images.png"
46 nblines=length(celList)%/%4 + as.numeric((length(celList)%%4)!=0)
47 png(images,width=800,height = 200*nblines)
48 par(mfrow=c(nblines,4))
49 image(data)
50 dev.off()
51 htmlfile=gsub(x=htmlfile,pattern = "###IMAGES###",replacement = images, fixed = TRUE)
52 file.copy(images,result.path)
53
54
55 plotMA="plotMA.png"
56 nblines=length(celList)%/%3 + as.numeric((length(celList)%%3)!=0)
57 png(plotMA,width=800,height =300*nblines )
58 par(mfrow=c(nblines,3))
59 MAplot(data)
60 dev.off()
61 htmlfile=gsub(x=htmlfile,pattern = "###PLOTMA###",replacement = plotMA, fixed = TRUE)
62 file.copy(plotMA,result.path)
63
64
65 if (normalization == "rma") {
66 eset <- rma(data)
67 } else if (normalization == "quantile") {
68 eset = rma(data,background = FALSE,normalize = TRUE)
69 } else if (normalization == "background"){
70 eset = rma(data,background = TRUE ,normalize = FALSE)
71 } else if (normalization == "log2") {
72 eset = rma(data,background = FALSE ,normalize = FALSE)
73 }
74
75
76 boxplotnorm="boxplotnorm.png"
77 png(boxplotnorm,width=800,height = 400)
78 par(mar=c(7,5,1,1))
79 boxplot(data.frame(exprs(eset)),las=2,outline=FALSE)
80 dev.off()
81 htmlfile=gsub(x=htmlfile,pattern = "###BOXPLOTNORM###",replacement = boxplotnorm, fixed = TRUE)
82 file.copy(boxplotnorm,result.path)
83
84 plotMAnorm="plotMAnorm.png"
85 nblines=length(celList)%/%3 + as.numeric((length(celList)%%3)!=0)
86 png(plotMAnorm,width=800,height =300*nblines )
87 par(mfrow=c(nblines,3))
88 #for (i in 1:length(celList)){
89 MAplot(eset)
90 #}
91
92 dev.off()
93 htmlfile=gsub(x=htmlfile,pattern = "###PLOTMANORM###",replacement = plotMAnorm, fixed = TRUE)
94 file.copy(plotMAnorm,result.path)
95 #write.table(tolower(c(condition1Name,condition2Name)),quote = FALSE,col.names = FALSE, row.names=FALSE,file=result_export_conditions)
96 #saveConditions=c(condition1Name,condition2Name)
97 save(eset,file=result_export_eset)
98 write(htmlfile,result)
99
100 #l=list()
101 #for(i in 1:length(esets))
102 #{
103 # l[[paste("study",i,sep="")]]<-res[[i]]
104 #}
105 #l[["Meta"]]=res[[length(res)-1]]
106 #showVenn(res,file.path(temp.files.path,"venn.png"))
107 #writeLines(c("<h2>Venn diagram</h2>"),file.conn)
108 #writeLines(c("<img src='venn.png'><br/><br/>"),file.conn)
109 #writeLines(c("</body></html>"),file.conn)
110 #close(file.conn)