Mercurial > repos > proteomisc > preprocess_dataset
comparison preprocess_datasets/Affymetrix_Preprocessing.R @ 27:b5eac045873c draft
Uploaded
author | proteomisc |
---|---|
date | Mon, 04 Dec 2023 12:41:06 +0000 |
parents | |
children | 183b24bc8574 |
comparison
equal
deleted
inserted
replaced
26:a085ddc4cb46 | 27:b5eac045873c |
---|---|
1 options(show.error.messages=F,warn=-1, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) | |
2 sink(stdout(), type = "message") | |
3 sink(stdout() ,type = "output") | |
4 suppressWarnings(suppressMessages(library(affy))) | |
5 suppressWarnings(suppressMessages(library(affyPLM))) | |
6 suppressWarnings(suppressMessages(library(batch))) | |
7 suppressWarnings(suppressMessages(library(annotate))) | |
8 suppressWarnings(suppressMessages(library(limma))) | |
9 suppressWarnings(suppressMessages(library(markdown))) | |
10 suppressWarnings(suppressMessages(library(knitr))) | |
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[["rawdata"]]=MicroArray_Object$affy_object | |
40 if(datasetsource=="intern"){ | |
41 designo<-MicroArray_Object$designo | |
42 } | |
43 | |
44 if(datasetsource=="extern"){ | |
45 listArguments<-append(listArguments,list(datasetsource=datasetsource,listfullnames=listfullnames)) | |
46 } | |
47 Prepro_object<-do.call(thefunctions,listArguments) | |
48 if(datasetsource=="extern"){ | |
49 rownames(Prepro_object$data.bg@phenoData@data)<-listfullnames | |
50 colnames(exprs(Prepro_object$data.bg))<-listfullnames | |
51 colnames(exprs(Prepro_object$data.sm))<-listfullnames | |
52 colnames(exprs(Prepro_object$data.norm))<-listfullnames | |
53 colnames(exprs(Prepro_object$data.bg))<-listfullnames | |
54 colnames(exprs(Prepro_object$data.norm))<-listfullnames | |
55 rownames(Prepro_object$data.norm@phenoData@data)<-listfullnames | |
56 rownames(Prepro_object$data.norm@protocolData@data)<-listfullnames | |
57 } | |
58 | |
59 png(filename ="boxplot_before_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white") | |
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 invisible(dev.off()) | |
62 | |
63 png(filename ="boxplot_after_NM.png",width = w, height = h, units = "px", pointsize = 14, bg = "white") | |
64 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)) | |
65 invisible(dev.off()) | |
66 | |
67 png(filename ="MA_plot.png",width = w, height = h) | |
68 MAplot((Prepro_object$data.norm) , | |
69 show.statistics = F, span = 2/3, family.loess = "gaussian", | |
70 cex = 2, plot.method = as.character("smoothScatter"), | |
71 azdd.loess = TRUE, lwd = 1, lty = 1, loess.col = "red") | |
72 | |
73 invisible(dev.off()) | |
74 | |
75 png(filename = "densities_plot_before_NM.png",width = w, height = h) | |
76 plotDensities(exprs(Prepro_object$data.bg),log=T) | |
77 invisible(dev.off()) | |
78 | |
79 png(filename = "densities_plot_after_NM.png",width = w, height = h) | |
80 plotDensities(exprs(Prepro_object$data.norm),log=T) | |
81 invisible(dev.off()) | |
82 | |
83 AffymetrixRmd=file_path("Affymetrix.Rmd") | |
84 Style=file_path("look.css") | |
85 suppressWarnings(suppressMessages(markdownToHTML(AffymetrixRmd,output="PreprocessingPlots.html",quiet = T, stylesheet=Style))) | |
86 #suppressWarnings(suppressMessages(knit2html(AffymetrixRmd,output="PreprocessingPlots.html",quiet = T))) | |
87 rm(listArguments) | |
88 save.image("MicroArray.Preprocessing.RData") | |
89 sink() | |
90 sink() |