annotate preprocess_datasets/Affymetrix_Preprocessing_Functions.R @ 22:2f468dd9ea39 draft

Uploaded
author proteomisc
date Sun, 03 Dec 2023 17:20:30 +0000
parents 471c893de71f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
471c893de71f Uploaded
proteomisc
parents: 15
diff changeset
1 AffymetrixPreprocessingFunction<-function(rawdata,backgroundcorrection_method,normalization_method,summary_method,datasetsource="",listfullnames="")
0
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
2 {
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
3 colnames(exprs(rawdata))<-listfullnames
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
4 data.bg<-bg.correct(rawdata, method=backgroundcorrection_method)
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
5 data.norm<-normalize(data.bg, method=normalization_method)
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
6 data.sm<-threestep(data.norm, background=F, normalize=F,summary.method=summary_method)
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
7 data_matrix=exprs(data.sm)
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
8 sampleNames(data.sm)<-listfullnames
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
9 if(datasetsource=="extern"){
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
10 colnames(data_matrix)<-listfullnames
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
11 data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
12 experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
13 write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
14 row.names=T, col.names=T,file="Matrix.Data.tsv")
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
15 }else{
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
16 colnames(data_matrix)<-designo$sample
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
17 data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
18 experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
19 write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
20 row.names=T, col.names=T,file="Matrix.Data.tsv")
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
21 }
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
22 installed<-as.data.frame(installed.packages())
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
23 lbraries=paste(annotation(data.sm),"db",sep='.')
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
24 if(!lbraries%in%installed$Package){
15
4b3faf457c37 Uploaded
proteomisc
parents: 0
diff changeset
25 suppressWarnings(suppressMessages(require("BiocManager", quietly = TRUE)))
4b3faf457c37 Uploaded
proteomisc
parents: 0
diff changeset
26 BiocManager::install(lbraries[!lbraries%in%installed$Package])}
0
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
27
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
28 suppressWarnings(suppressMessages(library(lbraries,character.only = TRUE)))
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
29
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
30 symbol<-getSYMBOL(rownames(exprs(data.sm)), annotation(data.sm))
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
31 return(list(data.bg=data.bg,data.norm=data.norm,data.sm=data.sm,matrix_data=exprs(data.sm),symbol=symbol))
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
32
ebf6607b4e6a Uploaded
proteomisc
parents:
diff changeset
33 }