0
|
1 options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)})
|
|
2 sink(stdout(), type = "message")
|
|
3 suppressWarnings(suppressMessages(library(affy)))
|
|
4 suppressWarnings(suppressMessages(library(affyPLM)))
|
|
5 suppressWarnings(suppressMessages(library(batch)))
|
|
6 suppressWarnings(suppressMessages(library(annotate)))
|
|
7 suppressWarnings(suppressMessages(library(limma)))
|
|
8 suppressWarnings(suppressMessages(library(markdown)))
|
|
9 suppressWarnings(suppressMessages(library(knitr)))
|
|
10 source_local <- function(fname){
|
|
11 argv <- commandArgs(trailingOnly = FALSE)
|
|
12 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
|
|
13 source(paste(base_dir, fname, sep="/"))
|
|
14 }
|
|
15 file_path <- function(fname){
|
|
16 argv <- commandArgs(trailingOnly = FALSE)
|
|
17 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
|
|
18 pato <- paste(base_dir, fname, sep="/")
|
|
19 return(pato)
|
|
20 }
|
|
21 base_dir <- function(){
|
|
22 argv <- commandArgs(trailingOnly = FALSE)
|
|
23 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
|
|
24 return(base_dir)
|
|
25 }
|
|
26 source_local("Affymetrix_Preprocessing_Functions.R")
|
|
27 listArguments = parseCommandArgs(evaluate=FALSE)
|
|
28 thefunctions=listArguments[["thefunctions"]]
|
|
29 listArguments[["thefunctions"]]=NULL
|
|
30 h=listArguments[["h"]]
|
|
31 listArguments[["h"]]=NULL
|
|
32 w=listArguments[["w"]]
|
|
33 listArguments[["w"]]=NULL
|
|
34 if (!is.null(listArguments[["image"]])){
|
|
35 load(listArguments[["image"]])
|
|
36 listArguments[["image"]]=NULL
|
|
37 }
|
|
38 listArguments[["rawdata"]]=MicroArray_Object$affy_object
|
|
39 if(datasetsource=="intern"){
|
|
40 designo<-MicroArray_Object$designo
|
|
41 }
|
|
42
|
|
43 if(datasetsource=="extern"){
|
|
44 listArguments<-append(listArguments,list(datasetsource=datasetsource,listfullnames=listfullnames))
|
|
45 }
|
|
46 Prepro_object<-do.call(thefunctions,listArguments)
|
|
47 if(datasetsource=="extern"){
|
|
48 rownames(Prepro_object$data.bg@phenoData@data)<-listfullnames
|
|
49 colnames(exprs(Prepro_object$data.bg))<-listfullnames
|
|
50 colnames(exprs(Prepro_object$data.sm))<-listfullnames
|
|
51 colnames(exprs(Prepro_object$data.norm))<-listfullnames
|
|
52 colnames(exprs(Prepro_object$data.bg))<-listfullnames
|
|
53 colnames(exprs(Prepro_object$data.norm))<-listfullnames
|
|
54 rownames(Prepro_object$data.norm@phenoData@data)<-listfullnames
|
|
55 rownames(Prepro_object$data.norm@protocolData@data)<-listfullnames
|
|
56 }
|
|
57 par(las=2,mar=c(15,2,1,1))
|
|
58 png(filename ="boxplot_before_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white")
|
|
59 par(las=2,mar=c(15,2,1,1))
|
|
60 boxplot((na.omit(as.data.frame(exprs(Prepro_object$data.bg)))), main="Boxplot of intensities before Normalization",col="red",las=2,mar=c(15,2,1,1))
|
|
61
|
|
62 dev.off()
|
|
63
|
|
64
|
|
65
|
|
66 par(las=2,mar=c(15,2,1,1))
|
|
67 png(filename ="boxplot_after_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white")
|
|
68 par(las=2,mar=c(15,2,1,1))
|
|
69 boxplot((na.omit(as.data.frame(exprs(Prepro_object$data.sm)))), main="Boxplot of intensities After Normalization",col="red",ylab="(intensities)",las=2,mar=c(15,2,1,1))
|
|
70
|
|
71 dev.off()
|
|
72 png(filename ="MA_plot.png",width = w, height = h)
|
|
73 MAplot((Prepro_object$data.norm) ,
|
|
74 show.statistics = F, span = 2/3, family.loess = "gaussian",
|
|
75 cex = 2, plot.method = as.character("smoothScatter"),
|
|
76 azdd.loess = TRUE, lwd = 1, lty = 1, loess.col = "red")
|
|
77
|
|
78 dev.off()
|
|
79 png(filename = "densities_plot_before_NM.png",width = w, height = h)
|
|
80 plotDensities(exprs(Prepro_object$data.bg),log=T)
|
|
81 dev.off()
|
|
82
|
|
83 png(filename = "densities_plot_after_NM.png",width = w, height = h)
|
|
84 plotDensities(exprs(Prepro_object$data.norm),log=T)
|
|
85 dev.off()
|
|
86 AffymetrixRmd=file_path("Affymetrix.Rmd")
|
|
87 Style=file_path("look.css")
|
|
88 suppressWarnings(suppressMessages(knit2html(AffymetrixRmd,output="PreprocessingPlots.html",quiet = T, stylesheet=Style)))
|
|
89 rm(listArguments)
|
|
90 save.image("MicroArray.Preprocessing.RData")
|