comparison preprocess_datasets/Affymetrix_Preprocessing.R @ 0:ebf6607b4e6a draft

Uploaded
author proteomisc
date Sat, 02 Dec 2023 14:15:26 +0000
parents
children a73997df371a
comparison
equal deleted inserted replaced
-1:000000000000 0:ebf6607b4e6a
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 suppressWarnings(suppressMessages(library(BiocInstaller)))
11 source_local <- function(fname){
12 argv <- commandArgs(trailingOnly = FALSE)
13 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
14 source(paste(base_dir, fname, sep="/"))
15 }
16 file_path <- function(fname){
17 argv <- commandArgs(trailingOnly = FALSE)
18 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
19 pato <- paste(base_dir, fname, sep="/")
20 return(pato)
21 }
22 base_dir <- function(){
23 argv <- commandArgs(trailingOnly = FALSE)
24 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8))
25 return(base_dir)
26 }
27 source_local("Affymetrix_Preprocessing_Functions.R")
28 listArguments = parseCommandArgs(evaluate=FALSE)
29 thefunctions=listArguments[["thefunctions"]]
30 listArguments[["thefunctions"]]=NULL
31 h=listArguments[["h"]]
32 listArguments[["h"]]=NULL
33 w=listArguments[["w"]]
34 listArguments[["w"]]=NULL
35 if (!is.null(listArguments[["image"]])){
36 load(listArguments[["image"]])
37 listArguments[["image"]]=NULL
38 }
39 listArguments[["path"]]=""
40 print(listArguments)
41 listArguments[["rawdata"]]=MicroArray_Object$affy_object
42 if(datasetsource=="intern"){
43 designo<-MicroArray_Object$designo
44 }
45
46 if(datasetsource=="extern"){
47 listArguments<-append(listArguments,list(datasetsource=datasetsource,listfullnames=listfullnames))
48 }
49 Prepro_object<-do.call(thefunctions,listArguments)
50 if(datasetsource=="extern"){
51 rownames(Prepro_object$data.bg@phenoData@data)<-listfullnames
52 colnames(exprs(Prepro_object$data.bg))<-listfullnames
53 colnames(exprs(Prepro_object$data.sm))<-listfullnames
54 colnames(exprs(Prepro_object$data.norm))<-listfullnames
55 colnames(exprs(Prepro_object$data.bg))<-listfullnames
56 colnames(exprs(Prepro_object$data.norm))<-listfullnames
57 rownames(Prepro_object$data.norm@phenoData@data)<-listfullnames
58 rownames(Prepro_object$data.norm@protocolData@data)<-listfullnames
59 }
60 par(las=2,mar=c(15,2,1,1))
61 png(filename ="boxplot_before_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white")
62 par(las=2,mar=c(15,2,1,1))
63 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))
64
65 dev.off()
66
67
68
69 par(las=2,mar=c(15,2,1,1))
70 png(filename ="boxplot_after_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white")
71 par(las=2,mar=c(15,2,1,1))
72 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))
73
74 dev.off()
75 png(filename ="MA_plot.png",width = w, height = h)
76 MAplot((Prepro_object$data.norm) ,
77 show.statistics = F, span = 2/3, family.loess = "gaussian",
78 cex = 2, plot.method = as.character("smoothScatter"),
79 azdd.loess = TRUE, lwd = 1, lty = 1, loess.col = "red")
80
81 dev.off()
82 png(filename = "densities_plot_before_NM.png",width = w, height = h)
83 plotDensities(exprs(Prepro_object$data.bg),log=T)
84 dev.off()
85
86 png(filename = "densities_plot_after_NM.png",width = w, height = h)
87 plotDensities(exprs(Prepro_object$data.norm),log=T)
88 dev.off()
89 AffymetrixRmd=file_path("Affymetrix.Rmd")
90 Style=file_path("look.css")
91 suppressWarnings(suppressMessages(knit2html(AffymetrixRmd,output="PreprocessingPlots.html",quiet = T, stylesheet=Style)))
92 rm(listArguments)
93 save.image("MicroArray.Preprocessing.RData")